Hi Tech,

In ntfs_access(), 'mask' is being built up in
three different places. From what I can see
'mode' doesn't change within this function,
so can't we simply set 'mask' once before
checking owner, groups and everyone?
Comments?

- Michael


Index: ntfs_vnops.c
===================================================================
RCS file: /cvs/src/sys/ntfs/ntfs_vnops.c,v
retrieving revision 1.26
diff -u -r1.26 ntfs_vnops.c
--- ntfs_vnops.c        20 Jun 2012 17:30:22 -0000      1.26
+++ ntfs_vnops.c        11 Oct 2012 13:52:51 -0000
@@ -380,37 +380,23 @@
                return (0);
 
        mask = 0;
+       if (mode & VEXEC)
+               mask |= S_IXOTH;
+       if (mode & VREAD)
+               mask |= S_IROTH;
+       if (mode & VWRITE)
+               mask |= S_IWOTH;
 
        /* Otherwise, check the owner. */
-       if (cred->cr_uid == ip->i_mp->ntm_uid) {
-               if (mode & VEXEC)
-                       mask |= S_IXUSR;
-               if (mode & VREAD)
-                       mask |= S_IRUSR;
-               if (mode & VWRITE)
-                       mask |= S_IWUSR;
+       if (cred->cr_uid == ip->i_mp->ntm_uid)
                return ((ip->i_mp->ntm_mode & mask) == mask ? 0 : EACCES);
-       }
 
        /* Otherwise, check the groups. */
        for (i = 0, gp = cred->cr_groups; i < cred->cr_ngroups; i++, gp++)
-               if (ip->i_mp->ntm_gid == *gp) {
-                       if (mode & VEXEC)
-                               mask |= S_IXGRP;
-                       if (mode & VREAD)
-                               mask |= S_IRGRP;
-                       if (mode & VWRITE)
-                               mask |= S_IWGRP;
+               if (ip->i_mp->ntm_gid == *gp)
                        return ((ip->i_mp->ntm_mode&mask) == mask ? 0 : EACCES);
-               }
 
        /* Otherwise, check everyone else. */
-       if (mode & VEXEC)
-               mask |= S_IXOTH;
-       if (mode & VREAD)
-               mask |= S_IROTH;
-       if (mode & VWRITE)
-               mask |= S_IWOTH;
        return ((ip->i_mp->ntm_mode & mask) == mask ? 0 : EACCES);
 }

Reply via email to