[Midnightbsd-cvs] src [8796] trunk/sys/fs/ext2fs: ext2fs: misc cleanup.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Sep 25 23:23:43 EDT 2016
Revision: 8796
http://svnweb.midnightbsd.org/src/?rev=8796
Author: laffer1
Date: 2016-09-25 23:23:43 -0400 (Sun, 25 Sep 2016)
Log Message:
-----------
ext2fs: misc cleanup. Correct off by one error
Modified Paths:
--------------
trunk/sys/fs/ext2fs/ext2_lookup.c
trunk/sys/fs/ext2fs/ext2_mount.h
trunk/sys/fs/ext2fs/ext2_vnops.c
Modified: trunk/sys/fs/ext2fs/ext2_lookup.c
===================================================================
--- trunk/sys/fs/ext2fs/ext2_lookup.c 2016-09-26 03:23:12 UTC (rev 8795)
+++ trunk/sys/fs/ext2fs/ext2_lookup.c 2016-09-26 03:23:43 UTC (rev 8796)
@@ -88,9 +88,8 @@
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 @@
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 @@
struct ucred *cred;
{
struct vnode *vp;
- int error, rootino, namlen;
+ int error, namlen;
struct dirtemplate dirbuf;
vp = ITOV(target);
@@ -1096,10 +1094,10 @@
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 @@
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: trunk/sys/fs/ext2fs/ext2_mount.h
===================================================================
--- trunk/sys/fs/ext2fs/ext2_mount.h 2016-09-26 03:23:12 UTC (rev 8795)
+++ trunk/sys/fs/ext2fs/ext2_mount.h 2016-09-26 03:23:43 UTC (rev 8796)
@@ -48,7 +48,6 @@
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: trunk/sys/fs/ext2fs/ext2_vnops.c
===================================================================
--- trunk/sys/fs/ext2fs/ext2_vnops.c 2016-09-26 03:23:12 UTC (rev 8795)
+++ trunk/sys/fs/ext2fs/ext2_vnops.c 2016-09-26 03:23:43 UTC (rev 8796)
@@ -736,7 +736,7 @@
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 @@
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 @@
* 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 @@
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 @@
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;
More information about the Midnightbsd-cvs
mailing list