Linux-kernel mailing list archive 1997-49,: generic find_inode_number for dcache.c

# generic find_inode_number for dcache.c

Bill Hawes (whawes@star.net)
Mon, 08 Dec 1997 10:39:54 -0500

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: Bill Hawes: "proposed dcache changes"
- Previous message: ther: "Re: Let's vote for PnP on 2.2 (Was: PnP in 2.2 ?)"

This is a multi-part message in MIME format.
--------------3A364430D28FE16CC8015A42
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

The attached patch adds a generic version of find_inode_number to
dcache.c. This routine is currently used by smbfs and ncpfs to sync
directory listings with existing dentries, in order to keep getwd()
working. It should be useful to any fs using synthetic inode numbers.

To support a generic fs, find_inode_number uses the fs-specific d_hash
operation before performing the lookup.

Dcache.c seemed like the best home for it, since it's basically using
low-level dentry operations.

Regards,
Bill
--------------3A364430D28FE16CC8015A42
Content-Type: text/plain; charset=us-ascii; name="dcache_71-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="dcache_71-patch"

--- linux-2.1.71/include/linux/fs.h.old Fri Dec 5 18:37:54 1997
+++ linux-2.1.71/include/linux/fs.h Mon Dec 8 11:16:02 1997
@@ -709,6 +709,7 @@
extern struct dentry * open_namei(const char * pathname, int flag, int mode);
extern struct dentry * do_mknod(const char * filename, int mode, dev_t dev);
extern int do_pipe(int *);
+extern ino_t find_inode_number(struct dentry *, struct qstr *);
/*
* Kernel pointers have redundant information, so we can use a
--- linux-2.1.71/fs/dcache.c.old Mon Dec 1 11:14:13 1997
+++ linux-2.1.71/fs/dcache.c Mon Dec 8 11:27:16 1997
@@ -744,6 +744,42 @@
return retval;
}
+/*
+ * Check whether a dentry already exists for the given name,
+ * and return the inode number if it has an inode.
+ *
+ * This routine is used to post-process directory listings for
+ * filesystems using synthetic inode numbers, and is necessary
+ * to keep getcwd() working.
+ */
+ino_t find_inode_number(struct dentry *dir, struct qstr *name)
+{
+ struct dentry * dentry;
+ ino_t ino = 0;
+
+ /*
+ * Check for a fs-specific hash function. Note that we must
+ * calculate the standard hash first, as the d_op->d_hash()
+ * routine may choose to leave the hash value unchanged.
+ */
+ name->hash = full_name_hash(name->name, name->len);
+ if (dir->d_op && dir->d_op->d_hash)
+ {
+ if (dir->d_op->d_hash(dir, name) != 0)
+ goto out;
+ }
+
+ dentry = d_lookup(dir, name);
+ if (dentry)
+ {
+ if (dentry->d_inode)
+ ino = dentry->d_inode->i_ino;
+ dput(dentry);
+ }
+out:
+ return ino;
+}
+
__initfunc(void dcache_init(void))
{
int i;
--- linux-2.1.71/kernel/ksyms.c.old Wed Dec 3 10:42:34 1997
+++ linux-2.1.71/kernel/ksyms.c Mon Dec 8 11:12:24 1997
@@ -202,6 +202,7 @@
EXPORT_SYMBOL(prune_dcache);
EXPORT_SYMBOL(shrink_dcache_sb);
EXPORT_SYMBOL(shrink_dcache_parent);
+EXPORT_SYMBOL(find_inode_number);
#if !defined(CONFIG_NFSD) && defined(CONFIG_NFSD_MODULE)
EXPORT_SYMBOL(do_nfsservctl);

--------------3A364430D28FE16CC8015A42--

- Next message: Bill Hawes: "proposed dcache changes"
- Previous message: ther: "Re: Let's vote for PnP on 2.2 (Was: PnP in 2.2 ?)"