Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add 64-bit directory entry structures, and adjust accessors ...
details: https://anonhg.NetBSD.org/src/rev/4fc81ff9278e
branches: trunk
changeset: 340628:4fc81ff9278e
user: dholland <dholland%NetBSD.org@localhost>
date: Mon Sep 21 01:24:23 2015 +0000
description:
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.)
diffstat:
sbin/fsck_lfs/dir.c | 34 +++++-----
sbin/fsck_lfs/extern.h | 4 +-
sbin/fsck_lfs/fsck.h | 4 +-
sbin/fsck_lfs/inode.c | 6 +-
sbin/fsck_lfs/pass2.c | 16 ++--
sbin/newfs_lfs/make_lfs.c | 6 +-
sys/ufs/lfs/lfs.h | 39 ++++++++++-
sys/ufs/lfs/lfs_accessors.h | 141 ++++++++++++++++++++++++++++++++++---------
sys/ufs/lfs/lfs_rename.c | 28 +++++---
sys/ufs/lfs/lfs_vnops.c | 6 +-
sys/ufs/lfs/ulfs_dirhash.c | 32 ++++----
sys/ufs/lfs/ulfs_dirhash.h | 8 +-
sys/ufs/lfs/ulfs_extern.h | 4 +-
sys/ufs/lfs/ulfs_lookup.c | 33 +++++----
sys/ufs/lfs/ulfs_vnops.c | 10 +-
15 files changed, 245 insertions(+), 126 deletions(-)
diffs (truncated from 1060 to 300 lines):
diff -r 27a0ee1a58ab -r 4fc81ff9278e sbin/fsck_lfs/dir.c
--- a/sbin/fsck_lfs/dir.c Mon Sep 21 01:22:18 2015 +0000
+++ b/sbin/fsck_lfs/dir.c Mon Sep 21 01:24:23 2015 +0000
@@ -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 @@
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 @@
int
dirscan(struct inodesc *idesc)
{
- struct lfs_dirheader *dp;
+ LFS_DIRHEADER *dp;
struct ubuf *bp;
int dsize, n;
long blksiz;
@@ -156,7 +156,7 @@
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 @@
/*
* 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 @@
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 @@
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 @@
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 @@
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 @@
* 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 @@
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 @@
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 @@
static void
zerodirblk(void *buf)
{
- struct lfs_dirheader *dirp;
+ LFS_DIRHEADER *dirp;
dirp = buf;
lfs_dir_setino(fs, dirp, 0);
@@ -673,7 +673,7 @@
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 @@
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));
diff -r 27a0ee1a58ab -r 4fc81ff9278e sbin/fsck_lfs/extern.h
--- a/sbin/fsck_lfs/extern.h Mon Sep 21 01:22:18 2015 +0000
+++ b/sbin/fsck_lfs/extern.h Mon Sep 21 01:24:23 2015 +0000
@@ -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 @@
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 *);
diff -r 27a0ee1a58ab -r 4fc81ff9278e sbin/fsck_lfs/fsck.h
--- a/sbin/fsck_lfs/fsck.h Mon Sep 21 01:22:18 2015 +0000
+++ b/sbin/fsck_lfs/fsck.h Mon Sep 21 01:24:23 2015 +0000
@@ -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 @@
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 */
};
diff -r 27a0ee1a58ab -r 4fc81ff9278e sbin/fsck_lfs/inode.c
--- a/sbin/fsck_lfs/inode.c Mon Sep 21 01:22:18 2015 +0000
+++ b/sbin/fsck_lfs/inode.c Mon Sep 21 01:24:23 2015 +0000
@@ -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 @@
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 @@
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);
diff -r 27a0ee1a58ab -r 4fc81ff9278e sbin/fsck_lfs/pass2.c
--- a/sbin/fsck_lfs/pass2.c Mon Sep 21 01:22:18 2015 +0000
+++ b/sbin/fsck_lfs/pass2.c Mon Sep 21 01:24:23 2015 +0000
@@ -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 @@
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 @@
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 @@
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));
}
diff -r 27a0ee1a58ab -r 4fc81ff9278e sbin/newfs_lfs/make_lfs.c
--- a/sbin/newfs_lfs/make_lfs.c Mon Sep 21 01:22:18 2015 +0000
+++ b/sbin/newfs_lfs/make_lfs.c Mon Sep 21 01:24:23 2015 +0000
@@ -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 @@
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;
diff -r 27a0ee1a58ab -r 4fc81ff9278e sys/ufs/lfs/lfs.h
--- a/sys/ufs/lfs/lfs.h Mon Sep 21 01:22:18 2015 +0000
+++ b/sys/ufs/lfs/lfs.h Mon Sep 21 01:24:23 2015 +0000
@@ -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 $ */
Home |
Main Index |
Thread Index |
Old Index