Add an accessor function for directory names.
This commit is contained in:
parent
653d6346b1
commit
98320dbc87
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dir.c,v 1.41 2015/09/15 15:01:38 dholland Exp $ */
|
||||
/* $NetBSD: dir.c,v 1.42 2015/09/15 15:02:01 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
|
@ -198,8 +198,8 @@ fsck_readdir(struct uvnode *vp, struct inodesc *idesc)
|
|||
lfs_dir_setnamlen(fs, dp, 0);
|
||||
lfs_dir_setreclen(fs, dp, LFS_DIRBLKSIZ);
|
||||
/* for now at least, don't zero the old contents */
|
||||
/*lfs_copydirname(fs, dp->d_name, "", 0, LFS_DIRBLKSIZ);*/
|
||||
dp->d_name[0] = '\0';
|
||||
/*lfs_copydirname(fs, lfs_dir_nameptr(fs, dp), "", 0, LFS_DIRBLKSIZ);*/
|
||||
lfs_dir_nameptr(fs, dp)[0] = '\0';
|
||||
if (fix)
|
||||
VOP_BWRITE(bp);
|
||||
else
|
||||
|
@ -281,7 +281,7 @@ dircheck(struct inodesc *idesc, struct lfs_direct *dp)
|
|||
printf("reclen<size, filesize<size, namlen too large, or type>15\n");
|
||||
return (0);
|
||||
}
|
||||
cp = dp->d_name;
|
||||
cp = lfs_dir_nameptr(fs, dp);
|
||||
for (size = 0; size < namlen; size++)
|
||||
if (*cp == '\0' || (*cp++ == '/')) {
|
||||
printf("name contains NUL or /\n");
|
||||
|
@ -400,7 +400,7 @@ mkentry(struct inodesc *idesc)
|
|||
lfs_dir_setreclen(fs, dirp, newreclen);
|
||||
lfs_dir_settype(fs, dirp, typemap[idesc->id_parent]);
|
||||
lfs_dir_setnamlen(fs, dirp, namlen);
|
||||
lfs_copydirname(fs, dirp->d_name, idesc->id_name,
|
||||
lfs_copydirname(fs, lfs_dir_nameptr(fs, dirp), idesc->id_name,
|
||||
namlen, newreclen);
|
||||
|
||||
return (ALTERED | STOP);
|
||||
|
@ -413,7 +413,7 @@ chgino(struct inodesc *idesc)
|
|||
int namlen;
|
||||
|
||||
namlen = lfs_dir_getnamlen(fs, dirp);
|
||||
if (memcmp(dirp->d_name, idesc->id_name, namlen + 1))
|
||||
if (memcmp(lfs_dir_nameptr(fs, dirp), idesc->id_name, namlen + 1))
|
||||
return (KEEPON);
|
||||
lfs_dir_setino(fs, dirp, idesc->id_parent);
|
||||
lfs_dir_settype(fs, dirp, typemap[idesc->id_parent]);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: inode.c,v 1.65 2015/09/15 15:01:22 dholland Exp $ */
|
||||
/* $NetBSD: inode.c,v 1.66 2015/09/15 15:02:01 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -515,7 +515,7 @@ findname(struct inodesc * idesc)
|
|||
}
|
||||
/* this is namebuf with utils.h */
|
||||
buf = __UNCONST(idesc->id_name);
|
||||
(void)memcpy(buf, dirp->d_name, len);
|
||||
(void)memcpy(buf, lfs_dir_nameptr(fs, dirp), len);
|
||||
return (STOP | FOUND);
|
||||
}
|
||||
|
||||
|
@ -528,7 +528,7 @@ findino(struct inodesc * idesc)
|
|||
ino = lfs_dir_getino(fs, dirp);
|
||||
if (ino == 0)
|
||||
return (KEEPON);
|
||||
if (strcmp(dirp->d_name, idesc->id_name) == 0 &&
|
||||
if (strcmp(lfs_dir_nameptr(fs, dirp), idesc->id_name) == 0 &&
|
||||
ino >= ULFS_ROOTINO && ino < maxino) {
|
||||
idesc->id_parent = ino;
|
||||
return (STOP | FOUND);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pass2.c,v 1.30 2015/09/15 15:01:38 dholland Exp $ */
|
||||
/* $NetBSD: pass2.c,v 1.31 2015/09/15 15:02:01 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
|
@ -226,7 +226,7 @@ pass2check(struct inodesc * idesc)
|
|||
*/
|
||||
if (idesc->id_entryno != 0)
|
||||
goto chk1;
|
||||
if (lfs_dir_getino(fs, dirp) != 0 && strcmp(dirp->d_name, ".") == 0) {
|
||||
if (lfs_dir_getino(fs, dirp) != 0 && strcmp(lfs_dir_nameptr(fs, dirp), ".") == 0) {
|
||||
if (lfs_dir_getino(fs, dirp) != idesc->id_number) {
|
||||
direrror(idesc->id_number, "BAD INODE NUMBER FOR '.'");
|
||||
if (reply("FIX") == 1) {
|
||||
|
@ -249,16 +249,16 @@ pass2check(struct inodesc * idesc)
|
|||
lfs_dir_setnamlen(fs, &proto, 1);
|
||||
entrysize = LFS_DIRECTSIZ(1);
|
||||
lfs_dir_setreclen(fs, &proto, entrysize);
|
||||
if (lfs_dir_getino(fs, dirp) != 0 && strcmp(dirp->d_name, "..") != 0) {
|
||||
if (lfs_dir_getino(fs, dirp) != 0 && strcmp(lfs_dir_nameptr(fs, dirp), "..") != 0) {
|
||||
pfatal("CANNOT FIX, FIRST ENTRY IN DIRECTORY CONTAINS %s\n",
|
||||
dirp->d_name);
|
||||
lfs_dir_nameptr(fs, dirp));
|
||||
} else if (lfs_dir_getreclen(fs, dirp) < entrysize) {
|
||||
pfatal("CANNOT FIX, INSUFFICIENT SPACE TO ADD '.'\n");
|
||||
} else if (lfs_dir_getreclen(fs, dirp) < 2 * entrysize) {
|
||||
/* convert this entry to a . entry */
|
||||
lfs_dir_setreclen(fs, &proto, lfs_dir_getreclen(fs, dirp));
|
||||
memcpy(dirp, &proto, sizeof(proto));
|
||||
lfs_copydirname(fs, dirp->d_name, ".", 1,
|
||||
lfs_copydirname(fs, lfs_dir_nameptr(fs, dirp), ".", 1,
|
||||
lfs_dir_getreclen(fs, dirp));
|
||||
if (reply("FIX") == 1)
|
||||
ret |= ALTERED;
|
||||
|
@ -266,7 +266,7 @@ pass2check(struct inodesc * idesc)
|
|||
/* split this entry and use the beginning for the . entry */
|
||||
n = lfs_dir_getreclen(fs, dirp) - entrysize;
|
||||
memcpy(dirp, &proto, sizeof(proto));
|
||||
lfs_copydirname(fs, dirp->d_name, ".", 1,
|
||||
lfs_copydirname(fs, lfs_dir_nameptr(fs, dirp), ".", 1,
|
||||
lfs_dir_getreclen(fs, dirp));
|
||||
idesc->id_entryno++;
|
||||
lncntp[lfs_dir_getino(fs, dirp)]--;
|
||||
|
@ -297,7 +297,7 @@ chk1:
|
|||
memset(dirp, 0, lfs_dir_getreclen(fs, &proto));
|
||||
lfs_dir_setreclen(fs, dirp, lfs_dir_getreclen(fs, &proto));
|
||||
}
|
||||
if (lfs_dir_getino(fs, dirp) != 0 && strcmp(dirp->d_name, "..") == 0) {
|
||||
if (lfs_dir_getino(fs, dirp) != 0 && strcmp(lfs_dir_nameptr(fs, dirp), "..") == 0) {
|
||||
inp->i_dotdot = lfs_dir_getino(fs, dirp);
|
||||
if (lfs_dir_gettype(fs, dirp) != LFS_DT_DIR) {
|
||||
direrror(idesc->id_number, "BAD TYPE VALUE FOR '..'");
|
||||
|
@ -307,10 +307,10 @@ chk1:
|
|||
}
|
||||
goto chk2;
|
||||
}
|
||||
if (lfs_dir_getino(fs, dirp) != 0 && strcmp(dirp->d_name, ".") != 0) {
|
||||
if (lfs_dir_getino(fs, dirp) != 0 && strcmp(lfs_dir_nameptr(fs, dirp), ".") != 0) {
|
||||
fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
|
||||
pfatal("CANNOT FIX, SECOND ENTRY IN DIRECTORY CONTAINS %s\n",
|
||||
dirp->d_name);
|
||||
lfs_dir_nameptr(fs, dirp));
|
||||
inp->i_dotdot = (ino_t) - 1;
|
||||
} else if (lfs_dir_getreclen(fs, dirp) < entrysize) {
|
||||
fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
|
||||
|
@ -324,7 +324,7 @@ chk1:
|
|||
fileerror(inp->i_parent, idesc->id_number, "MISSING '..'");
|
||||
lfs_dir_setreclen(fs, &proto, lfs_dir_getreclen(fs, dirp));
|
||||
memcpy(dirp, &proto, (size_t) entrysize);
|
||||
lfs_copydirname(fs, dirp->d_name, "..", 2,
|
||||
lfs_copydirname(fs, lfs_dir_nameptr(fs, dirp), "..", 2,
|
||||
lfs_dir_getreclen(fs, dirp));
|
||||
if (reply("FIX") == 1)
|
||||
ret |= ALTERED;
|
||||
|
@ -337,7 +337,7 @@ chk2:
|
|||
if (lfs_dir_getino(fs, dirp) == 0)
|
||||
return (ret | KEEPON);
|
||||
if (lfs_dir_getnamlen(fs, dirp) <= 2 &&
|
||||
dirp->d_name[0] == '.' &&
|
||||
lfs_dir_nameptr(fs, dirp)[0] == '.' &&
|
||||
idesc->id_entryno >= 2) {
|
||||
if (lfs_dir_getnamlen(fs, dirp) == 1) {
|
||||
direrror(idesc->id_number, "EXTRA '.' ENTRY");
|
||||
|
@ -347,7 +347,7 @@ chk2:
|
|||
}
|
||||
return (KEEPON | ret);
|
||||
}
|
||||
if (dirp->d_name[1] == '.') {
|
||||
if (lfs_dir_nameptr(fs, dirp)[1] == '.') {
|
||||
direrror(idesc->id_number, "EXTRA '..' ENTRY");
|
||||
if (reply("FIX") == 1) {
|
||||
lfs_dir_setino(fs, dirp, 0);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: make_lfs.c,v 1.52 2015/09/15 15:01:38 dholland Exp $ */
|
||||
/* $NetBSD: make_lfs.c,v 1.53 2015/09/15 15:02:01 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
|
@ -62,7 +62,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)lfs.c 8.5 (Berkeley) 5/24/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: make_lfs.c,v 1.52 2015/09/15 15:01:38 dholland Exp $");
|
||||
__RCSID("$NetBSD: make_lfs.c,v 1.53 2015/09/15 15:02:01 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -380,7 +380,7 @@ make_dir(struct lfs *fs, void *bufp,
|
|||
lfs_dir_setreclen(fs, ep, reclen);
|
||||
lfs_dir_settype(fs, ep, protodir[i].dp_type);
|
||||
lfs_dir_setnamlen(fs, ep, namlen);
|
||||
lfs_copydirname(fs, ep->d_name, protodir[i].dp_name,
|
||||
lfs_copydirname(fs, lfs_dir_nameptr(fs, ep), protodir[i].dp_name,
|
||||
namlen, reclen);
|
||||
ep = LFS_NEXTDIR(fs, ep);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lfs.h,v 1.187 2015/09/15 14:59:58 dholland Exp $ */
|
||||
/* $NetBSD: lfs.h,v 1.188 2015/09/15 15:02:01 dholland Exp $ */
|
||||
|
||||
/* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */
|
||||
/* from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp */
|
||||
|
@ -376,16 +376,6 @@ struct lfs_direct {
|
|||
char d_name[LFS_MAXNAMLEN + 1];/* name with length <= LFS_MAXNAMLEN */
|
||||
};
|
||||
|
||||
/* Note that this does *not* byteswap and should probably be phased out */
|
||||
#define LFS_DIRECT_INITIALIZER(ino, type, namlen, name) \
|
||||
{ \
|
||||
.d_ino = (ino), \
|
||||
.d_reclen = LFS_DIRECTSIZE(namlen), \
|
||||
.d_type = (type), \
|
||||
.d_namlen = (namlen), \
|
||||
.d_name = (name) \
|
||||
}
|
||||
|
||||
/*
|
||||
* Template for manipulating directories. Should use struct lfs_direct's,
|
||||
* but the name field is LFS_MAXNAMLEN - 1, and this just won't do.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lfs_accessors.h,v 1.25 2015/09/15 15:01:38 dholland Exp $ */
|
||||
/* $NetBSD: lfs_accessors.h,v 1.26 2015/09/15 15:02:01 dholland Exp $ */
|
||||
|
||||
/* from NetBSD: lfs.h,v 1.165 2015/07/24 06:59:32 dholland Exp */
|
||||
/* from NetBSD: dinode.h,v 1.22 2013/01/22 09:39:18 dholland Exp */
|
||||
|
@ -244,6 +244,12 @@
|
|||
#define LFS_NEXTDIR(fs, dp) \
|
||||
((struct lfs_direct *)((char *)(dp) + lfs_dir_getreclen(fs, dp)))
|
||||
|
||||
static __unused inline char *
|
||||
lfs_dir_nameptr(const STRUCT_LFS *fs, struct lfs_direct *dp)
|
||||
{
|
||||
return (char *)(&dp->d_header + 1);
|
||||
}
|
||||
|
||||
static __unused inline uint32_t
|
||||
lfs_dir_getino(const STRUCT_LFS *fs, const struct lfs_direct *dp)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lfs_rename.c,v 1.11 2015/09/15 15:00:32 dholland Exp $ */
|
||||
/* $NetBSD: lfs_rename.c,v 1.12 2015/09/15 15:02:01 dholland Exp $ */
|
||||
/* from NetBSD: ufs_rename.c,v 1.6 2013/01/22 09:39:18 dholland Exp */
|
||||
|
||||
/*-
|
||||
|
@ -89,7 +89,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.11 2015/09/15 15:00:32 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.12 2015/09/15 15:02:01 dholland Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -442,7 +442,7 @@ ulfs_rename_recalculate_fulr(struct vnode *dvp,
|
|||
if (fcnp->cn_namelen != ulfs_direct_namlen(ep, dvp))
|
||||
goto next; /* Wrong name length. */
|
||||
|
||||
if (memcmp(ep->d_name, fcnp->cn_nameptr, fcnp->cn_namelen))
|
||||
if (memcmp(lfs_dir_nameptr(fs, ep), fcnp->cn_nameptr, fcnp->cn_namelen))
|
||||
goto next; /* Wrong name. */
|
||||
|
||||
/* Got it! */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ulfs_dirhash.c,v 1.10 2015/09/15 14:58:06 dholland Exp $ */
|
||||
/* $NetBSD: ulfs_dirhash.c,v 1.11 2015/09/15 15:02:01 dholland Exp $ */
|
||||
/* from NetBSD: ufs_dirhash.c,v 1.34 2009/10/05 23:48:08 rmind Exp */
|
||||
|
||||
/*
|
||||
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ulfs_dirhash.c,v 1.10 2015/09/15 14:58:06 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ulfs_dirhash.c,v 1.11 2015/09/15 15:02:01 dholland Exp $");
|
||||
|
||||
/*
|
||||
* This implements a hash-based lookup scheme for ULFS directories.
|
||||
|
@ -236,7 +236,7 @@ ulfsdirhash_build(struct inode *ip)
|
|||
}
|
||||
if (lfs_dir_getino(fs, ep) != 0) {
|
||||
/* Add the entry (simplified ulfsdirhash_add). */
|
||||
slot = ulfsdirhash_hash(dh, ep->d_name,
|
||||
slot = ulfsdirhash_hash(dh, lfs_dir_nameptr(fs, ep),
|
||||
lfs_dir_getnamlen(fs, ep));
|
||||
while (DH_ENTRY(dh, slot) != DIRHASH_EMPTY)
|
||||
slot = WRAPINCR(slot, dh->dh_hlen);
|
||||
|
@ -433,7 +433,7 @@ restart:
|
|||
return (EJUSTRETURN);
|
||||
}
|
||||
if (lfs_dir_getnamlen(fs, dp) == namelen &&
|
||||
memcmp(dp->d_name, name, namelen) == 0) {
|
||||
memcmp(lfs_dir_nameptr(fs, dp), name, namelen) == 0) {
|
||||
/* Found. Get the prev offset if needed. */
|
||||
if (prevoffp != NULL) {
|
||||
if (offset & (dirblksiz - 1)) {
|
||||
|
@ -650,7 +650,8 @@ ulfsdirhash_add(struct inode *ip, struct lfs_direct *dirp, doff_t offset)
|
|||
}
|
||||
|
||||
/* Find a free hash slot (empty or deleted), and add the entry. */
|
||||
slot = ulfsdirhash_hash(dh, dirp->d_name, lfs_dir_getnamlen(fs, dirp));
|
||||
slot = ulfsdirhash_hash(dh, lfs_dir_nameptr(fs, dirp),
|
||||
lfs_dir_getnamlen(fs, dirp));
|
||||
while (DH_ENTRY(dh, slot) >= 0)
|
||||
slot = WRAPINCR(slot, dh->dh_hlen);
|
||||
if (DH_ENTRY(dh, slot) == DIRHASH_EMPTY)
|
||||
|
@ -687,7 +688,7 @@ ulfsdirhash_remove(struct inode *ip, struct lfs_direct *dirp, doff_t offset)
|
|||
|
||||
KASSERT(offset < dh->dh_dirblks * dirblksiz);
|
||||
/* Find the entry */
|
||||
slot = ulfsdirhash_findslot(dh, dirp->d_name,
|
||||
slot = ulfsdirhash_findslot(dh, lfs_dir_nameptr(fs, dirp),
|
||||
lfs_dir_getnamlen(fs, dirp), offset);
|
||||
|
||||
/* Remove the hash entry. */
|
||||
|
@ -722,7 +723,7 @@ ulfsdirhash_move(struct inode *ip, struct lfs_direct *dirp, doff_t oldoff,
|
|||
KASSERT(oldoff < dh->dh_dirblks * ip->i_lfs->um_dirblksiz &&
|
||||
newoff < dh->dh_dirblks * ip->i_lfs->um_dirblksiz);
|
||||
/* Find the entry, and update the offset. */
|
||||
slot = ulfsdirhash_findslot(dh, dirp->d_name,
|
||||
slot = ulfsdirhash_findslot(dh, lfs_dir_nameptr(fs, dirp),
|
||||
lfs_dir_getnamlen(fs, dirp), oldoff);
|
||||
DH_ENTRY(dh, slot) = newoff;
|
||||
DIRHASH_UNLOCK(dh);
|
||||
|
@ -872,7 +873,8 @@ ulfsdirhash_checkblock(struct inode *ip, char *sbuf, doff_t offset)
|
|||
}
|
||||
|
||||
/* Check that the entry exists (will panic if it doesn't). */
|
||||
ulfsdirhash_findslot(dh, dp->d_name, lfs_dir_getnamlen(fs, dp),
|
||||
ulfsdirhash_findslot(dh, lfs_dir_nameptr(fs, dp),
|
||||
lfs_dir_getnamlen(fs, dp),
|
||||
offset + i);
|
||||
|
||||
nfree += lfs_dir_getreclen(fs, dp) - LFS_DIRSIZ(fs, dp);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ulfs_lookup.c,v 1.30 2015/09/15 15:01:22 dholland Exp $ */
|
||||
/* $NetBSD: ulfs_lookup.c,v 1.31 2015/09/15 15:02:01 dholland Exp $ */
|
||||
/* from NetBSD: ufs_lookup.c,v 1.122 2013/01/22 09:39:18 dholland Exp */
|
||||
|
||||
/*
|
||||
|
@ -38,7 +38,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.30 2015/09/15 15:01:22 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.31 2015/09/15 15:02:01 dholland Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_lfs.h"
|
||||
|
@ -377,7 +377,7 @@ searchloop:
|
|||
|
||||
namlen = lfs_dir_getnamlen(fs, ep);
|
||||
if (namlen == cnp->cn_namelen &&
|
||||
!memcmp(cnp->cn_nameptr, ep->d_name,
|
||||
!memcmp(cnp->cn_nameptr, lfs_dir_nameptr(fs, ep),
|
||||
(unsigned)namlen)) {
|
||||
#ifdef LFS_DIRHASH
|
||||
foundentry:
|
||||
|
@ -683,7 +683,7 @@ ulfs_dirbadentry(struct vnode *dp, struct lfs_direct *ep, int entryoffsetinblock
|
|||
}
|
||||
if (lfs_dir_getino(fs, ep) == 0)
|
||||
return (0);
|
||||
name = ep->d_name;
|
||||
name = lfs_dir_nameptr(fs, ep);
|
||||
for (i = 0; i < namlen; i++)
|
||||
if (name[i] == '\0') {
|
||||
/*return (1); */
|
||||
|
@ -719,8 +719,8 @@ ulfs_direntry_assign(struct lfs *fs, struct lfs_direct *dirp,
|
|||
lfs_dir_setino(fs, dirp, inum);
|
||||
lfs_dir_setnamlen(fs, dirp, namlen);
|
||||
lfs_dir_settype(fs, dirp, dtype);
|
||||
memcpy(dirp->d_name, name, namlen);
|
||||
dirp->d_name[namlen] = '\0';
|
||||
memcpy(lfs_dir_nameptr(fs, dirp), name, namlen);
|
||||
lfs_dir_nameptr(fs, dirp)[namlen] = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -907,7 +907,7 @@ ulfs_direnter(struct vnode *dvp, const struct ulfs_lookup_results *ulr,
|
|||
*/
|
||||
if (lfs_dir_getino(fs, ep) == 0 ||
|
||||
(lfs_dir_getino(fs, ep) == ULFS_WINO &&
|
||||
memcmp(ep->d_name, name, namlen) == 0)) {
|
||||
memcmp(lfs_dir_nameptr(fs, ep), name, namlen) == 0)) {
|
||||
if (spacefree + dsize < newentrysize)
|
||||
panic("ulfs_direnter: compact1");
|
||||
reclen = spacefree + dsize;
|
||||
|
@ -1160,7 +1160,7 @@ ulfs_dirempty(struct inode *ip, ino_t parentino, kauth_cred_t cred)
|
|||
continue;
|
||||
/* accept only "." and ".." */
|
||||
namlen = lfs_dir_getnamlen(fs, dp);
|
||||
name = dp->d_name;
|
||||
name = lfs_dir_nameptr(fs, dp);
|
||||
if (namlen > 2)
|
||||
return (0);
|
||||
if (name[0] != '.')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ulfs_vnops.c,v 1.30 2015/09/15 15:00:32 dholland Exp $ */
|
||||
/* $NetBSD: ulfs_vnops.c,v 1.31 2015/09/15 15:02:01 dholland Exp $ */
|
||||
/* from NetBSD: ufs_vnops.c,v 1.213 2013/06/08 05:47:02 kardel Exp */
|
||||
|
||||
/*-
|
||||
|
@ -67,7 +67,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.30 2015/09/15 15:00:32 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.31 2015/09/15 15:02:01 dholland Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_lfs.h"
|
||||
|
@ -863,7 +863,8 @@ ulfs_readdir(void *v)
|
|||
_DIRENT_MINSIZE(ndp) > endp)
|
||||
break;
|
||||
ndp->d_fileno = lfs_dir_getino(fs, cdp);
|
||||
(void)memcpy(ndp->d_name, cdp->d_name, ndp->d_namlen);
|
||||
(void)memcpy(ndp->d_name, lfs_dir_nameptr(fs, cdp),
|
||||
ndp->d_namlen);
|
||||
memset(&ndp->d_name[ndp->d_namlen], 0,
|
||||
ndp->d_reclen - _DIRENT_NAMEOFF(ndp) - ndp->d_namlen);
|
||||
off += lfs_dir_getreclen(fs, cdp);
|
||||
|
|
Loading…
Reference in New Issue