]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/udf/dir.c
avoid overflows in kernel/time.c
[linux-2.6-omap-h63xx.git] / fs / udf / dir.c
index 9e3b9f97ddbc31bdc7715b51da85fb70ccb3b459..4b44e23caa1225a769f89b21dd4ad999034cf974 100644 (file)
 #include "udf_i.h"
 #include "udf_sb.h"
 
-/* Prototypes for file operations */
-static int udf_readdir(struct file *, void *, filldir_t);
-static int do_udf_readdir(struct inode *, struct file *, filldir_t, void *);
-
-/* readdir and lookup functions */
-
-const struct file_operations udf_dir_operations = {
-       .read                   = generic_read_dir,
-       .readdir                = udf_readdir,
-       .ioctl                  = udf_ioctl,
-       .fsync                  = udf_fsync_file,
-};
-
-/*
- * udf_readdir
- *
- * PURPOSE
- *     Read a directory entry.
- *
- * DESCRIPTION
- *     Optional - sys_getdents() will return -ENOTDIR if this routine is not
- *     available.
- *
- *     Refer to sys_getdents() in fs/readdir.c
- *     sys_getdents() -> .
- *
- * PRE-CONDITIONS
- *     filp                    Pointer to directory file.
- *     buf                     Pointer to directory entry buffer.
- *     filldir                 Pointer to filldir function.
- *
- * POST-CONDITIONS
- *     <return>                >=0 on success.
- *
- * HISTORY
- *     July 1, 1997 - Andrew E. Mileski
- *     Written, tested, and released.
- */
-
-int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
-{
-       struct inode *dir = filp->f_path.dentry->d_inode;
-       int result;
-
-       lock_kernel();
-
-       if (filp->f_pos == 0) {
-               if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0) {
-                       unlock_kernel();
-                       return 0;
-               }
-               filp->f_pos++;
-       }
-
-       result = do_udf_readdir(dir, filp, filldir, dirent);
-       unlock_kernel();
-       return result;
-}
-
-static int
-do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
-              void *dirent)
+static int do_udf_readdir(struct inode *dir, struct file *filp,
+                         filldir_t filldir, void *dirent)
 {
        struct udf_fileident_bh fibh;
        struct fileIdentDesc *fi = NULL;
@@ -117,6 +57,7 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
        int i, num;
        unsigned int dt_type;
        struct extent_position epos = { NULL, 0, {0, 0} };
+       struct udf_inode_info *iinfo;
 
        if (nf_pos >= size)
                return 0;
@@ -125,15 +66,17 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
                nf_pos = (udf_ext0_offset(dir) >> 2);
 
        fibh.soffset = fibh.eoffset = (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
-       if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
+       iinfo = UDF_I(dir);
+       if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) {
                fibh.sbh = fibh.ebh = NULL;
        } else if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2),
                              &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
                block = udf_get_lb_pblock(dir->i_sb, eloc, offset);
                if ((++offset << dir->i_sb->s_blocksize_bits) < elen) {
-                       if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
+                       if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT)
                                epos.offset -= sizeof(short_ad);
-                       else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
+                       else if (iinfo->i_alloc_type ==
+                                       ICBTAG_FLAG_AD_LONG)
                                epos.offset -= sizeof(long_ad);
                } else {
                        offset = 0;
@@ -244,3 +187,57 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
 
        return 0;
 }
+
+/*
+ * udf_readdir
+ *
+ * PURPOSE
+ *     Read a directory entry.
+ *
+ * DESCRIPTION
+ *     Optional - sys_getdents() will return -ENOTDIR if this routine is not
+ *     available.
+ *
+ *     Refer to sys_getdents() in fs/readdir.c
+ *     sys_getdents() -> .
+ *
+ * PRE-CONDITIONS
+ *     filp                    Pointer to directory file.
+ *     buf                     Pointer to directory entry buffer.
+ *     filldir                 Pointer to filldir function.
+ *
+ * POST-CONDITIONS
+ *     <return>                >=0 on success.
+ *
+ * HISTORY
+ *     July 1, 1997 - Andrew E. Mileski
+ *     Written, tested, and released.
+ */
+
+static int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
+{
+       struct inode *dir = filp->f_path.dentry->d_inode;
+       int result;
+
+       lock_kernel();
+
+       if (filp->f_pos == 0) {
+               if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0) {
+                       unlock_kernel();
+                       return 0;
+               }
+               filp->f_pos++;
+       }
+
+       result = do_udf_readdir(dir, filp, filldir, dirent);
+       unlock_kernel();
+       return result;
+}
+
+/* readdir and lookup functions */
+const struct file_operations udf_dir_operations = {
+       .read                   = generic_read_dir,
+       .readdir                = udf_readdir,
+       .ioctl                  = udf_ioctl,
+       .fsync                  = udf_fsync_file,
+};