Add 64-bit directory entry structures, and adjust accessors accordingly.
The LFS64 directory entry has a 64-bit inode number. This is stored as two 32-bit values to avoid inducing 64-bit alignment requirements. The exposed type for manipulating directory entries is now LFS_DIRHEADER, following the same convention as e.g. IFILE and SEGUSE. (But with LFS_ on it, because.)
This commit is contained in:
parent
80201f5aa5
commit
947343ea0e
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: dir.c,v 1.45 2015/09/21 01:22:18 dholland Exp $ */
|
||||
/* $NetBSD: dir.c,v 1.46 2015/09/21 01:24:23 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_dirheader *fsck_readdir(struct uvnode *, struct inodesc *);
|
||||
static 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_dirheader *dp;
|
||||
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_dirheader *) dbuf;
|
||||
idesc->id_dirp = (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_dirheader *
|
||||
static LFS_DIRHEADER *
|
||||
fsck_readdir(struct uvnode *vp, struct inodesc *idesc)
|
||||
{
|
||||
struct lfs_dirheader *dp, *ndp;
|
||||
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_dirheader *) (bp->b_data + idesc->id_loc);
|
||||
dp = (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_dirheader *) (bp->b_data + idesc->id_loc);
|
||||
dp = (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_dirheader *) (bp->b_data + dploc);
|
||||
dp = (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_dirheader *) (bp->b_data + idesc->id_loc);
|
||||
ndp = (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_dirheader *) (bp->b_data + dploc);
|
||||
dp = (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_dirheader *dp)
|
||||
dircheck(struct inodesc *idesc, 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_dirheader *dirp = idesc->id_dirp;
|
||||
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_dirheader *dirp = idesc->id_dirp;
|
||||
LFS_DIRHEADER *dirp = idesc->id_dirp;
|
||||
int namlen;
|
||||
|
||||
namlen = lfs_dir_getnamlen(fs, dirp);
|
||||
@ -593,7 +593,7 @@ makeentry(ino_t parent, ino_t ino, const char *name)
|
||||
static void
|
||||
zerodirblk(void *buf)
|
||||
{
|
||||
struct lfs_dirheader *dirp;
|
||||
LFS_DIRHEADER *dirp;
|
||||
|
||||
dirp = buf;
|
||||
lfs_dir_setino(fs, dirp, 0);
|
||||
@ -673,7 +673,7 @@ allocdir(ino_t parent, ino_t request, int mode)
|
||||
char *cp;
|
||||
union lfs_dinode *dp;
|
||||
struct ubuf *bp;
|
||||
struct lfs_dirheader *dirp;
|
||||
LFS_DIRHEADER *dirp;
|
||||
struct uvnode *vp;
|
||||
|
||||
ino = allocino(request, LFS_IFDIR | mode);
|
||||
@ -685,7 +685,7 @@ allocdir(ino_t parent, ino_t request, int mode)
|
||||
freeino(ino);
|
||||
return (0);
|
||||
}
|
||||
dirp = (struct lfs_dirheader *)bp->b_data;
|
||||
dirp = (LFS_DIRHEADER *)bp->b_data;
|
||||
/* . */
|
||||
lfs_dir_setino(fs, dirp, ino);
|
||||
lfs_dir_setreclen(fs, dirp, LFS_DIRECTSIZ(fs, 1));
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: extern.h,v 1.13 2015/09/15 15:02:25 dholland Exp $ */
|
||||
/* $NetBSD: extern.h,v 1.14 2015/09/21 01:24:23 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_dirheader *);
|
||||
int dircheck(struct inodesc *, 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.22 2015/09/15 15:02:25 dholland Exp $ */
|
||||
/* $NetBSD: fsck.h,v 1.23 2015/09/21 01:24:23 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_dirheader *id_dirp; /* for DATA nodes, ptr to current entry */
|
||||
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.67 2015/09/15 15:02:25 dholland Exp $ */
|
||||
/* $NetBSD: inode.c,v 1.68 2015/09/21 01:24:23 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_dirheader *dirp = idesc->id_dirp;
|
||||
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_dirheader *dirp = idesc->id_dirp;
|
||||
LFS_DIRHEADER *dirp = idesc->id_dirp;
|
||||
ino_t ino;
|
||||
|
||||
ino = lfs_dir_getino(fs, dirp);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pass2.c,v 1.33 2015/09/21 01:22:18 dholland Exp $ */
|
||||
/* $NetBSD: pass2.c,v 1.34 2015/09/21 01:24:23 dholland Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1980, 1986, 1993
|
||||
@ -52,7 +52,9 @@
|
||||
#include "fsutil.h"
|
||||
#include "extern.h"
|
||||
|
||||
#define MINDIRSIZE (sizeof (struct lfs_dirtemplate))
|
||||
#define MINDIRSIZE(fs) \
|
||||
((fs)->lfs_is64 ? sizeof(struct lfs_dirtemplate64) : \
|
||||
sizeof(struct lfs_dirtemplate32))
|
||||
|
||||
static int pass2check(struct inodesc *);
|
||||
static int blksort(const void *, const void *);
|
||||
@ -135,9 +137,9 @@ pass2(void)
|
||||
inp = *inpp;
|
||||
if (inp->i_isize == 0)
|
||||
continue;
|
||||
if (inp->i_isize < MINDIRSIZE) {
|
||||
if (inp->i_isize < MINDIRSIZE(fs)) {
|
||||
direrror(inp->i_number, "DIRECTORY TOO SHORT");
|
||||
inp->i_isize = roundup(MINDIRSIZE, LFS_DIRBLKSIZ);
|
||||
inp->i_isize = roundup(MINDIRSIZE(fs), LFS_DIRBLKSIZ);
|
||||
if (reply("FIX") == 1) {
|
||||
vp = vget(fs, inp->i_number);
|
||||
dp = VTOD(vp);
|
||||
@ -212,12 +214,12 @@ pass2(void)
|
||||
static int
|
||||
pass2check(struct inodesc * idesc)
|
||||
{
|
||||
struct lfs_dirheader *dirp = idesc->id_dirp;
|
||||
LFS_DIRHEADER *dirp = idesc->id_dirp;
|
||||
struct inoinfo *inp;
|
||||
int n, entrysize, ret = 0;
|
||||
union lfs_dinode *dp;
|
||||
const char *errmsg;
|
||||
struct lfs_dirheader proto;
|
||||
LFS_DIRHEADER proto;
|
||||
char namebuf[MAXPATHLEN + 1];
|
||||
char pathbuf[MAXPATHLEN + 1];
|
||||
|
||||
@ -293,7 +295,7 @@ chk1:
|
||||
lfs_dir_setreclen(fs, dirp, n);
|
||||
idesc->id_entryno++;
|
||||
lncntp[lfs_dir_getino(fs, dirp)]--;
|
||||
dirp = (struct lfs_dirheader *) ((char *) (dirp) + n);
|
||||
dirp = (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.55 2015/09/21 01:22:18 dholland Exp $ */
|
||||
/* $NetBSD: make_lfs.c,v 1.56 2015/09/21 01:24:23 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.55 2015/09/21 01:22:18 dholland Exp $");
|
||||
__RCSID("$NetBSD: make_lfs.c,v 1.56 2015/09/21 01:24:23 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_dirheader *ep;
|
||||
LFS_DIRHEADER *ep;
|
||||
unsigned spaceleft;
|
||||
unsigned namlen, reclen;
|
||||
unsigned i;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lfs.h,v 1.190 2015/09/20 04:51:43 dholland Exp $ */
|
||||
/* $NetBSD: lfs.h,v 1.191 2015/09/21 01:24:23 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 */
|
||||
@ -348,23 +348,52 @@
|
||||
/*
|
||||
* (See notes above)
|
||||
*/
|
||||
struct lfs_dirheader {
|
||||
|
||||
struct lfs_dirheader32 {
|
||||
u_int32_t dh_ino; /* inode number of entry */
|
||||
u_int16_t dh_reclen; /* length of this record */
|
||||
u_int8_t dh_type; /* file type, see below */
|
||||
u_int8_t dh_namlen; /* length of string in d_name */
|
||||
};
|
||||
|
||||
struct lfs_dirheader64 {
|
||||
u_int32_t dh_inoA; /* inode number of entry */
|
||||
u_int32_t dh_inoB; /* inode number of entry */
|
||||
u_int16_t dh_reclen; /* length of this record */
|
||||
u_int8_t dh_type; /* file type, see below */
|
||||
u_int8_t dh_namlen; /* length of string in d_name */
|
||||
};
|
||||
|
||||
union lfs_dirheader {
|
||||
struct lfs_dirheader64 u_64;
|
||||
struct lfs_dirheader32 u_32;
|
||||
};
|
||||
|
||||
typedef union lfs_dirheader LFS_DIRHEADER;
|
||||
|
||||
/*
|
||||
* Template for manipulating directories.
|
||||
*/
|
||||
struct lfs_dirtemplate {
|
||||
struct lfs_dirheader dot_header;
|
||||
|
||||
struct lfs_dirtemplate32 {
|
||||
struct lfs_dirheader32 dot_header;
|
||||
char dot_name[4]; /* must be multiple of 4 */
|
||||
struct lfs_dirheader dotdot_header;
|
||||
struct lfs_dirheader32 dotdot_header;
|
||||
char dotdot_name[4]; /* ditto */
|
||||
};
|
||||
|
||||
struct lfs_dirtemplate64 {
|
||||
struct lfs_dirheader64 dot_header;
|
||||
char dot_name[4]; /* must be multiple of 4 */
|
||||
struct lfs_dirheader64 dotdot_header;
|
||||
char dotdot_name[4]; /* ditto */
|
||||
};
|
||||
|
||||
union lfs_dirtemplate {
|
||||
struct lfs_dirtemplate64 u_64;
|
||||
struct lfs_dirtemplate32 u_32;
|
||||
};
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* This is the old format of directories, sans type element.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lfs_accessors.h,v 1.30 2015/09/21 01:22:18 dholland Exp $ */
|
||||
/* $NetBSD: lfs_accessors.h,v 1.31 2015/09/21 01:24:23 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 */
|
||||
@ -216,6 +216,9 @@
|
||||
* directories
|
||||
*/
|
||||
|
||||
#define LFS_DIRHEADERSIZE(fs) \
|
||||
((fs)->lfs_is64 ? sizeof(struct lfs_dirheader64) : sizeof(struct lfs_dirheader32))
|
||||
|
||||
/*
|
||||
* The LFS_DIRSIZ macro gives the minimum record length which will hold
|
||||
* the directory entry. This requires the amount of space in struct lfs_direct
|
||||
@ -223,7 +226,7 @@
|
||||
* null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
|
||||
*/
|
||||
#define LFS_DIRECTSIZ(fs, namlen) \
|
||||
(sizeof(struct lfs_dirheader) + (((namlen)+1 + 3) &~ 3))
|
||||
(LFS_DIRHEADERSIZE(fs) + (((namlen)+1 + 3) &~ 3))
|
||||
|
||||
/*
|
||||
* The size of the largest possible directory entry. This is
|
||||
@ -231,7 +234,7 @@
|
||||
* need a single constant value true for both lfs32 and lfs64.
|
||||
*/
|
||||
#define LFS_MAXDIRENTRYSIZE \
|
||||
(sizeof(struct lfs_dirheader) + (((LFS_MAXNAMLEN+1)+1 + 3) & ~3))
|
||||
(sizeof(struct lfs_dirheader64) + (((LFS_MAXNAMLEN+1)+1 + 3) & ~3))
|
||||
|
||||
#if (BYTE_ORDER == LITTLE_ENDIAN)
|
||||
#define LFS_OLDDIRSIZ(oldfmt, dp, needswap) \
|
||||
@ -250,75 +253,130 @@
|
||||
#define LFS_NEWDIRFMT 0
|
||||
|
||||
#define LFS_NEXTDIR(fs, dp) \
|
||||
((struct lfs_dirheader *)((char *)(dp) + lfs_dir_getreclen(fs, dp)))
|
||||
((LFS_DIRHEADER *)((char *)(dp) + lfs_dir_getreclen(fs, dp)))
|
||||
|
||||
static __unused inline char *
|
||||
lfs_dir_nameptr(const STRUCT_LFS *fs, struct lfs_dirheader *dh)
|
||||
lfs_dir_nameptr(const STRUCT_LFS *fs, LFS_DIRHEADER *dh)
|
||||
{
|
||||
return (char *)(dh + 1);
|
||||
if (fs->lfs_is64) {
|
||||
return (char *)(&dh->u_64 + 1);
|
||||
} else {
|
||||
return (char *)(&dh->u_32 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
static __unused inline uint32_t
|
||||
lfs_dir_getino(const STRUCT_LFS *fs, const struct lfs_dirheader *dh)
|
||||
static __unused inline uint64_t
|
||||
lfs_dir_getino(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh)
|
||||
{
|
||||
return LFS_SWAP_uint32_t(fs, dh->dh_ino);
|
||||
if (fs->lfs_is64) {
|
||||
uint64_t ino;
|
||||
|
||||
/*
|
||||
* XXX we can probably write this in a way that's both
|
||||
* still legal and generates better code.
|
||||
*/
|
||||
memcpy(&ino, &dh->u_64.dh_inoA, sizeof(dh->u_64.dh_inoA));
|
||||
memcpy((char *)&ino + sizeof(dh->u_64.dh_inoA),
|
||||
&dh->u_64.dh_inoB,
|
||||
sizeof(dh->u_64.dh_inoB));
|
||||
return LFS_SWAP_uint64_t(fs, ino);
|
||||
} else {
|
||||
return LFS_SWAP_uint32_t(fs, dh->u_32.dh_ino);
|
||||
}
|
||||
}
|
||||
|
||||
static __unused inline uint16_t
|
||||
lfs_dir_getreclen(const STRUCT_LFS *fs, const struct lfs_dirheader *dh)
|
||||
lfs_dir_getreclen(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh)
|
||||
{
|
||||
return LFS_SWAP_uint16_t(fs, dh->dh_reclen);
|
||||
if (fs->lfs_is64) {
|
||||
return LFS_SWAP_uint16_t(fs, dh->u_64.dh_reclen);
|
||||
} else {
|
||||
return LFS_SWAP_uint16_t(fs, dh->u_32.dh_reclen);
|
||||
}
|
||||
}
|
||||
|
||||
static __unused inline uint8_t
|
||||
lfs_dir_gettype(const STRUCT_LFS *fs, const struct lfs_dirheader *dh)
|
||||
lfs_dir_gettype(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh)
|
||||
{
|
||||
if (fs->lfs_hasolddirfmt) {
|
||||
if (fs->lfs_is64) {
|
||||
KASSERT(fs->lfs_hasolddirfmt == 0);
|
||||
return dh->u_64.dh_type;
|
||||
} else if (fs->lfs_hasolddirfmt) {
|
||||
return LFS_DT_UNKNOWN;
|
||||
} else {
|
||||
return dh->u_32.dh_type;
|
||||
}
|
||||
return dh->dh_type;
|
||||
}
|
||||
|
||||
static __unused inline uint8_t
|
||||
lfs_dir_getnamlen(const STRUCT_LFS *fs, const struct lfs_dirheader *dh)
|
||||
lfs_dir_getnamlen(const STRUCT_LFS *fs, const LFS_DIRHEADER *dh)
|
||||
{
|
||||
if (fs->lfs_hasolddirfmt && LFS_LITTLE_ENDIAN_ONDISK(fs)) {
|
||||
if (fs->lfs_is64) {
|
||||
KASSERT(fs->lfs_hasolddirfmt == 0);
|
||||
return dh->u_64.dh_type;
|
||||
} else if (fs->lfs_hasolddirfmt && LFS_LITTLE_ENDIAN_ONDISK(fs)) {
|
||||
/* low-order byte of old 16-bit namlen field */
|
||||
return dh->dh_type;
|
||||
return dh->u_32.dh_type;
|
||||
} else {
|
||||
return dh->u_32.dh_namlen;
|
||||
}
|
||||
return dh->dh_namlen;
|
||||
}
|
||||
|
||||
static __unused inline void
|
||||
lfs_dir_setino(STRUCT_LFS *fs, struct lfs_dirheader *dh, uint32_t ino)
|
||||
lfs_dir_setino(STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint64_t ino)
|
||||
{
|
||||
dh->dh_ino = LFS_SWAP_uint32_t(fs, ino);
|
||||
if (fs->lfs_is64) {
|
||||
|
||||
ino = LFS_SWAP_uint64_t(fs, ino);
|
||||
/*
|
||||
* XXX we can probably write this in a way that's both
|
||||
* still legal and generates better code.
|
||||
*/
|
||||
memcpy(&dh->u_64.dh_inoA, &ino, sizeof(dh->u_64.dh_inoA));
|
||||
memcpy(&dh->u_64.dh_inoB,
|
||||
(char *)&ino + sizeof(dh->u_64.dh_inoA),
|
||||
sizeof(dh->u_64.dh_inoB));
|
||||
} else {
|
||||
dh->u_32.dh_ino = LFS_SWAP_uint32_t(fs, ino);
|
||||
}
|
||||
}
|
||||
|
||||
static __unused inline void
|
||||
lfs_dir_setreclen(STRUCT_LFS *fs, struct lfs_dirheader *dh, uint16_t reclen)
|
||||
lfs_dir_setreclen(STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint16_t reclen)
|
||||
{
|
||||
dh->dh_reclen = LFS_SWAP_uint16_t(fs, reclen);
|
||||
if (fs->lfs_is64) {
|
||||
dh->u_64.dh_reclen = LFS_SWAP_uint16_t(fs, reclen);
|
||||
} else {
|
||||
dh->u_32.dh_reclen = LFS_SWAP_uint16_t(fs, reclen);
|
||||
}
|
||||
}
|
||||
|
||||
static __unused inline void
|
||||
lfs_dir_settype(const STRUCT_LFS *fs, struct lfs_dirheader *dh, uint8_t type)
|
||||
lfs_dir_settype(const STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint8_t type)
|
||||
{
|
||||
if (fs->lfs_hasolddirfmt) {
|
||||
if (fs->lfs_is64) {
|
||||
KASSERT(fs->lfs_hasolddirfmt == 0);
|
||||
dh->u_64.dh_type = type;
|
||||
} else if (fs->lfs_hasolddirfmt) {
|
||||
/* do nothing */
|
||||
return;
|
||||
} else {
|
||||
dh->u_32.dh_type = type;
|
||||
}
|
||||
dh->dh_type = type;
|
||||
}
|
||||
|
||||
static __unused inline void
|
||||
lfs_dir_setnamlen(const STRUCT_LFS *fs, struct lfs_dirheader *dh, uint8_t namlen)
|
||||
lfs_dir_setnamlen(const STRUCT_LFS *fs, LFS_DIRHEADER *dh, uint8_t namlen)
|
||||
{
|
||||
if (fs->lfs_hasolddirfmt && LFS_LITTLE_ENDIAN_ONDISK(fs)) {
|
||||
if (fs->lfs_is64) {
|
||||
KASSERT(fs->lfs_hasolddirfmt == 0);
|
||||
dh->u_64.dh_namlen = namlen;
|
||||
} else if (fs->lfs_hasolddirfmt && LFS_LITTLE_ENDIAN_ONDISK(fs)) {
|
||||
/* low-order byte of old 16-bit namlen field */
|
||||
dh->dh_type = namlen;
|
||||
dh->u_32.dh_type = namlen;
|
||||
} else {
|
||||
dh->u_32.dh_namlen = namlen;
|
||||
}
|
||||
dh->dh_namlen = namlen;
|
||||
}
|
||||
|
||||
static __unused inline void
|
||||
@ -327,8 +385,8 @@ lfs_copydirname(STRUCT_LFS *fs, char *dest, const char *src,
|
||||
{
|
||||
unsigned spacelen;
|
||||
|
||||
KASSERT(reclen > sizeof(struct lfs_dirheader));
|
||||
spacelen = reclen - sizeof(struct lfs_dirheader);
|
||||
KASSERT(reclen > LFS_DIRHEADERSIZE(fs));
|
||||
spacelen = reclen - LFS_DIRHEADERSIZE(fs);
|
||||
|
||||
/* must always be at least 1 byte as a null terminator */
|
||||
KASSERT(spacelen > namlen);
|
||||
@ -337,6 +395,27 @@ lfs_copydirname(STRUCT_LFS *fs, char *dest, const char *src,
|
||||
memset(dest + namlen, '\0', spacelen - namlen);
|
||||
}
|
||||
|
||||
static __unused LFS_DIRHEADER *
|
||||
lfs_dirtemplate_dotdot(STRUCT_LFS *fs, union lfs_dirtemplate *dt)
|
||||
{
|
||||
/* XXX blah, be nice to have a way to do this w/o casts */
|
||||
if (fs->lfs_is64) {
|
||||
return (LFS_DIRHEADER *)&dt->u_64.dotdot_header;
|
||||
} else {
|
||||
return (LFS_DIRHEADER *)&dt->u_32.dotdot_header;
|
||||
}
|
||||
}
|
||||
|
||||
static __unused char *
|
||||
lfs_dirtemplate_dotdotname(STRUCT_LFS *fs, union lfs_dirtemplate *dt)
|
||||
{
|
||||
if (fs->lfs_is64) {
|
||||
return dt->u_64.dotdot_name;
|
||||
} else {
|
||||
return dt->u_32.dotdot_name;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dinodes
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lfs_rename.c,v 1.15 2015/09/21 01:22:18 dholland Exp $ */
|
||||
/* $NetBSD: lfs_rename.c,v 1.16 2015/09/21 01:24:23 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.15 2015/09/21 01:22:18 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_rename.c,v 1.16 2015/09/21 01:24:23 dholland Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -318,7 +318,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_dirheader *ep, const struct vnode *vp)
|
||||
ulfs_direct_namlen(const LFS_DIRHEADER *ep, const struct vnode *vp)
|
||||
{
|
||||
struct lfs *fs;
|
||||
|
||||
@ -351,7 +351,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_dirheader *ep; /* Pointer to the entry we're examining. */
|
||||
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. */
|
||||
@ -420,7 +420,7 @@ ulfs_rename_recalculate_fulr(struct vnode *dvp,
|
||||
/*
|
||||
* Examine the directory entry at offset.
|
||||
*/
|
||||
ep = (struct lfs_dirheader *)(dirbuf + (offset - search_start));
|
||||
ep = (LFS_DIRHEADER *)(dirbuf + (offset - search_start));
|
||||
reclen = lfs_dir_getreclen(fs, ep);
|
||||
|
||||
if (lfs_dir_getino(fs, ep) == 0)
|
||||
@ -581,7 +581,9 @@ static int
|
||||
ulfs_read_dotdot(struct vnode *vp, kauth_cred_t cred, ino_t *ino_ret)
|
||||
{
|
||||
struct lfs *fs;
|
||||
struct lfs_dirtemplate dirbuf;
|
||||
union lfs_dirtemplate dirbuf;
|
||||
LFS_DIRHEADER *dotdot;
|
||||
const char *name;
|
||||
int error;
|
||||
|
||||
KASSERT(vp != NULL);
|
||||
@ -597,13 +599,15 @@ ulfs_read_dotdot(struct vnode *vp, kauth_cred_t cred, ino_t *ino_ret)
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
if (lfs_dir_getnamlen(fs, &dirbuf.dotdot_header) != 2 ||
|
||||
dirbuf.dotdot_name[0] != '.' ||
|
||||
dirbuf.dotdot_name[1] != '.')
|
||||
dotdot = lfs_dirtemplate_dotdot(fs, &dirbuf);
|
||||
name = lfs_dirtemplate_dotdotname(fs, &dirbuf);
|
||||
if (lfs_dir_getnamlen(fs, dotdot) != 2 ||
|
||||
name[0] != '.' ||
|
||||
name[1] != '.')
|
||||
/* XXX Panic? Print warning? */
|
||||
return ENOTDIR;
|
||||
|
||||
*ino_ret = lfs_dir_getino(fs, &dirbuf.dotdot_header);
|
||||
*ino_ret = lfs_dir_getino(fs, dotdot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -740,6 +744,7 @@ ulfs_gro_rename(struct mount *mp, kauth_cred_t cred,
|
||||
struct vnode *tdvp, struct componentname *tcnp,
|
||||
void *tde, struct vnode *tvp)
|
||||
{
|
||||
struct lfs *fs;
|
||||
struct ulfs_lookup_results *fulr = fde;
|
||||
struct ulfs_lookup_results *tulr = tde;
|
||||
bool directory_p, reparent_p;
|
||||
@ -768,6 +773,9 @@ ulfs_gro_rename(struct mount *mp, kauth_cred_t cred,
|
||||
KASSERT(VOP_ISLOCKED(tdvp) == LK_EXCLUSIVE);
|
||||
KASSERT((tvp == NULL) || (VOP_ISLOCKED(tvp) == LK_EXCLUSIVE));
|
||||
|
||||
fs = VTOI(fdvp)->i_lfs;
|
||||
KASSERT(fs == VTOI(tdvp)->i_lfs);
|
||||
|
||||
/*
|
||||
* We shall need to temporarily bump the link count, so make
|
||||
* sure there is room to do so.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lfs_vnops.c,v 1.292 2015/09/21 01:22:18 dholland Exp $ */
|
||||
/* $NetBSD: lfs_vnops.c,v 1.293 2015/09/21 01:24:23 dholland Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
|
||||
@ -125,7 +125,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.292 2015/09/21 01:22:18 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: lfs_vnops.c,v 1.293 2015/09/21 01:24:23 dholland Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_compat_netbsd.h"
|
||||
@ -849,7 +849,7 @@ lfs_mkdir(void *v)
|
||||
struct vattr *vap;
|
||||
struct ulfs_lookup_results *ulr;
|
||||
struct buf *bp;
|
||||
struct lfs_dirheader *dirp;
|
||||
LFS_DIRHEADER *dirp;
|
||||
int dirblksiz;
|
||||
int error;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ulfs_dirhash.c,v 1.13 2015/09/21 01:22:18 dholland Exp $ */
|
||||
/* $NetBSD: ulfs_dirhash.c,v 1.14 2015/09/21 01:24:23 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.13 2015/09/21 01:22:18 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ulfs_dirhash.c,v 1.14 2015/09/21 01:24:23 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_dirheader *dp,
|
||||
static doff_t ulfsdirhash_getprev(struct lfs *fs, 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_dirheader *ep;
|
||||
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_dirheader *)((char *)bp->b_data + (pos & bmask));
|
||||
ep = (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_dirheader *dp;
|
||||
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_dirheader *)((char *)bp->b_data + (offset & bmask));
|
||||
dp = (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_dirheader *dp;
|
||||
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_dirheader *dirp, doff_t offset)
|
||||
ulfsdirhash_add(struct inode *ip, 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_dirheader *dirp, doff_t offset)
|
||||
* `offset' within the directory.
|
||||
*/
|
||||
void
|
||||
ulfsdirhash_remove(struct inode *ip, struct lfs_dirheader *dirp, doff_t offset)
|
||||
ulfsdirhash_remove(struct inode *ip, 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_dirheader *dirp, doff_t offset)
|
||||
* when compacting directory blocks.
|
||||
*/
|
||||
void
|
||||
ulfsdirhash_move(struct inode *ip, struct lfs_dirheader *dirp, doff_t oldoff,
|
||||
ulfsdirhash_move(struct inode *ip, 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_dirheader *dp;
|
||||
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_dirheader *)(sbuf + i);
|
||||
dp = (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_dirheader *dirp,
|
||||
ulfsdirhash_getprev(struct lfs *fs, LFS_DIRHEADER *dirp,
|
||||
doff_t offset, int dirblksiz)
|
||||
{
|
||||
struct lfs_dirheader *dp;
|
||||
LFS_DIRHEADER *dp;
|
||||
char *blkbuf;
|
||||
doff_t blkoff, prevoff;
|
||||
int entrypos, i;
|
||||
@ -1034,7 +1034,7 @@ ulfsdirhash_getprev(struct lfs *fs, struct lfs_dirheader *dirp,
|
||||
|
||||
/* Scan from the start of the block until we get to the entry. */
|
||||
for (i = 0; i < entrypos; i += reclen) {
|
||||
dp = (struct lfs_dirheader *)(blkbuf + i);
|
||||
dp = (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.7 2015/09/21 01:22:18 dholland Exp $ */
|
||||
/* $NetBSD: ulfs_dirhash.h,v 1.8 2015/09/21 01:24:23 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_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_add(struct inode *, LFS_DIRHEADER *, doff_t);
|
||||
void ulfsdirhash_remove(struct inode *, LFS_DIRHEADER *, doff_t);
|
||||
void ulfsdirhash_move(struct inode *, 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.19 2015/09/15 15:02:25 dholland Exp $ */
|
||||
/* $NetBSD: ulfs_extern.h,v 1.20 2015/09/21 01:24:23 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_dirheader *, int);
|
||||
int ulfs_dirbadentry(struct vnode *, 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.33 2015/09/21 01:22:18 dholland Exp $ */
|
||||
/* $NetBSD: ulfs_lookup.c,v 1.34 2015/09/21 01:24:23 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.33 2015/09/21 01:22:18 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ulfs_lookup.c,v 1.34 2015/09/21 01:24:23 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_dirheader *ep; /* the current directory entry */
|
||||
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_dirheader *)((char *)bp->b_data +
|
||||
ep = (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_dirheader *)((char *)bp->b_data + entryoffsetinblock);
|
||||
ep = (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_dirheader *ep, int entryoffsetinblock)
|
||||
ulfs_dirbadentry(struct vnode *dp, 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_dirheader *dirp,
|
||||
ulfs_direntry_assign(struct lfs *fs, 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_dirheader *ep, *nep;
|
||||
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_dirheader *)((char *)bp->b_data + lfs_blkoff);
|
||||
ep = (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_dirheader *)dirbuf;
|
||||
ep = (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_dirheader *)(dirbuf + loc);
|
||||
nep = (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_dirheader *ep;
|
||||
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_dirheader *ep;
|
||||
LFS_DIRHEADER *ep;
|
||||
struct vnode *vdp = ITOV(dp);
|
||||
int error;
|
||||
|
||||
@ -1135,12 +1135,13 @@ 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_dirheader *dp = (struct lfs_dirheader *)&dbuf;
|
||||
union lfs_dirtemplate dbuf;
|
||||
LFS_DIRHEADER *dp = (LFS_DIRHEADER *)&dbuf;
|
||||
int error, namlen;
|
||||
const char *name;
|
||||
size_t count;
|
||||
#define MINDIRSIZ (sizeof (struct lfs_dirtemplate) / 2)
|
||||
/* XXX this should probably use LFS_DIRECTSIZ(fs, 2) */
|
||||
#define MINDIRSIZ (sizeof (struct lfs_dirtemplate64) / 2)
|
||||
|
||||
for (off = 0; off < ip->i_size; off += lfs_dir_getreclen(fs, dp)) {
|
||||
error = ulfs_bufio(UIO_READ, ITOV(ip), (void *)dp, MINDIRSIZ,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ulfs_vnops.c,v 1.33 2015/09/21 01:22:18 dholland Exp $ */
|
||||
/* $NetBSD: ulfs_vnops.c,v 1.34 2015/09/21 01:24:23 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.33 2015/09/21 01:22:18 dholland Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ulfs_vnops.c,v 1.34 2015/09/21 01:24:23 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_dirheader *cdp, *ecdp;
|
||||
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_dirheader *)(void *)cdbuf;
|
||||
ecdp = (struct lfs_dirheader *)(void *)&cdbuf[rcount];
|
||||
cdp = (LFS_DIRHEADER *)(void *)cdbuf;
|
||||
ecdp = (LFS_DIRHEADER *)(void *)&cdbuf[rcount];
|
||||
|
||||
ndbufsz = count;
|
||||
ndbuf = kmem_alloc(ndbufsz, KM_SLEEP);
|
||||
|
Loading…
Reference in New Issue
Block a user