Merge branch 'for-2.6.33' of git://git.kernel.dk/linux-2.6-block
[safe/jmp/linux-2.6] / fs / xfs / xfs_dir2_sf.c
index dcd09ca..e89734e 100644 (file)
@@ -332,7 +332,7 @@ xfs_dir2_sf_addname(
                /*
                 * Just checking or no space reservation, it doesn't fit.
                 */
-               if (args->justcheck || args->total == 0)
+               if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0)
                        return XFS_ERROR(ENOSPC);
                /*
                 * Convert to block form then add the name.
@@ -345,7 +345,7 @@ xfs_dir2_sf_addname(
        /*
         * Just checking, it fits.
         */
-       if (args->justcheck)
+       if (args->op_flags & XFS_DA_OP_JUSTCHECK)
                return 0;
        /*
         * Do it the easy way - just add it at the end.
@@ -748,12 +748,8 @@ xfs_dir2_sf_getdents(
         * Put . entry unless we're starting past it.
         */
        if (*offset <= dot_offset) {
-               ino = dp->i_ino;
-#if XFS_BIG_INUMS
-               ino += mp->m_inoadd;
-#endif
-               if (filldir(dirent, ".", 1, dot_offset, ino, DT_DIR)) {
-                       *offset = dot_offset;
+               if (filldir(dirent, ".", 1, dot_offset & 0x7fffffff, dp->i_ino, DT_DIR)) {
+                       *offset = dot_offset & 0x7fffffff;
                        return 0;
                }
        }
@@ -763,11 +759,8 @@ xfs_dir2_sf_getdents(
         */
        if (*offset <= dotdot_offset) {
                ino = xfs_dir2_sf_get_inumber(sfp, &sfp->hdr.parent);
-#if XFS_BIG_INUMS
-               ino += mp->m_inoadd;
-#endif
-               if (filldir(dirent, "..", 2, dotdot_offset, ino, DT_DIR)) {
-                       *offset = dotdot_offset;
+               if (filldir(dirent, "..", 2, dotdot_offset & 0x7fffffff, ino, DT_DIR)) {
+                       *offset = dotdot_offset & 0x7fffffff;
                        return 0;
                }
        }
@@ -786,19 +779,16 @@ xfs_dir2_sf_getdents(
                }
 
                ino = xfs_dir2_sf_get_inumber(sfp, xfs_dir2_sf_inumberp(sfep));
-#if XFS_BIG_INUMS
-               ino += mp->m_inoadd;
-#endif
-
                if (filldir(dirent, sfep->name, sfep->namelen,
-                                           off, ino, DT_UNKNOWN)) {
-                       *offset = off;
+                           off & 0x7fffffff, ino, DT_UNKNOWN)) {
+                       *offset = off & 0x7fffffff;
                        return 0;
                }
                sfep = xfs_dir2_sf_nextentry(sfp, sfep);
        }
 
-       *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0);
+       *offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) &
+                       0x7fffffff;
        return 0;
 }
 
@@ -812,9 +802,11 @@ xfs_dir2_sf_lookup(
 {
        xfs_inode_t             *dp;            /* incore directory inode */
        int                     i;              /* entry index */
+       int                     error;
        xfs_dir2_sf_entry_t     *sfep;          /* shortform directory entry */
        xfs_dir2_sf_t           *sfp;           /* shortform structure */
        enum xfs_dacmp          cmp;            /* comparison result */
+       xfs_dir2_sf_entry_t     *ci_sfep;       /* case-insens. entry */
 
        xfs_dir2_trace_args("sf_lookup", args);
        xfs_dir2_sf_check(args);
@@ -852,6 +844,7 @@ xfs_dir2_sf_lookup(
        /*
         * Loop over all the entries trying to match ours.
         */
+       ci_sfep = NULL;
        for (i = 0, sfep = xfs_dir2_sf_firstentry(sfp); i < sfp->hdr.count;
                                i++, sfep = xfs_dir2_sf_nextentry(sfp, sfep)) {
                /*
@@ -867,19 +860,19 @@ xfs_dir2_sf_lookup(
                                                xfs_dir2_sf_inumberp(sfep));
                        if (cmp == XFS_CMP_EXACT)
                                return XFS_ERROR(EEXIST);
+                       ci_sfep = sfep;
                }
        }
-       ASSERT(args->oknoent);
+       ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
        /*
         * Here, we can only be doing a lookup (not a rename or replace).
-        * If a case-insensitive match was found earlier, return "found".
-        */
-       if (args->cmpresult == XFS_CMP_CASE)
-               return XFS_ERROR(EEXIST);
-       /*
-        * Didn't find it.
+        * If a case-insensitive match was not found, return ENOENT.
         */
-       return XFS_ERROR(ENOENT);
+       if (!ci_sfep)
+               return XFS_ERROR(ENOENT);
+       /* otherwise process the CI match as required by the caller */
+       error = xfs_dir_cilookup_result(args, ci_sfep->name, ci_sfep->namelen);
+       return XFS_ERROR(error);
 }
 
 /*
@@ -1071,7 +1064,7 @@ xfs_dir2_sf_replace(
                 * Didn't find it.
                 */
                if (i == sfp->hdr.count) {
-                       ASSERT(args->oknoent);
+                       ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
 #if XFS_BIG_INUMS
                        if (i8elevated)
                                xfs_dir2_sf_toino4(args);