11/*
22 * super.c - NTFS kernel super block handling. Part of the Linux-NTFS project.
33 *
4- * Copyright (c) 2001-2004 Anton Altaparmakov
4+ * Copyright (c) 2001-2005 Anton Altaparmakov
55 * Copyright (c) 2001,2002 Richard Russon
66 *
77 * This program/include file is free software; you can redistribute it and/or
4141#include "malloc.h"
4242#include "ntfs.h"
4343
44- /* Number of mounted file systems which have compression enabled. */
44+ /* Number of mounted filesystems which have compression enabled. */
4545static unsigned long ntfs_nr_compression_users ;
4646
4747/* A global default upcase table and a corresponding reference count. */
@@ -102,7 +102,7 @@ static BOOL parse_options(ntfs_volume *vol, char *opt)
102102 gid_t gid = (gid_t )- 1 ;
103103 mode_t fmask = (mode_t )- 1 , dmask = (mode_t )- 1 ;
104104 int mft_zone_multiplier = -1 , on_errors = -1 ;
105- int show_sys_files = -1 , case_sensitive = -1 ;
105+ int show_sys_files = -1 , case_sensitive = -1 , disable_sparse = -1 ;
106106 struct nls_table * nls_map = NULL , * old_nls ;
107107
108108 /* I am lazy... (-8 */
@@ -162,6 +162,7 @@ static BOOL parse_options(ntfs_volume *vol, char *opt)
162162 else NTFS_GETOPT_WITH_DEFAULT ("sloppy" , sloppy , TRUE)
163163 else NTFS_GETOPT_BOOL ("show_sys_files" , show_sys_files )
164164 else NTFS_GETOPT_BOOL ("case_sensitive" , case_sensitive )
165+ else NTFS_GETOPT_BOOL ("disable_sparse" , disable_sparse )
165166 else NTFS_GETOPT_OPTIONS_ARRAY ("errors" , on_errors ,
166167 on_errors_arr )
167168 else if (!strcmp (p , "posix" ) || !strcmp (p , "show_inodes" ))
@@ -291,6 +292,21 @@ static BOOL parse_options(ntfs_volume *vol, char *opt)
291292 else
292293 NVolClearCaseSensitive (vol );
293294 }
295+ if (disable_sparse != -1 ) {
296+ if (disable_sparse )
297+ NVolClearSparseEnabled (vol );
298+ else {
299+ if (!NVolSparseEnabled (vol ) &&
300+ vol -> major_ver && vol -> major_ver < 3 )
301+ ntfs_warning (vol -> sb , "Not enabling sparse "
302+ "support due to NTFS volume "
303+ "version %i.%i (need at least "
304+ "version 3.0)." , vol -> major_ver ,
305+ vol -> minor_ver );
306+ else
307+ NVolSetSparseEnabled (vol );
308+ }
309+ }
294310 return TRUE;
295311needs_arg :
296312 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)
967983 tmp_ni = NTFS_I (tmp_ino );
968984 /* The $MFTMirr, like the $MFT is multi sector transfer protected. */
969985 NInoSetMstProtected (tmp_ni );
986+ NInoSetSparseDisabled (tmp_ni );
970987 /*
971988 * Set up our little cheat allowing us to reuse the async read io
972989 * completion handler for directories.
@@ -1122,6 +1139,7 @@ static BOOL load_and_check_logfile(ntfs_volume *vol)
11221139 /* ntfs_check_logfile() will have displayed error output. */
11231140 return FALSE;
11241141 }
1142+ NInoSetSparseDisabled (NTFS_I (tmp_ino ));
11251143 vol -> logfile_ino = tmp_ino ;
11261144 ntfs_debug ("Done." );
11271145 return TRUE;
@@ -1220,6 +1238,7 @@ static BOOL load_and_init_attrdef(ntfs_volume *vol)
12201238 iput (ino );
12211239 goto failed ;
12221240 }
1241+ NInoSetSparseDisabled (NTFS_I (ino ));
12231242 /* The size of FILE_AttrDef must be above 0 and fit inside 31 bits. */
12241243 i_size = i_size_read (ino );
12251244 if (i_size <= 0 || i_size > 0x7fffffff )
@@ -1439,6 +1458,7 @@ static BOOL load_system_files(ntfs_volume *vol)
14391458 iput (vol -> lcnbmp_ino );
14401459 goto bitmap_failed ;
14411460 }
1461+ NInoSetSparseDisabled (NTFS_I (vol -> lcnbmp_ino ));
14421462 if ((vol -> nr_clusters + 7 ) >> 3 > i_size_read (vol -> lcnbmp_ino )) {
14431463 iput (vol -> lcnbmp_ino );
14441464bitmap_failed :
@@ -1490,6 +1510,12 @@ static BOOL load_system_files(ntfs_volume *vol)
14901510 unmap_mft_record (NTFS_I (vol -> vol_ino ));
14911511 printk (KERN_INFO "NTFS volume version %i.%i.\n" , vol -> major_ver ,
14921512 vol -> minor_ver );
1513+ if (vol -> major_ver < 3 && NVolSparseEnabled (vol )) {
1514+ ntfs_warning (vol -> sb , "Disabling sparse support due to NTFS "
1515+ "volume version %i.%i (need at least version "
1516+ "3.0)." , vol -> major_ver , vol -> minor_ver );
1517+ NVolClearSparseEnabled (vol );
1518+ }
14931519#ifdef NTFS_RW
14941520 /* Make sure that no unsupported volume flags are set. */
14951521 if (vol -> vol_flags & VOLUME_MUST_MOUNT_RO_MASK ) {
@@ -2033,7 +2059,7 @@ static s64 get_nr_free_clusters(ntfs_volume *vol)
20332059/**
20342060 * __get_nr_free_mft_records - return the number of free inodes on a volume
20352061 * @vol: ntfs volume for which to obtain free inode count
2036- * @nr_free: number of mft records in file system
2062+ * @nr_free: number of mft records in filesystem
20372063 * @max_index: maximum number of pages containing set bits
20382064 *
20392065 * Calculate the number of free mft records (inodes) on the mounted NTFS
@@ -2138,13 +2164,13 @@ static int ntfs_statfs(struct super_block *sb, struct kstatfs *sfs)
21382164 /* Optimal transfer block size. */
21392165 sfs -> f_bsize = PAGE_CACHE_SIZE ;
21402166 /*
2141- * Total data blocks in file system in units of f_bsize and since
2167+ * Total data blocks in filesystem in units of f_bsize and since
21422168 * inodes are also stored in data blocs ($MFT is a file) this is just
21432169 * the total clusters.
21442170 */
21452171 sfs -> f_blocks = vol -> nr_clusters << vol -> cluster_size_bits >>
21462172 PAGE_CACHE_SHIFT ;
2147- /* Free data blocks in file system in units of f_bsize. */
2173+ /* Free data blocks in filesystem in units of f_bsize. */
21482174 size = get_nr_free_clusters (vol ) << vol -> cluster_size_bits >>
21492175 PAGE_CACHE_SHIFT ;
21502176 if (size < 0LL )
@@ -2163,7 +2189,7 @@ static int ntfs_statfs(struct super_block *sb, struct kstatfs *sfs)
21632189 max_index = ((((mft_ni -> initialized_size >> vol -> mft_record_size_bits )
21642190 + 7 ) >> 3 ) + PAGE_CACHE_SIZE - 1 ) >> PAGE_CACHE_SHIFT ;
21652191 read_unlock_irqrestore (& mft_ni -> size_lock , flags );
2166- /* Number of inodes in file system (at this point in time). */
2192+ /* Number of inodes in filesystem (at this point in time). */
21672193 sfs -> f_files = size ;
21682194 /* Free inodes in fs (based on current total count). */
21692195 sfs -> f_ffree = __get_nr_free_mft_records (vol , size , max_index );
@@ -2172,8 +2198,8 @@ static int ntfs_statfs(struct super_block *sb, struct kstatfs *sfs)
21722198 * File system id. This is extremely *nix flavour dependent and even
21732199 * within Linux itself all fs do their own thing. I interpret this to
21742200 * mean a unique id associated with the mounted fs and not the id
2175- * associated with the file system driver, the latter is already given
2176- * by the file system type in sfs->f_type. Thus we use the 64-bit
2201+ * associated with the filesystem driver, the latter is already given
2202+ * by the filesystem type in sfs->f_type. Thus we use the 64-bit
21772203 * volume serial number splitting it into two 32-bit parts. We enter
21782204 * the least significant 32-bits in f_fsid[0] and the most significant
21792205 * 32-bits in f_fsid[1].
@@ -2259,18 +2285,18 @@ static struct export_operations ntfs_export_ops = {
22592285};
22602286
22612287/**
2262- * ntfs_fill_super - mount an ntfs files system
2263- * @sb: super block of ntfs file system to mount
2288+ * ntfs_fill_super - mount an ntfs filesystem
2289+ * @sb: super block of ntfs filesystem to mount
22642290 * @opt: string containing the mount options
22652291 * @silent: silence error output
22662292 *
22672293 * ntfs_fill_super() is called by the VFS to mount the device described by @sb
2268- * with the mount otions in @data with the NTFS file system .
2294+ * with the mount otions in @data with the NTFS filesystem .
22692295 *
22702296 * If @silent is true, remain silent even if errors are detected. This is used
2271- * during bootup, when the kernel tries to mount the root file system with all
2272- * registered file systems one after the other until one succeeds. This implies
2273- * that all file systems except the correct one will quite correctly and
2297+ * during bootup, when the kernel tries to mount the root filesystem with all
2298+ * registered filesystems one after the other until one succeeds. This implies
2299+ * that all filesystems except the correct one will quite correctly and
22742300 * expectedly return an error, but nobody wants to see error messages when in
22752301 * fact this is what is supposed to happen.
22762302 *
@@ -2330,6 +2356,9 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
23302356
23312357 unlock_kernel ();
23322358
2359+ /* By default, enable sparse support. */
2360+ NVolSetSparseEnabled (vol );
2361+
23332362 /* Important to get the mount options dealt with now. */
23342363 if (!parse_options (vol , (char * )opt ))
23352364 goto err_out_now ;
@@ -2711,7 +2740,7 @@ static int __init init_ntfs_fs(void)
27112740 ntfs_debug ("NTFS driver registered successfully." );
27122741 return 0 ; /* Success! */
27132742 }
2714- printk (KERN_CRIT "NTFS: Failed to register NTFS file system driver!\n" );
2743+ printk (KERN_CRIT "NTFS: Failed to register NTFS filesystem driver!\n" );
27152744
27162745sysctl_err_out :
27172746 kmem_cache_destroy (ntfs_big_inode_cache );
@@ -2725,7 +2754,7 @@ static int __init init_ntfs_fs(void)
27252754 kmem_cache_destroy (ntfs_index_ctx_cache );
27262755ictx_err_out :
27272756 if (!err ) {
2728- printk (KERN_CRIT "NTFS: Aborting NTFS file system driver "
2757+ printk (KERN_CRIT "NTFS: Aborting NTFS filesystem driver "
27292758 "registration...\n" );
27302759 err = - ENOMEM ;
27312760 }
@@ -2765,7 +2794,7 @@ static void __exit exit_ntfs_fs(void)
27652794}
27662795
27672796MODULE_AUTHOR ("Anton Altaparmakov <aia21@cantab.net>" );
2768- MODULE_DESCRIPTION ("NTFS 1.2/3.x driver - Copyright (c) 2001-2004 Anton Altaparmakov" );
2797+ MODULE_DESCRIPTION ("NTFS 1.2/3.x driver - Copyright (c) 2001-2005 Anton Altaparmakov" );
27692798MODULE_VERSION (NTFS_VERSION );
27702799MODULE_LICENSE ("GPL" );
27712800#ifdef DEBUG
0 commit comments