Author: pfg
Date: Wed Feb 20 20:56:07 2013
New Revision: 247055
URL: http://svnweb.freebsd.org/changeset/base/247055

Log:
  MFC   r246347, r246348, r246349, r246350, r246351, r246352:
  
  ext2fs: Miscellaneous cleanups and fixes.
  
  Use EXT2_LINK_MAX instead of LINK_MAX.
  Use nitems().
  Correct off-by-one errors in FFTODT() and DDTOFT().
  Remove useless rootino local variable.
  Remove unused em_e2fsb definition.
  Move assignment where it is not dead.
  
  Submitted by:         Christoph Mallon

Modified:
  stable/9/sys/fs/ext2fs/ext2_lookup.c
  stable/9/sys/fs/ext2fs/ext2_mount.h
  stable/9/sys/fs/ext2fs/ext2_vnops.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/fs/   (props changed)

Modified: stable/9/sys/fs/ext2fs/ext2_lookup.c
==============================================================================
--- stable/9/sys/fs/ext2fs/ext2_lookup.c        Wed Feb 20 20:42:56 2013        
(r247054)
+++ stable/9/sys/fs/ext2fs/ext2_lookup.c        Wed Feb 20 20:56:07 2013        
(r247055)
@@ -88,9 +88,8 @@ static u_char ext2_ft_to_dt[] = {
        DT_SOCK,                /* EXT2_FT_SOCK */
        DT_LNK,                 /* EXT2_FT_SYMLINK */
 };
-#define        FTTODT(ft)                                              \
-    ((ft) > sizeof(ext2_ft_to_dt) / sizeof(ext2_ft_to_dt[0]) ? \
-    DT_UNKNOWN : ext2_ft_to_dt[(ft)])
+#define        FTTODT(ft) \
+    ((ft) < nitems(ext2_ft_to_dt) ? ext2_ft_to_dt[(ft)] : DT_UNKNOWN)
 
 static u_char dt_to_ext2_ft[] = {
        EXT2_FT_UNKNOWN,        /* DT_UNKNOWN */
@@ -109,9 +108,8 @@ static u_char dt_to_ext2_ft[] = {
        EXT2_FT_UNKNOWN,        /* unused */
        EXT2_FT_UNKNOWN,        /* DT_WHT */
 };
-#define        DTTOFT(dt)                                              \
-    ((dt) > sizeof(dt_to_ext2_ft) / sizeof(dt_to_ext2_ft[0]) ? \
-    EXT2_FT_UNKNOWN : dt_to_ext2_ft[(dt)])
+#define        DTTOFT(dt) \
+    ((dt) < nitems(dt_to_ext2_ft) ? dt_to_ext2_ft[(dt)] : EXT2_FT_UNKNOWN)
 
 static int     ext2_dirbadentry(struct vnode *dp, struct ext2fs_direct_2 *de,
                    int entryoffsetinblock);
@@ -1088,7 +1086,7 @@ ext2_checkpath(source, target, cred)
        struct ucred *cred;
 {
        struct vnode *vp;
-       int error, rootino, namlen;
+       int error, namlen;
        struct dirtemplate dirbuf;
 
        vp = ITOV(target);
@@ -1096,10 +1094,10 @@ ext2_checkpath(source, target, cred)
                error = EEXIST;
                goto out;
        }
-       rootino = EXT2_ROOTINO;
-       error = 0;
-       if (target->i_number == rootino)
+       if (target->i_number == EXT2_ROOTINO) {
+               error = 0;
                goto out;
+       }
 
        for (;;) {
                if (vp->v_type != VDIR) {
@@ -1123,7 +1121,7 @@ ext2_checkpath(source, target, cred)
                        error = EINVAL;
                        break;
                }
-               if (dirbuf.dotdot_ino == rootino)
+               if (dirbuf.dotdot_ino == EXT2_ROOTINO)
                        break;
                vput(vp);
                if ((error = VFS_VGET(vp->v_mount, dirbuf.dotdot_ino,

Modified: stable/9/sys/fs/ext2fs/ext2_mount.h
==============================================================================
--- stable/9/sys/fs/ext2fs/ext2_mount.h Wed Feb 20 20:42:56 2013        
(r247054)
+++ stable/9/sys/fs/ext2fs/ext2_mount.h Wed Feb 20 20:56:07 2013        
(r247055)
@@ -48,7 +48,6 @@ struct ext2mount {
        struct  vnode *um_devvp;                /* block device mounted vnode */
 
        struct  m_ext2fs *um_e2fs;              /* EXT2FS */
-#define em_e2fsb um_e2fs->e2fs
 
        u_long  um_nindir;                      /* indirect ptrs per block */
        u_long  um_bptrtodb;                    /* indir ptr to disk block */

Modified: stable/9/sys/fs/ext2fs/ext2_vnops.c
==============================================================================
--- stable/9/sys/fs/ext2fs/ext2_vnops.c Wed Feb 20 20:42:56 2013        
(r247054)
+++ stable/9/sys/fs/ext2fs/ext2_vnops.c Wed Feb 20 20:56:07 2013        
(r247055)
@@ -736,7 +736,7 @@ ext2_link(ap)
                goto out;
        }
        ip = VTOI(vp);
-       if ((nlink_t)ip->i_nlink >= LINK_MAX) {
+       if ((nlink_t)ip->i_nlink >= EXT2_LINK_MAX) {
                error = EMLINK;
                goto out;
        }
@@ -847,7 +847,7 @@ abortit:
                goto abortit;
        dp = VTOI(fdvp);
        ip = VTOI(fvp);
-       if (ip->i_nlink >= LINK_MAX) {
+       if (ip->i_nlink >= EXT2_LINK_MAX) {
                VOP_UNLOCK(fvp, 0);
                error = EMLINK;
                goto abortit;
@@ -945,7 +945,7 @@ abortit:
                 * parent we don't fool with the link count.
                 */
                if (doingdirectory && newparent) {
-                       if ((nlink_t)dp->i_nlink >= LINK_MAX) {
+                       if ((nlink_t)dp->i_nlink >= EXT2_LINK_MAX) {
                                error = EMLINK;
                                goto bad;
                        }
@@ -1166,7 +1166,7 @@ ext2_mkdir(ap)
                panic("ext2_mkdir: no name");
 #endif
        dp = VTOI(dvp);
-       if ((nlink_t)dp->i_nlink >= LINK_MAX) {
+       if ((nlink_t)dp->i_nlink >= EXT2_LINK_MAX) {
                error = EMLINK;
                goto out;
        }
@@ -1530,7 +1530,7 @@ ext2_pathconf(ap)
 
        switch (ap->a_name) {
        case _PC_LINK_MAX:
-               *ap->a_retval = LINK_MAX;
+               *ap->a_retval = EXT2_LINK_MAX;
                return (0);
        case _PC_NAME_MAX:
                *ap->a_retval = NAME_MAX;
_______________________________________________
svn-src-stable-9@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-stable-9
To unsubscribe, send any mail to "svn-src-stable-9-unsubscr...@freebsd.org"

Reply via email to