mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-04-01 03:44:08 +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
|
||||
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.
|
||||
Following values can be used for "opt":
|
||||
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
|
||||
record after which we abort the write returning -EOPNOTSUPP from
|
||||
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.
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* 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
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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
|
||||
* 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. */
|
||||
NInoSetNonResident(ni);
|
||||
NInoSetMstProtected(ni);
|
||||
NInoSetSparseDisabled(ni);
|
||||
ni->type = AT_DATA;
|
||||
ni->name = NULL;
|
||||
ni->name_len = 0;
|
||||
|
@ -2279,6 +2280,8 @@ int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt)
|
|||
seq_printf(sf, ",case_sensitive");
|
||||
if (NVolShowSystemFiles(vol))
|
||||
seq_printf(sf, ",show_sys_files");
|
||||
if (!NVolSparseEnabled(vol))
|
||||
seq_printf(sf, ",disable_sparse");
|
||||
for (i = 0; on_errors_arr[i].val; i++) {
|
||||
if (on_errors_arr[i].val & vol->on_errors)
|
||||
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
|
||||
* the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2001-2004 Anton Altaparmakov
|
||||
* Copyright (c) 2001-2005 Anton Altaparmakov
|
||||
* Copyright (c) 2002 Richard Russon
|
||||
*
|
||||
* 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).
|
||||
1: Create sparse files by default (d).
|
||||
1: Attribute is sparse (a). */
|
||||
NI_SparseDisabled, /* 1: May not create sparse regions. */
|
||||
NI_TruncateFailed, /* 1: Last ntfs_truncate() call failed. */
|
||||
} ntfs_inode_state_bits;
|
||||
|
||||
|
@ -218,6 +219,7 @@ NINO_FNS(IndexAllocPresent)
|
|||
NINO_FNS(Compressed)
|
||||
NINO_FNS(Encrypted)
|
||||
NINO_FNS(Sparse)
|
||||
NINO_FNS(SparseDisabled)
|
||||
NINO_FNS(TruncateFailed)
|
||||
|
||||
/*
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* layout.h - All NTFS associated on-disk structures. Part of the Linux-NTFS
|
||||
* project.
|
||||
*
|
||||
* Copyright (c) 2001-2004 Anton Altaparmakov
|
||||
* Copyright (c) 2001-2005 Anton Altaparmakov
|
||||
* Copyright (c) 2002 Richard Russon
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Copyright (c) 2001-2004 Anton Altaparmakov
|
||||
* Copyright (c) 2001-2005 Anton Altaparmakov
|
||||
* Copyright (c) 2001,2002 Richard Russon
|
||||
*
|
||||
* 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;
|
||||
mode_t fmask = (mode_t)-1, dmask = (mode_t)-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;
|
||||
|
||||
/* 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_BOOL("show_sys_files", show_sys_files)
|
||||
else NTFS_GETOPT_BOOL("case_sensitive", case_sensitive)
|
||||
else NTFS_GETOPT_BOOL("disable_sparse", disable_sparse)
|
||||
else NTFS_GETOPT_OPTIONS_ARRAY("errors", on_errors,
|
||||
on_errors_arr)
|
||||
else if (!strcmp(p, "posix") || !strcmp(p, "show_inodes"))
|
||||
|
@ -291,6 +292,21 @@ no_mount_options:
|
|||
else
|
||||
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;
|
||||
needs_arg:
|
||||
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);
|
||||
/* The $MFTMirr, like the $MFT is multi sector transfer protected. */
|
||||
NInoSetMstProtected(tmp_ni);
|
||||
NInoSetSparseDisabled(tmp_ni);
|
||||
/*
|
||||
* Set up our little cheat allowing us to reuse the async read io
|
||||
* 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. */
|
||||
return FALSE;
|
||||
}
|
||||
NInoSetSparseDisabled(NTFS_I(tmp_ino));
|
||||
vol->logfile_ino = tmp_ino;
|
||||
ntfs_debug("Done.");
|
||||
return TRUE;
|
||||
|
@ -1220,6 +1238,7 @@ static BOOL load_and_init_attrdef(ntfs_volume *vol)
|
|||
iput(ino);
|
||||
goto failed;
|
||||
}
|
||||
NInoSetSparseDisabled(NTFS_I(ino));
|
||||
/* The size of FILE_AttrDef must be above 0 and fit inside 31 bits. */
|
||||
i_size = i_size_read(ino);
|
||||
if (i_size <= 0 || i_size > 0x7fffffff)
|
||||
|
@ -1439,6 +1458,7 @@ static BOOL load_system_files(ntfs_volume *vol)
|
|||
iput(vol->lcnbmp_ino);
|
||||
goto bitmap_failed;
|
||||
}
|
||||
NInoSetSparseDisabled(NTFS_I(vol->lcnbmp_ino));
|
||||
if ((vol->nr_clusters + 7) >> 3 > i_size_read(vol->lcnbmp_ino)) {
|
||||
iput(vol->lcnbmp_ino);
|
||||
bitmap_failed:
|
||||
|
@ -1490,6 +1510,12 @@ get_ctx_vol_failed:
|
|||
unmap_mft_record(NTFS_I(vol->vol_ino));
|
||||
printk(KERN_INFO "NTFS volume version %i.%i.\n", vol->major_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
|
||||
/* Make sure that no unsupported volume flags are set. */
|
||||
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
|
||||
* @opt: string containing the mount options
|
||||
* @silent: silence error output
|
||||
|
@ -2330,6 +2356,9 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
|
|||
|
||||
unlock_kernel();
|
||||
|
||||
/* By default, enable sparse support. */
|
||||
NVolSetSparseEnabled(vol);
|
||||
|
||||
/* Important to get the mount options dealt with now. */
|
||||
if (!parse_options(vol, (char*)opt))
|
||||
goto err_out_now;
|
||||
|
@ -2765,7 +2794,7 @@ static void __exit exit_ntfs_fs(void)
|
|||
}
|
||||
|
||||
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_LICENSE("GPL");
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* the Linux-NTFS project. Adapted from the old NTFS driver,
|
||||
* 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
|
||||
* 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
|
||||
* of the Linux-NTFS project.
|
||||
*
|
||||
* Copyright (c) 2001-2004 Anton Altaparmakov
|
||||
* Copyright (c) 2001-2005 Anton Altaparmakov
|
||||
* Copyright (c) 2002 Richard Russon
|
||||
*
|
||||
* This program/include file is free software; you can redistribute it and/or
|
||||
|
@ -141,6 +141,7 @@ typedef enum {
|
|||
file names in WIN32 namespace. */
|
||||
NV_LogFileEmpty, /* 1: $LogFile journal is empty. */
|
||||
NV_QuotaOutOfDate, /* 1: $Quota is out of date. */
|
||||
NV_SparseEnabled, /* 1: May create sparse files. */
|
||||
} ntfs_volume_flags;
|
||||
|
||||
/*
|
||||
|
@ -167,5 +168,6 @@ NVOL_FNS(ShowSystemFiles)
|
|||
NVOL_FNS(CaseSensitive)
|
||||
NVOL_FNS(LogFileEmpty)
|
||||
NVOL_FNS(QuotaOutOfDate)
|
||||
NVOL_FNS(SparseEnabled)
|
||||
|
||||
#endif /* _LINUX_NTFS_VOLUME_H */
|
||||
|
|
Loading…
Add table
Reference in a new issue