[Pvfs2-cvs] commit by pcarns in pvfs2-1/src/kernel/linux-2.6: dir.c

CVS commit program cvs at parl.clemson.edu
Fri Feb 1 12:16:13 EST 2008


Update of /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6
In directory parlweb1:/tmp/cvs-serv8264/src/kernel/linux-2.6

Modified Files:
      Tag: pvfs-2-7-branch
	dir.c 
Log Message:
merging directory seek stuff from trunk to pvfs-2-7-branch


Index: dir.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/dir.c,v
diff -p -u -r1.49 -r1.49.2.1
--- dir.c	19 Aug 2007 18:20:27 -0000	1.49
+++ dir.c	1 Feb 2008 17:16:13 -0000	1.49.2.1
@@ -15,6 +15,11 @@
 #include "pvfs2-sysint.h"
 #include "pvfs2-internal.h"
 
+/* older kernels did not define this in fs.h */
+#ifndef SEEK_SET
+#define SEEK_SET 0
+#endif
+
 typedef struct 
 {
     int buffer_index;
@@ -878,6 +883,43 @@ static int pvfs2_readdirplus_lite(
 }
 #endif
 
+/** Change the file pointer position for an instance of an open dir.
+ *
+ *  \note If .llseek is overriden, we must acquire lock as described in
+ *        Documentation/filesystems/Locking.
+ */
+loff_t pvfs2_dir_llseek(struct file *file, loff_t offset, int origin)
+{
+    /* offsets 0 and 1 are fine */
+
+    if (origin == SEEK_SET && offset == 2)
+    {
+	gossip_debug(GOSSIP_DIR_DEBUG, "pvfs2_dir_llseek: setting READDIR_START\n");
+        /* offset 2 _really_ means the first true pvfs entry, skip . and .. */
+        offset = PVFS_READDIR_START;
+    }
+    else if (origin == SEEK_SET && ((offset == 3) || (offset == 4)))
+    {
+        /* we don't have any way to specify this; if we set offset to 
+         * 0 or 1 then pvfs_readdir() will think you want "." or ".."
+         */
+        gossip_err("PVFS can't seek directories to offset 3 or 4!\n");
+        return(-EINVAL);
+    }
+    else if (origin == SEEK_SET && offset > 4)
+    {
+	gossip_debug(GOSSIP_DIR_DEBUG, "pvfs2_dir_llseek: guessing directory token\n");
+        /* contrive what the pvfs readdir token probably is, assuming that
+         * we need to skip two entries as well */
+        offset -= 3;
+    }
+
+    gossip_debug(GOSSIP_FILE_DEBUG, "pvfs2_dir_llseek: offset is %ld | origin is %d\n",
+                (long)offset, origin);
+
+    return generic_file_llseek(file, offset, origin);
+}
+
 /** PVFS2 implementation of VFS directory operations */
 struct file_operations pvfs2_dir_operations =
 {
@@ -885,7 +927,8 @@ struct file_operations pvfs2_dir_operati
     read : generic_read_dir,
     readdir : pvfs2_readdir,
     open : pvfs2_file_open,
-    release : pvfs2_file_release
+    release : pvfs2_file_release,
+    llseek : pvfs2_dir_llseek
 #else
     .read = generic_read_dir,
     .readdir = pvfs2_readdir,
@@ -896,7 +939,8 @@ struct file_operations pvfs2_dir_operati
     .readdirplus_lite = pvfs2_readdirplus_lite,
 #endif
     .open = pvfs2_file_open,
-    .release = pvfs2_file_release
+    .release = pvfs2_file_release,
+    .llseek = pvfs2_dir_llseek
 #endif
 };
 



More information about the Pvfs2-cvs mailing list