Commit 6f3894e9 authored by Anton Altaparmakov's avatar Anton Altaparmakov

NTFS: The beginning of 2.0.8. - Major updates for handling of case sensitivity.

- Remove unused source file fs/ntfs/attraops.c.
- Remove show_inodes mount option(s), thus dropping support for
  displaying of short file names.
- Remove deprecated mount option posix.
- Restore show_sys_files mount option.
- Add new mount option case_sensitive, to determine if the driver treats
  file names as case sensitive or not. If case sensitive, create file names
  in the POSIX namespace. Otherwise create file names in the WIN32
  namespace. By default, or when case_sensitive is set to FALSE, files
  remain accessible via their short file name, if it exists.
- Add additional argument to ntfs_lookup_inode_by_name() in which we
  return information about the matching file name if the case is not
  matching or the match is a short file name. See comments above the
  function definition for details.
parent 0cf66ffc
...@@ -73,52 +73,27 @@ sloppy=<BOOL> If sloppy is specified, ignore unknown mount options. ...@@ -73,52 +73,27 @@ sloppy=<BOOL> If sloppy is specified, ignore unknown mount options.
Otherwise the default behaviour is to abort mount if Otherwise the default behaviour is to abort mount if
any unknown options are found. any unknown options are found.
posix=<bool> Deprecated option. Still supported but please use show_sys_files=<BOOL> If show_sys_files is specified, show the system files
show_inodes=posix in the future. See description for in directory listings. Otherwise the default behaviour
show_inodes=opt. is to hide the system files.
Note that even when show_sys_files is specified, "$MFT"
show_sys_files=<bool> Deprecated option. Still supported but please use will not be visible due to bugs/mis-features in glibc.
show_inodes=system in the future. See description for Further, note that irrespective of show_sys_files, all
show_inodes=opt. files are accessible by name, i.e. you can always do
"ls -l \$UpCase" for example to specifically show the
show_inodes=opt Allows choice of which types of inode names readdir() system file containing the Unicode upcase table.
returns, i.e. this affects what "ls" shows. Following
values can be used for "opt": case_sensitive=<BOOL> If case_sensitive is specified, treat all file names as
system: show system files case sensitive and create file names in the POSIX
win32: long file names (includes POSIX) [DEFAULT] namespace. Otherwise the default behaviour is to treat
long: same as win32 file names as case insensitive and to create file names
dos: short file names only (excludes POSIX) in the WIN32/LONG name space. Note, the Linux NTFS
short: same as dos driver will never create short file names and will
posix: same as both win32 and dos remove them on rename/delete of the corresponding long
all: all file names file name.
Note that the options are additive, i.e. specifying: Note that by default / when case_sensitive is set to
show_inodes=system,show_inodes=win32,show_inodes=dos FALSE, files remain accessible via their short file
is the same as specifying: name, if it exists.
show_inodes=all
Note that the "posix" and "all" options will show all
directory names, BUT the link count on each directory
inode entry is set to 1, due to Linux not supporting
directory hard links. This may well confuse some
user space applications, since the directory names will
have the same inode numbers. Thus it is NOT advisable
to use the "posix" and "all" options. We provide them
only for completeness sake.
Further, note that the "system" option will not show
"$MFT" due to bugs/mis-features in glibc. Even though
it does not show, you can specifically "ls" it:
ls -l \$MFT
And of course you can stat it, too.
Further, note that irrespective of what show_inodes
option(s) you use, all files are accessible when you
specify the correct name, even though they may not be
shown in a normal "ls", i.e. you can always access the
system files and both the short and long file names of
files and directories.
Finally, note that win32 and dos file names are not
case sensitive and can be accessed using any
combination of lower and upper case, while POSIX file
names are case sensitive and they can only be accessed
given the correct case.
errors=opt What to do when critical file system errors are found. errors=opt What to do when critical file system errors are found.
Following values can be used for "opt": Following values can be used for "opt":
...@@ -174,12 +149,22 @@ Features ...@@ -174,12 +149,22 @@ Features
(from 9:43 minutes on average down to 7:53). The time spent in user space (from 9:43 minutes on average down to 7:53). The time spent in user space
was unchanged but the time spent in the kernel was decreased by a factor of was unchanged but the time spent in the kernel was decreased by a factor of
2.5 (from 85 CPU seconds down to 33). 2.5 (from 85 CPU seconds down to 33).
- The driver does not support short file names in general. For backwards
compatibility, we implement access to files using their short file names if
they exist. The driver will not create short file names however, and a rename
will discard any existing short file name.
Known bugs and (mis-)features Known bugs and (mis-)features
============================= =============================
- None - The link count on each directory inode entry is set to 1, due to Linux not
supporting directory hard links. This may well confuse some user space
applications, since the directory names will have the same inode numbers.
This also speeds up ntfs_read_inode() immensely. And we haven't found any
problems with this approach so far. If you find a problem with this, please
let us know.
Please send bug reports/comments/feedback/abuse to the Linux-NTFS development Please send bug reports/comments/feedback/abuse to the Linux-NTFS development
list at sourceforge: linux-ntfs-dev@lists.sourceforge.net list at sourceforge: linux-ntfs-dev@lists.sourceforge.net
...@@ -262,6 +247,18 @@ ChangeLog ...@@ -262,6 +247,18 @@ ChangeLog
Note that a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog. Note that a technical ChangeLog aimed at kernel hackers is in fs/ntfs/ChangeLog.
2.0.8:
- Remove now obsolete show_inodes and posix mount option(s).
- Restore show_sys_files mount option.
- Add new mount option case_sensitive, to determine if the driver
treats file names as case sensitive or not.
- Mostly drop support for short file names (for backwards compatibility
we only support accessing files via their short file name if one
exists).
- Fix dcache aliasing issues wrt short/long file names.
- Cleanups.
2.0.7:
- Just cleanups.
2.0.6: 2.0.6:
- Major bugfix to make compatible with other kernel changes. This fixes - Major bugfix to make compatible with other kernel changes. This fixes
the hangs/oopses on umount. the hangs/oopses on umount.
......
...@@ -21,8 +21,29 @@ ToDo: ...@@ -21,8 +21,29 @@ ToDo:
several copies of almost identicall functions and the functions are several copies of almost identicall functions and the functions are
quite big. Modularising them a bit, e.g. a-la get_block(), will make quite big. Modularising them a bit, e.g. a-la get_block(), will make
them cleaner and make code reuse easier. them cleaner and make code reuse easier.
- Want to use dummy inodes for address space i/o. We need some VFS - Want to use dummy inodes for address space i/o.
changes first, which are currently under discussion.
2.0.8 - Major updates for handling of case sensitivity and dcache aliasing.
- Remove unused source file fs/ntfs/attraops.c.
- Remove show_inodes mount option(s), thus dropping support for
displaying of short file names.
- Remove deprecated mount option posix.
- Restore show_sys_files mount option.
- Add new mount option case_sensitive, to determine if the driver
treats file names as case sensitive or not. If case sensitive, create
file names in the POSIX namespace. Otherwise create file names in the
LONG/WIN32 name space. By default, or when case_sensitive is set to
FALSE, files remain accessible via their short file name, if it
exists.
- Fix dcache aliasing issues wrt short/long file names via changes
to fs/ntfs/dir.c::ntfs_lookup_inode_by_name() and
fs/ntfs/namei.c::ntfs_lookup(). (The latter is still TODO:)
- Add additional argument to ntfs_lookup_inode_by_name() in which we
return information about the matching file name if the case is not
matching or the match is a short file name. See comments above the
function definition for details.
- TODO: (AIA) Change ntfs_lookup()...
2.0.7 - Minor cleanups and updates for changes in core kernel code. 2.0.7 - Minor cleanups and updates for changes in core kernel code.
......
...@@ -5,7 +5,7 @@ obj-$(CONFIG_NTFS_FS) += ntfs.o ...@@ -5,7 +5,7 @@ obj-$(CONFIG_NTFS_FS) += ntfs.o
ntfs-objs := aops.o attrib.o compress.o debug.o dir.o file.o inode.o mft.o \ ntfs-objs := aops.o attrib.o compress.o debug.o dir.o file.o inode.o mft.o \
mst.o namei.o super.o sysctl.o time.o unistr.o upcase.o mst.o namei.o super.o sysctl.o time.o unistr.o upcase.o
EXTRA_CFLAGS = -DNTFS_VERSION=\"2.0.7\" EXTRA_CFLAGS = -DNTFS_VERSION=\"2.0.8\"
ifeq ($(CONFIG_NTFS_DEBUG),y) ifeq ($(CONFIG_NTFS_DEBUG),y)
EXTRA_CFLAGS += -DDEBUG EXTRA_CFLAGS += -DDEBUG
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include "ntfs.h" #include "ntfs.h"
#include "dir.h"
/* Temporary helper functions -- might become macros */ /* Temporary helper functions -- might become macros */
......
This diff is collapsed.
/*
* dir.h - Defines for directory handling in NTFS Linux kernel driver. Part of
* the Linux-NTFS project.
*
* Copyright (c) 2002 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
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program/include file is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (in the main directory of the Linux-NTFS
* distribution in the file COPYING); if not, write to the Free Software
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LINUX_NTFS_DIR_H
#define _LINUX_NTFS_DIR_H
#include "layout.h"
/*
* ntfs_name is used to return the file name to the caller of
* ntfs_lookup_inode_by_name() in order for the caller (namei.c::ntfs_lookup())
* to be able to deal with dcache aliasing issues.
*/
typedef struct {
MFT_REF mref;
FILE_NAME_TYPE_FLAGS type;
u8 len;
uchar_t name[0];
} __attribute__ ((__packed__)) ntfs_name;
/* The little endian Unicode string $I30 as a global constant. */
extern const uchar_t I30[5];
extern u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const uchar_t *uname,
const int uname_len, ntfs_name **res);
#endif /* _LINUX_NTFS_FS_DIR_H */
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include "ntfs.h" #include "ntfs.h"
#include "dir.h"
struct inode *ntfs_alloc_big_inode(struct super_block *sb) struct inode *ntfs_alloc_big_inode(struct super_block *sb)
{ {
...@@ -1337,13 +1338,6 @@ void ntfs_clear_big_inode(struct inode *vi) ...@@ -1337,13 +1338,6 @@ void ntfs_clear_big_inode(struct inode *vi)
return; return;
} }
static const option_t si_readdir_opts_arr[] = {
{ SHOW_SYSTEM, "system" },
{ SHOW_WIN32, "win32" },
{ SHOW_DOS, "dos" },
{ 0, NULL }
};
/** /**
* ntfs_show_options - show mount options in /proc/mounts * ntfs_show_options - show mount options in /proc/mounts
* @sf: seq_file in which to write our mount options * @sf: seq_file in which to write our mount options
...@@ -1368,20 +1362,10 @@ int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt) ...@@ -1368,20 +1362,10 @@ int ntfs_show_options(struct seq_file *sf, struct vfsmount *mnt)
seq_printf(sf, ",dmask=0%o", vol->dmask); seq_printf(sf, ",dmask=0%o", vol->dmask);
} }
seq_printf(sf, ",nls=%s", vol->nls_map->charset); seq_printf(sf, ",nls=%s", vol->nls_map->charset);
switch (vol->readdir_opts) { if (NVolCaseSensitive(vol))
case SHOW_ALL: seq_printf(sf, ",case_sensitive");
seq_printf(sf, ",show_inodes=all"); if (NVolShowSystemFiles(vol))
break; seq_printf(sf, ",show_sys_files");
case SHOW_POSIX:
seq_printf(sf, ",show_inodes=posix");
break;
default:
for (i = 0; si_readdir_opts_arr[i].val; i++) {
if (si_readdir_opts_arr[i].val & vol->readdir_opts)
seq_printf(sf, ",show_inodes=%s",
si_readdir_opts_arr[i].str);
}
}
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);
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <asm/byteorder.h> #include <asm/byteorder.h>
#include "volume.h" #include "types.h"
/* /*
* Constant endianness conversion defines. * Constant endianness conversion defines.
...@@ -679,7 +679,7 @@ typedef ATTR_RECORD ATTR_REC; ...@@ -679,7 +679,7 @@ typedef ATTR_RECORD ATTR_REC;
*/ */
typedef enum { typedef enum {
/* /*
* These flags are only presnt in the STANDARD_INFORMATION attribute * These flags are only present in the STANDARD_INFORMATION attribute
* (in the field file_attributes). * (in the field file_attributes).
*/ */
FILE_ATTR_READONLY = const_cpu_to_le32(0x00000001), FILE_ATTR_READONLY = const_cpu_to_le32(0x00000001),
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
*/ */
#include "ntfs.h" #include "ntfs.h"
#include "dir.h"
/** /**
* ntfs_lookup - find the inode represented by a dentry in a directory inode * ntfs_lookup - find the inode represented by a dentry in a directory inode
...@@ -43,6 +44,48 @@ ...@@ -43,6 +44,48 @@
* dentry @dent. The dentry is then termed a negative dentry. * dentry @dent. The dentry is then termed a negative dentry.
* *
* Only if an actual error occurs, do we return an error via ERR_PTR(). * Only if an actual error occurs, do we return an error via ERR_PTR().
*
* TODO: Implement the below! (AIA)
*
* In order to handle the case insensitivity issues of NTFS with regards to the
* dcache and the dcache requiring only one dentry per directory, we deal with
* dentry aliases that only differ in case in ->ntfs_lookup() while maintining
* a case sensitive dcache. This means that we get the full benefit of dcache
* speed when the file/directory is looked up with the same case as returned by
* ->ntfs_readdir() but that a lookup for any other case (or for the short file
* name) will not find anything in dcache and will enter ->ntfs_lookup()
* instead, where we search the directory for a fully matching file name
* (including case) and if that is not found, we search for a file name that
* matches with different case and if that has non-POSIX semantics we return
* that. We actually do only one search (case sensitive) and keep tabs on
* whether we have found a case insensitive match in the process.
*
* To simplify matters for us, we do not treat the short vs long filenames as
* two hard links but instead if the lookup matches a short filename, we
* return the dentry for the corresponding long filename instead.
*
* There are three cases we need to distinguish here:
*
* 1) @dent perfectly matches (i.e. including case) a directory entry with a
* file name in the WIN32 or POSIX namespaces. In this case
* ntfs_lookup_inode_by_name() will return with name set to NULL and we
* just d_add() @dent.
* 2) @dent matches (not including case) a directory entry with a file name in
* the WIN32 or POSIX namespaces. In this case ntfs_lookup_inode_by_name()
* will return with name set to point to a kmalloc()ed ntfs_name structure
* containing the properly cased little endian Unicode name. We convert the
* name to the current NLS code page, search if a dentry with this name
* already exists and if so return that instead of @dent. The VFS will then
* destroy the old @dent and use the one we returned. If a dentry is not
* found, we allocate a new one, d_add() it, and return it as above.
* 3) @dent matches either perfectly or not (i.e. we don't care about case) a
* directory entry with a file name in the DOS namespace. In this case
* ntfs_lookup_inode_by_name() will return with name set to point to a
* kmalloc()ed ntfs_name structure containing the mft reference (cpu endian)
* of the inode. We use the mft reference to read the inode and to find the
* file name in the WIN32 namespace corresponding to the matched short file
* name. We then convert the name to the current NLS code page, and proceed
* searching for a dentry with this name, etc, as in case 2), above.
*/ */
static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent) static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent)
{ {
...@@ -52,6 +95,7 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent) ...@@ -52,6 +95,7 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent)
unsigned long dent_ino; unsigned long dent_ino;
uchar_t *uname; uchar_t *uname;
int uname_len; int uname_len;
ntfs_name *name = NULL;
ntfs_debug("Looking up %s in directory inode 0x%lx.", ntfs_debug("Looking up %s in directory inode 0x%lx.",
dent->d_name.name, dir_ino->i_ino); dent->d_name.name, dir_ino->i_ino);
...@@ -62,8 +106,12 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent) ...@@ -62,8 +106,12 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent)
ntfs_error(vol->sb, "Failed to convert name to Unicode."); ntfs_error(vol->sb, "Failed to convert name to Unicode.");
return ERR_PTR(uname_len); return ERR_PTR(uname_len);
} }
mref = ntfs_lookup_inode_by_name(NTFS_I(dir_ino), uname, uname_len); mref = ntfs_lookup_inode_by_name(NTFS_I(dir_ino), uname, uname_len,
&name);
kmem_cache_free(ntfs_name_cache, uname); kmem_cache_free(ntfs_name_cache, uname);
// TODO: Handle name. (AIA)
if (name)
kfree(name);
if (!IS_ERR_MREF(mref)) { if (!IS_ERR_MREF(mref)) {
dent_ino = (unsigned long)MREF(mref); dent_ino = (unsigned long)MREF(mref);
ntfs_debug("Found inode 0x%lx. Calling iget.", dent_ino); ntfs_debug("Found inode 0x%lx. Calling iget.", dent_ino);
...@@ -102,7 +150,10 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent) ...@@ -102,7 +150,10 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent)
return ERR_PTR(MREF_ERR(mref)); return ERR_PTR(MREF_ERR(mref));
} }
/*
* Inode operations for directories.
*/
struct inode_operations ntfs_dir_inode_ops = { struct inode_operations ntfs_dir_inode_ops = {
lookup: ntfs_lookup, /* lookup directory. */ lookup: ntfs_lookup, /* VFS: Lookup directory. */
}; };
...@@ -96,9 +96,6 @@ extern kmem_cache_t *ntfs_inode_cache; ...@@ -96,9 +96,6 @@ extern kmem_cache_t *ntfs_inode_cache;
extern kmem_cache_t *ntfs_big_inode_cache; extern kmem_cache_t *ntfs_big_inode_cache;
extern kmem_cache_t *ntfs_attr_ctx_cache; extern kmem_cache_t *ntfs_attr_ctx_cache;
/* The little endian Unicode string $I30 as a global constant. */
extern const uchar_t I30[5];
/* The various operations structs defined throughout the driver files. */ /* The various operations structs defined throughout the driver files. */
extern struct super_operations ntfs_mount_sops; extern struct super_operations ntfs_mount_sops;
extern struct super_operations ntfs_sops; extern struct super_operations ntfs_sops;
...@@ -223,10 +220,6 @@ extern inline s64 utc2ntfs(const time_t time); ...@@ -223,10 +220,6 @@ extern inline s64 utc2ntfs(const time_t time);
extern inline s64 get_current_ntfs_time(void); extern inline s64 get_current_ntfs_time(void);
extern inline time_t ntfs2utc(const s64 time); extern inline time_t ntfs2utc(const s64 time);
/* From fs/ntfs/dir.c */
extern u64 ntfs_lookup_inode_by_name(ntfs_inode *dir_ni, const uchar_t *uname,
const int uname_len);
/* From fs/ntfs/unistr.c */ /* From fs/ntfs/unistr.c */
extern BOOL ntfs_are_names_equal(const uchar_t *s1, size_t s1_len, extern BOOL ntfs_are_names_equal(const uchar_t *s1, size_t s1_len,
const uchar_t *s2, size_t s2_len, const uchar_t *s2, size_t s2_len,
......
...@@ -52,17 +52,6 @@ const option_t on_errors_arr[] = { ...@@ -52,17 +52,6 @@ const option_t on_errors_arr[] = {
{ 0, NULL } { 0, NULL }
}; };
static const option_t readdir_opts_arr[] = {
{ SHOW_SYSTEM, "system" },
{ SHOW_WIN32, "win32" },
{ SHOW_WIN32, "long" },
{ SHOW_DOS, "dos" },
{ SHOW_DOS, "short" },
{ SHOW_POSIX, "posix" },
{ SHOW_ALL, "all" },
{ 0, NULL }
};
/** /**
* simple_getbool - * simple_getbool -
* *
...@@ -98,7 +87,8 @@ static BOOL parse_options(ntfs_volume *vol, char *opt) ...@@ -98,7 +87,8 @@ static BOOL parse_options(ntfs_volume *vol, char *opt)
uid_t uid = (uid_t)-1; uid_t uid = (uid_t)-1;
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, readdir_opts = -1; int mft_zone_multiplier = -1, on_errors = -1;
int show_sys_files = -1, case_sensitive = -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 */
...@@ -120,6 +110,13 @@ static BOOL parse_options(ntfs_volume *vol, char *opt) ...@@ -120,6 +110,13 @@ static BOOL parse_options(ntfs_volume *vol, char *opt)
if (*v) \ if (*v) \
goto needs_val; \ goto needs_val; \
} }
#define NTFS_GETOPT_BOOL(option, variable) \
if (!strcmp(p, option)) { \
BOOL val; \
if (!simple_getbool(v, &val)) \
goto needs_bool; \
variable = val; \
}
#define NTFS_GETOPT_OPTIONS_ARRAY(option, variable, opt_array) \ #define NTFS_GETOPT_OPTIONS_ARRAY(option, variable, opt_array) \
if (!strcmp(p, option)) { \ if (!strcmp(p, option)) { \
int _i; \ int _i; \
...@@ -146,47 +143,16 @@ static BOOL parse_options(ntfs_volume *vol, char *opt) ...@@ -146,47 +143,16 @@ static BOOL parse_options(ntfs_volume *vol, char *opt)
else NTFS_GETOPT("umask", fmask = dmask) else NTFS_GETOPT("umask", fmask = dmask)
else NTFS_GETOPT("fmask", fmask) else NTFS_GETOPT("fmask", fmask)
else NTFS_GETOPT("dmask", dmask) else NTFS_GETOPT("dmask", dmask)
else NTFS_GETOPT_WITH_DEFAULT("sloppy", sloppy, TRUE)
else NTFS_GETOPT("mft_zone_multiplier", mft_zone_multiplier) else NTFS_GETOPT("mft_zone_multiplier", mft_zone_multiplier)
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_OPTIONS_ARRAY("errors", on_errors, else NTFS_GETOPT_OPTIONS_ARRAY("errors", on_errors,
on_errors_arr) on_errors_arr)
else NTFS_GETOPT_OPTIONS_ARRAY("show_inodes", readdir_opts, else if (!strcmp(p, "posix") || !strcmp(p, "show_inodes"))
readdir_opts_arr) ntfs_warning(vol->sb, "Ignoring obsolete option %s.",
else if (!strcmp(p, "show_sys_files")) { p);
BOOL val = FALSE; else if (!strcmp(p, "nls") || !strcmp(p, "iocharset")) {
ntfs_warning(vol->sb, "Option show_sys_files is "
"deprecated. Please use option "
"show_inodes=system in the future.");
if (!v || !*v)
val = TRUE;
else if (!simple_getbool(v, &val))
goto needs_bool;
if (val) {
if (readdir_opts == -1)
readdir_opts = 0;
readdir_opts |= SHOW_SYSTEM;
}
} else if (!strcmp(p, "posix")) {
BOOL val = FALSE;
ntfs_warning(vol->sb, "Option posix is deprecated. "
"Please use option show_inodes=posix "
"instead. Be aware that some userspace "
"applications may be confused by this, "
"since the short and long names of "
"directory inodes will have the same inode "
"numbers, yet each will only have a link "
"count of 1 due to Linux not supporting "
"directory hard links.");
if (!v || !*v)
goto needs_arg;
else if (!simple_getbool(v, &val))
goto needs_bool;
if (val) {
if (readdir_opts == -1)
readdir_opts = 0;
readdir_opts |= SHOW_POSIX;
}
} else if (!strcmp(p, "nls") || !strcmp(p, "iocharset")) {
if (!strcmp(p, "iocharset")) if (!strcmp(p, "iocharset"))
ntfs_warning(vol->sb, "Option iocharset is " ntfs_warning(vol->sb, "Option iocharset is "
"deprecated. Please use " "deprecated. Please use "
...@@ -232,6 +198,7 @@ static BOOL parse_options(ntfs_volume *vol, char *opt) ...@@ -232,6 +198,7 @@ static BOOL parse_options(ntfs_volume *vol, char *opt)
errors++; errors++;
} }
#undef NTFS_GETOPT_OPTIONS_ARRAY #undef NTFS_GETOPT_OPTIONS_ARRAY
#undef NTFS_GETOPT_BOOL
#undef NTFS_GETOPT #undef NTFS_GETOPT
#undef NTFS_GETOPT_WITH_DEFAULT #undef NTFS_GETOPT_WITH_DEFAULT
} }
...@@ -297,8 +264,18 @@ static BOOL parse_options(ntfs_volume *vol, char *opt) ...@@ -297,8 +264,18 @@ static BOOL parse_options(ntfs_volume *vol, char *opt)
vol->fmask = fmask; vol->fmask = fmask;
if (dmask != (mode_t)-1) if (dmask != (mode_t)-1)
vol->dmask = dmask; vol->dmask = dmask;
if (readdir_opts != -1) if (show_sys_files != -1) {
vol->readdir_opts = readdir_opts; if (show_sys_files)
NVolSetShowSystemFiles(vol);
else
NVolClearShowSystemFiles(vol);
}
if (case_sensitive != -1) {
if (case_sensitive)
NVolSetCaseSensitive(vol);
else
NVolClearCaseSensitive(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);
...@@ -1492,6 +1469,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) ...@@ -1492,6 +1469,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
vol->root_ino = NULL; vol->root_ino = NULL;
vol->secure_ino = NULL; vol->secure_ino = NULL;
vol->uid = vol->gid = 0; vol->uid = vol->gid = 0;
vol->flags = 0;
vol->on_errors = 0; vol->on_errors = 0;
vol->mft_zone_multiplier = 0; vol->mft_zone_multiplier = 0;
vol->nls_map = NULL; vol->nls_map = NULL;
...@@ -1531,12 +1509,6 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) ...@@ -1531,12 +1509,6 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
vol->fmask = 0177; vol->fmask = 0177;
vol->dmask = 0077; vol->dmask = 0077;
/*
* Default is to show long file names (including POSIX file names), and
* not to show system files and short file names.
*/
vol->readdir_opts = SHOW_WIN32;
/* 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;
......
...@@ -26,18 +26,30 @@ ...@@ -26,18 +26,30 @@
#include "types.h" #include "types.h"
/* These are used to determine which inode names are returned by readdir(). */ /*
* Defined bits for the flags field in the ntfs_volume structure.
*/
typedef enum { typedef enum {
SHOW_SYSTEM = 1, NV_ShowSystemFiles, /* 1: Return system files in ntfs_readdir(). */
SHOW_WIN32 = 2, NV_CaseSensitive, /* 1: Treat file names as case sensitive and
SHOW_DOS = 4, create filenames in the POSIX namespace.
SHOW_POSIX = SHOW_WIN32 | SHOW_DOS, Otherwise be case insensitive and create
SHOW_ALL = SHOW_SYSTEM | SHOW_POSIX, file names in WIN32 namespace. */
} READDIR_OPTIONS; } ntfs_volume_flags;
#define NVolShowSystemFiles(n_vol) test_bit(NV_ShowSystemFiles, \
&(n_vol)->flags)
#define NVolSetShowSystemFiles(n_vol) set_bit(NV_ShowSystemFiles, \
&(n_vol)->flags)
#define NVolClearShowSystemFiles(n_vol) clear_bit(NV_ShowSystemFiles, \
&(n_vol)->flags)
#define RHideSystemFiles(x) (!((x) & SHOW_SYSTEM)) #define NVolCaseSensitive(n_vol) test_bit(NV_CaseSensitive, \
#define RHideLongNames(x) (!((x) & SHOW_WIN32)) &(n_vol)->flags)
#define RHideDosNames(x) (!((x) & SHOW_DOS)) #define NVolSetCaseSensitive(n_vol) set_bit(NV_CaseSensitive, \
&(n_vol)->flags)
#define NVolClearCaseSensitive(n_vol) clear_bit(NV_CaseSensitive, \
&(n_vol)->flags)
/* /*
* The NTFS in memory super block structure. * The NTFS in memory super block structure.
...@@ -57,13 +69,13 @@ typedef struct { ...@@ -57,13 +69,13 @@ typedef struct {
LCN nr_blocks; /* Number of NTFS_BLOCK_SIZE bytes LCN nr_blocks; /* Number of NTFS_BLOCK_SIZE bytes
sized blocks on the device. */ sized blocks on the device. */
/* Configuration provided by user at mount time. */ /* Configuration provided by user at mount time. */
unsigned long flags; /* Miscellaneous flags, see above. */
uid_t uid; /* uid that files will be mounted as. */ uid_t uid; /* uid that files will be mounted as. */
gid_t gid; /* gid that files will be mounted as. */ gid_t gid; /* gid that files will be mounted as. */
mode_t fmask; /* The mask for file permissions. */ mode_t fmask; /* The mask for file permissions. */
mode_t dmask; /* The mask for directory mode_t dmask; /* The mask for directory
permissions. */ permissions. */
READDIR_OPTIONS readdir_opts; /* Namespace of inode names to show. */ u8 mft_zone_multiplier; /* Initial mft zone multiplier. */
u8 mft_zone_multiplier; /* Initial mft zone multiplier. */
u8 on_errors; /* What to do on file system errors. */ u8 on_errors; /* What to do on file system errors. */
/* NTFS bootsector provided information. */ /* NTFS bootsector provided information. */
u16 sector_size; /* in bytes */ u16 sector_size; /* in bytes */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment