From f700131fd413571a9cf04faa1e1c923d1e4968ce Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 18 Dec 2008 00:54:15 +0000 Subject: [PATCH] Apply the big hammer: o remove all of compat except for pwcache and strstuftoll; these might end up in libutil or similar so keep them in the subdir o mv getid.c up to the top level; this looks like something that'll be makefs-specific o eliminate private versions of .h files in sys; use system files instead o eliminate private ffs_tables.c; use the system version directly (might want to adopt const'ification at some point but that's the only diff I can see) o mv remaining code from sys to ffs and strip out unused bits; this now becomes part of makefs o add compat defs and shims to makefs.h o strip all vestiges of nbtool_config.h, compat_defs.h, etc. o fixup includes after file shuffling o rename system #defines that do implicit byte swapping to have an _swap suffix; e.g. DIRSIZ -> DIRSIZ_SWAP, cg_inosused -> cg_inosused_swap; if we ever add endian-agnostic support to the kernel these can go back to their original names o strip some netbsd'isms that aren't worth shim'ing (e.g. _DIAGASSERT) Code compiles w/o complaints but is untested. --- Makefile | 17 +- compat/compat_defs.h | 167 ------- compat/machine/bswap.h | 0 compat/namespace.h | 14 - compat/nbtool_config.h | 137 ------ compat/pwcache.c | 22 - compat/strsuftoll.c | 41 +- compat/util.h | 0 ffs.c | 18 +- ffs/buf.c | 4 - ffs/ffs_alloc.c | 51 +-- ffs/ffs_balloc.c | 6 +- {sys/ufs/ffs => ffs}/ffs_bswap.c | 117 ++--- {sys/ufs/ffs => ffs}/ffs_subr.c | 170 +------- ffs/mkfs.c | 26 +- ffs/ufs_bmap.c | 6 +- {sys/ufs/ufs => ffs}/ufs_bswap.h | 2 +- compat/getid.c => getid.c | 7 +- makefs.c | 4 - makefs.h | 71 ++- sys/ufs/ffs/ffs_extern.h | 202 --------- sys/ufs/ffs/ffs_tables.c | 141 ------ sys/ufs/ffs/fs.h | 728 ------------------------------- sys/ufs/ufs/dinode.h | 175 -------- sys/ufs/ufs/dir.h | 160 ------- walk.c | 4 - 26 files changed, 195 insertions(+), 2095 deletions(-) delete mode 100644 compat/compat_defs.h delete mode 100644 compat/machine/bswap.h delete mode 100644 compat/namespace.h delete mode 100644 compat/nbtool_config.h delete mode 100644 compat/util.h rename {sys/ufs/ffs => ffs}/ffs_bswap.c (77%) rename {sys/ufs/ffs => ffs}/ffs_subr.c (57%) rename {sys/ufs/ufs => ffs}/ufs_bswap.h (99%) rename compat/getid.c => getid.c (99%) delete mode 100644 sys/ufs/ffs/ffs_extern.h delete mode 100644 sys/ufs/ffs/ffs_tables.c delete mode 100644 sys/ufs/ffs/fs.h delete mode 100644 sys/ufs/ufs/dinode.h delete mode 100644 sys/ufs/ufs/dir.h diff --git a/Makefile b/Makefile index 08da3dd82ed..7c2c24b952c 100644 --- a/Makefile +++ b/Makefile @@ -5,25 +5,22 @@ MAN= makefs.8 WARNS?= 2 -CFLAGS+=-DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 - CFLAGS+=-I. -SRCS= ffs.c makefs.c walk.c +SRCS= ffs.c getid.c makefs.c walk.c .PATH: ${.CURDIR}/ffs CFLAGS+=-Iffs -SRCS+= buf.c ffs_alloc.c ffs_balloc.c mkfs.c ufs_bmap.c +SRCS+= buf.c ffs_alloc.c ffs_balloc.c ffs_bswap.c ffs_subr.c mkfs.c ufs_bmap.c -.PATH: ${.CURDIR}/sys/ufs/ffs -CFLAGS+=-Isys -Isys/ufs -SRCS+= ffs_bswap.c ffs_subr.c ffs_tables.c +.PATH: ${.CURDIR}/compat +CFLAGS+=-Icompat +SRCS+= pwcache.c strsuftoll.c .PATH: ${.CURDIR}/../mtree CFLAGS+=-I../mtree SRCS+= misc.c spec.c -.PATH: ${.CURDIR}/compat -CFLAGS+=-Icompat -SRCS+= fparseln.c getid.c getmode.c pwcache.c strsuftoll.c +.PATH: ${.CURDIR}/../../sys/ufs/ffs +SRCS+= ffs_tables.c .include diff --git a/compat/compat_defs.h b/compat/compat_defs.h deleted file mode 100644 index 8ba4047a7a8..00000000000 --- a/compat/compat_defs.h +++ /dev/null @@ -1,167 +0,0 @@ -/* $NetBSD: compat_defs.h,v 1.43 2004/06/23 11:08:01 tron Exp $ */ - -#ifndef __NETBSD_COMPAT_DEFS_H__ -#define __NETBSD_COMPAT_DEFS_H__ - -/* Work around some complete brain damage. */ - -#undef _POSIX_SOURCE -#undef _POSIX_C_SOURCE - -/* System headers needed for (re)definitions below. */ - -#include -#include -#include -/* time.h needs to be pulled in first at least on netbsd w/o _NETBSD_SOURCE */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if HAVE_SYS_CDEFS_H -#include -#endif -#if HAVE_SYS_SYSLIMITS_H -#include -#endif -#if HAVE_SYS_SYSMACROS_H -/* major(), minor() on SVR4 */ -#include -#endif -#if HAVE_INTTYPES_H -#include -#endif -#if HAVE_STDDEF_H -#include -#endif - -/* We don't include here, so that "compat_pwd.h" works. */ -struct passwd; - -/* Some things usually in BSD . */ -#ifndef __RENAME -#define __RENAME(x) -#endif - -/* Dirent support. */ -#include -#define NAMLEN(dirent) (strlen((dirent)->d_name)) - -#if !HAVE_FPARSELN || defined(__NetBSD__) -# define FPARSELN_UNESCESC 0x01 -# define FPARSELN_UNESCCONT 0x02 -# define FPARSELN_UNESCCOMM 0x04 -# define FPARSELN_UNESCREST 0x08 -# define FPARSELN_UNESCALL 0x0f -char *fparseln(FILE *, size_t *, size_t *, const char [3], int); -#endif - -#define __nbcompat_bswap16(x) ((((x) << 8) & 0xff00) | (((x) >> 8) & 0x00ff)) - -#define __nbcompat_bswap32(x) ((((x) << 24) & 0xff000000) | \ - (((x) << 8) & 0x00ff0000) | \ - (((x) >> 8) & 0x0000ff00) | \ - (((x) >> 24) & 0x000000ff)) - -#define __nbcompat_bswap64(x) (((u_int64_t)bswap32((x)) << 32) | \ - ((u_int64_t)bswap32((x) >> 32))) - -#if !HAVE_BSWAP16 -#ifdef bswap16 -#undef bswap16 -#endif -#define bswap16(x) __nbcompat_bswap16(x) -#endif -#if !HAVE_BSWAP32 -#ifdef bswap32 -#undef bswap32 -#endif -#define bswap32(x) __nbcompat_bswap32(x) -#endif -#if !HAVE_BSWAP64 -#ifdef bswap64 -#undef bswap64 -#endif -#define bswap64(x) __nbcompat_bswap64(x) -#endif - -#if !HAVE_PWCACHE_USERDB -int uid_from_user(const char *, uid_t *); -int pwcache_userdb(int (*)(int), void (*)(void), - struct passwd * (*)(const char *), struct passwd * (*)(uid_t)); -int gid_from_group(const char *, gid_t *); -int pwcache_groupdb(int (*)(int), void (*)(void), - struct group * (*)(const char *), struct group * (*)(gid_t)); -#endif -/* Make them use our version */ -# define user_from_uid __nbcompat_user_from_uid -/* Make them use our version */ -# define group_from_gid __nbcompat_group_from_gid -#if HAVE_GROUP_FROM_GID -const char *group_from_gid(gid_t, int); -#endif - -#if !HAVE_SETENV -int setenv(const char *, const char *, int); -#endif - -#if !HAVE_STRSUFTOLL -long long strsuftoll(const char *, const char *, long long, long long); -long long strsuftollx(const char *, const char *, - long long, long long, char *, size_t); -#endif - -#if !HAVE_USER_FROM_UID -const char *user_from_uid(uid_t, int); -#endif - -#if !HAVE_GROUP_FROM_GID -const char *group_from_gid(gid_t, int); -#endif - -/* - * getmode() and setmode() are always defined, as these function names - * exist but with very different meanings on other OS's. The compat - * versions here simply accept an octal mode number; the "u+x,g-w" type - * of syntax is not accepted. - */ - -#define getmode __nbcompat_getmode -#define setmode __nbcompat_setmode - -mode_t getmode(const void *, mode_t); -void *setmode(const char *); - -/* Eliminate assertions embedded in binaries. */ - -#undef _DIAGASSERT -#define _DIAGASSERT(x) - -/* Various sources use this */ -#undef __RCSID -#define __RCSID(x) -#undef __SCCSID -#define __SCCSID(x) -#undef __COPYRIGHT -#define __COPYRIGHT(x) -#undef __KERNEL_RCSID -#define __KERNEL_RCSID(x,y) - -/* Heimdal expects this one. */ - -#undef RCSID -#define RCSID(x) - -#ifndef MAXFRAG -#define MAXFRAG 8 -#endif - -#endif /* !__NETBSD_COMPAT_DEFS_H__ */ diff --git a/compat/machine/bswap.h b/compat/machine/bswap.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/compat/namespace.h b/compat/namespace.h deleted file mode 100644 index 0e6a6f257dc..00000000000 --- a/compat/namespace.h +++ /dev/null @@ -1,14 +0,0 @@ -/* $NetBSD: namespace.h,v 1.3 2003/10/27 00:12:43 lukem Exp $ */ - -/* - * Mainly empty header to make reachover bits of libc happy. - * - * Since all reachover bits will include this, it's a good place to pull - * in nbtool_config.h. - */ -#include "nbtool_config.h" - -/* No aliases in reachover-based libc sources. */ -#undef __indr_reference -#undef __weak_alias -#undef __warn_references diff --git a/compat/nbtool_config.h b/compat/nbtool_config.h deleted file mode 100644 index 676ae03b621..00000000000 --- a/compat/nbtool_config.h +++ /dev/null @@ -1,137 +0,0 @@ -/* nbtool_config.h. Generated automatically by configure. */ -/* $NetBSD: nbtool_config.h.in,v 1.4 2004/06/20 22:20:15 jmc Exp $ */ - -#ifndef __NETBSD_NBTOOL_CONFIG_H__ -#define __NETBSD_NBTOOL_CONFIG_H__ - -/* Values set by "configure" based on available functions in the host. */ - -#define PATH_BSHELL "/bin/sh" - -/* #undef HAVE_ALLOCA_H */ -#define HAVE_DIRENT_H 1 -#define HAVE_ERR_H 1 -/* #undef HAVE_FEATURES_H */ -#define HAVE_GETOPT_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_LIBGEN_H 1 -/* #undef HAVE_NDIR_H */ -#define HAVE_NETDB_H 1 -/* #undef HAVE_MACHINE_BSWAP_H */ -/* #undef HAVE_MALLOC_H */ -#define HAVE_SYS_POLL_H 1 -#define HAVE_STDDEF_H 1 -#define HAVE_STRING_H 1 -/* #undef HAVE_SYS_DIR_H */ -#define HAVE_SYS_ENDIAN_H 1 -/* #undef HAVE_SYS_NDIR_H */ -/* #undef HAVE_SYS_SYSLIMITS_H */ -/* #undef HAVE_SYS_SYSMACROS_H */ -#define HAVE_SYS_TYPES_H 1 -#define HAVE_TERMIOS_H 1 -#define HAVE_UNISTD_H 1 -#define STDC_HEADERS 1 - -#define HAVE_ID_T 1 -#define HAVE_SOCKLEN_T 1 -#define HAVE_LONG_LONG 1 -#define HAVE_U_LONG 1 -#define HAVE_U_CHAR 1 -#define HAVE_U_INT 1 -#define HAVE_U_SHORT 1 -#define HAVE_U_QUAD_T 1 - -/* #undef HAVE_BSWAP16 */ -/* #undef HAVE_BSWAP32 */ -/* #undef HAVE_BSWAP64 */ -/* #undef HAVE_HTOBE16 */ -/* #undef HAVE_HTOBE32 */ -/* #undef HAVE_HTOBE64 */ -/* #undef HAVE_HTOLE16 */ -/* #undef HAVE_HTOLE32 */ -/* #undef HAVE_HTOLE64 */ -/* #undef HAVE_BE16TOH */ -/* #undef HAVE_BE32TOH */ -/* #undef HAVE_BE64TOH */ -/* #undef HAVE_LE16TOH */ -/* #undef HAVE_LE32TOH */ -/* #undef HAVE_LE64TOH */ - -#define HAVE_DIR_DD_FD 1 -#define HAVE_STRUCT_DIRENT_D_NAMLEN 1 -#define HAVE_STRUCT_STAT_ST_FLAGS 1 -#define HAVE_STRUCT_STAT_ST_GEN 1 -#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1 -/* #undef HAVE_STRUCT_STAT_ST_ATIM */ -/* #undef HAVE_STRUCT_STAT_ST_MTIMENSEC */ -#define HAVE_STRUCT_STATFS_F_IOSIZE 1 - -#define HAVE_DECL_OPTIND 1 -#define HAVE_DECL_OPTRESET 1 -#define HAVE_DECL_SYS_SIGNAME 1 - -#define HAVE_ASPRINTF 1 -/* #undef HAVE_ASNPRINTF */ -#define HAVE_BASENAME 1 -/* #undef HAVE_CGETNEXT */ -#define HAVE_DEVNAME 1 -/* #undef HAVE_DIRFD */ -#define HAVE_DIRNAME 1 -#define HAVE_FGETLN 1 -#define HAVE_FLOCK 1 -/* #undef HAVE_FPARSELN */ -#define HAVE_FUTIMES 1 -#define HAVE_GETOPT 1 -#define HAVE_GETOPT_LONG 1 -#define HAVE_GROUP_FROM_GID 1 -#define HAVE_ISBLANK 1 -#define HAVE_ISSETUGID 1 -#define HAVE_LCHFLAGS 1 -#define HAVE_LCHMOD 1 -#define HAVE_LCHOWN 1 -#define HAVE_LUTIMES 1 -#define HAVE_MKSTEMP 1 -#define HAVE_MKDTEMP 1 -#define HAVE_POLL 1 -#define HAVE_PREAD 1 -#define HAVE_PUTC_UNLOCKED 1 -/* #undef HAVE_PWCACHE_USERDB */ -#define HAVE_PWRITE 1 -#define HAVE_RANDOM 1 -#define HAVE_SETENV 1 -#define HAVE_SETGROUPENT 1 -#define HAVE_SETPASSENT 1 -#define HAVE_SETPROGNAME 1 -#define HAVE_SNPRINTF 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRSEP 1 -/* #undef HAVE_STRSUFTOULL */ -#define HAVE_STRTOLL 1 -#define HAVE_USER_FROM_UID 1 -#define HAVE_VASPRINTF 1 -/* #undef HAVE_VASNPRINTF */ -#define HAVE_VSNPRINTF 1 - -#define HAVE_DECL_SETGROUPENT 1 -#define HAVE_DECL_SETPASSENT 1 - -/* #undef WORDS_BIGENDIAN */ - -/* Typedefs that might be missing. */ - -/* #undef size_t */ -/* #undef uint8_t */ -/* #undef uint16_t */ -/* #undef uint32_t */ -/* #undef uint64_t */ -/* #undef u_int8_t */ -/* #undef u_int16_t */ -/* #undef u_int32_t */ -/* #undef u_int64_t */ - -/* Now pull in the compatibility definitions. */ - -#include "compat_defs.h" - -#endif /* !__NETBSD_NBTOOL_CONFIG_H__ */ diff --git a/compat/pwcache.c b/compat/pwcache.c index 157010a84cc..18e4a29b978 100644 --- a/compat/pwcache.c +++ b/compat/pwcache.c @@ -66,16 +66,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -/* - * XXX Undefine the renames of these functions so that we don't - * XXX rename the versions found in the host's by mistake! - */ -#undef group_from_gid -#undef user_from_uid -#endif - #include #if defined(LIBC_SCCS) && !defined(lint) #if 0 @@ -85,8 +75,6 @@ __RCSID("$NetBSD: pwcache.c,v 1.29 2004/06/20 22:20:14 jmc Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#include "namespace.h" - #include #include @@ -98,12 +86,6 @@ __RCSID("$NetBSD: pwcache.c,v 1.29 2004/06/20 22:20:14 jmc Exp $"); #include #include -#if HAVE_NBTOOL_CONFIG_H -/* XXX Now, re-apply the renaming that we undid above. */ -#define group_from_gid __nbcompat_group_from_gid -#define user_from_uid __nbcompat_user_from_uid -#endif - #ifdef __weak_alias __weak_alias(user_from_uid,_user_from_uid) __weak_alias(group_from_gid,_group_from_gid) @@ -111,7 +93,6 @@ __weak_alias(pwcache_userdb,_pwcache_userdb) __weak_alias(pwcache_groupdb,_pwcache_groupdb) #endif -#if !HAVE_PWCACHE_USERDB || HAVE_NBTOOL_CONFIG_H #include "pwcache.h" /* @@ -162,8 +143,6 @@ st_hash(const char *name, size_t len, int tabsz) { u_int key = 0; - _DIAGASSERT(name != NULL); - while (len--) { key += *name++; key = (key << 8) | (key >> 24); @@ -648,4 +627,3 @@ main(int argc, char *argv[]) return (0); } #endif /* TEST_PWCACHE */ -#endif /* !HAVE_PWCACHE_USERDB */ diff --git a/compat/strsuftoll.c b/compat/strsuftoll.c index a4d157fc897..cb796a928a1 100644 --- a/compat/strsuftoll.c +++ b/compat/strsuftoll.c @@ -67,22 +67,12 @@ * SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include #if defined(LIBC_SCCS) && !defined(lint) __RCSID("$NetBSD: strsuftoll.c,v 1.6 2004/03/05 05:58:29 lukem Exp $"); #endif /* LIBC_SCCS and not lint */ -#ifdef _LIBC -#include "namespace.h" -#endif - -#if !HAVE_STRSUFTOLL - #include #include @@ -118,19 +108,6 @@ __weak_alias(strsuftollx, _strsuftollx) * appropriate error. * */ -/* LONGLONG */ -long long -strsuftoll(const char *desc, const char *val, - long long min, long long max) -{ - long long result; - char errbuf[100]; - - result = strsuftollx(desc, val, min, max, errbuf, sizeof(errbuf)); - if (*errbuf != '\0') - errx(1, "%s", errbuf); - return (result); -} /* * As strsuftoll(), but returns the error message into the provided buffer @@ -144,10 +121,6 @@ strsuftollx(const char *desc, const char *val, long long num, t; char *expr; - _DIAGASSERT(desc != NULL); - _DIAGASSERT(val != NULL); - _DIAGASSERT(ebuf != NULL); - errno = 0; ebuf[0] = '\0'; @@ -244,4 +217,16 @@ strsuftollx(const char *desc, const char *val, return (num); } -#endif /* !HAVE_STRSUFTOLL */ +/* LONGLONG */ +long long +strsuftoll(const char *desc, const char *val, + long long min, long long max) +{ + long long result; + char errbuf[100]; + + result = strsuftollx(desc, val, min, max, errbuf, sizeof(errbuf)); + if (*errbuf != '\0') + errx(1, "%s", errbuf); + return (result); +} diff --git a/compat/util.h b/compat/util.h deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/ffs.c b/ffs.c index 0c442655a5f..6147df27dc9 100644 --- a/ffs.c +++ b/ffs.c @@ -65,10 +65,6 @@ * @(#)ffs_alloc.c 8.19 (Berkeley) 7/13/95 */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include #if defined(__RCSID) && !defined(__lint) __RCSID("$NetBSD: ffs.c,v 1.30 2004/06/24 22:30:13 lukem Exp $"); @@ -94,8 +90,8 @@ __RCSID("$NetBSD: ffs.c,v 1.30 2004/06/24 22:30:13 lukem Exp $"); #include #include #include -#include +#include "ffs/ufs_bswap.h" #include "ffs/ufs_inode.h" #include "ffs/newfs_extern.h" #include "ffs/ffs_extern.h" @@ -516,7 +512,7 @@ ffs_size_dir(fsnode *root, fsinfo_t *fsopts) #define ADDDIRENT(e) do { \ tmpdir.d_namlen = strlen((e)); \ - this = DIRSIZ(0, &tmpdir, 0); \ + this = DIRSIZ_SWAP(0, &tmpdir, 0); \ if (debug & DEBUG_FS_SIZE_DIR_ADD_DIRENT) \ printf("ADDDIRENT: was: %s (%d) this %d cur %d\n", \ e, tmpdir.d_namlen, this, curdirsize); \ @@ -943,13 +939,13 @@ ffs_make_dirbuf(dirbuf_t *dbuf, const char *name, fsnode *node, int needswap) de.d_type = IFTODT(node->type); de.d_namlen = (uint8_t)strlen(name); strcpy(de.d_name, name); - reclen = DIRSIZ(0, &de, needswap); + reclen = DIRSIZ_SWAP(0, &de, needswap); de.d_reclen = ufs_rw16(reclen, needswap); dp = (struct direct *)(dbuf->buf + dbuf->cur); llen = 0; if (dp != NULL) - llen = DIRSIZ(0, dp, needswap); + llen = DIRSIZ_SWAP(0, dp, needswap); if (debug & DEBUG_FS_MAKE_DIRBUF) printf( @@ -1008,10 +1004,10 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts) ffs_rdfs(fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, &sbbuf, fsopts); cgp = (struct cg *)sbbuf; - if (!cg_chkmagic(cgp, fsopts->needswap)) + if (!cg_chkmagic_swap(cgp, fsopts->needswap)) errx(1, "ffs_write_inode: cg %d: bad magic number", cg); - assert (isclr(cg_inosused(cgp, fsopts->needswap), cgino)); + assert (isclr(cg_inosused_swap(cgp, fsopts->needswap), cgino)); buf = malloc(fs->fs_bsize); if (buf == NULL) @@ -1027,7 +1023,7 @@ ffs_write_inode(union dinode *dp, uint32_t ino, const fsinfo_t *fsopts) errx(1, "ffs_write_inode: cg %d out of inodes for ino %u", cg, ino); - setbit(cg_inosused(cgp, fsopts->needswap), cgino); + setbit(cg_inosused_swap(cgp, fsopts->needswap), cgino); ufs_add32(cgp->cg_cs.cs_nifree, -1, fsopts->needswap); fs->fs_cstotal.cs_nifree--; fs->fs_cs(fs, cg).cs_nifree--; diff --git a/ffs/buf.c b/ffs/buf.c index 3426cec7be5..84825c344d1 100644 --- a/ffs/buf.c +++ b/ffs/buf.c @@ -35,10 +35,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include #if defined(__RCSID) && !defined(__lint) __RCSID("$NetBSD: buf.c,v 1.12 2004/06/20 22:20:18 jmc Exp $"); diff --git a/ffs/ffs_alloc.c b/ffs/ffs_alloc.c index 2eef2eb1609..a36bce530fc 100644 --- a/ffs/ffs_alloc.c +++ b/ffs/ffs_alloc.c @@ -41,10 +41,6 @@ * @(#)ffs_alloc.c 8.19 (Berkeley) 7/13/95 */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include #if defined(__RCSID) && !defined(__lint) __RCSID("$NetBSD: ffs_alloc.c,v 1.14 2004/06/20 22:20:18 jmc Exp $"); @@ -58,14 +54,13 @@ __RCSID("$NetBSD: ffs_alloc.c,v 1.14 2004/06/20 22:20:18 jmc Exp $"); #include "makefs.h" #include -#include #include +#include "ffs/ufs_bswap.h" #include "ffs/buf.h" #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" - static int scanc(u_int, const u_char *, const u_char *, int); static daddr_t ffs_alloccg(struct inode *, int, daddr_t, int); @@ -74,10 +69,6 @@ static daddr_t ffs_hashalloc(struct inode *, int, daddr_t, int, daddr_t (*)(struct inode *, int, daddr_t, int)); static int32_t ffs_mapsearch(struct fs *, struct cg *, daddr_t, int); -/* in ffs_tables.c */ -extern const int inside[], around[]; -extern const u_char * const fragtbl[]; - /* * Allocate a block in the file system. * @@ -321,7 +312,7 @@ ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size) return (0); } cgp = (struct cg *)bp->b_data; - if (!cg_chkmagic(cgp, needswap) || + if (!cg_chkmagic_swap(cgp, needswap) || (cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) { brelse(bp); return (0); @@ -352,7 +343,7 @@ ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size) bno = ffs_alloccgblk(ip, bp, bpref); bpref = dtogd(fs, bno); for (i = frags; i < fs->fs_frag; i++) - setbit(cg_blksfree(cgp, needswap), bpref + i); + setbit(cg_blksfree_swap(cgp, needswap), bpref + i); i = fs->fs_frag - frags; ufs_add32(cgp->cg_cs.cs_nffree, i, needswap); fs->fs_cstotal.cs_nffree += i; @@ -364,7 +355,7 @@ ffs_alloccg(struct inode *ip, int cg, daddr_t bpref, int size) } bno = ffs_mapsearch(fs, cgp, bpref, allocsiz); for (i = 0; i < frags; i++) - clrbit(cg_blksfree(cgp, needswap), bno + i); + clrbit(cg_blksfree_swap(cgp, needswap), bno + i); ufs_add32(cgp->cg_cs.cs_nffree, -frags, needswap); fs->fs_cstotal.cs_nffree -= frags; fs->fs_cs(fs, cg).cs_nffree -= frags; @@ -399,7 +390,7 @@ ffs_alloccgblk(struct inode *ip, struct buf *bp, daddr_t bpref) u_int8_t *blksfree; cgp = (struct cg *)bp->b_data; - blksfree = cg_blksfree(cgp, needswap); + blksfree = cg_blksfree_swap(cgp, needswap); if (bpref == 0 || dtog(fs, bpref) != ufs_rw32(cgp->cg_cgx, needswap)) { bpref = ufs_rw32(cgp->cg_rotor, needswap); } else { @@ -464,18 +455,18 @@ ffs_blkfree(struct inode *ip, daddr_t bno, long size) return; } cgp = (struct cg *)bp->b_data; - if (!cg_chkmagic(cgp, needswap)) { + if (!cg_chkmagic_swap(cgp, needswap)) { brelse(bp); return; } cgbno = dtogd(fs, bno); if (size == fs->fs_bsize) { fragno = fragstoblks(fs, cgbno); - if (!ffs_isfreeblock(fs, cg_blksfree(cgp, needswap), fragno)) { + if (!ffs_isfreeblock(fs, cg_blksfree_swap(cgp, needswap), fragno)) { errx(1, "blkfree: freeing free block %lld", (long long)bno); } - ffs_setblock(fs, cg_blksfree(cgp, needswap), fragno); + ffs_setblock(fs, cg_blksfree_swap(cgp, needswap), fragno); ffs_clusteracct(fs, cgp, fragno, 1); ufs_add32(cgp->cg_cs.cs_nbfree, 1, needswap); fs->fs_cstotal.cs_nbfree++; @@ -485,18 +476,18 @@ ffs_blkfree(struct inode *ip, daddr_t bno, long size) /* * decrement the counts associated with the old frags */ - blk = blkmap(fs, cg_blksfree(cgp, needswap), bbase); - ffs_fragacct(fs, blk, cgp->cg_frsum, -1, needswap); + blk = blkmap(fs, cg_blksfree_swap(cgp, needswap), bbase); + ffs_fragacct_swap(fs, blk, cgp->cg_frsum, -1, needswap); /* * deallocate the fragment */ frags = numfrags(fs, size); for (i = 0; i < frags; i++) { - if (isset(cg_blksfree(cgp, needswap), cgbno + i)) { + if (isset(cg_blksfree_swap(cgp, needswap), cgbno + i)) { errx(1, "blkfree: freeing free frag: block %lld", (long long)(cgbno + i)); } - setbit(cg_blksfree(cgp, needswap), cgbno + i); + setbit(cg_blksfree_swap(cgp, needswap), cgbno + i); } ufs_add32(cgp->cg_cs.cs_nffree, i, needswap); fs->fs_cstotal.cs_nffree += i; @@ -504,13 +495,13 @@ ffs_blkfree(struct inode *ip, daddr_t bno, long size) /* * add back in counts associated with the new frags */ - blk = blkmap(fs, cg_blksfree(cgp, needswap), bbase); - ffs_fragacct(fs, blk, cgp->cg_frsum, 1, needswap); + blk = blkmap(fs, cg_blksfree_swap(cgp, needswap), bbase); + ffs_fragacct_swap(fs, blk, cgp->cg_frsum, 1, needswap); /* * if a complete block has been reassembled, account for it */ fragno = fragstoblks(fs, bbase); - if (ffs_isblock(fs, cg_blksfree(cgp, needswap), fragno)) { + if (ffs_isblock(fs, cg_blksfree_swap(cgp, needswap), fragno)) { ufs_add32(cgp->cg_cs.cs_nffree, -fs->fs_frag, needswap); fs->fs_cstotal.cs_nffree -= fs->fs_frag; fs->fs_cs(fs, cg).cs_nffree -= fs->fs_frag; @@ -562,14 +553,14 @@ ffs_mapsearch(struct fs *fs, struct cg *cgp, daddr_t bpref, int allocsiz) ostart = start; olen = len; loc = scanc((u_int)len, - (const u_char *)&cg_blksfree(cgp, needswap)[start], + (const u_char *)&cg_blksfree_swap(cgp, needswap)[start], (const u_char *)fragtbl[fs->fs_frag], (1 << (allocsiz - 1 + (fs->fs_frag % NBBY)))); if (loc == 0) { len = start + 1; start = 0; loc = scanc((u_int)len, - (const u_char *)&cg_blksfree(cgp, needswap)[0], + (const u_char *)&cg_blksfree_swap(cgp, needswap)[0], (const u_char *)fragtbl[fs->fs_frag], (1 << (allocsiz - 1 + (fs->fs_frag % NBBY)))); if (loc == 0) { @@ -577,7 +568,7 @@ ffs_mapsearch(struct fs *fs, struct cg *cgp, daddr_t bpref, int allocsiz) "ffs_alloccg: map corrupted: start %d len %d offset %d %ld", ostart, olen, ufs_rw32(cgp->cg_freeoff, needswap), - (long)cg_blksfree(cgp, needswap) - (long)cgp); + (long)cg_blksfree_swap(cgp, needswap) - (long)cgp); /* NOTREACHED */ } } @@ -588,7 +579,7 @@ ffs_mapsearch(struct fs *fs, struct cg *cgp, daddr_t bpref, int allocsiz) * sift through the bits to find the selected frag */ for (i = bno + NBBY; bno < i; bno += fs->fs_frag) { - blk = blkmap(fs, cg_blksfree(cgp, needswap), bno); + blk = blkmap(fs, cg_blksfree_swap(cgp, needswap), bno); blk <<= 1; field = around[allocsiz]; subfield = inside[allocsiz]; @@ -619,8 +610,8 @@ ffs_clusteracct(struct fs *fs, struct cg *cgp, int32_t blkno, int cnt) if (fs->fs_contigsumsize <= 0) return; - freemapp = cg_clustersfree(cgp, needswap); - sump = cg_clustersum(cgp, needswap); + freemapp = cg_clustersfree_swap(cgp, needswap); + sump = cg_clustersum_swap(cgp, needswap); /* * Allocate or clear the actual block. */ diff --git a/ffs/ffs_balloc.c b/ffs/ffs_balloc.c index 8761e459e23..fc3c2adc29e 100644 --- a/ffs/ffs_balloc.c +++ b/ffs/ffs_balloc.c @@ -32,10 +32,6 @@ * @(#)ffs_balloc.c 8.8 (Berkeley) 6/16/95 */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include #if defined(__RCSID) && !defined(__lint) __RCSID("$NetBSD: ffs_balloc.c,v 1.13 2004/06/20 22:20:18 jmc Exp $"); @@ -53,9 +49,9 @@ __RCSID("$NetBSD: ffs_balloc.c,v 1.13 2004/06/20 22:20:18 jmc Exp $"); #include "makefs.h" #include -#include #include +#include "ffs/ufs_bswap.h" #include "ffs/buf.h" #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" diff --git a/sys/ufs/ffs/ffs_bswap.c b/ffs/ffs_bswap.c similarity index 77% rename from sys/ufs/ffs/ffs_bswap.c rename to ffs/ffs_bswap.c index c9a271c3525..5488bbb81f9 100644 --- a/sys/ufs/ffs/ffs_bswap.c +++ b/ffs/ffs_bswap.c @@ -30,12 +30,11 @@ * */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include +#if 0 __KERNEL_RCSID(0, "$NetBSD: ffs_bswap.c,v 1.28 2004/05/25 14:54:59 hannken Exp $"); +#endif +__FBSDID("$FreeBSD$"); #include #if defined(_KERNEL) @@ -43,8 +42,15 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_bswap.c,v 1.28 2004/05/25 14:54:59 hannken Exp $ #endif #include -#include +#include "ffs/ufs_bswap.h" #include +/* XXX temporary */ +struct ufsmount; +struct bufobj; +struct mount; +struct vnode; +typedef int vfs_vget_t(struct mount *mp, ino_t ino, int flags, + struct vnode **vpp); #include #if !defined(_KERNEL) @@ -55,6 +61,20 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_bswap.c,v 1.28 2004/05/25 14:54:59 hannken Exp $ #define panic(x) printf("%s\n", (x)), abort() #endif +#define fs_old_postbloff fs_spare5[0] +#define fs_old_rotbloff fs_spare5[1] +#define fs_old_postbl_start fs_maxbsize +#define fs_old_headswitch fs_id[0] +#define fs_old_trkseek fs_id[1] +#define fs_old_csmask fs_spare1[0] +#define fs_old_csshift fs_spare1[1] + +#define FS_42POSTBLFMT -1 /* 4.2BSD rotational table format */ +#define FS_DYNAMICPOSTBLFMT 1 /* dynamic rotational table format */ + +void ffs_csum_swap(struct csum *o, struct csum *n, int size); +void ffs_csumtotal_swap(struct csum_total *o, struct csum_total *n); + void ffs_sb_swap(struct fs *o, struct fs *n) { @@ -211,60 +231,43 @@ ffs_cg_swap(struct cg *o, struct cg *n, struct fs *fs) for (i = 0; i < MAXFRAG; i++) n->cg_frsum[i] = bswap32(o->cg_frsum[i]); - if ((fs->fs_magic != FS_UFS2_MAGIC) && - (fs->fs_old_postblformat == FS_42POSTBLFMT)) { /* old format */ - struct ocg *on, *oo; - int j; - on = (struct ocg *)n; - oo = (struct ocg *)o; - - for (i = 0; i < 32; i++) { - on->cg_btot[i] = bswap32(oo->cg_btot[i]); - for (j = 0; j < 8; j++) - on->cg_b[i][j] = bswap16(oo->cg_b[i][j]); - } - memmove(on->cg_iused, oo->cg_iused, 256); - on->cg_magic = bswap32(oo->cg_magic); - } else { /* new format */ + n->cg_old_btotoff = bswap32(o->cg_old_btotoff); + n->cg_old_boff = bswap32(o->cg_old_boff); + n->cg_iusedoff = bswap32(o->cg_iusedoff); + n->cg_freeoff = bswap32(o->cg_freeoff); + n->cg_nextfreeoff = bswap32(o->cg_nextfreeoff); + n->cg_clustersumoff = bswap32(o->cg_clustersumoff); + n->cg_clusteroff = bswap32(o->cg_clusteroff); + n->cg_nclusterblks = bswap32(o->cg_nclusterblks); + n->cg_niblk = bswap32(o->cg_niblk); + n->cg_initediblk = bswap32(o->cg_initediblk); + n->cg_time = bswap64(o->cg_time); - n->cg_old_btotoff = bswap32(o->cg_old_btotoff); - n->cg_old_boff = bswap32(o->cg_old_boff); - n->cg_iusedoff = bswap32(o->cg_iusedoff); - n->cg_freeoff = bswap32(o->cg_freeoff); - n->cg_nextfreeoff = bswap32(o->cg_nextfreeoff); - n->cg_clustersumoff = bswap32(o->cg_clustersumoff); - n->cg_clusteroff = bswap32(o->cg_clusteroff); - n->cg_nclusterblks = bswap32(o->cg_nclusterblks); - n->cg_niblk = bswap32(o->cg_niblk); - n->cg_initediblk = bswap32(o->cg_initediblk); - n->cg_time = bswap64(o->cg_time); + if (fs->fs_magic == FS_UFS2_MAGIC) + return; - if (fs->fs_magic == FS_UFS2_MAGIC) - return; - - if (n->cg_magic == CG_MAGIC) { - btotoff = n->cg_old_btotoff; - boff = n->cg_old_boff; - clustersumoff = n->cg_clustersumoff; - } else { - btotoff = bswap32(n->cg_old_btotoff); - boff = bswap32(n->cg_old_boff); - clustersumoff = bswap32(n->cg_clustersumoff); - } - n32 = (u_int32_t *)((u_int8_t *)n + btotoff); - o32 = (u_int32_t *)((u_int8_t *)o + btotoff); - n16 = (u_int16_t *)((u_int8_t *)n + boff); - o16 = (u_int16_t *)((u_int8_t *)o + boff); + if (n->cg_magic == CG_MAGIC) { + btotoff = n->cg_old_btotoff; + boff = n->cg_old_boff; + clustersumoff = n->cg_clustersumoff; + } else { + btotoff = bswap32(n->cg_old_btotoff); + boff = bswap32(n->cg_old_boff); + clustersumoff = bswap32(n->cg_clustersumoff); + } + n32 = (u_int32_t *)((u_int8_t *)n + btotoff); + o32 = (u_int32_t *)((u_int8_t *)o + btotoff); + n16 = (u_int16_t *)((u_int8_t *)n + boff); + o16 = (u_int16_t *)((u_int8_t *)o + boff); - for (i = 0; i < fs->fs_old_cpg; i++) - n32[i] = bswap32(o32[i]); - - for (i = 0; i < fs->fs_old_cpg * fs->fs_old_nrpos; i++) - n16[i] = bswap16(o16[i]); + for (i = 0; i < fs->fs_old_cpg; i++) + n32[i] = bswap32(o32[i]); + + for (i = 0; i < fs->fs_old_cpg * fs->fs_old_nrpos; i++) + n16[i] = bswap16(o16[i]); - n32 = (u_int32_t *)((u_int8_t *)n + clustersumoff); - o32 = (u_int32_t *)((u_int8_t *)o + clustersumoff); - for (i = 1; i < fs->fs_contigsumsize + 1; i++) - n32[i] = bswap32(o32[i]); - } + n32 = (u_int32_t *)((u_int8_t *)n + clustersumoff); + o32 = (u_int32_t *)((u_int8_t *)o + clustersumoff); + for (i = 1; i < fs->fs_contigsumsize + 1; i++) + n32[i] = bswap32(o32[i]); } diff --git a/sys/ufs/ffs/ffs_subr.c b/ffs/ffs_subr.c similarity index 57% rename from sys/ufs/ffs/ffs_subr.c rename to ffs/ffs_subr.c index f08724ea03f..37a20689f3b 100644 --- a/sys/ufs/ffs/ffs_subr.c +++ b/ffs/ffs_subr.c @@ -31,141 +31,34 @@ * @(#)ffs_subr.c 8.5 (Berkeley) 3/21/95 */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include +#if 0 __KERNEL_RCSID(0, "$NetBSD: ffs_subr.c,v 1.32 2003/12/30 12:33:24 pk Exp $"); +#endif +__FBSDID("$FreeBSD$"); #include -/* in ffs_tables.c */ -extern const int inside[], around[]; -extern const u_char * const fragtbl[]; - -#ifndef _KERNEL #include #include +/* XXX temporary */ +struct ufsmount; +struct bufobj; +struct mount; +struct vnode; +typedef int vfs_vget_t(struct mount *mp, ino_t ino, int flags, + struct vnode **vpp); #include -#include +#include "ffs/ufs_bswap.h" void panic __P((const char *, ...)) __attribute__((__noreturn__,__format__(__printf__,1,2))); -#else /* _KERNEL */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Return buffer with the contents of block "offset" from the beginning of - * directory "ip". If "res" is non-zero, fill it in with a pointer to the - * remaining space in the directory. - */ -int -ffs_blkatoff(v) - void *v; -{ - struct vop_blkatoff_args /* { - struct vnode *a_vp; - off_t a_offset; - char **a_res; - struct buf **a_bpp; - } */ *ap = v; - struct inode *ip; - struct fs *fs; - struct buf *bp; - daddr_t lbn; - int bsize, error; - - ip = VTOI(ap->a_vp); - fs = ip->i_fs; - lbn = lblkno(fs, ap->a_offset); - bsize = blksize(fs, ip, lbn); - - *ap->a_bpp = NULL; - if ((error = bread(ap->a_vp, lbn, bsize, NOCRED, &bp)) != 0) { - brelse(bp); - return (error); - } - if (ap->a_res) - *ap->a_res = (char *)bp->b_data + blkoff(fs, ap->a_offset); - *ap->a_bpp = bp; - return (0); -} - - -/* - * Load up the contents of an inode and copy the appropriate pieces - * to the incore copy. - */ -void -ffs_load_inode(bp, ip, fs, ino) - struct buf *bp; - struct inode *ip; - struct fs *fs; - ino_t ino; -{ - struct ufs1_dinode *dp1; - struct ufs2_dinode *dp2; - - if (ip->i_ump->um_fstype == UFS1) { - dp1 = (struct ufs1_dinode *)bp->b_data + ino_to_fsbo(fs, ino); -#ifdef FFS_EI - if (UFS_FSNEEDSWAP(fs)) - ffs_dinode1_swap(dp1, ip->i_din.ffs1_din); - else -#endif - *ip->i_din.ffs1_din = *dp1; - - ip->i_mode = ip->i_ffs1_mode; - ip->i_nlink = ip->i_ffs1_nlink; - ip->i_size = ip->i_ffs1_size; - ip->i_flags = ip->i_ffs1_flags; - ip->i_gen = ip->i_ffs1_gen; - ip->i_uid = ip->i_ffs1_uid; - ip->i_gid = ip->i_ffs1_gid; - } else { - dp2 = (struct ufs2_dinode *)bp->b_data + ino_to_fsbo(fs, ino); -#ifdef FFS_EI - if (UFS_FSNEEDSWAP(fs)) - ffs_dinode2_swap(dp2, ip->i_din.ffs2_din); - else -#endif - *ip->i_din.ffs2_din = *dp2; - - ip->i_mode = ip->i_ffs2_mode; - ip->i_nlink = ip->i_ffs2_nlink; - ip->i_size = ip->i_ffs2_size; - ip->i_flags = ip->i_ffs2_flags; - ip->i_gen = ip->i_ffs2_gen; - ip->i_uid = ip->i_ffs2_uid; - ip->i_gid = ip->i_ffs2_gid; - } -} - -#endif /* _KERNEL */ - /* * Update the frsum fields to reflect addition or deletion * of some frags. */ void -ffs_fragacct(fs, fragmap, fraglist, cnt, needswap) - struct fs *fs; - int fragmap; - int32_t fraglist[]; - int cnt; - int needswap; +ffs_fragacct_swap(struct fs *fs, int fragmap, int32_t fraglist[], int cnt, int needswap) { int inblk; int field, subfield; @@ -193,45 +86,6 @@ ffs_fragacct(fs, fragmap, fraglist, cnt, needswap) } } -#if defined(_KERNEL) && defined(DIAGNOSTIC) -void -ffs_checkoverlap(bp, ip) - struct buf *bp; - struct inode *ip; -{ -#if 0 - struct buf *ebp, *ep; - daddr_t start, last; - struct vnode *vp; - - ebp = &buf[nbuf]; - start = bp->b_blkno; - last = start + btodb(bp->b_bcount) - 1; - for (ep = buf; ep < ebp; ep++) { - if (ep == bp || (ep->b_flags & B_INVAL) || - ep->b_vp == NULLVP) - continue; - if (VOP_BMAP(ep->b_vp, (daddr_t)0, &vp, (daddr_t)0, NULL)) - continue; - if (vp != ip->i_devvp) - continue; - /* look for overlap */ - if (ep->b_bcount == 0 || ep->b_blkno > last || - ep->b_blkno + btodb(ep->b_bcount) <= start) - continue; - vprint("Disk overlap", vp); - printf("\tstart %" PRId64 ", end %" PRId64 " overlap start " - "%" PRId64 ", end %" PRId64 "\n", - start, last, ep->b_blkno, - ep->b_blkno + btodb(ep->b_bcount) - 1); - panic("Disk buffer overlap"); - } -#else - printf("ffs_checkoverlap disabled due to buffer cache implementation changes\n"); -#endif -} -#endif /* _KERNEL && DIAGNOSTIC */ - /* * block operations * diff --git a/ffs/mkfs.c b/ffs/mkfs.c index 1a4c0666538..bee433d9d08 100644 --- a/ffs/mkfs.c +++ b/ffs/mkfs.c @@ -38,10 +38,6 @@ * SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include #ifndef lint #if 0 @@ -66,9 +62,9 @@ __RCSID("$NetBSD: mkfs.c,v 1.20 2004/06/24 22:30:13 lukem Exp $"); #include "makefs.h" #include -#include #include +#include "ffs/ufs_bswap.h" #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" #include "ffs/newfs_extern.h" @@ -114,7 +110,6 @@ static int opt; /* optimization preference (space or time) */ static int density; /* number of bytes per inode */ static int maxcontig; /* max contiguous blocks to allocate */ static int maxbpg; /* maximum blocks per file in a cyl group */ -static int bbsize; /* boot block size */ static int sbsize; /* superblock size */ static int avgfilesize; /* expected average file size */ static int avgfpdir; /* expected number of files per directory */ @@ -143,7 +138,6 @@ ffs_mkfs(const char *fsys, const fsinfo_t *fsopts) maxbpg = fsopts->maxbpg; avgfilesize = fsopts->avgfilesize; avgfpdir = fsopts->avgfpdir; - bbsize = BBSIZE; sbsize = SBLOCKSIZE; if (Oflag == 0) { @@ -663,7 +657,7 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts) acg.cg_cs.cs_nifree += sblock.fs_ipg; if (cylno == 0) for (i = 0; i < ROOTINO; i++) { - setbit(cg_inosused(&acg, 0), i); + setbit(cg_inosused_swap(&acg, 0), i); acg.cg_cs.cs_nifree--; } if (cylno > 0) { @@ -672,9 +666,9 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts) * for boot and super blocks. */ for (d = 0, blkno = 0; d < dlower;) { - ffs_setblock(&sblock, cg_blksfree(&acg, 0), blkno); + ffs_setblock(&sblock, cg_blksfree_swap(&acg, 0), blkno); if (sblock.fs_contigsumsize > 0) - setbit(cg_clustersfree(&acg, 0), blkno); + setbit(cg_clustersfree_swap(&acg, 0), blkno); acg.cg_cs.cs_nbfree++; d += sblock.fs_frag; blkno++; @@ -683,15 +677,15 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts) if ((i = (dupper & (sblock.fs_frag - 1))) != 0) { acg.cg_frsum[sblock.fs_frag - i]++; for (d = dupper + sblock.fs_frag - i; dupper < d; dupper++) { - setbit(cg_blksfree(&acg, 0), dupper); + setbit(cg_blksfree_swap(&acg, 0), dupper); acg.cg_cs.cs_nffree++; } } for (d = dupper, blkno = dupper >> sblock.fs_fragshift; d + sblock.fs_frag <= acg.cg_ndblk; ) { - ffs_setblock(&sblock, cg_blksfree(&acg, 0), blkno); + ffs_setblock(&sblock, cg_blksfree_swap(&acg, 0), blkno); if (sblock.fs_contigsumsize > 0) - setbit(cg_clustersfree(&acg, 0), blkno); + setbit(cg_clustersfree_swap(&acg, 0), blkno); acg.cg_cs.cs_nbfree++; d += sblock.fs_frag; blkno++; @@ -699,13 +693,13 @@ initcg(int cylno, time_t utime, const fsinfo_t *fsopts) if (d < acg.cg_ndblk) { acg.cg_frsum[acg.cg_ndblk - d]++; for (; d < acg.cg_ndblk; d++) { - setbit(cg_blksfree(&acg, 0), d); + setbit(cg_blksfree_swap(&acg, 0), d); acg.cg_cs.cs_nffree++; } } if (sblock.fs_contigsumsize > 0) { - int32_t *sump = cg_clustersum(&acg, 0); - u_char *mapp = cg_clustersfree(&acg, 0); + int32_t *sump = cg_clustersum_swap(&acg, 0); + u_char *mapp = cg_clustersfree_swap(&acg, 0); int map = *mapp++; int bit = 1; int run = 0; diff --git a/ffs/ufs_bmap.c b/ffs/ufs_bmap.c index 8e21ae60323..cc6ade108b7 100644 --- a/ffs/ufs_bmap.c +++ b/ffs/ufs_bmap.c @@ -37,10 +37,6 @@ * @(#)ufs_bmap.c 8.8 (Berkeley) 8/11/95 */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include #if defined(__RCSID) && !defined(__lint) __RCSID("$NetBSD: ufs_bmap.c,v 1.14 2004/06/20 22:20:18 jmc Exp $"); @@ -56,9 +52,9 @@ __RCSID("$NetBSD: ufs_bmap.c,v 1.14 2004/06/20 22:20:18 jmc Exp $"); #include "makefs.h" #include -#include #include +#include "ffs/ufs_bswap.h" #include "ffs/ufs_inode.h" #include "ffs/ffs_extern.h" diff --git a/sys/ufs/ufs/ufs_bswap.h b/ffs/ufs_bswap.h similarity index 99% rename from sys/ufs/ufs/ufs_bswap.h rename to ffs/ufs_bswap.h index faddc7b37de..344317c4009 100644 --- a/sys/ufs/ufs/ufs_bswap.h +++ b/ffs/ufs_bswap.h @@ -37,7 +37,7 @@ #include "opt_ffs.h" #endif -#include +#include /* Macros to access UFS flags */ #ifdef FFS_EI diff --git a/compat/getid.c b/getid.c similarity index 99% rename from compat/getid.c rename to getid.c index 907ff722f76..7c24293a5a2 100644 --- a/compat/getid.c +++ b/getid.c @@ -67,10 +67,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include #include @@ -82,6 +78,8 @@ #include #include +#include "makefs.h" + #include "mtree.h" #include "extern.h" @@ -433,4 +431,3 @@ pwmatchline(int search, uid_t uid, const char *name) return 1; } - diff --git a/makefs.c b/makefs.c index 4a64ab397a0..2b4356104bb 100644 --- a/makefs.c +++ b/makefs.c @@ -35,10 +35,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include #if defined(__RCSID) && !defined(__lint) __RCSID("$NetBSD: makefs.c,v 1.20 2004/06/20 22:20:18 jmc Exp $"); diff --git a/makefs.h b/makefs.h index ada563b1c5e..13339c2fb53 100644 --- a/makefs.h +++ b/makefs.h @@ -38,16 +38,6 @@ #ifndef _MAKEFS_H #define _MAKEFS_H -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#else -#define HAVE_STRUCT_STAT_ST_FLAGS 1 -#define HAVE_STRUCT_STAT_ST_GEN 1 -#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1 -#define HAVE_STRUCT_STATVFS_F_IOSIZE 1 -#define HAVE_STRUCT_STAT_BIRTHTIME 1 -#endif - #include #include @@ -231,7 +221,7 @@ extern struct timespec start_time; gettimeofday(&end, NULL); \ timersub(&end, &(x), &td); \ printf("%s took %ld.%06ld seconds\n", \ - (d), td.tv_sec, td.tv_usec); \ + (d), (long) td.tv_sec, (long) td.tv_usec); \ } @@ -247,5 +237,64 @@ extern struct timespec start_time; #define FFS_EI /* for opposite endian support in ffs headers */ +/* + * Write-arounds/compat shims for endian-agnostic support. + * These belong in the kernel if/when it's possible to mount + * filesystems w/ either byte order. + */ + +/* + * File system internal flags, also in fs_flags. + * (Pick highest number to avoid conflicts with others) + */ +#define FS_SWAPPED 0x80000000 /* file system is endian swapped */ +#define FS_INTERNAL 0x80000000 /* mask for internal flags */ + +#define FS_ISCLEAN 1 + +#define DINODE1_SIZE (sizeof(struct ufs1_dinode)) +#define DINODE2_SIZE (sizeof(struct ufs2_dinode)) + +#define MAXSYMLINKLEN_UFS1 ((NDADDR + NIADDR) * sizeof(ufs1_daddr_t)) +#define MAXSYMLINKLEN_UFS2 ((NDADDR + NIADDR) * sizeof(ufs2_daddr_t)) + +#if (BYTE_ORDER == LITTLE_ENDIAN) +#define DIRSIZ_SWAP(oldfmt, dp, needswap) \ + (((oldfmt) && !(needswap)) ? \ + DIRECTSIZ((dp)->d_type) : DIRECTSIZ((dp)->d_namlen)) +#else +#define DIRSIZ_SWAP(oldfmt, dp, needswap) \ + (((oldfmt) && (needswap)) ? \ + DIRECTSIZ((dp)->d_type) : DIRECTSIZ((dp)->d_namlen)) +#endif + +#define cg_chkmagic_swap(cgp, ns) \ + (ufs_rw32(cg_chkmagic(cgp), (ns)) == CG_MAGIC) +#define cg_inosused_swap(cgp, ns) cg_inosused(cgp) +#define cg_blksfree_swap(cgp, ns) cg_blksfree(cgp) +#define cg_clustersfree_swap(cgp, ns) cg_clustersfree(cgp) +#define cg_clustersum_swap(cgp, ns) \ + ((int32_t *)((uintptr_t)(cgp) + ufs_rw32((cgp)->cg_clustersumoff, ns))) + +struct fs; +void ffs_fragacct_swap(struct fs *, int, int32_t [], int, int); + +/* + * Declarations for compat routines. + */ +long long strsuftoll(const char *, const char *, long long, long long); +long long strsuftollx(const char *, const char *, + long long, long long, char *, size_t); + +struct passwd; +int uid_from_user(const char *, uid_t *); +int pwcache_userdb(int (*)(int), void (*)(void), + struct passwd * (*)(const char *), struct passwd * (*)(uid_t)); +struct group; +int gid_from_group(const char *, gid_t *); +int pwcache_groupdb(int (*)(int), void (*)(void), + struct group * (*)(const char *), struct group * (*)(gid_t)); + +int setup_getid(const char *dir); #endif /* _MAKEFS_H */ diff --git a/sys/ufs/ffs/ffs_extern.h b/sys/ufs/ffs/ffs_extern.h deleted file mode 100644 index ee03ca77f38..00000000000 --- a/sys/ufs/ffs/ffs_extern.h +++ /dev/null @@ -1,202 +0,0 @@ -/* $NetBSD: ffs_extern.h,v 1.40 2004/06/04 07:43:56 he Exp $ */ - -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ffs_extern.h 8.6 (Berkeley) 3/30/95 - */ - -#ifndef _UFS_FFS_FFS_EXTERN_H_ -#define _UFS_FFS_FFS_EXTERN_H_ - -/* - * Sysctl values for the fast filesystem. - */ -#define FFS_CLUSTERREAD 1 /* cluster reading enabled */ -#define FFS_CLUSTERWRITE 2 /* cluster writing enabled */ -#define FFS_REALLOCBLKS 3 /* block reallocation enabled */ -#define FFS_ASYNCFREE 4 /* asynchronous block freeing enabled */ -#define FFS_LOG_CHANGEOPT 5 /* log optimalization strategy change */ -#define FFS_MAXID 6 /* number of valid ffs ids */ - -#define FFS_NAMES { \ - { 0, 0 }, \ - { "doclusterread", CTLTYPE_INT }, \ - { "doclusterwrite", CTLTYPE_INT }, \ - { "doreallocblks", CTLTYPE_INT }, \ - { "doasyncfree", CTLTYPE_INT }, \ - { "log_changeopt", CTLTYPE_INT }, \ -} - -struct buf; -struct fid; -struct fs; -struct inode; -struct ufs1_dinode; -struct ufs2_dinode; -struct mount; -struct nameidata; -struct proc; -struct statvfs; -struct timeval; -struct timespec; -struct ucred; -struct ufsmount; -struct uio; -struct vnode; -struct mbuf; -struct cg; - -extern struct pool ffs_inode_pool; /* memory pool for inodes */ -extern struct pool ffs_dinode1_pool; /* memory pool for UFS1 dinodes */ -extern struct pool ffs_dinode2_pool; /* memory pool for UFS2 dinodes */ - -__BEGIN_DECLS - -/* ffs_alloc.c */ -int ffs_alloc __P((struct inode *, daddr_t, daddr_t , int, struct ucred *, - daddr_t *)); -int ffs_realloccg __P((struct inode *, daddr_t, daddr_t, int, int , - struct ucred *, struct buf **, daddr_t *)); -int ffs_reallocblks __P((void *)); -int ffs_valloc __P((void *)); -daddr_t ffs_blkpref_ufs1 __P((struct inode *, daddr_t, int, int32_t *)); -daddr_t ffs_blkpref_ufs2 __P((struct inode *, daddr_t, int, int64_t *)); -void ffs_blkfree __P((struct fs *, struct vnode *, daddr_t, long, ino_t)); -int ffs_vfree __P((void *)); -void ffs_clusteracct __P((struct fs *, struct cg *, int32_t, int)); -int ffs_checkfreefile __P((struct fs *, struct vnode *, ino_t)); - -/* ffs_balloc.c */ -int ffs_balloc __P((void *)); - -/* ffs_bswap.c */ -void ffs_sb_swap __P((struct fs*, struct fs *)); -void ffs_dinode1_swap __P((struct ufs1_dinode *, struct ufs1_dinode *)); -void ffs_dinode2_swap __P((struct ufs2_dinode *, struct ufs2_dinode *)); -void ffs_csum_swap __P((struct csum *, struct csum *, int)); -void ffs_csumtotal_swap __P((struct csum_total *, struct csum_total *)); -void ffs_cg_swap __P((struct cg *, struct cg *, struct fs *)); - -/* ffs_inode.c */ -int ffs_update __P((void *)); -int ffs_truncate __P((void *)); - -/* ffs_subr.c */ -void ffs_load_inode __P((struct buf *, struct inode *, struct fs *, ino_t)); -int ffs_blkatoff __P((void *)); -int ffs_freefile __P((void *)); -void ffs_fragacct __P((struct fs *, int, int32_t[], int, int)); -#ifdef DIAGNOSTIC -void ffs_checkoverlap __P((struct buf *, struct inode *)); -#endif -int ffs_isblock __P((struct fs *, u_char *, int32_t)); -int ffs_isfreeblock __P((struct fs *, u_char *, int32_t)); -void ffs_clrblock __P((struct fs *, u_char *, int32_t)); -void ffs_setblock __P((struct fs *, u_char *, int32_t)); - -/* ffs_vfsops.c */ -void ffs_init __P((void)); -void ffs_reinit __P((void)); -void ffs_done __P((void)); -int ffs_mountroot __P((void)); -int ffs_mount __P((struct mount *, const char *, void *, struct nameidata *, - struct proc *)); -int ffs_reload __P((struct mount *, struct ucred *, struct proc *)); -int ffs_mountfs __P((struct vnode *, struct mount *, struct proc *)); -int ffs_unmount __P((struct mount *, int, struct proc *)); -int ffs_flushfiles __P((struct mount *, int, struct proc *)); -int ffs_statvfs __P((struct mount *, struct statvfs *, struct proc *)); -int ffs_sync __P((struct mount *, int, struct ucred *, struct proc *)); -int ffs_vget __P((struct mount *, ino_t, struct vnode **)); -int ffs_fhtovp __P((struct mount *, struct fid *, struct vnode **)); -int ffs_vptofh __P((struct vnode *, struct fid *)); -int ffs_sbupdate __P((struct ufsmount *, int)); -int ffs_cgupdate __P((struct ufsmount *, int)); - -/* ffs_appleufs.c */ -u_int16_t ffs_appleufs_cksum __P((const struct appleufslabel *)); -int ffs_appleufs_validate __P((const char*,const struct appleufslabel *,struct appleufslabel *)); -void ffs_appleufs_set __P((struct appleufslabel *, const char *, time_t, uint64_t)); - - -/* ffs_vnops.c */ -int ffs_read __P((void *)); -int ffs_write __P((void *)); -int ffs_fsync __P((void *)); -int ffs_reclaim __P((void *)); -int ffs_getpages __P((void *)); -int ffs_putpages __P((void *)); -void ffs_gop_size __P((struct vnode *, off_t, off_t *, int)); - -#ifdef SYSCTL_SETUP_PROTO -SYSCTL_SETUP_PROTO(sysctl_vfs_ffs_setup); -#endif /* SYSCTL_SETUP_PROTO */ - -__END_DECLS - - -/* - * Snapshot function prototypes. - */ -int ffs_snapblkfree(struct fs *, struct vnode *, daddr_t, long, ino_t); -void ffs_snapremove(struct vnode *); -int ffs_snapshot(struct mount *, struct vnode *, struct timespec *); -void ffs_snapshot_mount(struct mount *); -void ffs_snapshot_unmount(struct mount *); -void ffs_snapgone(struct inode *); - -/* - * Soft dependency function prototypes. - */ -void softdep_initialize __P((void)); -void softdep_reinitialize __P((void)); -int softdep_mount __P((struct vnode *, struct mount *, struct fs *, - struct ucred *)); -int softdep_flushworklist __P((struct mount *, int *, struct proc *)); -int softdep_flushfiles __P((struct mount *, int, struct proc *)); -void softdep_update_inodeblock __P((struct inode *, struct buf *, int)); -void softdep_load_inodeblock __P((struct inode *)); -void softdep_freefile __P((void *)); -void softdep_setup_freeblocks __P((struct inode *, off_t, int)); -void softdep_setup_inomapdep __P((struct buf *, struct inode *, ino_t)); -void softdep_setup_blkmapdep __P((struct buf *, struct fs *, daddr_t)); -void softdep_setup_allocdirect __P((struct inode *, daddr_t, daddr_t, - daddr_t, long, long, struct buf *)); -void softdep_setup_allocindir_meta __P((struct buf *, struct inode *, - struct buf *, int, daddr_t)); -void softdep_setup_allocindir_page __P((struct inode *, daddr_t, - struct buf *, int, daddr_t, daddr_t, struct buf *)); -void softdep_fsync_mountdev __P((struct vnode *)); -int softdep_sync_metadata __P((void *)); - -extern int (**ffs_vnodeop_p) __P((void *)); -extern int (**ffs_specop_p) __P((void *)); -extern int (**ffs_fifoop_p) __P((void *)); - -#endif /* !_UFS_FFS_FFS_EXTERN_H_ */ diff --git a/sys/ufs/ffs/ffs_tables.c b/sys/ufs/ffs/ffs_tables.c deleted file mode 100644 index a7c222e899c..00000000000 --- a/sys/ufs/ffs/ffs_tables.c +++ /dev/null @@ -1,141 +0,0 @@ -/* $NetBSD: ffs_tables.c,v 1.7 2003/10/27 00:12:42 lukem Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ffs_tables.c 8.1 (Berkeley) 6/11/93 - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__KERNEL_RCSID(0, "$NetBSD: ffs_tables.c,v 1.7 2003/10/27 00:12:42 lukem Exp $"); - -#include - -/* - * Bit patterns for identifying fragments in the block map - * used as ((map & around) == inside) - */ -const int around[9] = { - 0x3, 0x7, 0xf, 0x1f, 0x3f, 0x7f, 0xff, 0x1ff, 0x3ff -}; -const int inside[9] = { - 0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe -}; - -/* - * Given a block map bit pattern, the frag tables tell whether a - * particular size fragment is available. - * - * used as: - * if ((1 << (size - 1)) & fragtbl[fs->fs_frag][map] { - * at least one fragment of the indicated size is available - * } - * - * These tables are used by the scanc instruction on the VAX to - * quickly find an appropriate fragment. - */ -const u_char fragtbl124[256] = { - 0x00, 0x16, 0x16, 0x2a, 0x16, 0x16, 0x26, 0x4e, - 0x16, 0x16, 0x16, 0x3e, 0x2a, 0x3e, 0x4e, 0x8a, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e, - 0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x26, 0x36, 0x36, 0x2e, 0x36, 0x36, 0x26, 0x6e, - 0x36, 0x36, 0x36, 0x3e, 0x2e, 0x3e, 0x6e, 0xae, - 0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e, - 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x16, 0x16, 0x16, 0x3e, 0x16, 0x16, 0x36, 0x5e, - 0x16, 0x16, 0x16, 0x3e, 0x3e, 0x3e, 0x5e, 0x9e, - 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, - 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe, - 0x2a, 0x3e, 0x3e, 0x2a, 0x3e, 0x3e, 0x2e, 0x6e, - 0x3e, 0x3e, 0x3e, 0x3e, 0x2a, 0x3e, 0x6e, 0xaa, - 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, - 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x3e, 0x7e, 0xbe, - 0x4e, 0x5e, 0x5e, 0x6e, 0x5e, 0x5e, 0x6e, 0x4e, - 0x5e, 0x5e, 0x5e, 0x7e, 0x6e, 0x7e, 0x4e, 0xce, - 0x8a, 0x9e, 0x9e, 0xaa, 0x9e, 0x9e, 0xae, 0xce, - 0x9e, 0x9e, 0x9e, 0xbe, 0xaa, 0xbe, 0xce, 0x8a, -}; - -const u_char fragtbl8[256] = { - 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x04, - 0x01, 0x01, 0x01, 0x03, 0x02, 0x03, 0x04, 0x08, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x02, 0x03, 0x03, 0x02, 0x04, 0x05, 0x08, 0x10, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, - 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, - 0x04, 0x05, 0x05, 0x06, 0x08, 0x09, 0x10, 0x20, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11, - 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, - 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a, - 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04, - 0x08, 0x09, 0x09, 0x0a, 0x10, 0x11, 0x20, 0x40, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x03, 0x03, 0x03, 0x03, 0x05, 0x05, 0x09, 0x11, - 0x01, 0x01, 0x01, 0x03, 0x01, 0x01, 0x03, 0x05, - 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x05, 0x09, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, - 0x05, 0x05, 0x05, 0x07, 0x09, 0x09, 0x11, 0x21, - 0x02, 0x03, 0x03, 0x02, 0x03, 0x03, 0x02, 0x06, - 0x03, 0x03, 0x03, 0x03, 0x02, 0x03, 0x06, 0x0a, - 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x07, - 0x02, 0x03, 0x03, 0x02, 0x06, 0x07, 0x0a, 0x12, - 0x04, 0x05, 0x05, 0x06, 0x05, 0x05, 0x06, 0x04, - 0x05, 0x05, 0x05, 0x07, 0x06, 0x07, 0x04, 0x0c, - 0x08, 0x09, 0x09, 0x0a, 0x09, 0x09, 0x0a, 0x0c, - 0x10, 0x11, 0x11, 0x12, 0x20, 0x21, 0x40, 0x80, -}; - -/* - * The actual fragtbl array. - */ -const u_char * const fragtbl[MAXFRAG + 1] = { - 0, fragtbl124, fragtbl124, 0, fragtbl124, 0, 0, 0, fragtbl8, -}; diff --git a/sys/ufs/ffs/fs.h b/sys/ufs/ffs/fs.h deleted file mode 100644 index 45aa7ae7b56..00000000000 --- a/sys/ufs/ffs/fs.h +++ /dev/null @@ -1,728 +0,0 @@ -/* $NetBSD: fs.h,v 1.44 2004/05/25 14:54:59 hannken Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)fs.h 8.13 (Berkeley) 3/21/95 - */ - -#ifndef _UFS_FFS_FS_H_ -#define _UFS_FFS_FS_H_ - -/* - * Each disk drive contains some number of file systems. - * A file system consists of a number of cylinder groups. - * Each cylinder group has inodes and data. - * - * A file system is described by its super-block, which in turn - * describes the cylinder groups. The super-block is critical - * data and is replicated in each cylinder group to protect against - * catastrophic loss. This is done at `newfs' time and the critical - * super-block data does not change, so the copies need not be - * referenced further unless disaster strikes. - * - * For file system fs, the offsets of the various blocks of interest - * are given in the super block as: - * [fs->fs_sblkno] Super-block - * [fs->fs_cblkno] Cylinder group block - * [fs->fs_iblkno] Inode blocks - * [fs->fs_dblkno] Data blocks - * The beginning of cylinder group cg in fs, is given by - * the ``cgbase(fs, cg)'' macro. - * - * Depending on the architecture and the media, the superblock may - * reside in any one of four places. For tiny media where every block - * counts, it is placed at the very front of the partition. Historically, - * UFS1 placed it 8K from the front to leave room for the disk label and - * a small bootstrap. For UFS2 it got moved to 64K from the front to leave - * room for the disk label and a bigger bootstrap, and for really piggy - * systems we check at 256K from the front if the first three fail. In - * all cases the size of the superblock will be SBLOCKSIZE. All values are - * given in byte-offset form, so they do not imply a sector size. The - * SBLOCKSEARCH specifies the order in which the locations should be searched. - * - * Unfortunately the UFS2/FFSv2 change was done without adequate consideration - * of backward compatibility. In particular 'newfs' for a FFSv2 partition - * must overwrite any old FFSv1 superblock at 8k, and preferrably as many - * of the alternates as it can find - otherwise attempting to mount on a - * system that only supports FFSv1 is likely to succeed!. - * For a small FFSv1 filesystem, an old FFSv2 superblock can be left on - * the disk, and a system that tries to find an FFSv2 filesystem in preference - * to and FFSv1 one (as NetBSD does) can mount the old FFSv2 filesystem. - * As a added bonus, the 'first alternate' superblock of a FFSv1 filesystem - * with 64k blocks is at 64k - just where the code looks first when playing - * 'hunt the superblock'. - * - * The ffsv2 superblock layout (which might contain an ffsv1 filesystem) - * can be detected by checking for sb->fs_old_flags & FS_FLAGS_UPDATED. - * This is the default suberblock type for NetBSD since ffsv2 support was added. - */ -#define BBSIZE 8192 -#define BBOFF ((off_t)(0)) -#define BBLOCK ((daddr_t)(0)) - -#define SBLOCK_FLOPPY 0 -#define SBLOCK_UFS1 8192 -#define SBLOCK_UFS2 65536 -#define SBLOCK_PIGGY 262144 -#define SBLOCKSIZE 8192 -/* - * NB: Do not, under any circumstances, look for an ffsv1 filesystem at - * SBLOCK_UFS2. Doing so will find the wrong superblock for filesystems - * with a 64k block size. - */ -#define SBLOCKSEARCH \ - { SBLOCK_UFS2, SBLOCK_UFS1, SBLOCK_FLOPPY, SBLOCK_PIGGY, -1 } - -/* - * Max number of fragments per block. This value is NOT tweakable. - */ -#define MAXFRAG 8 - - - -/* - * Addresses stored in inodes are capable of addressing fragments - * of `blocks'. File system blocks of at most size MAXBSIZE can - * be optionally broken into 2, 4, or 8 pieces, each of which is - * addressable; these pieces may be DEV_BSIZE, or some multiple of - * a DEV_BSIZE unit. - * - * Large files consist of exclusively large data blocks. To avoid - * undue wasted disk space, the last data block of a small file may be - * allocated as only as many fragments of a large block as are - * necessary. The file system format retains only a single pointer - * to such a fragment, which is a piece of a single large block that - * has been divided. The size of such a fragment is determinable from - * information in the inode, using the ``blksize(fs, ip, lbn)'' macro. - * - * The file system records space availability at the fragment level; - * to determine block availability, aligned fragments are examined. - */ - -/* - * MINBSIZE is the smallest allowable block size. - * In order to insure that it is possible to create files of size - * 2^32 with only two levels of indirection, MINBSIZE is set to 4096. - * MINBSIZE must be big enough to hold a cylinder group block, - * thus changes to (struct cg) must keep its size within MINBSIZE. - * Note that super blocks are always of size SBSIZE, - * and that both SBSIZE and MAXBSIZE must be >= MINBSIZE. - */ -#define MINBSIZE 4096 - -/* - * The path name on which the file system is mounted is maintained - * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in - * the super block for this name. - */ -#define MAXMNTLEN 468 - -/* - * The volume name for this filesystem is maintained in fs_volname. - * MAXVOLLEN defines the length of the buffer allocated. - * This space used to be part of of fs_fsmnt. - */ -#define MAXVOLLEN 32 - -/* - * There is a 128-byte region in the superblock reserved for in-core - * pointers to summary information. Originally this included an array - * of pointers to blocks of struct csum; now there are just four - * pointers and the remaining space is padded with fs_ocsp[]. - * NOCSPTRS determines the size of this padding. One pointer (fs_csp) - * is taken away to point to a contiguous array of struct csum for - * all cylinder groups; a second (fs_maxcluster) points to an array - * of cluster sizes that is computed as cylinder groups are inspected; - * the third (fs_contigdirs) points to an array that tracks the - * creation of new directories; and the fourth (fs_active) is used - * by snapshots. - */ -#define NOCSPTRS ((128 / sizeof(void *)) - 4) - -/* - * A summary of contiguous blocks of various sizes is maintained - * in each cylinder group. Normally this is set by the initial - * value of fs_maxcontig. To conserve space, a maximum summary size - * is set by FS_MAXCONTIG. - */ -#define FS_MAXCONTIG 16 - -/* - * The maximum number of snapshot nodes that can be associated - * with each filesystem. This limit affects only the number of - * snapshot files that can be recorded within the superblock so - * that they can be found when the filesystem is mounted. However, - * maintaining too many will slow the filesystem performance, so - * having this limit is a good idea. - */ -#define FSMAXSNAP 20 - -/* - * Used to identify special blocks in snapshots: - * - * BLK_NOCOPY - A block that was unallocated at the time the snapshot - * was taken, hence does not need to be copied when written. - * BLK_SNAP - A block held by another snapshot that is not needed by this - * snapshot. When the other snapshot is freed, the BLK_SNAP entries - * are converted to BLK_NOCOPY. These are needed to allow fsck to - * identify blocks that are in use by other snapshots (which are - * expunged from this snapshot). - */ -#define BLK_NOCOPY ((daddr_t)(1)) -#define BLK_SNAP ((daddr_t)(2)) - -/* - * MINFREE gives the minimum acceptable percentage of file system - * blocks which may be free. If the freelist drops below this level - * only the superuser may continue to allocate blocks. This may - * be set to 0 if no reserve of free blocks is deemed necessary, - * however throughput drops by fifty percent if the file system - * is run at between 95% and 100% full; thus the minimum default - * value of fs_minfree is 5%. However, to get good clustering - * performance, 10% is a better choice. hence we use 10% as our - * default value. With 10% free space, fragmentation is not a - * problem, so we choose to optimize for time. - */ -#define MINFREE 5 -#define DEFAULTOPT FS_OPTTIME - -/* - * Grigoriy Orlov has done some extensive work to fine - * tune the layout preferences for directories within a filesystem. - * His algorithm can be tuned by adjusting the following parameters - * which tell the system the average file size and the average number - * of files per directory. These defaults are well selected for typical - * filesystems, but may need to be tuned for odd cases like filesystems - * being used for squid caches or news spools. - */ -#define AVFILESIZ 16384 /* expected average file size */ -#define AFPDIR 64 /* expected number of files per directory */ - -/* - * Per cylinder group information; summarized in blocks allocated - * from first cylinder group data blocks. These blocks have to be - * read in from fs_csaddr (size fs_cssize) in addition to the - * super block. - */ -struct csum { - int32_t cs_ndir; /* number of directories */ - int32_t cs_nbfree; /* number of free blocks */ - int32_t cs_nifree; /* number of free inodes */ - int32_t cs_nffree; /* number of free frags */ -}; - -struct csum_total { - int64_t cs_ndir; /* number of directories */ - int64_t cs_nbfree; /* number of free blocks */ - int64_t cs_nifree; /* number of free inodes */ - int64_t cs_nffree; /* number of free frags */ - int64_t cs_spare[4]; /* future expansion */ -}; - - -/* - * Super block for an FFS file system in memory. - */ -struct fs { - int32_t fs_firstfield; /* historic file system linked list, */ - int32_t fs_unused_1; /* used for incore super blocks */ - int32_t fs_sblkno; /* addr of super-block in filesys */ - int32_t fs_cblkno; /* offset of cyl-block in filesys */ - int32_t fs_iblkno; /* offset of inode-blocks in filesys */ - int32_t fs_dblkno; /* offset of first data after cg */ - int32_t fs_old_cgoffset; /* cylinder group offset in cylinder */ - int32_t fs_old_cgmask; /* used to calc mod fs_ntrak */ - int32_t fs_old_time; /* last time written */ - int32_t fs_old_size; /* number of blocks in fs */ - int32_t fs_old_dsize; /* number of data blocks in fs */ - int32_t fs_ncg; /* number of cylinder groups */ - int32_t fs_bsize; /* size of basic blocks in fs */ - int32_t fs_fsize; /* size of frag blocks in fs */ - int32_t fs_frag; /* number of frags in a block in fs */ -/* these are configuration parameters */ - int32_t fs_minfree; /* minimum percentage of free blocks */ - int32_t fs_old_rotdelay; /* num of ms for optimal next block */ - int32_t fs_old_rps; /* disk revolutions per second */ -/* these fields can be computed from the others */ - int32_t fs_bmask; /* ``blkoff'' calc of blk offsets */ - int32_t fs_fmask; /* ``fragoff'' calc of frag offsets */ - int32_t fs_bshift; /* ``lblkno'' calc of logical blkno */ - int32_t fs_fshift; /* ``numfrags'' calc number of frags */ -/* these are configuration parameters */ - int32_t fs_maxcontig; /* max number of contiguous blks */ - int32_t fs_maxbpg; /* max number of blks per cyl group */ -/* these fields can be computed from the others */ - int32_t fs_fragshift; /* block to frag shift */ - int32_t fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */ - int32_t fs_sbsize; /* actual size of super block */ - int32_t fs_spare1[2]; /* old fs_csmask */ - /* old fs_csshift */ - int32_t fs_nindir; /* value of NINDIR */ - int32_t fs_inopb; /* value of INOPB */ - int32_t fs_old_nspf; /* value of NSPF */ -/* yet another configuration parameter */ - int32_t fs_optim; /* optimization preference, see below */ -/* these fields are derived from the hardware */ - int32_t fs_old_npsect; /* # sectors/track including spares */ - int32_t fs_old_interleave; /* hardware sector interleave */ - int32_t fs_old_trackskew; /* sector 0 skew, per track */ -/* fs_id takes the space of the unused fs_headswitch and fs_trkseek fields */ - int32_t fs_id[2]; /* unique file system id */ -/* sizes determined by number of cylinder groups and their sizes */ - int32_t fs_old_csaddr; /* blk addr of cyl grp summary area */ - int32_t fs_cssize; /* size of cyl grp summary area */ - int32_t fs_cgsize; /* cylinder group size */ -/* these fields are derived from the hardware */ - int32_t fs_spare2; /* old fs_ntrak */ - int32_t fs_old_nsect; /* sectors per track */ - int32_t fs_old_spc; /* sectors per cylinder */ - int32_t fs_old_ncyl; /* cylinders in file system */ - int32_t fs_old_cpg; /* cylinders per group */ - int32_t fs_ipg; /* inodes per group */ - int32_t fs_fpg; /* blocks per group * fs_frag */ -/* this data must be re-computed after crashes */ - struct csum fs_old_cstotal; /* cylinder summary information */ -/* these fields are cleared at mount time */ - int8_t fs_fmod; /* super block modified flag */ - int8_t fs_clean; /* file system is clean flag */ - int8_t fs_ronly; /* mounted read-only flag */ - uint8_t fs_old_flags; /* see FS_ flags below */ - u_char fs_fsmnt[MAXMNTLEN]; /* name mounted on */ - u_char fs_volname[MAXVOLLEN]; /* volume name */ - uint64_t fs_swuid; /* system-wide uid */ - int32_t fs_pad; -/* these fields retain the current block allocation info */ - int32_t fs_cgrotor; /* last cg searched (UNUSED) */ - void *fs_ocsp[NOCSPTRS]; /* padding; was list of fs_cs buffers */ - u_int8_t *fs_contigdirs; /* # of contiguously allocated dirs */ - struct csum *fs_csp; /* cg summary info buffer for fs_cs */ - int32_t *fs_maxcluster; /* max cluster in each cyl group */ - u_char *fs_active; /* used by snapshots to track fs */ - int32_t fs_old_cpc; /* cyl per cycle in postbl */ -/* this area is otherwise allocated unless fs_old_flags & FS_FLAGS_UPDATED */ - int32_t fs_maxbsize; /* maximum blocking factor permitted */ - int64_t fs_sparecon64[17]; /* old rotation block list head */ - int64_t fs_sblockloc; /* byte offset of standard superblock */ - struct csum_total fs_cstotal; /* cylinder summary information */ - int64_t fs_time; /* last time written */ - int64_t fs_size; /* number of blocks in fs */ - int64_t fs_dsize; /* number of data blocks in fs */ - int64_t fs_csaddr; /* blk addr of cyl grp summary area */ - int64_t fs_pendingblocks; /* blocks in process of being freed */ - int32_t fs_pendinginodes; /* inodes in process of being freed */ - int32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */ -/* back to stuff that has been around a while */ - int32_t fs_avgfilesize; /* expected average file size */ - int32_t fs_avgfpdir; /* expected # of files per directory */ - int32_t fs_save_cgsize; /* save real cg size to use fs_bsize */ - int32_t fs_sparecon32[26]; /* reserved for future constants */ - uint32_t fs_flags; /* see FS_ flags below */ -/* back to stuff that has been around a while (again) */ - int32_t fs_contigsumsize; /* size of cluster summary array */ - int32_t fs_maxsymlinklen; /* max length of an internal symlink */ - int32_t fs_old_inodefmt; /* format of on-disk inodes */ - u_int64_t fs_maxfilesize; /* maximum representable file size */ - int64_t fs_qbmask; /* ~fs_bmask for use with 64-bit size */ - int64_t fs_qfmask; /* ~fs_fmask for use with 64-bit size */ - int32_t fs_state; /* validate fs_clean field (UNUSED) */ - int32_t fs_old_postblformat; /* format of positional layout tables */ - int32_t fs_old_nrpos; /* number of rotational positions */ - int32_t fs_spare5[2]; /* old fs_postbloff */ - /* old fs_rotbloff */ - int32_t fs_magic; /* magic number */ -}; - -#define fs_old_postbloff fs_spare5[0] -#define fs_old_rotbloff fs_spare5[1] -#define fs_old_postbl_start fs_maxbsize -#define fs_old_headswitch fs_id[0] -#define fs_old_trkseek fs_id[1] -#define fs_old_csmask fs_spare1[0] -#define fs_old_csshift fs_spare1[1] - -#define FS_42POSTBLFMT -1 /* 4.2BSD rotational table format */ -#define FS_DYNAMICPOSTBLFMT 1 /* dynamic rotational table format */ - -#define old_fs_postbl(fs_, cylno, opostblsave) \ - ((((fs_)->fs_old_postblformat == FS_42POSTBLFMT) || \ - ((fs_)->fs_old_postbloff == offsetof(struct fs, fs_old_postbl_start))) \ - ? ((int16_t *)(opostblsave) + (cylno) * (fs_)->fs_old_nrpos) \ - : ((int16_t *)((uint8_t *)(fs_) + \ - (fs_)->fs_old_postbloff) + (cylno) * (fs_)->fs_old_nrpos)) -#define old_fs_rotbl(fs) \ - (((fs)->fs_old_postblformat == FS_42POSTBLFMT) \ - ? ((uint8_t *)(&(fs)->fs_magic+1)) \ - : ((uint8_t *)((uint8_t *)(fs) + (fs)->fs_old_rotbloff))) - -/* - * File system identification - */ -#define FS_UFS1_MAGIC 0x011954 /* UFS1 fast file system magic number */ -#define FS_UFS2_MAGIC 0x19540119 /* UFS2 fast file system magic number */ -#define FS_UFS1_MAGIC_SWAPPED 0x54190100 -#define FS_UFS2_MAGIC_SWAPPED 0x19015419 -#define FS_OKAY 0x7c269d38 /* superblock checksum */ -#define FS_42INODEFMT -1 /* 4.2BSD inode format */ -#define FS_44INODEFMT 2 /* 4.4BSD inode format */ - -/* - * File system clean flags - */ -#define FS_ISCLEAN 0x01 -#define FS_WASCLEAN 0x02 - -/* - * Preference for optimization. - */ -#define FS_OPTTIME 0 /* minimize allocation time */ -#define FS_OPTSPACE 1 /* minimize disk fragmentation */ - -/* - * File system flags - */ -#define FS_UNCLEAN 0x01 /* file system not clean at mount (unused) */ -#define FS_DOSOFTDEP 0x02 /* file system using soft dependencies */ -#define FS_NEEDSFSCK 0x04 /* needs sync fsck (FreeBSD compat, unused) */ -#define FS_INDEXDIRS 0x08 /* kernel supports indexed directories */ -#define FS_ACLS 0x10 /* file system has ACLs enabled */ -#define FS_MULTILABEL 0x20 /* file system is MAC multi-label */ -#define FS_FLAGS_UPDATED 0x80 /* flags have been moved to new location */ - -/* - * File system internal flags, also in fs_flags. - * (Pick highest number to avoid conflicts with others) - */ -#define FS_SWAPPED 0x80000000 /* file system is endian swapped */ -#define FS_INTERNAL 0x80000000 /* mask for internal flags */ - -/* - * Macros to access bits in the fs_active array. - */ -#define ACTIVECG_SET(fs, cg) \ - do { \ - if ((fs)->fs_active != NULL) \ - setbit((fs)->fs_active, (cg)); \ - } while (/*CONSTCOND*/ 0) -#define ACTIVECG_CLR(fs, cg) \ - do { \ - if ((fs)->fs_active != NULL) \ - clrbit((fs)->fs_active, (cg)); \ - } while (/*CONSTCOND*/ 0) -#define ACTIVECG_ISSET(fs, cg) \ - ((fs)->fs_active != NULL && isset((fs)->fs_active, (cg))) - -/* - * The size of a cylinder group is calculated by CGSIZE. The maximum size - * is limited by the fact that cylinder groups are at most one block. - * Its size is derived from the size of the maps maintained in the - * cylinder group and the (struct cg) size. - */ -#define CGSIZE_IF(fs, ipg, fpg) \ - /* base cg */ (sizeof(struct cg) + sizeof(int32_t) + \ - /* old btotoff */ (fs)->fs_old_cpg * sizeof(int32_t) + \ - /* old boff */ (fs)->fs_old_cpg * sizeof(u_int16_t) + \ - /* inode map */ howmany((ipg), NBBY) + \ - /* block map */ howmany((fpg), NBBY) +\ - /* if present */ ((fs)->fs_contigsumsize <= 0 ? 0 : \ - /* cluster sum */ (fs)->fs_contigsumsize * sizeof(int32_t) + \ - /* cluster map */ howmany(fragstoblks(fs, (fpg)), NBBY))) - -#define CGSIZE(fs) CGSIZE_IF((fs), (fs)->fs_ipg, (fs)->fs_fpg) - -/* - * The minimal number of cylinder groups that should be created. - */ -#define MINCYLGRPS 4 - - -/* - * Convert cylinder group to base address of its global summary info. - */ -#define fs_cs(fs, indx) fs_csp[indx] - -/* - * Cylinder group block for a file system. - */ -#define CG_MAGIC 0x090255 -struct cg { - int32_t cg_firstfield; /* historic cyl groups linked list */ - int32_t cg_magic; /* magic number */ - int32_t cg_old_time; /* time last written */ - int32_t cg_cgx; /* we are the cgx'th cylinder group */ - int16_t cg_old_ncyl; /* number of cyl's this cg */ - int16_t cg_old_niblk; /* number of inode blocks this cg */ - int32_t cg_ndblk; /* number of data blocks this cg */ - struct csum cg_cs; /* cylinder summary information */ - int32_t cg_rotor; /* position of last used block */ - int32_t cg_frotor; /* position of last used frag */ - int32_t cg_irotor; /* position of last used inode */ - int32_t cg_frsum[MAXFRAG]; /* counts of available frags */ - int32_t cg_old_btotoff; /* (int32) block totals per cylinder */ - int32_t cg_old_boff; /* (u_int16) free block positions */ - int32_t cg_iusedoff; /* (u_int8) used inode map */ - int32_t cg_freeoff; /* (u_int8) free block map */ - int32_t cg_nextfreeoff; /* (u_int8) next available space */ - int32_t cg_clustersumoff; /* (u_int32) counts of avail clusters */ - int32_t cg_clusteroff; /* (u_int8) free cluster map */ - int32_t cg_nclusterblks; /* number of clusters this cg */ - int32_t cg_niblk; /* number of inode blocks this cg */ - int32_t cg_initediblk; /* last initialized inode */ - int32_t cg_sparecon32[3]; /* reserved for future use */ - int64_t cg_time; /* time last written */ - int64_t cg_sparecon64[3]; /* reserved for future use */ - u_int8_t cg_space[1]; /* space for cylinder group maps */ -/* actually longer */ -}; - -/* - * The following structure is defined - * for compatibility with old file systems. - */ -struct ocg { - int32_t cg_firstfield; /* historic linked list of cyl groups */ - int32_t cg_unused_1; /* used for incore cyl groups */ - int32_t cg_time; /* time last written */ - int32_t cg_cgx; /* we are the cgx'th cylinder group */ - int16_t cg_ncyl; /* number of cyl's this cg */ - int16_t cg_niblk; /* number of inode blocks this cg */ - int32_t cg_ndblk; /* number of data blocks this cg */ - struct csum cg_cs; /* cylinder summary information */ - int32_t cg_rotor; /* position of last used block */ - int32_t cg_frotor; /* position of last used frag */ - int32_t cg_irotor; /* position of last used inode */ - int32_t cg_frsum[8]; /* counts of available frags */ - int32_t cg_btot[32]; /* block totals per cylinder */ - int16_t cg_b[32][8]; /* positions of free blocks */ - u_int8_t cg_iused[256]; /* used inode map */ - int32_t cg_magic; /* magic number */ - u_int8_t cg_free[1]; /* free block map */ -/* actually longer */ -}; - - -/* - * Macros for access to cylinder group array structures. - */ -#define old_cg_blktot_old(cgp, ns) \ - (((struct ocg *)(cgp))->cg_btot) -#define old_cg_blks_old(fs, cgp, cylno, ns) \ - (((struct ocg *)(cgp))->cg_b[cylno]) - -#define old_cg_blktot_new(cgp, ns) \ - ((int32_t *)((u_int8_t *)(cgp) + \ - ufs_rw32((cgp)->cg_old_btotoff, (ns)))) -#define old_cg_blks_new(fs, cgp, cylno, ns) \ - ((int16_t *)((u_int8_t *)(cgp) + \ - ufs_rw32((cgp)->cg_old_boff, (ns))) + (cylno) * (fs)->fs_old_nrpos) - -#define old_cg_blktot(cgp, ns) \ - ((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \ - old_cg_blktot_old(cgp, ns) : old_cg_blktot_new(cgp, ns)) -#define old_cg_blks(fs, cgp, cylno, ns) \ - ((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \ - old_cg_blks_old(fs, cgp, cylno, ns) : old_cg_blks_new(fs, cgp, cylno, ns)) - -#define cg_inosused_new(cgp, ns) \ - ((u_int8_t *)((u_int8_t *)(cgp) + \ - ufs_rw32((cgp)->cg_iusedoff, (ns)))) -#define cg_blksfree_new(cgp, ns) \ - ((u_int8_t *)((u_int8_t *)(cgp) + \ - ufs_rw32((cgp)->cg_freeoff, (ns)))) -#define cg_chkmagic_new(cgp, ns) \ - (ufs_rw32((cgp)->cg_magic, (ns)) == CG_MAGIC) - -#define cg_inosused_old(cgp, ns) \ - (((struct ocg *)(cgp))->cg_iused) -#define cg_blksfree_old(cgp, ns) \ - (((struct ocg *)(cgp))->cg_free) -#define cg_chkmagic_old(cgp, ns) \ - (ufs_rw32(((struct ocg *)(cgp))->cg_magic, (ns)) == CG_MAGIC) - -#define cg_inosused(cgp, ns) \ - ((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \ - cg_inosused_old(cgp, ns) : cg_inosused_new(cgp, ns)) -#define cg_blksfree(cgp, ns) \ - ((ufs_rw32((cgp)->cg_magic, (ns)) != CG_MAGIC) ? \ - cg_blksfree_old(cgp, ns) : cg_blksfree_new(cgp, ns)) -#define cg_chkmagic(cgp, ns) \ - (cg_chkmagic_new(cgp, ns) || cg_chkmagic_old(cgp, ns)) - -#define cg_clustersfree(cgp, ns) \ - ((u_int8_t *)((u_int8_t *)(cgp) + \ - ufs_rw32((cgp)->cg_clusteroff, (ns)))) -#define cg_clustersum(cgp, ns) \ - ((int32_t *)((u_int8_t *)(cgp) + \ - ufs_rw32((cgp)->cg_clustersumoff, (ns)))) - - -/* - * Turn file system block numbers into disk block addresses. - * This maps file system blocks to device size blocks. - */ -#define fsbtodb(fs, b) ((b) << (fs)->fs_fsbtodb) -#define dbtofsb(fs, b) ((b) >> (fs)->fs_fsbtodb) - -/* - * Cylinder group macros to locate things in cylinder groups. - * They calc file system addresses of cylinder group data structures. - */ -#define cgbase(fs, c) (((daddr_t)(fs)->fs_fpg) * (c)) -#define cgstart_ufs1(fs, c) \ - (cgbase(fs, c) + (fs)->fs_old_cgoffset * ((c) & ~((fs)->fs_old_cgmask))) -#define cgstart_ufs2(fs, c) cgbase((fs), (c)) -#define cgstart(fs, c) ((fs)->fs_magic == FS_UFS2_MAGIC \ - ? cgstart_ufs2((fs), (c)) : cgstart_ufs1((fs), (c))) -#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */ -#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */ -#define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */ -#define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */ - -/* - * Macros for handling inode numbers: - * inode number to file system block offset. - * inode number to cylinder group number. - * inode number to file system block address. - */ -#define ino_to_cg(fs, x) ((x) / (fs)->fs_ipg) -#define ino_to_fsba(fs, x) \ - ((daddr_t)(cgimin(fs, ino_to_cg(fs, x)) + \ - (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs)))))) -#define ino_to_fsbo(fs, x) ((x) % INOPB(fs)) - -/* - * Give cylinder group number for a file system block. - * Give cylinder group block number for a file system block. - */ -#define dtog(fs, d) ((d) / (fs)->fs_fpg) -#define dtogd(fs, d) ((d) % (fs)->fs_fpg) - -/* - * Extract the bits for a block from a map. - * Compute the cylinder and rotational position of a cyl block addr. - */ -#define blkmap(fs, map, loc) \ - (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag))) -#define old_cbtocylno(fs, bno) \ - (fsbtodb(fs, bno) / (fs)->fs_old_spc) -#define old_cbtorpos(fs, bno) \ - ((fs)->fs_old_nrpos <= 1 ? 0 : \ - (fsbtodb(fs, bno) % (fs)->fs_old_spc / (fs)->fs_old_nsect * (fs)->fs_old_trackskew + \ - fsbtodb(fs, bno) % (fs)->fs_old_spc % (fs)->fs_old_nsect * (fs)->fs_old_interleave) % \ - (fs)->fs_old_nsect * (fs)->fs_old_nrpos / (fs)->fs_old_npsect) - -/* - * The following macros optimize certain frequently calculated - * quantities by using shifts and masks in place of divisions - * modulos and multiplications. - */ -#define blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \ - ((loc) & (fs)->fs_qbmask) -#define fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \ - ((loc) & (fs)->fs_qfmask) -#define lfragtosize(fs, frag) /* calculates ((off_t)frag * fs->fs_fsize) */ \ - (((off_t)(frag)) << (fs)->fs_fshift) -#define lblktosize(fs, blk) /* calculates ((off_t)blk * fs->fs_bsize) */ \ - (((off_t)(blk)) << (fs)->fs_bshift) -#define lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \ - ((loc) >> (fs)->fs_bshift) -#define numfrags(fs, loc) /* calculates (loc / fs->fs_fsize) */ \ - ((loc) >> (fs)->fs_fshift) -#define blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \ - (((size) + (fs)->fs_qbmask) & (fs)->fs_bmask) -#define fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \ - (((size) + (fs)->fs_qfmask) & (fs)->fs_fmask) -#define fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \ - ((frags) >> (fs)->fs_fragshift) -#define blkstofrags(fs, blks) /* calculates (blks * fs->fs_frag) */ \ - ((blks) << (fs)->fs_fragshift) -#define fragnum(fs, fsb) /* calculates (fsb % fs->fs_frag) */ \ - ((fsb) & ((fs)->fs_frag - 1)) -#define blknum(fs, fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \ - ((fsb) &~ ((fs)->fs_frag - 1)) - -/* - * Determine the number of available frags given a - * percentage to hold in reserve. - */ -#define freespace(fs, percentreserved) \ - (blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \ - (fs)->fs_cstotal.cs_nffree - \ - (((off_t)((fs)->fs_dsize)) * (percentreserved) / 100)) - -/* - * Determining the size of a file block in the file system. - */ -#define blksize(fs, ip, lbn) \ - (((lbn) >= NDADDR || (ip)->i_size >= lblktosize(fs, (lbn) + 1)) \ - ? (fs)->fs_bsize \ - : (fragroundup(fs, blkoff(fs, (ip)->i_size)))) - -#define sblksize(fs, size, lbn) \ - (((lbn) >= NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \ - ? (fs)->fs_bsize \ - : (fragroundup(fs, blkoff(fs, (size))))) - - -/* - * Number of inodes in a secondary storage block/fragment. - */ -#define INOPB(fs) ((fs)->fs_inopb) -#define INOPF(fs) ((fs)->fs_inopb >> (fs)->fs_fragshift) - -/* - * Number of indirects in a file system block. - */ -#define NINDIR(fs) ((fs)->fs_nindir) - -/* - * Apple UFS Label: - * We check for this to decide to use APPLEUFS_DIRBLKSIZ - */ -#define APPLEUFS_LABEL_MAGIC 0x4c41424c /* LABL */ -#define APPLEUFS_LABEL_SIZE 1024 -#define APPLEUFS_LABEL_OFFSET (BBSIZE - APPLEUFS_LABEL_SIZE) /* located at 7k */ -#define APPLEUFS_LABEL_VERSION 1 -#define APPLEUFS_MAX_LABEL_NAME 512 - -struct appleufslabel { - u_int32_t ul_magic; - u_int16_t ul_checksum; - u_int16_t ul_unused0; - u_int32_t ul_version; - u_int32_t ul_time; - u_int16_t ul_namelen; - u_char ul_name[APPLEUFS_MAX_LABEL_NAME]; /* Warning: may not be null terminated */ - u_int16_t ul_unused1; - u_int64_t ul_uuid; /* Note this is only 4 byte aligned */ - u_char ul_reserved[24]; - u_char ul_unused[460]; -} __attribute__((__packed__)); - - -#endif /* !_UFS_FFS_FS_H_ */ diff --git a/sys/ufs/ufs/dinode.h b/sys/ufs/ufs/dinode.h deleted file mode 100644 index 10e62f125dc..00000000000 --- a/sys/ufs/ufs/dinode.h +++ /dev/null @@ -1,175 +0,0 @@ -/* $NetBSD: dinode.h,v 1.18 2003/08/07 16:34:42 agc Exp $ */ - -/* - * Copyright (c) 2002 Networks Associates Technology, Inc. - * All rights reserved. - * - * This software was developed for the FreeBSD Project by Marshall - * Kirk McKusick and Network Associates Laboratories, the Security - * Research Division of Network Associates, Inc. under DARPA/SPAWAR - * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS - * research program - * - * Copyright (c) 1982, 1989, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)dinode.h 8.9 (Berkeley) 3/29/95 - */ - -#ifndef _UFS_UFS_DINODE_H_ -#define _UFS_UFS_DINODE_H_ - -/* - * The root inode is the root of the file system. Inode 0 can't be used for - * normal purposes and historically bad blocks were linked to inode 1, thus - * the root inode is 2. (Inode 1 is no longer used for this purpose, however - * numerous dump tapes make this assumption, so we are stuck with it). - */ -#define ROOTINO ((ino_t)2) - -/* - * The Whiteout inode# is a dummy non-zero inode number which will - * never be allocated to a real file. It is used as a place holder - * in the directory entry which has been tagged as a DT_W entry. - * See the comments about ROOTINO above. - */ -#define WINO ((ino_t)1) - -/* - * A dinode contains all the meta-data associated with a UFS file. - * This structure defines the on-disk format of a dinode. Since - * this structure describes an on-disk structure, all its fields - * are defined by types with precise widths. - */ - -#define NXADDR 2 -#define NDADDR 12 /* Direct addresses in inode. */ -#define NIADDR 3 /* Indirect addresses in inode. */ - -struct ufs1_dinode { - u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ - int16_t di_nlink; /* 2: File link count. */ - union { - u_int16_t oldids[2]; /* 4: Ffs: old user and group ids. */ - u_int32_t inumber; /* 4: Lfs: inode number. */ - } di_u; - u_int64_t di_size; /* 8: File byte count. */ - int32_t di_atime; /* 16: Last access time. */ - int32_t di_atimensec; /* 20: Last access time. */ - int32_t di_mtime; /* 24: Last modified time. */ - int32_t di_mtimensec; /* 28: Last modified time. */ - int32_t di_ctime; /* 32: Last inode change time. */ - int32_t di_ctimensec; /* 36: Last inode change time. */ - int32_t di_db[NDADDR]; /* 40: Direct disk blocks. */ - int32_t di_ib[NIADDR]; /* 88: Indirect disk blocks. */ - u_int32_t di_flags; /* 100: Status flags (chflags). */ - u_int32_t di_blocks; /* 104: Blocks actually held. */ - int32_t di_gen; /* 108: Generation number. */ - u_int32_t di_uid; /* 112: File owner. */ - u_int32_t di_gid; /* 116: File group. */ - int32_t di_spare[2]; /* 120: Reserved; currently unused */ -}; - -struct ufs2_dinode { - u_int16_t di_mode; /* 0: IFMT, permissions; see below. */ - int16_t di_nlink; /* 2: File link count. */ - u_int32_t di_uid; /* 4: File owner. */ - u_int32_t di_gid; /* 8: File group. */ - u_int32_t di_blksize; /* 12: Inode blocksize. */ - u_int64_t di_size; /* 16: File byte count. */ - u_int64_t di_blocks; /* 24: Bytes actually held. */ - int64_t di_atime; /* 32: Last access time. */ - int64_t di_mtime; /* 40: Last modified time. */ - int64_t di_ctime; /* 48: Last inode change time. */ - int64_t di_birthtime; /* 56: Inode creation time. */ - int32_t di_mtimensec; /* 64: Last modified time. */ - int32_t di_atimensec; /* 68: Last access time. */ - int32_t di_ctimensec; /* 72: Last inode change time. */ - int32_t di_birthnsec; /* 76: Inode creation time. */ - int32_t di_gen; /* 80: Generation number. */ - u_int32_t di_kernflags; /* 84: Kernel flags. */ - u_int32_t di_flags; /* 88: Status flags (chflags). */ - int32_t di_extsize; /* 92: External attributes block. */ - int64_t di_extb[NXADDR];/* 96: External attributes block. */ - int64_t di_db[NDADDR]; /* 112: Direct disk blocks. */ - int64_t di_ib[NIADDR]; /* 208: Indirect disk blocks. */ - int64_t di_spare[3]; /* 232: Reserved; currently unused */ -}; - -/* - * The di_db fields may be overlaid with other information for - * file types that do not have associated disk storage. Block - * and character devices overlay the first data block with their - * dev_t value. Short symbolic links place their path in the - * di_db area. - */ -#define di_inumber di_u.inumber -#define di_ogid di_u.oldids[1] -#define di_ouid di_u.oldids[0] -#define di_rdev di_db[0] -#define MAXSYMLINKLEN_UFS1 ((NDADDR + NIADDR) * sizeof(int32_t)) -#define MAXSYMLINKLEN_UFS2 ((NDADDR + NIADDR) * sizeof(int64_t)) - -#define MAXSYMLINKLEN(ip) \ - ((ip)->i_ump->um_fstype == UFS1) ? \ - MAXSYMLINKLEN_UFS1 : MAXSYMLINKLEN_UFS2 - -/* NeXT used to keep short symlinks in the inode even when using - * FS_42INODEFMT. In that case fs->fs_maxsymlinklen is probably -1, - * but short symlinks were stored in inodes shorter than this: - */ -#define APPLEUFS_MAXSYMLINKLEN 60 - -/* File permissions. */ -#define IEXEC 0000100 /* Executable. */ -#define IWRITE 0000200 /* Writable. */ -#define IREAD 0000400 /* Readable. */ -#define ISVTX 0001000 /* Sticky bit. */ -#define ISGID 0002000 /* Set-gid. */ -#define ISUID 0004000 /* Set-uid. */ - -/* File types. */ -#define IFMT 0170000 /* Mask of file type. */ -#define IFIFO 0010000 /* Named pipe (fifo). */ -#define IFCHR 0020000 /* Character device. */ -#define IFDIR 0040000 /* Directory file. */ -#define IFBLK 0060000 /* Block device. */ -#define IFREG 0100000 /* Regular file. */ -#define IFLNK 0120000 /* Symbolic link. */ -#define IFSOCK 0140000 /* UNIX domain socket. */ -#define IFWHT 0160000 /* Whiteout. */ - -/* Size of the on-disk inode. */ -#define DINODE1_SIZE (sizeof(struct ufs1_dinode)) /* 128 */ -#define DINODE2_SIZE (sizeof(struct ufs2_dinode)) - -#endif /* !_UFS_UFS_DINODE_H_ */ diff --git a/sys/ufs/ufs/dir.h b/sys/ufs/ufs/dir.h deleted file mode 100644 index 1aed962a1c5..00000000000 --- a/sys/ufs/ufs/dir.h +++ /dev/null @@ -1,160 +0,0 @@ -/* $NetBSD: dir.h,v 1.17 2003/08/07 16:34:42 agc Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1989, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)dir.h 8.5 (Berkeley) 4/27/95 - */ - -#ifndef _UFS_UFS_DIR_H_ -#define _UFS_UFS_DIR_H_ - -/* - * Theoretically, directories can be more than 2Gb in length, however, in - * practice this seems unlikely. So, we define the type doff_t as a 32-bit - * quantity to keep down the cost of doing lookup on a 32-bit machine. - */ -#define doff_t int32_t -#define MAXDIRSIZE (0x7fffffff) - -/* - * A directory consists of some number of blocks of DIRBLKSIZ - * bytes, where DIRBLKSIZ is chosen such that it can be transferred - * to disk in a single atomic operation (e.g. 512 bytes on most machines). - * - * Each DIRBLKSIZ byte block contains some number of directory entry - * structures, which are of variable length. Each directory entry has - * a struct direct at the front of it, containing its inode number, - * the length of the entry, and the length of the name contained in - * the entry. These are followed by the name padded to a 4 byte boundary. - * All names are guaranteed null terminated. - * The maximum length of a name in a directory is MAXNAMLEN. - * - * The macro DIRSIZ(fmt, dp) gives the amount of space required to represent - * a directory entry. Free space in a directory is represented by - * entries which have dp->d_reclen > DIRSIZ(fmt, dp). All DIRBLKSIZ bytes - * in a directory block are claimed by the directory entries. This - * usually results in the last entry in a directory having a large - * dp->d_reclen. When entries are deleted from a directory, the - * space is returned to the previous entry in the same directory - * block by increasing its dp->d_reclen. If the first entry of - * a directory block is free, then its dp->d_ino is set to 0. - * Entries other than the first in a directory do not normally have - * dp->d_ino set to 0. - */ -#undef DIRBLKSIZ -#define DIRBLKSIZ DEV_BSIZE -#undef MAXNAMLEN -#define MAXNAMLEN 255 -#define APPLEUFS_DIRBLKSIZ 1024 - -struct direct { - u_int32_t d_ino; /* inode number of entry */ - u_int16_t d_reclen; /* length of this record */ - u_int8_t d_type; /* file type, see below */ - u_int8_t d_namlen; /* length of string in d_name */ - char d_name[MAXNAMLEN + 1];/* name with length <= MAXNAMLEN */ -}; - -/* - * File types - */ -#define DT_UNKNOWN 0 -#define DT_FIFO 1 -#define DT_CHR 2 -#define DT_DIR 4 -#define DT_BLK 6 -#define DT_REG 8 -#define DT_LNK 10 -#define DT_SOCK 12 -#define DT_WHT 14 - -/* - * Convert between stat structure types and directory types. - */ -#define IFTODT(mode) (((mode) & 0170000) >> 12) -#define DTTOIF(dirtype) ((dirtype) << 12) - -/* - * The DIRSIZ macro gives the minimum record length which will hold - * the directory entry. This requires the amount of space in struct direct - * without the d_name field, plus enough space for the name with a terminating - * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary. - */ -#define DIRECTSIZ(namlen) \ - ((sizeof(struct direct) - (MAXNAMLEN+1)) + (((namlen)+1 + 3) &~ 3)) - -#if (BYTE_ORDER == LITTLE_ENDIAN) -#define DIRSIZ(oldfmt, dp, needswap) \ - (((oldfmt) && !(needswap)) ? \ - DIRECTSIZ((dp)->d_type) : DIRECTSIZ((dp)->d_namlen)) -#else -#define DIRSIZ(oldfmt, dp, needswap) \ - (((oldfmt) && (needswap)) ? \ - DIRECTSIZ((dp)->d_type) : DIRECTSIZ((dp)->d_namlen)) -#endif - -#define OLDDIRFMT 1 -#define NEWDIRFMT 0 - -/* - * Template for manipulating directories. Should use struct direct's, - * but the name field is MAXNAMLEN - 1, and this just won't do. - */ -struct dirtemplate { - u_int32_t dot_ino; - int16_t dot_reclen; - u_int8_t dot_type; - u_int8_t dot_namlen; - char dot_name[4]; /* must be multiple of 4 */ - u_int32_t dotdot_ino; - int16_t dotdot_reclen; - u_int8_t dotdot_type; - u_int8_t dotdot_namlen; - char dotdot_name[4]; /* ditto */ -}; - -/* - * This is the old format of directories, sanz type element. - */ -struct odirtemplate { - u_int32_t dot_ino; - int16_t dot_reclen; - u_int16_t dot_namlen; - char dot_name[4]; /* must be multiple of 4 */ - u_int32_t dotdot_ino; - int16_t dotdot_reclen; - u_int16_t dotdot_namlen; - char dotdot_name[4]; /* ditto */ -}; -#endif /* !_UFS_UFS_DIR_H_ */ diff --git a/walk.c b/walk.c index 8529df63ad7..f2dc159f835 100644 --- a/walk.c +++ b/walk.c @@ -71,10 +71,6 @@ * SUCH DAMAGE. */ -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - #include #if defined(__RCSID) && !defined(__lint) __RCSID("$NetBSD: walk.c,v 1.17 2004/06/20 22:20:18 jmc Exp $"); -- 2.45.0