Pass around struct lfs_dirheader instead of struct lfs_direct.
This commit is contained in:
parent
98320dbc87
commit
805a8504cb
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dir.c,v 1.42 2015/09/15 15:02:01 dholland Exp $ */
|
||||
/* $NetBSD: dir.c,v 1.43 2015/09/15 15:02:25 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
|
@ -85,7 +85,7 @@ struct lfs_odirtemplate odirhead = {
|
|||
|
||||
static int expanddir(struct uvnode *, union lfs_dinode *, char *);
|
||||
static void freedir(ino_t, ino_t);
|
||||
static struct lfs_direct *fsck_readdir(struct uvnode *, struct inodesc *);
|
||||
static struct lfs_dirheader *fsck_readdir(struct uvnode *, struct inodesc *);
|
||||
static int lftempname(char *, ino_t);
|
||||
static int mkentry(struct inodesc *);
|
||||
static int chgino(struct inodesc *);
|
||||
|
@ -132,7 +132,7 @@ propagate(void)
|
|||
int
|
||||
dirscan(struct inodesc *idesc)
|
||||
{
|
||||
struct lfs_direct *dp;
|
||||
struct lfs_dirheader *dp;
|
||||
struct ubuf *bp;
|
||||
int dsize, n;
|
||||
long blksiz;
|
||||
|
@ -156,7 +156,7 @@ dirscan(struct inodesc *idesc)
|
|||
dp = fsck_readdir(vp, idesc)) {
|
||||
dsize = lfs_dir_getreclen(fs, dp);
|
||||
memcpy(dbuf, dp, (size_t) dsize);
|
||||
idesc->id_dirp = (struct lfs_direct *) dbuf;
|
||||
idesc->id_dirp = (struct lfs_dirheader *) dbuf;
|
||||
if ((n = (*idesc->id_func) (idesc)) & ALTERED) {
|
||||
bread(vp, idesc->id_lblkno, blksiz, 0, &bp);
|
||||
memcpy(bp->b_data + idesc->id_loc - dsize, dbuf,
|
||||
|
@ -173,10 +173,10 @@ dirscan(struct inodesc *idesc)
|
|||
/*
|
||||
* get next entry in a directory.
|
||||
*/
|
||||
static struct lfs_direct *
|
||||
static struct lfs_dirheader *
|
||||
fsck_readdir(struct uvnode *vp, struct inodesc *idesc)
|
||||
{
|
||||
struct lfs_direct *dp, *ndp;
|
||||
struct lfs_dirheader *dp, *ndp;
|
||||
struct ubuf *bp;
|
||||
long size, blksiz, fix, dploc;
|
||||
|
||||
|
@ -184,7 +184,7 @@ fsck_readdir(struct uvnode *vp, struct inodesc *idesc)
|
|||
bread(vp, idesc->id_lblkno, blksiz, 0, &bp);
|
||||
if (idesc->id_loc % LFS_DIRBLKSIZ == 0 && idesc->id_filesize > 0 &&
|
||||
idesc->id_loc < blksiz) {
|
||||
dp = (struct lfs_direct *) (bp->b_data + idesc->id_loc);
|
||||
dp = (struct lfs_dirheader *) (bp->b_data + idesc->id_loc);
|
||||
if (dircheck(idesc, dp))
|
||||
goto dpok;
|
||||
brelse(bp, 0);
|
||||
|
@ -192,7 +192,7 @@ fsck_readdir(struct uvnode *vp, struct inodesc *idesc)
|
|||
return (0);
|
||||
fix = dofix(idesc, "DIRECTORY CORRUPTED");
|
||||
bread(vp, idesc->id_lblkno, blksiz, 0, &bp);
|
||||
dp = (struct lfs_direct *) (bp->b_data + idesc->id_loc);
|
||||
dp = (struct lfs_dirheader *) (bp->b_data + idesc->id_loc);
|
||||
lfs_dir_setino(fs, dp, 0);
|
||||
lfs_dir_settype(fs, dp, LFS_DT_UNKNOWN);
|
||||
lfs_dir_setnamlen(fs, dp, 0);
|
||||
|
@ -214,14 +214,14 @@ dpok:
|
|||
return NULL;
|
||||
}
|
||||
dploc = idesc->id_loc;
|
||||
dp = (struct lfs_direct *) (bp->b_data + dploc);
|
||||
dp = (struct lfs_dirheader *) (bp->b_data + dploc);
|
||||
idesc->id_loc += lfs_dir_getreclen(fs, dp);
|
||||
idesc->id_filesize -= lfs_dir_getreclen(fs, dp);
|
||||
if ((idesc->id_loc % LFS_DIRBLKSIZ) == 0) {
|
||||
brelse(bp, 0);
|
||||
return dp;
|
||||
}
|
||||
ndp = (struct lfs_direct *) (bp->b_data + idesc->id_loc);
|
||||
ndp = (struct lfs_dirheader *) (bp->b_data + idesc->id_loc);
|
||||
if (idesc->id_loc < blksiz && idesc->id_filesize > 0 &&
|
||||
dircheck(idesc, ndp) == 0) {
|
||||
brelse(bp, 0);
|
||||
|
@ -232,7 +232,7 @@ dpok:
|
|||
return 0;
|
||||
fix = dofix(idesc, "DIRECTORY CORRUPTED");
|
||||
bread(vp, idesc->id_lblkno, blksiz, 0, &bp);
|
||||
dp = (struct lfs_direct *) (bp->b_data + dploc);
|
||||
dp = (struct lfs_dirheader *) (bp->b_data + dploc);
|
||||
lfs_dir_setreclen(fs, dp, lfs_dir_getreclen(fs, dp) + size);
|
||||
if (fix)
|
||||
VOP_BWRITE(bp);
|
||||
|
@ -249,7 +249,7 @@ dpok:
|
|||
* This is a superset of the checks made in the kernel.
|
||||
*/
|
||||
int
|
||||
dircheck(struct inodesc *idesc, struct lfs_direct *dp)
|
||||
dircheck(struct inodesc *idesc, struct lfs_dirheader *dp)
|
||||
{
|
||||
int size;
|
||||
const char *cp;
|
||||
|
@ -370,7 +370,7 @@ adjust(struct inodesc *idesc, short lcnt)
|
|||
static int
|
||||
mkentry(struct inodesc *idesc)
|
||||
{
|
||||
struct lfs_direct *dirp = idesc->id_dirp;
|
||||
struct lfs_dirheader *dirp = idesc->id_dirp;
|
||||
unsigned namlen;
|
||||
unsigned newreclen, oldreclen;
|
||||
|
||||
|
@ -409,7 +409,7 @@ mkentry(struct inodesc *idesc)
|
|||
static int
|
||||
chgino(struct inodesc *idesc)
|
||||
{
|
||||
struct lfs_direct *dirp = idesc->id_dirp;
|
||||
struct lfs_dirheader *dirp = idesc->id_dirp;
|
||||
int namlen;
|
||||
|
||||
namlen = lfs_dir_getnamlen(fs, dirp);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: extern.h,v 1.12 2015/08/12 18:28:00 dholland Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.13 2015/09/15 15:02:25 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994 James A. Jegers
|
||||
|
@ -36,7 +36,7 @@ int chkrange(daddr_t, int);
|
|||
void ckfini(int);
|
||||
int ckinode(union lfs_dinode *, struct inodesc *);
|
||||
void clri(struct inodesc *, const char *, int);
|
||||
int dircheck(struct inodesc *, struct lfs_direct *);
|
||||
int dircheck(struct inodesc *, struct lfs_dirheader *);
|
||||
void direrror(ino_t, const char *);
|
||||
int dirscan(struct inodesc *);
|
||||
int dofix(struct inodesc *, const char *);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fsck.h,v 1.21 2015/08/12 18:28:00 dholland Exp $ */
|
||||
/* $NetBSD: fsck.h,v 1.22 2015/09/15 15:02:25 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -132,7 +132,7 @@ struct inodesc {
|
|||
off_t id_filesize; /* for DATA nodes, the size of the directory */
|
||||
int id_loc; /* for DATA nodes, current location in dir */
|
||||
int id_entryno; /* for DATA nodes, current entry number */
|
||||
struct lfs_direct *id_dirp; /* for DATA nodes, ptr to current entry */
|
||||
struct lfs_dirheader *id_dirp; /* for DATA nodes, ptr to current entry */
|
||||
const char *id_name; /* for DATA nodes, name to find or enter */
|
||||
char id_type; /* type of descriptor, DATA or ADDR */
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: inode.c,v 1.66 2015/09/15 15:02:01 dholland Exp $ */
|
||||
/* $NetBSD: inode.c,v 1.67 2015/09/15 15:02:25 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
|
||||
|
@ -501,7 +501,7 @@ clearinode(ino_t inumber)
|
|||
int
|
||||
findname(struct inodesc * idesc)
|
||||
{
|
||||
struct lfs_direct *dirp = idesc->id_dirp;
|
||||
struct lfs_dirheader *dirp = idesc->id_dirp;
|
||||
size_t len;
|
||||
char *buf;
|
||||
|
||||
|
@ -522,7 +522,7 @@ findname(struct inodesc * idesc)
|
|||
int
|
||||
findino(struct inodesc * idesc)
|
||||
{
|
||||
struct lfs_direct *dirp = idesc->id_dirp;
|
||||
struct lfs_dirheader *dirp = idesc->id_dirp;
|
||||
ino_t ino;
|
||||
|
||||
ino = lfs_dir_getino(fs, dirp);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pass2.c,v 1.31 2015/09/15 15:02:01 dholland Exp $ */
|
||||
/* $NetBSD: pass2.c,v 1.32 2015/09/15 15:02:25 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
|
@ -212,12 +212,12 @@ pass2(void)
|
|||
static int
|
||||
pass2check(struct inodesc * idesc)
|
||||
{
|
||||
struct lfs_direct *dirp = idesc->id_dirp;
|
||||
struct lfs_dirheader *dirp = idesc->id_dirp;
|
||||
struct inoinfo *inp;
|
||||
int n, entrysize, ret = 0;
|
||||
union lfs_dinode *dp;
|
||||
const char *errmsg;
|
||||
struct lfs_direct proto;
|
||||
struct lfs_dirheader proto;
|
||||
char namebuf[MAXPATHLEN + 1];
|
||||
char pathbuf[MAXPATHLEN + 1];
|
||||
|
||||
|
@ -293,7 +293,7 @@ chk1:
|
|||
lfs_dir_setreclen(fs, dirp, n);
|
||||
idesc->id_entryno++;
|
||||
lncntp[lfs_dir_getino(fs, dirp)]--;
|
||||
dirp = (struct lfs_direct *) ((char *) (dirp) + n);
|
||||
dirp = (struct lfs_dirheader *) ((char *) (dirp) + n);
|
||||
memset(dirp, 0, lfs_dir_getreclen(fs, &proto));
|
||||
lfs_dir_setreclen(fs, dirp, lfs_dir_getreclen(fs, &proto));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: make_lfs.c,v 1.53 2015/09/15 15:02:01 dholland Exp $ */
|
||||
/* $NetBSD: make_lfs.c,v 1.54 2015/09/15 15:02:25 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.53 2015/09/15 15:02:01 dholland Exp $");
|
||||
__RCSID("$NetBSD: make_lfs.c,v 1.54 2015/09/15 15:02:25 dholland Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -357,7 +357,7 @@ static void
|
|||
make_dir(struct lfs *fs, void *bufp,
|
||||
const struct dirproto *protodir, unsigned numentries)
|
||||
{
|
||||
struct lfs_direct *ep;
|
||||
struct lfs_dirheader *ep;
|
||||
unsigned spaceleft;
|
||||
unsigned namlen, reclen;
|
||||
unsigned i;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lfs_accessors.h,v 1.26 2015/09/15 15:02:01 dholland Exp $ */
|
||||
/* $NetBSD: lfs_accessors.h,v 1.27 2015/09/15 15:02:25 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 */
|
||||
|
@ -223,7 +223,7 @@
|
|||
* null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
|
||||
*/
|
||||
#define LFS_DIRECTSIZ(namlen) \
|
||||
((sizeof(struct lfs_direct) - (LFS_MAXNAMLEN+1)) + (((namlen)+1 + 3) &~ 3))
|
||||
(sizeof(struct lfs_dirheader) + (((namlen)+1 + 3) &~ 3))
|
||||
|
||||
#if (BYTE_ORDER == LITTLE_ENDIAN)
|
||||
#define LFS_OLDDIRSIZ(oldfmt, dp, needswap) \
|
||||
|
@ -242,75 +242,75 @@
|
|||
#define LFS_NEWDIRFMT 0
|
||||
|
||||
#define LFS_NEXTDIR(fs, dp) \
|
||||
((struct lfs_direct *)((char *)(dp) + lfs_dir_getreclen(fs, dp)))
|
||||
((struct lfs_dirheader *)((char *)(dp) + lfs_dir_getreclen(fs, dp)))
|
||||
|
||||
static __unused inline char *
|
||||
lfs_dir_nameptr(const STRUCT_LFS *fs, struct lfs_direct *dp)
|
||||
lfs_dir_nameptr(const STRUCT_LFS *fs, struct lfs_dirheader *dh)
|
||||
{
|
||||
return (char *)(&dp->d_header + 1);
|
||||
return (char *)(dh + 1);
|
||||
}
|
||||
|
||||
static __unused inline uint32_t
|
||||
lfs_dir_getino(const STRUCT_LFS *fs, const struct lfs_direct *dp)
|
||||
lfs_dir_getino(const STRUCT_LFS *fs, const struct lfs_dirheader *dh)
|
||||
{
|
||||
return LFS_SWAP_uint32_t(fs, dp->d_header.dh_ino);
|
||||
return LFS_SWAP_uint32_t(fs, dh->dh_ino);
|
||||
}
|
||||
|
||||
static __unused inline uint16_t
|
||||
lfs_dir_getreclen(const STRUCT_LFS *fs, const struct lfs_direct *dp)
|
||||
lfs_dir_getreclen(const STRUCT_LFS *fs, const struct lfs_dirheader *dh)
|
||||
{
|
||||
return LFS_SWAP_uint16_t(fs, dp->d_header.dh_reclen);
|
||||
return LFS_SWAP_uint16_t(fs, dh->dh_reclen);
|
||||
}
|
||||
|
||||
static __unused inline uint8_t
|
||||
lfs_dir_gettype(const STRUCT_LFS *fs, const struct lfs_direct *dp)
|
||||
lfs_dir_gettype(const STRUCT_LFS *fs, const struct lfs_dirheader *dh)
|
||||
{
|
||||
if (fs->lfs_hasolddirfmt) {
|
||||
return LFS_DT_UNKNOWN;
|
||||
}
|
||||
return dp->d_header.dh_type;
|
||||
return dh->dh_type;
|
||||
}
|
||||
|
||||
static __unused inline uint8_t
|
||||
lfs_dir_getnamlen(const STRUCT_LFS *fs, const struct lfs_direct *dp)
|
||||
lfs_dir_getnamlen(const STRUCT_LFS *fs, const struct lfs_dirheader *dh)
|
||||
{
|
||||
if (fs->lfs_hasolddirfmt && LFS_LITTLE_ENDIAN_ONDISK(fs)) {
|
||||
/* low-order byte of old 16-bit namlen field */
|
||||
return dp->d_header.dh_type;
|
||||
return dh->dh_type;
|
||||
}
|
||||
return dp->d_header.dh_namlen;
|
||||
return dh->dh_namlen;
|
||||
}
|
||||
|
||||
static __unused inline void
|
||||
lfs_dir_setino(STRUCT_LFS *fs, struct lfs_direct *dp, uint32_t ino)
|
||||
lfs_dir_setino(STRUCT_LFS *fs, struct lfs_dirheader *dh, uint32_t ino)
|
||||
{
|
||||
dp->d_header.dh_ino = LFS_SWAP_uint32_t(fs, ino);
|
||||
dh->dh_ino = LFS_SWAP_uint32_t(fs, ino);
|
||||
}
|
||||
|
||||
static __unused inline void
|
||||
lfs_dir_setreclen(STRUCT_LFS *fs, struct lfs_direct *dp, uint16_t reclen)
|
||||
lfs_dir_setreclen(STRUCT_LFS *fs, struct lfs_dirheader *dh, uint16_t reclen)
|
||||
{
|
||||
dp->d_header.dh_reclen = LFS_SWAP_uint16_t(fs, reclen);
|
||||
dh->dh_reclen = LFS_SWAP_uint16_t(fs, reclen);
|
||||
}
|
||||
|
||||
static __unused inline void
|
||||
lfs_dir_settype(const STRUCT_LFS *fs, struct lfs_direct *dp, uint8_t type)
|
||||
lfs_dir_settype(const STRUCT_LFS *fs, struct lfs_dirheader *dh, uint8_t type)
|
||||
{
|
||||
if (fs->lfs_hasolddirfmt) {
|
||||
/* do nothing */
|
||||
return;
|
||||
}
|
||||
dp->d_header.dh_type = type;
|
||||
dh->dh_type = type;
|
||||
}
|
||||
|
||||
static __unused inline void
|
||||
lfs_dir_setnamlen(const STRUCT_LFS *fs, struct lfs_direct *dp, uint8_t namlen)
|
||||
lfs_dir_setnamlen(const STRUCT_LFS *fs, struct lfs_dirheader *dh, uint8_t namlen)
|
||||
{
|
||||
if (fs->lfs_hasolddirfmt && LFS_LITTLE_ENDIAN_ONDISK(fs)) {
|
||||
/* low-order byte of old 16-bit namlen field */
|
||||
dp->d_header.dh_type = namlen;
|
||||
dh->dh_type = namlen;
|
||||
}
|
||||
dp->d_header.dh_namlen = namlen;
|
||||
dh->dh_namlen = namlen;
|
||||
}
|
||||
|
||||
static __unused inline void
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lfs_rename.c,v 1.12 2015/09/15 15:02:01 dholland Exp $ */
|
||||
/* $NetBSD: lfs_rename.c,v 1.13 2015/09/15 15:02:25 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.12 2015/09/15 15:02:01 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.13 2015/09/15 15:02:25 dholland Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
|
@ -328,7 +328,7 @@ ulfs_rename_ulr_overlap_p(const struct ulfs_lookup_results *fulr,
|
|||
* the directory vp.
|
||||
*/
|
||||
static int /* XXX int? uint8_t? */
|
||||
ulfs_direct_namlen(const struct lfs_direct *ep, const struct vnode *vp)
|
||||
ulfs_direct_namlen(const struct lfs_dirheader *ep, const struct vnode *vp)
|
||||
{
|
||||
struct lfs *fs;
|
||||
|
||||
|
@ -361,7 +361,7 @@ ulfs_rename_recalculate_fulr(struct vnode *dvp,
|
|||
doff_t offset; /* Offset of entry we're examining. */
|
||||
struct buf *bp; /* I/O block we're examining. */
|
||||
char *dirbuf; /* Pointer into directory at search_start. */
|
||||
struct lfs_direct *ep; /* Pointer to the entry we're examining. */
|
||||
struct lfs_dirheader *ep; /* Pointer to the entry we're examining. */
|
||||
/* XXX direct::d_reclen is 16-bit;
|
||||
* ulfs_lookup_results::ulr_reclen is 32-bit. Blah. */
|
||||
uint32_t reclen; /* Length of the entry we're examining. */
|
||||
|
@ -430,7 +430,7 @@ ulfs_rename_recalculate_fulr(struct vnode *dvp,
|
|||
/*
|
||||
* Examine the directory entry at offset.
|
||||
*/
|
||||
ep = (struct lfs_direct *)(dirbuf + (offset - search_start));
|
||||
ep = (struct lfs_dirheader *)(dirbuf + (offset - search_start));
|
||||
reclen = lfs_dir_getreclen(fs, ep);
|
||||
|
||||
if (lfs_dir_getino(fs, ep) == 0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ulfs_dirhash.c,v 1.11 2015/09/15 15:02:01 dholland Exp $ */
|
||||
/* $NetBSD: ulfs_dirhash.c,v 1.12 2015/09/15 15:02:25 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.11 2015/09/15 15:02:01 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ulfs_dirhash.c,v 1.12 2015/09/15 15:02:25 dholland Exp $");
|
||||
|
||||
/*
|
||||
* This implements a hash-based lookup scheme for ULFS directories.
|
||||
|
@ -73,7 +73,7 @@ static void ulfsdirhash_adjfree(struct dirhash *dh, doff_t offset, int diff,
|
|||
static void ulfsdirhash_delslot(struct dirhash *dh, int slot);
|
||||
static int ulfsdirhash_findslot(struct dirhash *dh, const char *name,
|
||||
int namelen, doff_t offset);
|
||||
static doff_t ulfsdirhash_getprev(struct lfs *fs, struct lfs_direct *dp,
|
||||
static doff_t ulfsdirhash_getprev(struct lfs *fs, struct lfs_dirheader *dp,
|
||||
doff_t offset, int dirblksiz);
|
||||
static int ulfsdirhash_recycle(int wanted);
|
||||
|
||||
|
@ -117,7 +117,7 @@ ulfsdirhash_build(struct inode *ip)
|
|||
struct lfs *fs = ip->i_lfs;
|
||||
struct dirhash *dh;
|
||||
struct buf *bp = NULL;
|
||||
struct lfs_direct *ep;
|
||||
struct lfs_dirheader *ep;
|
||||
struct vnode *vp;
|
||||
doff_t bmask, pos;
|
||||
int dirblocks, i, j, memreqd, nblocks, narrays, nslots, slot;
|
||||
|
@ -227,7 +227,7 @@ ulfsdirhash_build(struct inode *ip)
|
|||
}
|
||||
|
||||
/* Add this entry to the hash. */
|
||||
ep = (struct lfs_direct *)((char *)bp->b_data + (pos & bmask));
|
||||
ep = (struct lfs_dirheader *)((char *)bp->b_data + (pos & bmask));
|
||||
if (lfs_dir_getreclen(fs, ep) == 0 || lfs_dir_getreclen(fs, ep) >
|
||||
dirblksiz - (pos & (dirblksiz - 1))) {
|
||||
/* Corrupted directory. */
|
||||
|
@ -328,7 +328,7 @@ ulfsdirhash_lookup(struct inode *ip, const char *name, int namelen, doff_t *offp
|
|||
{
|
||||
struct lfs *fs = ip->i_lfs;
|
||||
struct dirhash *dh, *dh_next;
|
||||
struct lfs_direct *dp;
|
||||
struct lfs_dirheader *dp;
|
||||
struct vnode *vp;
|
||||
struct buf *bp;
|
||||
doff_t blkoff, bmask, offset, prevoff;
|
||||
|
@ -424,7 +424,7 @@ restart:
|
|||
return (EJUSTRETURN);
|
||||
}
|
||||
}
|
||||
dp = (struct lfs_direct *)((char *)bp->b_data + (offset & bmask));
|
||||
dp = (struct lfs_dirheader *)((char *)bp->b_data + (offset & bmask));
|
||||
if (lfs_dir_getreclen(fs, dp) == 0 || lfs_dir_getreclen(fs, dp) >
|
||||
dirblksiz - (offset & (dirblksiz - 1))) {
|
||||
/* Corrupted directory. */
|
||||
|
@ -501,7 +501,7 @@ doff_t
|
|||
ulfsdirhash_findfree(struct inode *ip, int slotneeded, int *slotsize)
|
||||
{
|
||||
struct lfs *fs = ip->i_lfs;
|
||||
struct lfs_direct *dp;
|
||||
struct lfs_dirheader *dp;
|
||||
struct dirhash *dh;
|
||||
struct buf *bp;
|
||||
doff_t pos, slotstart;
|
||||
|
@ -621,7 +621,7 @@ ulfsdirhash_enduseful(struct inode *ip)
|
|||
* the offset of this entry.
|
||||
*/
|
||||
void
|
||||
ulfsdirhash_add(struct inode *ip, struct lfs_direct *dirp, doff_t offset)
|
||||
ulfsdirhash_add(struct inode *ip, struct lfs_dirheader *dirp, doff_t offset)
|
||||
{
|
||||
struct lfs *fs = ip->i_lfs;
|
||||
struct dirhash *dh;
|
||||
|
@ -669,7 +669,7 @@ ulfsdirhash_add(struct inode *ip, struct lfs_direct *dirp, doff_t offset)
|
|||
* `offset' within the directory.
|
||||
*/
|
||||
void
|
||||
ulfsdirhash_remove(struct inode *ip, struct lfs_direct *dirp, doff_t offset)
|
||||
ulfsdirhash_remove(struct inode *ip, struct lfs_dirheader *dirp, doff_t offset)
|
||||
{
|
||||
struct lfs *fs = ip->i_lfs;
|
||||
struct dirhash *dh;
|
||||
|
@ -704,7 +704,7 @@ ulfsdirhash_remove(struct inode *ip, struct lfs_direct *dirp, doff_t offset)
|
|||
* when compacting directory blocks.
|
||||
*/
|
||||
void
|
||||
ulfsdirhash_move(struct inode *ip, struct lfs_direct *dirp, doff_t oldoff,
|
||||
ulfsdirhash_move(struct inode *ip, struct lfs_dirheader *dirp, doff_t oldoff,
|
||||
doff_t newoff)
|
||||
{
|
||||
struct lfs *fs = ip->i_lfs;
|
||||
|
@ -831,7 +831,7 @@ ulfsdirhash_checkblock(struct inode *ip, char *sbuf, doff_t offset)
|
|||
{
|
||||
struct lfs *fs = ip->i_lfs;
|
||||
struct dirhash *dh;
|
||||
struct lfs_direct *dp;
|
||||
struct lfs_dirheader *dp;
|
||||
int block, ffslot, i, nfree;
|
||||
int dirblksiz = ip->i_lfs->um_dirblksiz;
|
||||
|
||||
|
@ -853,7 +853,7 @@ ulfsdirhash_checkblock(struct inode *ip, char *sbuf, doff_t offset)
|
|||
|
||||
nfree = 0;
|
||||
for (i = 0; i < dirblksiz; i += lfs_dir_getreclen(fs, dp)) {
|
||||
dp = (struct lfs_direct *)(sbuf + i);
|
||||
dp = (struct lfs_dirheader *)(sbuf + i);
|
||||
if (lfs_dir_getreclen(fs, dp) == 0 || i + lfs_dir_getreclen(fs, dp) > dirblksiz)
|
||||
panic("ulfsdirhash_checkblock: bad dir");
|
||||
|
||||
|
@ -1014,10 +1014,10 @@ ulfsdirhash_delslot(struct dirhash *dh, int slot)
|
|||
* other problem occurred.
|
||||
*/
|
||||
static doff_t
|
||||
ulfsdirhash_getprev(struct lfs *fs, struct lfs_direct *dirp,
|
||||
ulfsdirhash_getprev(struct lfs *fs, struct lfs_dirheader *dirp,
|
||||
doff_t offset, int dirblksiz)
|
||||
{
|
||||
struct lfs_direct *dp;
|
||||
struct lfs_dirheader *dp;
|
||||
char *blkbuf;
|
||||
doff_t blkoff, prevoff;
|
||||
int entrypos, i;
|
||||
|
@ -1034,7 +1034,7 @@ ulfsdirhash_getprev(struct lfs *fs, struct lfs_direct *dirp,
|
|||
|
||||
/* Scan from the start of the block until we get to the entry. */
|
||||
for (i = 0; i < entrypos; i += reclen) {
|
||||
dp = (struct lfs_direct *)(blkbuf + i);
|
||||
dp = (struct lfs_dirheader *)(blkbuf + i);
|
||||
reclen = lfs_dir_getreclen(fs, dp);
|
||||
if (reclen == 0 || i + reclen > entrypos)
|
||||
return (-1); /* Corrupted directory. */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ulfs_dirhash.h,v 1.5 2013/06/08 02:14:46 dholland Exp $ */
|
||||
/* $NetBSD: ulfs_dirhash.h,v 1.6 2015/09/15 15:02:25 dholland Exp $ */
|
||||
/* from NetBSD: dirhash.h,v 1.6 2008/06/04 11:33:19 ad Exp */
|
||||
|
||||
/*
|
||||
|
@ -118,9 +118,9 @@ doff_t ulfsdirhash_enduseful(struct inode *);
|
|||
int ulfsdirhash_lookup(struct inode *, const char *, int, doff_t *,
|
||||
struct buf **, doff_t *);
|
||||
void ulfsdirhash_newblk(struct inode *, doff_t);
|
||||
void ulfsdirhash_add(struct inode *, struct lfs_direct *, doff_t);
|
||||
void ulfsdirhash_remove(struct inode *, struct lfs_direct *, doff_t);
|
||||
void ulfsdirhash_move(struct inode *, struct lfs_direct *, doff_t, doff_t);
|
||||
void ulfsdirhash_add(struct inode *, struct lfs_dirheader *, doff_t);
|
||||
void ulfsdirhash_remove(struct inode *, struct lfs_dirheader *, doff_t);
|
||||
void ulfsdirhash_move(struct inode *, struct lfs_dirheader *, doff_t, doff_t);
|
||||
void ulfsdirhash_dirtrunc(struct inode *, doff_t);
|
||||
void ulfsdirhash_free(struct inode *);
|
||||
void ulfsdirhash_checkblock(struct inode *, char *, doff_t);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ulfs_extern.h,v 1.18 2015/09/15 15:01:03 dholland Exp $ */
|
||||
/* $NetBSD: ulfs_extern.h,v 1.19 2015/09/15 15:02:25 dholland Exp $ */
|
||||
/* from NetBSD: ufs_extern.h,v 1.72 2012/05/09 00:21:18 riastradh Exp */
|
||||
|
||||
/*-
|
||||
|
@ -109,7 +109,7 @@ int ulfs_balloc_range(struct vnode *, off_t, off_t, kauth_cred_t, int);
|
|||
|
||||
/* ulfs_lookup.c */
|
||||
void ulfs_dirbad(struct inode *, doff_t, const char *);
|
||||
int ulfs_dirbadentry(struct vnode *, struct lfs_direct *, int);
|
||||
int ulfs_dirbadentry(struct vnode *, struct lfs_dirheader *, int);
|
||||
int ulfs_direnter(struct vnode *, const struct ulfs_lookup_results *,
|
||||
struct vnode *,
|
||||
struct componentname *, ino_t, unsigned,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ulfs_lookup.c,v 1.31 2015/09/15 15:02:01 dholland Exp $ */
|
||||
/* $NetBSD: ulfs_lookup.c,v 1.32 2015/09/15 15:02:25 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.31 2015/09/15 15:02:01 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.32 2015/09/15 15:02:25 dholland Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_lfs.h"
|
||||
|
@ -123,7 +123,7 @@ ulfs_lookup(void *v)
|
|||
struct vnode *vdp = ap->a_dvp; /* vnode for directory being searched */
|
||||
struct inode *dp = VTOI(vdp); /* inode for directory being searched */
|
||||
struct buf *bp; /* a buffer of directory entries */
|
||||
struct lfs_direct *ep; /* the current directory entry */
|
||||
struct lfs_dirheader *ep; /* the current directory entry */
|
||||
int entryoffsetinblock; /* offset of ep in bp's buffer */
|
||||
enum {
|
||||
NONE, /* need to search a slot for our new entry */
|
||||
|
@ -263,7 +263,7 @@ ulfs_lookup(void *v)
|
|||
switch (ulfsdirhash_lookup(dp, cnp->cn_nameptr, cnp->cn_namelen,
|
||||
&results->ulr_offset, &bp, nameiop == DELETE ? &prevoff : NULL)) {
|
||||
case 0:
|
||||
ep = (struct lfs_direct *)((char *)bp->b_data +
|
||||
ep = (struct lfs_dirheader *)((char *)bp->b_data +
|
||||
(results->ulr_offset & bmask));
|
||||
goto foundentry;
|
||||
case ENOENT:
|
||||
|
@ -327,7 +327,7 @@ searchloop:
|
|||
* "lfs_dirchk" to be true.
|
||||
*/
|
||||
KASSERT(bp != NULL);
|
||||
ep = (struct lfs_direct *)((char *)bp->b_data + entryoffsetinblock);
|
||||
ep = (struct lfs_dirheader *)((char *)bp->b_data + entryoffsetinblock);
|
||||
if (lfs_dir_getreclen(fs, ep) == 0 ||
|
||||
(lfs_dirchk && ulfs_dirbadentry(vdp, ep, entryoffsetinblock))) {
|
||||
int i;
|
||||
|
@ -657,7 +657,7 @@ ulfs_dirbad(struct inode *ip, doff_t offset, const char *how)
|
|||
* name must be as long as advertised, and null terminated
|
||||
*/
|
||||
int
|
||||
ulfs_dirbadentry(struct vnode *dp, struct lfs_direct *ep, int entryoffsetinblock)
|
||||
ulfs_dirbadentry(struct vnode *dp, struct lfs_dirheader *ep, int entryoffsetinblock)
|
||||
{
|
||||
int i;
|
||||
int namlen;
|
||||
|
@ -712,7 +712,7 @@ bad:
|
|||
* Does not set d_reclen.
|
||||
*/
|
||||
static void
|
||||
ulfs_direntry_assign(struct lfs *fs, struct lfs_direct *dirp,
|
||||
ulfs_direntry_assign(struct lfs *fs, struct lfs_dirheader *dirp,
|
||||
const char *name, size_t namlen,
|
||||
ino_t inum, unsigned dtype)
|
||||
{
|
||||
|
@ -764,7 +764,7 @@ ulfs_direnter(struct vnode *dvp, const struct ulfs_lookup_results *ulr,
|
|||
struct inode *dp;
|
||||
struct buf *bp;
|
||||
u_int dsize;
|
||||
struct lfs_direct *ep, *nep;
|
||||
struct lfs_dirheader *ep, *nep;
|
||||
int error, ret, lfs_blkoff, loc, spacefree;
|
||||
char *dirbuf;
|
||||
struct timespec ts;
|
||||
|
@ -803,7 +803,7 @@ ulfs_direnter(struct vnode *dvp, const struct ulfs_lookup_results *ulr,
|
|||
dp->i_flag |= IN_CHANGE | IN_UPDATE;
|
||||
uvm_vnp_setsize(dvp, dp->i_size);
|
||||
lfs_blkoff = ulr->ulr_offset & (ump->um_mountp->mnt_stat.f_iosize - 1);
|
||||
ep = (struct lfs_direct *)((char *)bp->b_data + lfs_blkoff);
|
||||
ep = (struct lfs_dirheader *)((char *)bp->b_data + lfs_blkoff);
|
||||
ulfs_direntry_assign(fs, ep, name, namlen, inum, dtype);
|
||||
lfs_dir_setreclen(fs, ep, dirblksiz);
|
||||
#ifdef LFS_DIRHASH
|
||||
|
@ -860,11 +860,11 @@ ulfs_direnter(struct vnode *dvp, const struct ulfs_lookup_results *ulr,
|
|||
* arranged that compacting the region ulr_offset to
|
||||
* ulr_offset + ulr_count would yield the space.
|
||||
*/
|
||||
ep = (struct lfs_direct *)dirbuf;
|
||||
ep = (struct lfs_dirheader *)dirbuf;
|
||||
dsize = (lfs_dir_getino(fs, ep) != 0) ? LFS_DIRSIZ(fs, ep) : 0;
|
||||
spacefree = lfs_dir_getreclen(fs, ep) - dsize;
|
||||
for (loc = lfs_dir_getreclen(fs, ep); loc < ulr->ulr_count; ) {
|
||||
nep = (struct lfs_direct *)(dirbuf + loc);
|
||||
nep = (struct lfs_dirheader *)(dirbuf + loc);
|
||||
|
||||
/* Trim the existing slot (NB: dsize may be zero). */
|
||||
lfs_dir_setreclen(fs, ep, dsize);
|
||||
|
@ -995,7 +995,7 @@ ulfs_dirremove(struct vnode *dvp, const struct ulfs_lookup_results *ulr,
|
|||
{
|
||||
struct inode *dp = VTOI(dvp);
|
||||
struct lfs *fs = dp->i_lfs;
|
||||
struct lfs_direct *ep;
|
||||
struct lfs_dirheader *ep;
|
||||
struct buf *bp;
|
||||
int error;
|
||||
|
||||
|
@ -1097,7 +1097,7 @@ ulfs_dirrewrite(struct inode *dp, off_t offset,
|
|||
{
|
||||
struct lfs *fs = dp->i_lfs;
|
||||
struct buf *bp;
|
||||
struct lfs_direct *ep;
|
||||
struct lfs_dirheader *ep;
|
||||
struct vnode *vdp = ITOV(dp);
|
||||
int error;
|
||||
|
||||
|
@ -1136,7 +1136,7 @@ ulfs_dirempty(struct inode *ip, ino_t parentino, kauth_cred_t cred)
|
|||
struct lfs *fs = ip->i_lfs;
|
||||
doff_t off;
|
||||
struct lfs_dirtemplate dbuf;
|
||||
struct lfs_direct *dp = (struct lfs_direct *)&dbuf;
|
||||
struct lfs_dirheader *dp = (struct lfs_dirheader *)&dbuf;
|
||||
int error, namlen;
|
||||
const char *name;
|
||||
size_t count;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ulfs_vnops.c,v 1.31 2015/09/15 15:02:01 dholland Exp $ */
|
||||
/* $NetBSD: ulfs_vnops.c,v 1.32 2015/09/15 15:02:25 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.31 2015/09/15 15:02:01 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.32 2015/09/15 15:02:25 dholland Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_lfs.h"
|
||||
|
@ -775,7 +775,7 @@ ulfs_readdir(void *v)
|
|||
int *ncookies;
|
||||
} */ *ap = v;
|
||||
struct vnode *vp = ap->a_vp;
|
||||
struct lfs_direct *cdp, *ecdp;
|
||||
struct lfs_dirheader *cdp, *ecdp;
|
||||
struct dirent *ndp;
|
||||
char *cdbuf, *ndbuf, *endp;
|
||||
struct uio auio, *uio;
|
||||
|
@ -816,8 +816,8 @@ ulfs_readdir(void *v)
|
|||
|
||||
rcount -= auio.uio_resid;
|
||||
|
||||
cdp = (struct lfs_direct *)(void *)cdbuf;
|
||||
ecdp = (struct lfs_direct *)(void *)&cdbuf[rcount];
|
||||
cdp = (struct lfs_dirheader *)(void *)cdbuf;
|
||||
ecdp = (struct lfs_dirheader *)(void *)&cdbuf[rcount];
|
||||
|
||||
ndbufsz = count;
|
||||
ndbuf = kmem_alloc(ndbufsz, KM_SLEEP);
|
||||
|
|
Loading…
Reference in New Issue