a1d312de7780e (Thomas Gleixner 2019-05-22 09:51:42 +0200 1) // SPDX-License-Identifier: GPL-2.0-or-later
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 2) /*
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 3) * namei.c - NTFS kernel directory inode operations. Part of the Linux-NTFS
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 4) * project.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 5) *
67b1dfe77a2eb (Anton Altaparmakov 2006-03-23 14:57:43 +0000 6) * Copyright (c) 2001-2006 Anton Altaparmakov
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 7) */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 8)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 9) #include <linux/dcache.h>
a569425512253 (Christoph Hellwig 2007-07-17 04:04:28 -0700 10) #include <linux/exportfs.h>
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 11) #include <linux/security.h>
5a0e3ad6af866 (Tejun Heo 2010-03-24 17:04:11 +0900 12) #include <linux/slab.h>
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 13)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 14) #include "attrib.h"
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 15) #include "debug.h"
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 16) #include "dir.h"
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 17) #include "mft.h"
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 18) #include "ntfs.h"
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 19)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 20) /**
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 21) * ntfs_lookup - find the inode represented by a dentry in a directory inode
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 22) * @dir_ino: directory inode in which to look for the inode
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 23) * @dent: dentry representing the inode to look for
89076bc31950e (Al Viro 2015-05-12 08:29:38 -0400 24) * @flags: lookup flags
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 25) *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 26) * In short, ntfs_lookup() looks for the inode represented by the dentry @dent
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 27) * in the directory inode @dir_ino and if found attaches the inode to the
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 28) * dentry @dent.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 29) *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 30) * In more detail, the dentry @dent specifies which inode to look for by
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 31) * supplying the name of the inode in @dent->d_name.name. ntfs_lookup()
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 32) * converts the name to Unicode and walks the contents of the directory inode
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 33) * @dir_ino looking for the converted Unicode name. If the name is found in the
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 34) * directory, the corresponding inode is loaded by calling ntfs_iget() on its
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 35) * inode number and the inode is associated with the dentry @dent via a call to
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 36) * d_splice_alias().
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 37) *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 38) * If the name is not found in the directory, a NULL inode is inserted into the
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 39) * dentry @dent via a call to d_add(). The dentry is then termed a negative
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 40) * dentry.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 41) *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 42) * Only if an actual error occurs, do we return an error via ERR_PTR().
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 43) *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 44) * In order to handle the case insensitivity issues of NTFS with regards to the
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 45) * dcache and the dcache requiring only one dentry per directory, we deal with
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 46) * dentry aliases that only differ in case in ->ntfs_lookup() while maintaining
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 47) * a case sensitive dcache. This means that we get the full benefit of dcache
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 48) * speed when the file/directory is looked up with the same case as returned by
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 49) * ->ntfs_readdir() but that a lookup for any other case (or for the short file
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 50) * name) will not find anything in dcache and will enter ->ntfs_lookup()
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 51) * instead, where we search the directory for a fully matching file name
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 52) * (including case) and if that is not found, we search for a file name that
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 53) * matches with different case and if that has non-POSIX semantics we return
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 54) * that. We actually do only one search (case sensitive) and keep tabs on
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 55) * whether we have found a case insensitive match in the process.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 56) *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 57) * To simplify matters for us, we do not treat the short vs long filenames as
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 58) * two hard links but instead if the lookup matches a short filename, we
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 59) * return the dentry for the corresponding long filename instead.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 60) *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 61) * There are three cases we need to distinguish here:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 62) *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 63) * 1) @dent perfectly matches (i.e. including case) a directory entry with a
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 64) * file name in the WIN32 or POSIX namespaces. In this case
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 65) * ntfs_lookup_inode_by_name() will return with name set to NULL and we
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 66) * just d_splice_alias() @dent.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 67) * 2) @dent matches (not including case) a directory entry with a file name in
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 68) * the WIN32 namespace. In this case ntfs_lookup_inode_by_name() will return
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 69) * with name set to point to a kmalloc()ed ntfs_name structure containing
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 70) * the properly cased little endian Unicode name. We convert the name to the
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 71) * current NLS code page, search if a dentry with this name already exists
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 72) * and if so return that instead of @dent. At this point things are
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 73) * complicated by the possibility of 'disconnected' dentries due to NFS
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 74) * which we deal with appropriately (see the code comments). The VFS will
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 75) * then destroy the old @dent and use the one we returned. If a dentry is
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 76) * not found, we allocate a new one, d_splice_alias() it, and return it as
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 77) * above.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 78) * 3) @dent matches either perfectly or not (i.e. we don't care about case) a
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 79) * directory entry with a file name in the DOS namespace. In this case
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 80) * ntfs_lookup_inode_by_name() will return with name set to point to a
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 81) * kmalloc()ed ntfs_name structure containing the mft reference (cpu endian)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 82) * of the inode. We use the mft reference to read the inode and to find the
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 83) * file name in the WIN32 namespace corresponding to the matched short file
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 84) * name. We then convert the name to the current NLS code page, and proceed
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 85) * searching for a dentry with this name, etc, as in case 2), above.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 86) *
1b1dcc1b57a49 (Jes Sorensen 2006-01-09 15:59:24 -0800 87) * Locking: Caller must hold i_mutex on the directory.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 88) */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 89) static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
00cd8dd3bf95f (Al Viro 2012-06-10 17:13:09 -0400 90) unsigned int flags)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 91) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 92) ntfs_volume *vol = NTFS_SB(dir_ino->i_sb);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 93) struct inode *dent_inode;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 94) ntfschar *uname;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 95) ntfs_name *name = NULL;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 96) MFT_REF mref;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 97) unsigned long dent_ino;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 98) int uname_len;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 99)
a455589f181e6 (Al Viro 2014-10-21 20:11:25 -0400 100) ntfs_debug("Looking up %pd in directory inode 0x%lx.",
a455589f181e6 (Al Viro 2014-10-21 20:11:25 -0400 101) dent, dir_ino->i_ino);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 102) /* Convert the name of the dentry to Unicode. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 103) uname_len = ntfs_nlstoucs(vol, dent->d_name.name, dent->d_name.len,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 104) &uname);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 105) if (uname_len < 0) {
834ba600cefe6 (Anton Altaparmakov 2006-03-23 16:25:23 +0000 106) if (uname_len != -ENAMETOOLONG)
834ba600cefe6 (Anton Altaparmakov 2006-03-23 16:25:23 +0000 107) ntfs_error(vol->sb, "Failed to convert name to "
834ba600cefe6 (Anton Altaparmakov 2006-03-23 16:25:23 +0000 108) "Unicode.");
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 109) return ERR_PTR(uname_len);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 110) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 111) mref = ntfs_lookup_inode_by_name(NTFS_I(dir_ino), uname, uname_len,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 112) &name);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 113) kmem_cache_free(ntfs_name_cache, uname);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 114) if (!IS_ERR_MREF(mref)) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 115) dent_ino = MREF(mref);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 116) ntfs_debug("Found inode 0x%lx. Calling ntfs_iget.", dent_ino);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 117) dent_inode = ntfs_iget(vol->sb, dent_ino);
cc22c800e15b0 (Denis Efremov 2019-09-25 16:49:43 -0700 118) if (!IS_ERR(dent_inode)) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 119) /* Consistency check. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 120) if (is_bad_inode(dent_inode) || MSEQNO(mref) ==
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 121) NTFS_I(dent_inode)->seq_no ||
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 122) dent_ino == FILE_MFT) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 123) /* Perfect WIN32/POSIX match. -- Case 1. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 124) if (!name) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 125) ntfs_debug("Done. (Case 1.)");
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 126) return d_splice_alias(dent_inode, dent);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 127) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 128) /*
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 129) * We are too indented. Handle imperfect
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 130) * matches and short file names further below.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 131) */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 132) goto handle_name;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 133) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 134) ntfs_error(vol->sb, "Found stale reference to inode "
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 135) "0x%lx (reference sequence number = "
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 136) "0x%x, inode sequence number = 0x%x), "
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 137) "returning -EIO. Run chkdsk.",
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 138) dent_ino, MSEQNO(mref),
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 139) NTFS_I(dent_inode)->seq_no);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 140) iput(dent_inode);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 141) dent_inode = ERR_PTR(-EIO);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 142) } else
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 143) ntfs_error(vol->sb, "ntfs_iget(0x%lx) failed with "
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 144) "error code %li.", dent_ino,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 145) PTR_ERR(dent_inode));
251c8427c9c41 (Jesper Juhl 2005-04-04 14:59:56 +0100 146) kfree(name);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 147) /* Return the error code. */
fee2aa7538238 (Kees Cook 2017-05-08 14:45:26 -0700 148) return ERR_CAST(dent_inode);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 149) }
834ba600cefe6 (Anton Altaparmakov 2006-03-23 16:25:23 +0000 150) /* It is guaranteed that @name is no longer allocated at this point. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 151) if (MREF_ERR(mref) == -ENOENT) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 152) ntfs_debug("Entry was not found, adding negative dentry.");
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 153) /* The dcache will handle negative entries. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 154) d_add(dent, NULL);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 155) ntfs_debug("Done.");
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 156) return NULL;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 157) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 158) ntfs_error(vol->sb, "ntfs_lookup_ino_by_name() failed with error "
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 159) "code %i.", -MREF_ERR(mref));
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 160) return ERR_PTR(MREF_ERR(mref));
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 161) // TODO: Consider moving this lot to a separate function! (AIA)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 162) handle_name:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 163) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 164) MFT_RECORD *m;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 165) ntfs_attr_search_ctx *ctx;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 166) ntfs_inode *ni = NTFS_I(dent_inode);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 167) int err;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 168) struct qstr nls_name;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 169)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 170) nls_name.name = NULL;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 171) if (name->type != FILE_NAME_DOS) { /* Case 2. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 172) ntfs_debug("Case 2.");
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 173) nls_name.len = (unsigned)ntfs_ucstonls(vol,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 174) (ntfschar*)&name->name, name->len,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 175) (unsigned char**)&nls_name.name, 0);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 176) kfree(name);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 177) } else /* if (name->type == FILE_NAME_DOS) */ { /* Case 3. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 178) FILE_NAME_ATTR *fn;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 179)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 180) ntfs_debug("Case 3.");
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 181) kfree(name);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 182)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 183) /* Find the WIN32 name corresponding to the matched DOS name. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 184) ni = NTFS_I(dent_inode);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 185) m = map_mft_record(ni);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 186) if (IS_ERR(m)) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 187) err = PTR_ERR(m);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 188) m = NULL;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 189) ctx = NULL;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 190) goto err_out;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 191) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 192) ctx = ntfs_attr_get_search_ctx(ni, m);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 193) if (unlikely(!ctx)) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 194) err = -ENOMEM;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 195) goto err_out;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 196) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 197) do {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 198) ATTR_RECORD *a;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 199) u32 val_len;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 200)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 201) err = ntfs_attr_lookup(AT_FILE_NAME, NULL, 0, 0, 0,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 202) NULL, 0, ctx);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 203) if (unlikely(err)) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 204) ntfs_error(vol->sb, "Inode corrupt: No WIN32 "
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 205) "namespace counterpart to DOS "
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 206) "file name. Run chkdsk.");
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 207) if (err == -ENOENT)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 208) err = -EIO;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 209) goto err_out;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 210) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 211) /* Consistency checks. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 212) a = ctx->attr;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 213) if (a->non_resident || a->flags)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 214) goto eio_err_out;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 215) val_len = le32_to_cpu(a->data.resident.value_length);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 216) if (le16_to_cpu(a->data.resident.value_offset) +
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 217) val_len > le32_to_cpu(a->length))
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 218) goto eio_err_out;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 219) fn = (FILE_NAME_ATTR*)((u8*)ctx->attr + le16_to_cpu(
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 220) ctx->attr->data.resident.value_offset));
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 221) if ((u32)(fn->file_name_length * sizeof(ntfschar) +
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 222) sizeof(FILE_NAME_ATTR)) > val_len)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 223) goto eio_err_out;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 224) } while (fn->file_name_type != FILE_NAME_WIN32);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 225)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 226) /* Convert the found WIN32 name to current NLS code page. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 227) nls_name.len = (unsigned)ntfs_ucstonls(vol,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 228) (ntfschar*)&fn->file_name, fn->file_name_length,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 229) (unsigned char**)&nls_name.name, 0);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 230)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 231) ntfs_attr_put_search_ctx(ctx);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 232) unmap_mft_record(ni);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 233) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 234) m = NULL;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 235) ctx = NULL;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 236)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 237) /* Check if a conversion error occurred. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 238) if ((signed)nls_name.len < 0) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 239) err = (signed)nls_name.len;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 240) goto err_out;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 241) }
8387ff2577eb9 (Linus Torvalds 2016-06-10 07:51:30 -0700 242) nls_name.hash = full_name_hash(dent, nls_name.name, nls_name.len);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 243)
2690421743b03 (Christoph Hellwig 2008-08-07 23:50:21 +0200 244) dent = d_add_ci(dent, dent_inode, &nls_name);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 245) kfree(nls_name.name);
2690421743b03 (Christoph Hellwig 2008-08-07 23:50:21 +0200 246) return dent;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 247)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 248) eio_err_out:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 249) ntfs_error(vol->sb, "Illegal file name attribute. Run chkdsk.");
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 250) err = -EIO;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 251) err_out:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 252) if (ctx)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 253) ntfs_attr_put_search_ctx(ctx);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 254) if (m)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 255) unmap_mft_record(ni);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 256) iput(dent_inode);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 257) ntfs_error(vol->sb, "Failed, returning error code %i.", err);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 258) return ERR_PTR(err);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 259) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 260) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 261)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 262) /**
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 263) * Inode operations for directories.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 264) */
92e1d5be91a0e (Arjan van de Ven 2007-02-12 00:55:39 -0800 265) const struct inode_operations ntfs_dir_inode_ops = {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 266) .lookup = ntfs_lookup, /* VFS: Lookup directory. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 267) };
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 268)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 269) /**
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 270) * ntfs_get_parent - find the dentry of the parent of a given directory dentry
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 271) * @child_dent: dentry of the directory whose parent directory to find
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 272) *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 273) * Find the dentry for the parent directory of the directory specified by the
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 274) * dentry @child_dent. This function is called from
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 275) * fs/exportfs/expfs.c::find_exported_dentry() which in turn is called from the
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 276) * default ->decode_fh() which is export_decode_fh() in the same file.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 277) *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 278) * The code is based on the ext3 ->get_parent() implementation found in
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 279) * fs/ext3/namei.c::ext3_get_parent().
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 280) *
2b0143b5c986b (David Howells 2015-03-17 22:25:59 +0000 281) * Note: ntfs_get_parent() is called with @d_inode(child_dent)->i_mutex down.
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 282) *
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 283) * Return the dentry of the parent directory on success or the error code on
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 284) * error (IS_ERR() is true).
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 285) */
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 286) static struct dentry *ntfs_get_parent(struct dentry *child_dent)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 287) {
2b0143b5c986b (David Howells 2015-03-17 22:25:59 +0000 288) struct inode *vi = d_inode(child_dent);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 289) ntfs_inode *ni = NTFS_I(vi);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 290) MFT_RECORD *mrec;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 291) ntfs_attr_search_ctx *ctx;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 292) ATTR_RECORD *attr;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 293) FILE_NAME_ATTR *fn;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 294) unsigned long parent_ino;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 295) int err;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 296)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 297) ntfs_debug("Entering for inode 0x%lx.", vi->i_ino);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 298) /* Get the mft record of the inode belonging to the child dentry. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 299) mrec = map_mft_record(ni);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 300) if (IS_ERR(mrec))
995f608e7a349 (Al Viro 2018-10-12 22:46:50 -0400 301) return ERR_CAST(mrec);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 302) /* Find the first file name attribute in the mft record. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 303) ctx = ntfs_attr_get_search_ctx(ni, mrec);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 304) if (unlikely(!ctx)) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 305) unmap_mft_record(ni);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 306) return ERR_PTR(-ENOMEM);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 307) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 308) try_next:
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 309) err = ntfs_attr_lookup(AT_FILE_NAME, NULL, 0, CASE_SENSITIVE, 0, NULL,
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 310) 0, ctx);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 311) if (unlikely(err)) {
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 312) ntfs_attr_put_search_ctx(ctx);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 313) unmap_mft_record(ni);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 314) if (err == -ENOENT)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 315) ntfs_error(vi->i_sb, "Inode 0x%lx does not have a "
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 316) "file name attribute. Run chkdsk.",
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 317) vi->i_ino);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 318) return ERR_PTR(err);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 319) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 320) attr = ctx->attr;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 321) if (unlikely(attr->non_resident))
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 322) goto try_next;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 323) fn = (FILE_NAME_ATTR *)((u8 *)attr +
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 324) le16_to_cpu(attr->data.resident.value_offset));
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 325) if (unlikely((u8 *)fn + le32_to_cpu(attr->data.resident.value_length) >
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 326) (u8*)attr + le32_to_cpu(attr->length)))
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 327) goto try_next;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 328) /* Get the inode number of the parent directory. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 329) parent_ino = MREF_LE(fn->parent_directory);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 330) /* Release the search context and the mft record of the child. */
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 331) ntfs_attr_put_search_ctx(ctx);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 332) unmap_mft_record(ni);
440037287c5eb (Christoph Hellwig 2008-08-11 15:49:04 +0200 333)
440037287c5eb (Christoph Hellwig 2008-08-11 15:49:04 +0200 334) return d_obtain_alias(ntfs_iget(vi->i_sb, parent_ino));
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 335) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 336)
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 337) static struct inode *ntfs_nfs_get_inode(struct super_block *sb,
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 338) u64 ino, u32 generation)
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 339) {
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 340) struct inode *inode;
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 341)
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 342) inode = ntfs_iget(sb, ino);
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 343) if (!IS_ERR(inode)) {
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 344) if (is_bad_inode(inode) || inode->i_generation != generation) {
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 345) iput(inode);
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 346) inode = ERR_PTR(-ESTALE);
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 347) }
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 348) }
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 349)
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 350) return inode;
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 351) }
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 352)
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 353) static struct dentry *ntfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 354) int fh_len, int fh_type)
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 355) {
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 356) return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 357) ntfs_nfs_get_inode);
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 358) }
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 359)
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 360) static struct dentry *ntfs_fh_to_parent(struct super_block *sb, struct fid *fid,
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 361) int fh_len, int fh_type)
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 362) {
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 363) return generic_fh_to_parent(sb, fid, fh_len, fh_type,
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 364) ntfs_nfs_get_inode);
^1da177e4c3f4 (Linus Torvalds 2005-04-16 15:20:36 -0700 365) }
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 366)
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 367) /**
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 368) * Export operations allowing NFS exporting of mounted NTFS partitions.
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 369) *
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 370) * We use the default ->encode_fh() for now. Note that they
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 371) * use 32 bits to store the inode number which is an unsigned long so on 64-bit
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 372) * architectures is usually 64 bits so it would all fail horribly on huge
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 373) * volumes. I guess we need to define our own encode and decode fh functions
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 374) * that store 64-bit inode numbers at some point but for now we will ignore the
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 375) * problem...
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 376) *
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 377) * We also use the default ->get_name() helper (used by ->decode_fh() via
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 378) * fs/exportfs/expfs.c::find_exported_dentry()) as that is completely fs
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 379) * independent.
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 380) *
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 381) * The default ->get_parent() just returns -EACCES so we have to provide our
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 382) * own and the default ->get_dentry() is incompatible with NTFS due to not
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 383) * allowing the inode number 0 which is used in NTFS for the system file $MFT
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 384) * and due to using iget() whereas NTFS needs ntfs_iget().
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 385) */
3965516440594 (Christoph Hellwig 2007-10-21 16:42:17 -0700 386) const struct export_operations ntfs_export_ops = {
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 387) .get_parent = ntfs_get_parent, /* Find the parent of a given
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 388) directory. */
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 389) .fh_to_dentry = ntfs_fh_to_dentry,
a35132068a919 (Christoph Hellwig 2007-10-21 16:42:10 -0700 390) .fh_to_parent = ntfs_fh_to_parent,
413826868fb49 (Anton Altaparmakov 2005-03-03 13:44:15 +0000 391) };