Patch to implement getattr [patch]

Magnus Ahltorp (map@stacken.kth.se)
14 Jul 1999 00:56:20 +0200


The Linux VFS requires the file system to use unique inode numbers.
This is not always possible, especially when these must be mapped from
larger numbers (e.g. 128-bit AFS identifiers).

I presented this problem to the list about a year ago, and the
response I got was to use the integer value of pointers to my
extra-data structures. This produces inode numbers that are unique
within a machine at any given point in time. They are not, however,
persistent with respect to given file.

This would not be a problem if there was a way for the file system to
control what inode number is passed to userland. This is not possible
in the current kernel, since stat only copies the information from the
struct inode. The below patch implements an inode operation that lets
the file system decide what the stat system call should return.

--- include/linux/fs.h.orig Tue Jan 26 05:00:51 1999
+++ include/linux/fs.h Tue Jul 13 20:16:55 1999
@@ -613,6 +613,7 @@
int (*smap) (struct inode *,int);
int (*updatepage) (struct file *, struct page *, unsigned long, unsigned int, int);
int (*revalidate) (struct dentry *);
+ int (*getattr) (struct inode *, struct stat *);
};

struct super_operations {
--- fs/stat.c.orig Tue Jul 13 20:17:22 1999
+++ fs/stat.c Tue Jul 13 22:02:52 1999
@@ -62,6 +62,13 @@
struct stat tmp;
unsigned int blocks, indirect;

+ if (inode->i_op && inode->i_op->getattr) {
+ int ret;
+
+ ret = inode->i_op->getattr(inode, &tmp);
+ if (ret)
+ return ret;
+ } else {
memset(&tmp, 0, sizeof(tmp));
tmp.st_dev = kdev_t_to_nr(inode->i_dev);
tmp.st_ino = inode->i_ino;
@@ -109,6 +116,7 @@
} else {
tmp.st_blocks = inode->i_blocks;
tmp.st_blksize = inode->i_blksize;
+ }
}
return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/