mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 09:31:14 +00:00
NTFS: - Add disable_sparse mount option together with a per volume sparse
enable bit which is set appropriately and a per inode sparse disable bit which is preset on some system file inodes as appropriate. - Enforce that sparse support is disabled on NTFS volumes pre 3.0. Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
This commit is contained in:
parent
f40661be03
commit
c002f42543
9 changed files with 80 additions and 33 deletions
|
@ -149,6 +149,13 @@ case_sensitive=<BOOL> If case_sensitive is specified, treat all file names as
|
||||||
name, if it exists. If case_sensitive, you will need
|
name, if it exists. If case_sensitive, you will need
|
||||||
to provide the correct case of the short file name.
|
to provide the correct case of the short file name.
|
||||||
|
|
||||||
|
disable_sparse=<BOOL> If disable_sparse is specified, creation of sparse
|
||||||
|
regions, i.e. holes, inside files is disabled for the
|
||||||
|
volume (for the duration of this mount only). By
|
||||||
|
default, creation of sparse regions is enabled, which
|
||||||
|
is consistent with the behaviour of traditional Unix
|
||||||
|
filesystems.
|
||||||
|
|
||||||
errors=opt What to do when critical filesystem errors are found.
|
errors=opt What to do when critical filesystem errors are found.
|
||||||
Following values can be used for "opt":
|
Following values can be used for "opt":
|
||||||
continue: DEFAULT, try to clean-up as much as
|
continue: DEFAULT, try to clean-up as much as
|
||||||
|
|
|
@ -56,6 +56,10 @@ ToDo/Notes:
|
||||||
this only works until the data attribute becomes too big for the mft
|
this only works until the data attribute becomes too big for the mft
|
||||||
record after which we abort the write returning -EOPNOTSUPP from
|
record after which we abort the write returning -EOPNOTSUPP from
|
||||||
ntfs_prepare_write().
|
ntfs_prepare_write().
|
||||||
|
- Add disable_sparse mount option together with a per volume sparse
|
||||||
|
enable bit which is set appropriately and a per inode sparse disable
|
||||||
|
bit which is preset on some system file inodes as appropriate.
|
||||||
|
- Enforce that sparse support is disabled on NTFS volumes pre 3.0.
|
||||||
|
|
||||||
2.1.22 - Many bug and race fixes and error handling improvements.
|
2.1.22 - Many bug and race fixes and error handling improvements.
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* dir.c - NTFS kernel directory operations. Part of the Linux-NTFS project.
|
* dir.c - NTFS kernel directory operations. Part of the Linux-NTFS project.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2001-2004 Anton Altaparmakov
|
* Copyright (c) 2001-2005 Anton Altaparmakov
|
||||||
* Copyright (c) 2002 Richard Russon
|
* Copyright (c) 2002 Richard Russon
|
||||||
*
|
*
|
||||||
* This program/include file is free software; you can redistribute it and/or
|
* This program/include file is free software; you can redistribute it and/or
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* inode.c - NTFS kernel inode handling. Part of the Linux-NTFS project.
|
* inode.c - NTFS kernel inode handling. Part of the Linux-NTFS project.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2001-2004 Anton Altaparmakov
|
* Copyright (c) 2001-2005 Anton Altaparmakov
|
||||||
*
|
*
|
||||||
* This program/include file is free software; you can redistribute it and/or
|
* This program/include file is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License as published
|
* modify it under the terms of the GNU General Public License as published
|
||||||
|
@ -1731,6 +1731,7 @@ int ntfs_read_inode_mount(struct inode *vi)
|
||||||
/* Setup the data attribute. It is special as it is mst protected. */
|
/* Setup the data attribute. It is special as it is mst protected. */
|
||||||
NInoSetNonResident(ni);
|
NInoSetNonResident(ni);
|
||||||
NInoSetMstProtected(ni);
|
NInoSetMstProtected(ni);
|
||||||
|
NInoSetSparseDisabled(ni);
|
||||||
ni->type = AT_DATA;
|
ni->type = AT_DATA;
|
||||||
ni->name = NULL;
|
ni->name = NULL;
|
||||||
ni->name_len = 0;
|
ni->name_len = 0;
|
||||||
|
@ -2279,6 +2280,8 @@ int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt)
|
||||||
seq_printf(sf, ",case_sensitive");
|
seq_printf(sf, ",case_sensitive");
|
||||||
if (NVolShowSystemFiles(vol))
|
if (NVolShowSystemFiles(vol))
|
||||||
seq_printf(sf, ",show_sys_files");
|
seq_printf(sf, ",show_sys_files");
|
||||||
|
if (!NVolSparseEnabled(vol))
|
||||||
|
seq_printf(sf, ",disable_sparse");
|
||||||
for (i = 0; on_errors_arr[i].val; i++) {
|
for (i = 0; on_errors_arr[i].val; i++) {
|
||||||
if (on_errors_arr[i].val & vol->on_errors)
|
if (on_errors_arr[i].val & vol->on_errors)
|
||||||
seq_printf(sf, ",errors=%s", on_errors_arr[i].str);
|
seq_printf(sf, ",errors=%s", on_errors_arr[i].str);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* inode.h - Defines for inode structures NTFS Linux kernel driver. Part of
|
* inode.h - Defines for inode structures NTFS Linux kernel driver. Part of
|
||||||
* the Linux-NTFS project.
|
* the Linux-NTFS project.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2001-2004 Anton Altaparmakov
|
* Copyright (c) 2001-2005 Anton Altaparmakov
|
||||||
* Copyright (c) 2002 Richard Russon
|
* Copyright (c) 2002 Richard Russon
|
||||||
*
|
*
|
||||||
* This program/include file is free software; you can redistribute it and/or
|
* This program/include file is free software; you can redistribute it and/or
|
||||||
|
@ -166,6 +166,7 @@ typedef enum {
|
||||||
NI_Sparse, /* 1: Unnamed data attr is sparse (f).
|
NI_Sparse, /* 1: Unnamed data attr is sparse (f).
|
||||||
1: Create sparse files by default (d).
|
1: Create sparse files by default (d).
|
||||||
1: Attribute is sparse (a). */
|
1: Attribute is sparse (a). */
|
||||||
|
NI_SparseDisabled, /* 1: May not create sparse regions. */
|
||||||
NI_TruncateFailed, /* 1: Last ntfs_truncate() call failed. */
|
NI_TruncateFailed, /* 1: Last ntfs_truncate() call failed. */
|
||||||
} ntfs_inode_state_bits;
|
} ntfs_inode_state_bits;
|
||||||
|
|
||||||
|
@ -218,6 +219,7 @@ NINO_FNS(IndexAllocPresent)
|
||||||
NINO_FNS(Compressed)
|
NINO_FNS(Compressed)
|
||||||
NINO_FNS(Encrypted)
|
NINO_FNS(Encrypted)
|
||||||
NINO_FNS(Sparse)
|
NINO_FNS(Sparse)
|
||||||
|
NINO_FNS(SparseDisabled)
|
||||||
NINO_FNS(TruncateFailed)
|
NINO_FNS(TruncateFailed)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* layout.h - All NTFS associated on-disk structures. Part of the Linux-NTFS
|
* layout.h - All NTFS associated on-disk structures. Part of the Linux-NTFS
|
||||||
* project.
|
* project.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2001-2004 Anton Altaparmakov
|
* Copyright (c) 2001-2005 Anton Altaparmakov
|
||||||
* Copyright (c) 2002 Richard Russon
|
* Copyright (c) 2002 Richard Russon
|
||||||
*
|
*
|
||||||
* This program/include file is free software; you can redistribute it and/or
|
* This program/include file is free software; you can redistribute it and/or
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* super.c - NTFS kernel super block handling. Part of the Linux-NTFS project.
|
* super.c - NTFS kernel super block handling. Part of the Linux-NTFS project.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2001-2004 Anton Altaparmakov
|
* Copyright (c) 2001-2005 Anton Altaparmakov
|
||||||
* Copyright (c) 2001,2002 Richard Russon
|
* Copyright (c) 2001,2002 Richard Russon
|
||||||
*
|
*
|
||||||
* This program/include file is free software; you can redistribute it and/or
|
* This program/include file is free software; you can redistribute it and/or
|
||||||
|
@ -102,7 +102,7 @@ static BOOL parse_options(ntfs_volume *vol, char *opt)
|
||||||
gid_t gid = (gid_t)-1;
|
gid_t gid = (gid_t)-1;
|
||||||
mode_t fmask = (mode_t)-1, dmask = (mode_t)-1;
|
mode_t fmask = (mode_t)-1, dmask = (mode_t)-1;
|
||||||
int mft_zone_multiplier = -1, on_errors = -1;
|
int mft_zone_multiplier = -1, on_errors = -1;
|
||||||
int show_sys_files = -1, case_sensitive = -1;
|
int show_sys_files = -1, case_sensitive = -1, disable_sparse = -1;
|
||||||
struct nls_table *nls_map = NULL, *old_nls;
|
struct nls_table *nls_map = NULL, *old_nls;
|
||||||
|
|
||||||
/* I am lazy... (-8 */
|
/* I am lazy... (-8 */
|
||||||
|
@ -162,6 +162,7 @@ static BOOL parse_options(ntfs_volume *vol, char *opt)
|
||||||
else NTFS_GETOPT_WITH_DEFAULT("sloppy", sloppy, TRUE)
|
else NTFS_GETOPT_WITH_DEFAULT("sloppy", sloppy, TRUE)
|
||||||
else NTFS_GETOPT_BOOL("show_sys_files", show_sys_files)
|
else NTFS_GETOPT_BOOL("show_sys_files", show_sys_files)
|
||||||
else NTFS_GETOPT_BOOL("case_sensitive", case_sensitive)
|
else NTFS_GETOPT_BOOL("case_sensitive", case_sensitive)
|
||||||
|
else NTFS_GETOPT_BOOL("disable_sparse", disable_sparse)
|
||||||
else NTFS_GETOPT_OPTIONS_ARRAY("errors", on_errors,
|
else NTFS_GETOPT_OPTIONS_ARRAY("errors", on_errors,
|
||||||
on_errors_arr)
|
on_errors_arr)
|
||||||
else if (!strcmp(p, "posix") || !strcmp(p, "show_inodes"))
|
else if (!strcmp(p, "posix") || !strcmp(p, "show_inodes"))
|
||||||
|
@ -291,6 +292,21 @@ no_mount_options:
|
||||||
else
|
else
|
||||||
NVolClearCaseSensitive(vol);
|
NVolClearCaseSensitive(vol);
|
||||||
}
|
}
|
||||||
|
if (disable_sparse != -1) {
|
||||||
|
if (disable_sparse)
|
||||||
|
NVolClearSparseEnabled(vol);
|
||||||
|
else {
|
||||||
|
if (!NVolSparseEnabled(vol) &&
|
||||||
|
vol->major_ver && vol->major_ver < 3)
|
||||||
|
ntfs_warning(vol->sb, "Not enabling sparse "
|
||||||
|
"support due to NTFS volume "
|
||||||
|
"version %i.%i (need at least "
|
||||||
|
"version 3.0).", vol->major_ver,
|
||||||
|
vol->minor_ver);
|
||||||
|
else
|
||||||
|
NVolSetSparseEnabled(vol);
|
||||||
|
}
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
needs_arg:
|
needs_arg:
|
||||||
ntfs_error(vol->sb, "The %s option requires an argument.", p);
|
ntfs_error(vol->sb, "The %s option requires an argument.", p);
|
||||||
|
@ -967,6 +983,7 @@ static BOOL load_and_init_mft_mirror(ntfs_volume *vol)
|
||||||
tmp_ni = NTFS_I(tmp_ino);
|
tmp_ni = NTFS_I(tmp_ino);
|
||||||
/* The $MFTMirr, like the $MFT is multi sector transfer protected. */
|
/* The $MFTMirr, like the $MFT is multi sector transfer protected. */
|
||||||
NInoSetMstProtected(tmp_ni);
|
NInoSetMstProtected(tmp_ni);
|
||||||
|
NInoSetSparseDisabled(tmp_ni);
|
||||||
/*
|
/*
|
||||||
* Set up our little cheat allowing us to reuse the async read io
|
* Set up our little cheat allowing us to reuse the async read io
|
||||||
* completion handler for directories.
|
* completion handler for directories.
|
||||||
|
@ -1122,6 +1139,7 @@ static BOOL load_and_check_logfile(ntfs_volume *vol)
|
||||||
/* ntfs_check_logfile() will have displayed error output. */
|
/* ntfs_check_logfile() will have displayed error output. */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
NInoSetSparseDisabled(NTFS_I(tmp_ino));
|
||||||
vol->logfile_ino = tmp_ino;
|
vol->logfile_ino = tmp_ino;
|
||||||
ntfs_debug("Done.");
|
ntfs_debug("Done.");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1220,6 +1238,7 @@ static BOOL load_and_init_attrdef(ntfs_volume *vol)
|
||||||
iput(ino);
|
iput(ino);
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
|
NInoSetSparseDisabled(NTFS_I(ino));
|
||||||
/* The size of FILE_AttrDef must be above 0 and fit inside 31 bits. */
|
/* The size of FILE_AttrDef must be above 0 and fit inside 31 bits. */
|
||||||
i_size = i_size_read(ino);
|
i_size = i_size_read(ino);
|
||||||
if (i_size <= 0 || i_size > 0x7fffffff)
|
if (i_size <= 0 || i_size > 0x7fffffff)
|
||||||
|
@ -1439,6 +1458,7 @@ static BOOL load_system_files(ntfs_volume *vol)
|
||||||
iput(vol->lcnbmp_ino);
|
iput(vol->lcnbmp_ino);
|
||||||
goto bitmap_failed;
|
goto bitmap_failed;
|
||||||
}
|
}
|
||||||
|
NInoSetSparseDisabled(NTFS_I(vol->lcnbmp_ino));
|
||||||
if ((vol->nr_clusters + 7) >> 3 > i_size_read(vol->lcnbmp_ino)) {
|
if ((vol->nr_clusters + 7) >> 3 > i_size_read(vol->lcnbmp_ino)) {
|
||||||
iput(vol->lcnbmp_ino);
|
iput(vol->lcnbmp_ino);
|
||||||
bitmap_failed:
|
bitmap_failed:
|
||||||
|
@ -1490,6 +1510,12 @@ get_ctx_vol_failed:
|
||||||
unmap_mft_record(NTFS_I(vol->vol_ino));
|
unmap_mft_record(NTFS_I(vol->vol_ino));
|
||||||
printk(KERN_INFO "NTFS volume version %i.%i.\n", vol->major_ver,
|
printk(KERN_INFO "NTFS volume version %i.%i.\n", vol->major_ver,
|
||||||
vol->minor_ver);
|
vol->minor_ver);
|
||||||
|
if (vol->major_ver < 3 && NVolSparseEnabled(vol)) {
|
||||||
|
ntfs_warning(vol->sb, "Disabling sparse support due to NTFS "
|
||||||
|
"volume version %i.%i (need at least version "
|
||||||
|
"3.0).", vol->major_ver, vol->minor_ver);
|
||||||
|
NVolClearSparseEnabled(vol);
|
||||||
|
}
|
||||||
#ifdef NTFS_RW
|
#ifdef NTFS_RW
|
||||||
/* Make sure that no unsupported volume flags are set. */
|
/* Make sure that no unsupported volume flags are set. */
|
||||||
if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) {
|
if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) {
|
||||||
|
@ -2259,7 +2285,7 @@ static struct export_operations ntfs_export_ops = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ntfs_fill_super - mount an ntfs files system
|
* ntfs_fill_super - mount an ntfs filesystem
|
||||||
* @sb: super block of ntfs filesystem to mount
|
* @sb: super block of ntfs filesystem to mount
|
||||||
* @opt: string containing the mount options
|
* @opt: string containing the mount options
|
||||||
* @silent: silence error output
|
* @silent: silence error output
|
||||||
|
@ -2330,6 +2356,9 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
|
||||||
|
|
||||||
unlock_kernel();
|
unlock_kernel();
|
||||||
|
|
||||||
|
/* By default, enable sparse support. */
|
||||||
|
NVolSetSparseEnabled(vol);
|
||||||
|
|
||||||
/* Important to get the mount options dealt with now. */
|
/* Important to get the mount options dealt with now. */
|
||||||
if (!parse_options(vol, (char*)opt))
|
if (!parse_options(vol, (char*)opt))
|
||||||
goto err_out_now;
|
goto err_out_now;
|
||||||
|
@ -2765,7 +2794,7 @@ static void __exit exit_ntfs_fs(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
MODULE_AUTHOR("Anton Altaparmakov <aia21@cantab.net>");
|
MODULE_AUTHOR("Anton Altaparmakov <aia21@cantab.net>");
|
||||||
MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2004 Anton Altaparmakov");
|
MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2005 Anton Altaparmakov");
|
||||||
MODULE_VERSION(NTFS_VERSION);
|
MODULE_VERSION(NTFS_VERSION);
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* the Linux-NTFS project. Adapted from the old NTFS driver,
|
* the Linux-NTFS project. Adapted from the old NTFS driver,
|
||||||
* Copyright (C) 1997 Martin von Löwis, Régis Duchesne
|
* Copyright (C) 1997 Martin von Löwis, Régis Duchesne
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2004 Anton Altaparmakov
|
* Copyright (c) 2002-2005 Anton Altaparmakov
|
||||||
*
|
*
|
||||||
* This program/include file is free software; you can redistribute it and/or
|
* This program/include file is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License as published
|
* modify it under the terms of the GNU General Public License as published
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* volume.h - Defines for volume structures in NTFS Linux kernel driver. Part
|
* volume.h - Defines for volume structures in NTFS Linux kernel driver. Part
|
||||||
* of the Linux-NTFS project.
|
* of the Linux-NTFS project.
|
||||||
*
|
*
|
||||||
* Copyright (c) 2001-2004 Anton Altaparmakov
|
* Copyright (c) 2001-2005 Anton Altaparmakov
|
||||||
* Copyright (c) 2002 Richard Russon
|
* Copyright (c) 2002 Richard Russon
|
||||||
*
|
*
|
||||||
* This program/include file is free software; you can redistribute it and/or
|
* This program/include file is free software; you can redistribute it and/or
|
||||||
|
@ -141,6 +141,7 @@ typedef enum {
|
||||||
file names in WIN32 namespace. */
|
file names in WIN32 namespace. */
|
||||||
NV_LogFileEmpty, /* 1: $LogFile journal is empty. */
|
NV_LogFileEmpty, /* 1: $LogFile journal is empty. */
|
||||||
NV_QuotaOutOfDate, /* 1: $Quota is out of date. */
|
NV_QuotaOutOfDate, /* 1: $Quota is out of date. */
|
||||||
|
NV_SparseEnabled, /* 1: May create sparse files. */
|
||||||
} ntfs_volume_flags;
|
} ntfs_volume_flags;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -167,5 +168,6 @@ NVOL_FNS(ShowSystemFiles)
|
||||||
NVOL_FNS(CaseSensitive)
|
NVOL_FNS(CaseSensitive)
|
||||||
NVOL_FNS(LogFileEmpty)
|
NVOL_FNS(LogFileEmpty)
|
||||||
NVOL_FNS(QuotaOutOfDate)
|
NVOL_FNS(QuotaOutOfDate)
|
||||||
|
NVOL_FNS(SparseEnabled)
|
||||||
|
|
||||||
#endif /* _LINUX_NTFS_VOLUME_H */
|
#endif /* _LINUX_NTFS_VOLUME_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue