Whamcloud - gitweb
Branch b1_6
[fs/lustre-release.git] / lustre / llite / llite_internal.h
index f98f79e..65ab7f9 100644 (file)
@@ -5,7 +5,6 @@
 #ifndef LLITE_INTERNAL_H
 #define LLITE_INTERNAL_H
 
-#include <linux/ext2_fs.h>
 #ifdef CONFIG_FS_POSIX_ACL
 # include <linux/fs.h>
 #ifdef HAVE_XATTR_ACL
@@ -48,6 +47,26 @@ static inline struct lookup_intent *ll_nd2it(struct nameidata *nd)
 }
 #endif
 
+/*
+ * Directory entries are currently in the same format as ext2/ext3, but will
+ * be changed in the future to accomodate FIDs
+ */
+#define LL_DIR_NAME_LEN (255)
+#define LL_DIR_PAD      (4)
+
+struct ll_dir_entry {
+        /* number of inode, referenced by this entry */
+       __le32  lde_inode;
+        /* total record length, multiple of LL_DIR_PAD */
+       __le16  lde_rec_len;
+        /* length of name */
+       __u8    lde_name_len;
+        /* file type: regular, directory, device, etc. */
+       __u8    lde_file_type;
+        /* name. NOT NUL-terminated */
+       char    lde_name[LL_DIR_NAME_LEN];
+};
+
 struct ll_dentry_data {
         int                      lld_cwd_count;
         int                      lld_mnt_count;
@@ -504,27 +523,26 @@ extern struct file_operations ll_dir_operations;
 extern struct inode_operations ll_dir_inode_operations;
 
 struct page *ll_get_dir_page(struct inode *dir, unsigned long n);
-/*
- * p is at least 6 bytes before the end of page
- */
-typedef struct ext2_dir_entry_2 ext2_dirent;
 
-static inline ext2_dirent *ext2_next_entry(ext2_dirent *p)
+static inline unsigned ll_dir_rec_len(unsigned name_len)
 {
-        return (ext2_dirent *)((char*)p + le16_to_cpu(p->rec_len));
+        return (name_len + 8 + LL_DIR_PAD - 1) & ~(LL_DIR_PAD - 1);
 }
 
-static inline unsigned
-ext2_validate_entry(char *base, unsigned offset, unsigned mask)
+static inline struct ll_dir_entry *ll_entry_at(void *base, unsigned offset)
+{
+        return (struct ll_dir_entry *)((char *)base + offset);
+}
+
+/*
+ * p is at least 6 bytes before the end of page
+ */
+static inline struct ll_dir_entry *ll_dir_next_entry(struct ll_dir_entry *p)
 {
-        ext2_dirent *de = (ext2_dirent*)(base + offset);
-        ext2_dirent *p = (ext2_dirent*)(base + (offset&mask));
-        while ((char*)p < (char*)de)
-                p = ext2_next_entry(p);
-        return (char *)p - base;
+        return ll_entry_at(p, le16_to_cpu(p->lde_rec_len));
 }
 
-static inline void ext2_put_page(struct page *page)
+static inline void ll_put_page(struct page *page)
 {
         kunmap(page);
         page_cache_release(page);