Browse Source

Remove ufs code

Signed-off-by: Graham MacDonald <grahamamacdonald@gmail.com>
Graham MacDonald 6 months ago
parent
commit
8cd891d431
57 changed files with 0 additions and 42083 deletions
  1. 0 149
      sys/include/ufs/dinode.h
  2. 0 129
      sys/include/ufs/dir.h
  3. 0 114
      sys/include/ufs/freebsd_util.h
  4. 0 748
      sys/include/ufs/fs.h
  5. 0 175
      sys/include/ufs/inode.h
  6. 0 117
      sys/include/ufs/libufs.h
  7. 0 79
      sys/include/ufs/libufsdat.h
  8. 0 247
      sys/include/ufs/quota.h
  9. 0 124
      sys/include/ufs/ufsmount.h
  10. 0 79
      sys/src/9/ufs/README.acls
  11. 0 91
      sys/src/9/ufs/README.extattr
  12. 0 42
      sys/src/9/ufs/acl.h
  13. 0 126
      sys/src/9/ufs/dirhash.h
  14. 0 134
      sys/src/9/ufs/extattr.h
  15. 0 3194
      sys/src/9/ufs/ffs_alloc.c
  16. 0 678
      sys/src/9/ufs/ffs_balloc.c
  17. 0 189
      sys/src/9/ufs/ffs_extern.h
  18. 0 762
      sys/src/9/ufs/ffs_inode.c
  19. 0 450
      sys/src/9/ufs/ffs_rawread.c
  20. 0 2647
      sys/src/9/ufs/ffs_snapshot.c
  21. 0 14045
      sys/src/9/ufs/ffs_softdep.c
  22. 0 96
      sys/src/9/ufs/ffs_subr.c
  23. 0 329
      sys/src/9/ufs/ffs_suspend.c
  24. 0 2136
      sys/src/9/ufs/ffs_vfsops.c
  25. 0 1648
      sys/src/9/ufs/ffs_vnops.c
  26. 0 9
      sys/src/9/ufs/port-scripts/list-spatch-breakers.sh
  27. 0 52
      sys/src/9/ufs/port-scripts/macros.h
  28. 0 4
      sys/src/9/ufs/port-scripts/null.cocci
  29. 0 6
      sys/src/9/ufs/port-scripts/replace-ids-with-harvey-incs.cocci
  30. 0 47
      sys/src/9/ufs/port-scripts/scalar.cocci
  31. 0 47
      sys/src/9/ufs/port-scripts/strip-includes.cocci
  32. 0 1105
      sys/src/9/ufs/softdep.h
  33. 0 37
      sys/src/9/ufs/ufs.json
  34. 0 663
      sys/src/9/ufs/ufs_acl.c
  35. 0 357
      sys/src/9/ufs/ufs_bmap.c
  36. 0 1295
      sys/src/9/ufs/ufs_dirhash.c
  37. 0 1280
      sys/src/9/ufs/ufs_extattr.c
  38. 0 118
      sys/src/9/ufs/ufs_extern.h
  39. 0 343
      sys/src/9/ufs/ufs_harvey_external.c
  40. 0 158
      sys/src/9/ufs/ufs_harvey_internal.c
  41. 0 258
      sys/src/9/ufs/ufs_harvey_vnode.c
  42. 0 241
      sys/src/9/ufs/ufs_inode.c
  43. 0 1414
      sys/src/9/ufs/ufs_lookup.c
  44. 0 1837
      sys/src/9/ufs/ufs_quota.c
  45. 0 235
      sys/src/9/ufs/ufs_vfsops.c
  46. 0 2643
      sys/src/9/ufs/ufs_vnops.c
  47. 0 187
      sys/src/9/ufs/ufsdat.h
  48. 0 52
      sys/src/9/ufs/ufsfns.h
  49. 0 183
      sys/src/libufs/block.c
  50. 0 210
      sys/src/libufs/cgroup.c
  51. 0 137
      sys/src/libufs/ffs_tables.c
  52. 0 95
      sys/src/libufs/inode.c
  53. 0 14
      sys/src/libufs/klibufs.json
  54. 0 19
      sys/src/libufs/libufs.json
  55. 0 264
      sys/src/libufs/libufs_subr.c
  56. 0 152
      sys/src/libufs/sblock.c
  57. 0 93
      sys/src/libufs/type.c

+ 0 - 149
sys/include/ufs/dinode.h

@@ -1,149 +0,0 @@
-/*-
- * 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
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * 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. The names of the authors may not be used to endorse or promote
- *    products derived from this software without specific prior written
- *    permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.3 (Berkeley) 1/21/94
- * $FreeBSD$
- */
-
-/*
- * The root inode is the root of the filesystem.  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	UFS_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_WHT entry.
- * See the comments about UFS_ROOTINO above.
- */
-#define	UFS_WINO	((ino_t)1)
-
-/* File permissions. */
-#define	IEXEC		0000100		/* Executable. */
-#define	IWRITE		0000200		/* Writeable. */
-#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. */
-
-/*
- * A dinode contains all the meta-data associated with a UFS2 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	UFS_NXADDR	2		/* External addresses in inode. */
-#define	UFS_NDADDR	12		/* Direct addresses in inode. */
-#define	UFS_NIADDR	3		/* Indirect addresses in inode. */
-
-typedef struct ufs2_dinode {
-	uint16_t	di_mode;	/*   0: IFMT, permissions; see below. */
-	int16_t		di_nlink;	/*   2: File link count. */
-	uint32_t	di_uid;		/*   4: File owner. */
-	uint32_t	di_gid;		/*   8: File group. */
-	uint32_t	di_blksize;	/*  12: Inode blocksize. */
-	uint64_t	di_size;	/*  16: File byte count. */
-	uint64_t	di_blocks;	/*  24: Blocks actually held. */
-	ufs_time_t	di_atime;	/*  32: Last access time. */
-	ufs_time_t	di_mtime;	/*  40: Last modified time. */
-	ufs_time_t	di_ctime;	/*  48: Last inode change time. */
-	ufs_time_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. */
-	uint32_t	di_gen;		/*  80: Generation number. */
-	uint32_t	di_kernflags;	/*  84: Kernel flags. */
-	uint32_t	di_flags;	/*  88: Status flags (chflags). */
-	uint32_t	di_extsize;	/*  92: External attributes size. */
-	ufs2_daddr_t	di_extb[UFS_NXADDR];/* 96: External attributes block. */
-	ufs2_daddr_t	di_db[UFS_NDADDR]; /* 112: Direct disk blocks. */
-	ufs2_daddr_t	di_ib[UFS_NIADDR]; /* 208: Indirect disk blocks. */
-	uint64_t	di_modrev;	/* 232: i_modrev for NFSv4 */
-	uint32_t	di_freelink;	/* 240: SUJ: Next unlinked inode. */
-	uint32_t	di_spare[3];	/* 244: Reserved; currently unused */
-} ufs2_dinode;
-
-/*
- * 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_rdev di_db[0]

+ 0 - 129
sys/include/ufs/dir.h

@@ -1,129 +0,0 @@
-/*-
- * 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.2 (Berkeley) 1/21/94
- * $FreeBSD$
- */
-
-/*
- * 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
- * with null bytes.  All names are guaranteed null terminated.
- * The maximum length of a name in a directory is UFS_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.
- */
-#define	DIRBLKSIZ	DEV_BSIZE
-#define	UFS_MAXNAMLEN	255
-
-typedef struct Direct {
-	uint32_t d_ino;		/* inode number of entry */
-	uint16_t d_reclen;		/* length of this record */
-	uint8_t  d_type; 		/* file type, see below */
-	uint8_t  d_namlen;		/* length of string in d_name */
-	char	  d_name[UFS_MAXNAMLEN + 1];
-					/* name with length <= UFS_MAXNAMLEN */
-} Direct;
-
-/*
- * 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)						\
-	((offsetof(Direct, d_name) +				\
-	  ((namlen)+1)*sizeof(((Direct *)0)->d_name[0]) + 3) & ~3)
-#define	DIRSIZ(dp) \
-    DIRECTSIZ((dp)->d_namlen)
-
-/*
- * Template for manipulating directories.  Should use struct direct's,
- * but the name field is UFS_MAXNAMLEN - 1, and this just won't do.
- */
-struct dirtemplate {
-	uint32_t	dot_ino;
-	int16_t		dot_reclen;
-	uint8_t	dot_type;
-	uint8_t	dot_namlen;
-	char		dot_name[4];	/* must be multiple of 4 */
-	uint32_t	dotdot_ino;
-	int16_t		dotdot_reclen;
-	uint8_t	dotdot_type;
-	uint8_t	dotdot_namlen;
-	char		dotdot_name[4];	/* ditto */
-};

+ 0 - 114
sys/include/ufs/freebsd_util.h

@@ -1,114 +0,0 @@
-/*-
- * Copyright (c) 1991, 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.
- *
- *	@(#)queue.h	8.5 (Berkeley) 8/20/94
- * $FreeBSD$
- */
-
-#define	TAILQ_HEAD(name, type)						\
-struct name {								\
-	struct type *tqh_first;	/* first element */			\
-	struct type **tqh_last;	/* addr of last next element */		\
-}
-
-#define	TAILQ_ENTRY(type)						\
-struct {								\
-	struct type *tqe_next;	/* next element */			\
-	struct type **tqe_prev;	/* address of previous next element */	\
-}
-
-#define	LIST_HEAD(name, type)						\
-struct name {								\
-	struct type *lh_first;	/* first element */			\
-}
-
-#define	LIST_ENTRY(type)						\
-struct {								\
-	struct type *le_next;	/* next element */			\
-	struct type **le_prev;	/* address of previous next element */	\
-}
-
-
-typedef	uint32_t uid_t;		/* user id */
-typedef	uint32_t gid_t;		/* group id */
-typedef	uint16_t nlink_t;	/* link count */
-typedef	uint16_t mode_t;	/* permissions */
-
-typedef int64_t intmax_t;	/* FIXME: This should probably be moved to <u.h> or replaced with a spatch */
-
-
-/*
- * User specifiable flags, stored in mnt_flag.
- */
-#define	MNT_RDONLY	0x0000000000000001ULL /* read only filesystem */
-
-/*
- * External filesystem command modifier flags.
- * Unmount can use the MNT_FORCE flag.
- * XXX: These are not STATES and really should be somewhere else.
- * XXX: MNT_BYFSID and MNT_NONBUSY collide with MNT_ACLS and MNT_MULTILABEL,
- *      but because MNT_ACLS and MNT_MULTILABEL are only used for mount(2),
- *      and MNT_BYFSID and MNT_NONBUSY are only used for unmount(2),
- *      it's harmless.
- */
-#define	MNT_FORCE	0x0000000000080000ULL /* force unmount or readonly */
-
-/*
- * Flags set by internal operations,
- * but visible to the user.
- * XXX some of these are not quite right.. (I've never seen the root flag set)
- */
-#define	MNT_LOCAL	0x0000000000001000ULL /* filesystem is stored locally */
-
-/*
- * Flags for various system call interfaces.
- *
- * waitfor flags to vfs_sync() and getfsstat()
- */
-#define MNT_WAIT	1	/* synchronously wait for I/O to complete */
-
-/*
- * Error codes used by UFS.
- * TODO HARVEY Translate to error strings.
- */
-#define	EPERM		1		/* Operation not permitted */
-#define	ENOENT		2		/* No such file or directory */
-#define	EIO		5		/* Input/output error */
-#define	EINVAL		22		/* Invalid argument */
-#define	EFBIG		27		/* File too large */
-#define	ENOSPC		28		/* No space left on device */
-#define	EOVERFLOW	84		/* Value too large to be stored in data type */
-
-#define	EJUSTRETURN	(-2)		/* don't modify regs, just return */
-
-#define S_IFMT 0170000		/* type of file */
-
-/*
- * Super-user changeable flags.
- */
-#define	SF_SNAPSHOT	0x00200000	/* snapshot inode */

+ 0 - 748
sys/include/ufs/fs.h

@@ -1,748 +0,0 @@
-/*-
- * 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
- * $FreeBSD$
- */
-
-/*
- * Each disk drive contains some number of filesystems.
- * A filesystem consists of a number of cylinder groups.
- * Each cylinder group has inodes and data.
- *
- * A filesystem 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 filesystem 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.
- */
-#define	SBLOCK_FLOPPY	     0
-#define	SBLOCK_UFS1	  8192
-#define	SBLOCK_UFS2	 65536
-#define	SBLOCK_PIGGY	262144
-#define	SBLOCKSIZE	  8192
-#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 filesystem 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 filesystem 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 SBLOCKSIZE,
- * and that both SBLOCKSIZE and MAXBSIZE must be >= MINBSIZE.
- */
-#define	MINBSIZE	4096
-
-/*
- * The path name on which the filesystem 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.
- */
-#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 a few
- * 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,
- * and the third points to an array that tracks the creation of new
- * directories. A fourth pointer, fs_active, is used when creating
- * snapshots; it points to a bitmap of cylinder groups for which the
- * free-block bitmap has changed since the snapshot operation began.
- */
-#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
-
-/*
- * MINFREE gives the minimum acceptable percentage of filesystem
- * 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 filesystem
- * 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		8
-#define	DEFAULTOPT	FS_OPTTIME
-
-/*
- * Grigoriy Orlov <gluk@ptci.ru> 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 */
-
-/*
- * 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 ((ufs2_daddr_t)(1))
-#define	BLK_SNAP ((ufs2_daddr_t)(2))
-
-/*
- * Sysctl values for the fast filesystem.
- */
-#define	FFS_ADJ_REFCNT		 1	/* adjust inode reference count */
-#define	FFS_ADJ_BLKCNT		 2	/* adjust inode used block count */
-#define	FFS_BLK_FREE		 3	/* free range of blocks in map */
-#define	FFS_DIR_FREE		 4	/* free specified dir inodes in map */
-#define	FFS_FILE_FREE		 5	/* free specified file inodes in map */
-#define	FFS_SET_FLAGS		 6	/* set filesystem flags */
-#define	FFS_ADJ_NDIR		 7	/* adjust number of directories */
-#define	FFS_ADJ_NBFREE		 8	/* adjust number of free blocks */
-#define	FFS_ADJ_NIFREE		 9	/* adjust number of free inodes */
-#define	FFS_ADJ_NFFREE		10 	/* adjust number of free frags */
-#define	FFS_ADJ_NUMCLUSTERS	11	/* adjust number of free clusters */
-#define	FFS_SET_CWD		12	/* set current directory */
-#define	FFS_SET_DOTDOT		13	/* set inode number for ".." */
-#define	FFS_UNLINK		14	/* remove a name in the filesystem */
-#define	FFS_SET_INODE		15	/* update an on-disk inode */
-#define	FFS_SET_BUFOUTPUT	16	/* set buffered writing on descriptor */
-#define	FFS_MAXID		16	/* number of valid ffs ids */
-
-/*
- * Command structure passed in to the filesystem to adjust filesystem values.
- */
-#define	FFS_CMD_VERSION		0x19790518	/* version ID */
-struct fsck_cmd {
-	int32_t	version;	/* version of command structure */
-	int32_t	handle;		/* reference to filesystem to be changed */
-	int64_t	value;		/* inode or block number to be affected */
-	int64_t	size;		/* amount or range to be adjusted */
-	int64_t	spare;		/* reserved for future use */
-};
-
-/*
- * 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.
- */
-typedef 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 */
-} csum;
-typedef 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_numclusters;		/* number of free clusters */
-	int64_t	cs_spare[3];		/* future expansion */
-} csum_total;
-
-
-/*
- * Super block for an FFS filesystem.
- */
-typedef struct Fs {
-	int32_t	 fs_firstfield;		/* historic filesystem linked list, */
-	int32_t	 fs_unused_1;		/*     used for incore super blocks */
-	int32_t	 fs_sblkno;		/* offset 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 */
-	uint32_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 */
-	uint32_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 */
-	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 */
-	int32_t	 fs_id[2];		/* unique filesystem 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 */
-	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 filesystem */
-	int32_t	 fs_old_cpg;		/* cylinders per group */
-	uint32_t fs_ipg;		/* inodes per group */
-	int32_t	 fs_fpg;		/* blocks per group * fs_frag */
-/* this data must be re-computed after crashes */
-	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;		/* filesystem is clean flag */
-	int8_t 	 fs_ronly;		/* mounted read-only flag */
-	int8_t   fs_old_flags;		/* old FS_ flags */
-	uint8_t	 fs_fsmnt[MAXMNTLEN];	/* name mounted on */
-	uint8_t	 fs_volname[MAXVOLLEN];	/* volume name */
-	uint64_t fs_swuid;		/* system-wide uid */
-	int32_t  fs_pad;		/* due to alignment of fs_swuid */
-/* these fields retain the current block allocation info */
-	int32_t	 fs_cgrotor;		/* last cg searched */
-	void 	*fs_ocsp[NOCSPTRS];	/* padding; was list of fs_cs buffers */
-	uint8_t *fs_contigdirs;	/* (u) # of contig. allocated dirs */
-	csum    *fs_csp;		/* (u) cg summary info buffer */
-	int32_t	*fs_maxcluster;		/* (u) max cluster in each cyl group */
-	uint	*fs_active;		/* (u) used by snapshots to track fs */
-	int32_t	 fs_old_cpc;		/* cyl per cycle in postbl */
-	int32_t	 fs_maxbsize;		/* maximum blocking factor permitted */
-	int64_t	 fs_unrefs;		/* number of unreferenced inodes */
-	int64_t  fs_providersize;	/* size of underlying GEOM provider */
-	int64_t	 fs_metaspace;		/* size of area reserved for metadata */
-	int64_t	 fs_sparecon64[14];	/* old rotation block list head */
-	int64_t	 fs_sblockloc;		/* byte offset of standard superblock */
-	csum_total fs_cstotal;		/* (u) cylinder summary information */
-	ufs_time_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 */
-	ufs2_daddr_t fs_csaddr;		/* blk addr of cyl grp summary area */
-	int64_t	 fs_pendingblocks;	/* (u) blocks being freed */
-	uint32_t fs_pendinginodes;	/* (u) inodes being freed */
-	uint32_t fs_snapinum[FSMAXSNAP];/* list of snapshot inode numbers */
-	uint32_t fs_avgfilesize;	/* expected average file size */
-	uint32_t fs_avgfpdir;		/* expected # of files per directory */
-	int32_t	 fs_save_cgsize;	/* save real cg size to use fs_bsize */
-	ufs_time_t fs_mtime;		/* Last mount or fsck time. */
-	int32_t  fs_sujfree;		/* SUJ free list */
-	int32_t	 fs_sparecon32[23];	/* reserved for future constants */
-	int32_t  fs_flags;		/* see FS_ flags below */
-	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 */
-	uint64_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 */
-	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 */
-} Fs;
-
-/* Sanity checking. */
-#ifdef CTASSERT
-CTASSERT(sizeof(Fs) == 1376);
-#endif
-
-/*
- * Filesystem identification
- */
-#define	FS_UFS1_MAGIC	0x011954	/* UFS1 fast filesystem magic number */
-#define	FS_UFS2_MAGIC	0x19540119	/* UFS2 fast filesystem magic number */
-#define	FS_BAD_MAGIC	0x19960408	/* UFS incomplete newfs magic number */
-#define	FS_OKAY		0x7c269d38	/* superblock checksum */
-#define	FS_42INODEFMT	-1		/* 4.2BSD inode format */
-#define	FS_44INODEFMT	2		/* 4.4BSD inode format */
-
-/*
- * Preference for optimization.
- */
-#define	FS_OPTTIME	0	/* minimize allocation time */
-#define	FS_OPTSPACE	1	/* minimize disk fragmentation */
-
-/*
- * Filesystem flags.
- *
- * The FS_UNCLEAN flag is set by the kernel when the filesystem was
- * mounted with fs_clean set to zero. The FS_DOSOFTDEP flag indicates
- * that the filesystem should be managed by the soft updates code.
- * Note that the FS_NEEDSFSCK flag is set and cleared only by the
- * fsck utility. It is set when background fsck finds an unexpected
- * inconsistency which requires a traditional foreground fsck to be
- * run. Such inconsistencies should only be found after an uncorrectable
- * disk error. A foreground fsck will clear the FS_NEEDSFSCK flag when
- * it has successfully cleaned up the filesystem. The kernel uses this
- * flag to enforce that inconsistent filesystems be mounted read-only.
- * The FS_INDEXDIRS flag when set indicates that the kernel maintains
- * on-disk auxiliary indexes (such as B-trees) for speeding directory
- * accesses. Kernels that do not support auxiliary indices clear the
- * flag to indicate that the indices need to be rebuilt (by fsck) before
- * they can be used.
- *
- * FS_ACLS indicates that POSIX.1e ACLs are administratively enabled
- * for the file system, so they should be loaded from extended attributes,
- * observed for access control purposes, and be administered by object
- * owners.  FS_NFS4ACLS indicates that NFSv4 ACLs are administratively
- * enabled.  This flag is mutually exclusive with FS_ACLS.  FS_MULTILABEL
- * indicates that the TrustedBSD MAC Framework should attempt to back MAC
- * labels into extended attributes on the file system rather than maintain
- * a single mount label for all objects.
- */
-#define	FS_UNCLEAN	0x0001	/* filesystem not clean at mount */
-#define	FS_DOSOFTDEP	0x0002	/* filesystem using soft dependencies */
-#define	FS_NEEDSFSCK	0x0004	/* filesystem needs sync fsck before mount */
-#define	FS_SUJ       	0x0008	/* Filesystem using softupdate journal */
-#define	FS_ACLS		0x0010	/* file system has POSIX.1e ACLs enabled */
-#define	FS_MULTILABEL	0x0020	/* file system is MAC multi-label */
-#define	FS_GJOURNAL	0x0040	/* gjournaled file system */
-#define	FS_FLAGS_UPDATED 0x0080	/* flags have been moved to new location */
-#define	FS_NFS4ACLS	0x0100	/* file system has NFSv4 ACLs enabled */
-#define	FS_INDEXDIRS	0x0200	/* kernel supports indexed directories */
-#define	FS_TRIM		0x0400	/* issue BIO_DELETE for deleted blocks */
-
-/*
- * Macros to access bits in the fs_active array.
- */
-#define	ACTIVECGNUM(fs, cg)	((fs)->fs_active[(cg) / (NBBY * sizeof(int))])
-#define	ACTIVECGOFF(cg)		(1 << ((cg) % (NBBY * sizeof(int))))
-#define	ACTIVESET(fs, cg)	do {					\
-	if ((fs)->fs_active)						\
-		ACTIVECGNUM((fs), (cg)) |= ACTIVECGOFF((cg));		\
-} while (0)
-#define	ACTIVECLEAR(fs, cg)	do {					\
-	if ((fs)->fs_active)						\
-		ACTIVECGNUM((fs), (cg)) &= ~ACTIVECGOFF((cg));		\
-} while (0)
-
-/*
- * 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 filesystem.
- */
-#define	CG_MAGIC	0x090255
-typedef 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 */
-	uint32_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 */
-	uint32_t cg_ndblk;		/* number of data blocks this cg */
-	struct	 csum cg_cs;		/* cylinder summary information */
-	uint32_t cg_rotor;		/* position of last used block */
-	uint32_t cg_frotor;		/* position of last used frag */
-	uint32_t cg_irotor;		/* position of last used inode */
-	uint32_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 */
-	uint32_t cg_iusedoff;		/* (u_int8) used inode map */
-	uint32_t cg_freeoff;		/* (u_int8) free block map */
-	uint32_t cg_nextfreeoff;	/* (u_int8) next available space */
-	uint32_t cg_clustersumoff;	/* (u_int32) counts of avail clusters */
-	uint32_t cg_clusteroff;		/* (u_int8) free cluster map */
-	uint32_t cg_nclusterblks;	/* number of clusters this cg */
-	uint32_t cg_niblk;		/* number of inode blocks this cg */
-	uint32_t cg_initediblk;		/* last initialized inode */
-	uint32_t cg_unrefs;		/* number of unreferenced inodes */
-	int32_t	 cg_sparecon32[2];	/* reserved for future use */
-	ufs_time_t cg_time;		/* time last written */
-	int64_t	 cg_sparecon64[3];	/* reserved for future use */
-	uint8_t cg_space[1];		/* space for cylinder group maps */
-/* actually longer */
-} Cg;
-
-/*
- * Macros for access to cylinder group array structures
- */
-#define	cg_chkmagic(cgp) ((cgp)->cg_magic == CG_MAGIC)
-#define	cg_inosused(cgp) \
-    ((uint8_t *)((uint8_t *)(cgp) + (cgp)->cg_iusedoff))
-#define	cg_blksfree(cgp) \
-    ((uint8_t *)((uint8_t *)(cgp) + (cgp)->cg_freeoff))
-#define	cg_clustersfree(cgp) \
-    ((uint8_t *)((uint8_t *)(cgp) + (cgp)->cg_clusteroff))
-#define	cg_clustersum(cgp) \
-    ((int32_t *)((uintptr_t)(cgp) + (cgp)->cg_clustersumoff))
-
-/*
- * Turn filesystem block numbers into disk block addresses.
- * This maps filesystem blocks to device size blocks.
- */
-#define	fsbtodb(fs, b)	((daddr_t)(b) << (fs)->fs_fsbtodb)
-#define	dbtofsb(fs, b)	((b) >> (fs)->fs_fsbtodb)
-
-/*
- * Cylinder group macros to locate things in cylinder groups.
- * They calc filesystem addresses of cylinder group data structures.
- */
-#define	cgbase(fs, c)	(((ufs2_daddr_t)(fs)->fs_fpg) * (c))
-#define	cgdata(fs, c)	(cgdmin(fs, c) + (fs)->fs_metaspace)	/* data zone */
-#define	cgmeta(fs, c)	(cgdmin(fs, c))				/* meta data */
-#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 */
-#define	cgstart(fs, c)	(cgbase(fs, c))
-
-/*
- * Macros for handling inode numbers:
- *     inode number to filesystem block offset.
- *     inode number to cylinder group number.
- *     inode number to filesystem block address.
- */
-#define	ino_to_cg(fs, x)	(((ino_t)(x)) / (fs)->fs_ipg)
-#define	ino_to_fsba(fs, x)						\
-	((ufs2_daddr_t)(cgimin(fs, ino_to_cg(fs, (ino_t)(x))) +		\
-	    (blkstofrags((fs), ((((ino_t)(x)) % (fs)->fs_ipg) / INOPB(fs))))))
-#define	ino_to_fsbo(fs, x)	(((ino_t)(x)) % INOPB(fs))
-
-/*
- * Give cylinder group number for a filesystem block.
- * Give cylinder group block number for a filesystem 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)))
-
-/*
- * 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)
-/* Use this only when `blk' is known to be small, e.g., < UFS_NDADDR. */
-#define	smalllblktosize(fs, blk)    /* calculates (blk * fs->fs_bsize) */ \
-	((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 filesystem.
- */
-#define	blksize(fs, ip, lbn) \
-	(((lbn) >= UFS_NDADDR || (ip)->i_size >= \
-	    (uint64_t)smalllblktosize(fs, (lbn) + 1)) \
-	    ? (fs)->fs_bsize \
-	    : (fragroundup(fs, blkoff(fs, (ip)->i_size))))
-#define	sblksize(fs, size, lbn) \
-	(((lbn) >= UFS_NDADDR || (size) >= ((lbn) + 1) << (fs)->fs_bshift) \
-	  ? (fs)->fs_bsize \
-	  : (fragroundup(fs, blkoff(fs, (size)))))
-
-/*
- * Number of indirects in a filesystem block.
- */
-#define	NINDIR(fs)	((fs)->fs_nindir)
-
-/*
- * Indirect lbns are aligned on UFS_NDADDR addresses where single indirects
- * are the negated address of the lowest lbn reachable, double indirects
- * are this lbn - 1 and triple indirects are this lbn - 2.  This yields
- * an unusual bit order to determine level.
- */
-static inline int
-lbn_level(ufs_lbn_t lbn)
-{
-	if (lbn >= 0)
-		return 0;
-	switch (lbn & 0x3) {
-	case 0:
-		return (0);
-	case 1:
-		break;
-	case 2:
-		return (2);
-	case 3:
-		return (1);
-	default:
-		break;
-	}
-	return (-1);
-}
-
-static inline ufs_lbn_t
-lbn_offset(Fs *fs, int level)
-{
-	ufs_lbn_t res;
-
-	for (res = 1; level > 0; level--)
-		res *= NINDIR(fs);
-	return (res);
-}
-
-/*
- * Number of inodes in a secondary storage block/fragment.
- */
-#define	INOPB(fs)	((fs)->fs_inopb)
-#define	INOPF(fs)	((fs)->fs_inopb >> (fs)->fs_fragshift)
-
-/*
- * Softdep journal record format.
- */
-
-#define	JOP_ADDREF	1	/* Add a reference to an inode. */
-#define	JOP_REMREF	2	/* Remove a reference from an inode. */
-#define	JOP_NEWBLK	3	/* Allocate a block. */
-#define	JOP_FREEBLK	4	/* Free a block or a tree of blocks. */
-#define	JOP_MVREF	5	/* Move a reference from one off to another. */
-#define	JOP_TRUNC	6	/* Partial truncation record. */
-#define	JOP_SYNC	7	/* fsync() complete record. */
-
-#define	JREC_SIZE	32	/* Record and segment header size. */
-
-#define	SUJ_MIN		(4 * 1024 * 1024)	/* Minimum journal size */
-#define	SUJ_MAX		(32 * 1024 * 1024)	/* Maximum journal size */
-#define	SUJ_FILE	".sujournal"		/* Journal file name */
-
-/*
- * Size of the segment record header.  There is at most one for each disk
- * block in the journal.  The segment header is followed by an array of
- * records.  fsck depends on the first element in each record being 'op'
- * and the second being 'ino'.  Segments may span multiple disk blocks but
- * the header is present on each.
- */
-struct jsegrec {
-	uint64_t	jsr_seq;	/* Our sequence number */
-	uint64_t	jsr_oldest;	/* Oldest valid sequence number */
-	uint16_t	jsr_cnt;	/* Count of valid records */
-	uint16_t	jsr_blocks;	/* Count of device bsize blocks. */
-	uint32_t	jsr_crc;	/* 32bit crc of the valid space */
-	ufs_time_t	jsr_time;	/* timestamp for mount instance */
-};
-
-/*
- * Reference record.  Records a single link count modification.
- */
-struct jrefrec {
-	uint32_t	jr_op;
-	uint32_t	jr_ino;
-	uint32_t	jr_parent;
-	uint16_t	jr_nlink;
-	uint16_t	jr_mode;
-	int64_t		jr_diroff;
-	uint64_t	jr_unused;
-};
-
-/*
- * Move record.  Records a reference moving within a directory block.  The
- * nlink is unchanged but we must search both locations.
- */
-struct jmvrec {
-	uint32_t	jm_op;
-	uint32_t	jm_ino;
-	uint32_t	jm_parent;
-	uint16_t	jm_unused;
-	int64_t		jm_oldoff;
-	int64_t		jm_newoff;
-};
-
-/*
- * Block record.  A set of frags or tree of blocks starting at an indirect are
- * freed or a set of frags are allocated.
- */
-struct jblkrec {
-	uint32_t	jb_op;
-	uint32_t	jb_ino;
-	ufs2_daddr_t	jb_blkno;
-	ufs_lbn_t	jb_lbn;
-	uint16_t	jb_frags;
-	uint16_t	jb_oldfrags;
-	uint32_t	jb_unused;
-};
-
-/*
- * Truncation record.  Records a partial truncation so that it may be
- * completed at check time.  Also used for sync records.
- */
-struct jtrncrec {
-	uint32_t	jt_op;
-	uint32_t	jt_ino;
-	int64_t		jt_size;
-	uint32_t	jt_extsize;
-	uint32_t	jt_pad[3];
-};
-
-union jrec {
-	struct jsegrec	rec_jsegrec;
-	struct jrefrec	rec_jrefrec;
-	struct jmvrec	rec_jmvrec;
-	struct jblkrec	rec_jblkrec;
-	struct jtrncrec	rec_jtrncrec;
-};
-
-#ifdef CTASSERT
-CTASSERT(sizeof(struct jsegrec) == JREC_SIZE);
-CTASSERT(sizeof(struct jrefrec) == JREC_SIZE);
-CTASSERT(sizeof(struct jmvrec) == JREC_SIZE);
-CTASSERT(sizeof(struct jblkrec) == JREC_SIZE);
-CTASSERT(sizeof(struct jtrncrec) == JREC_SIZE);
-CTASSERT(sizeof(union jrec) == JREC_SIZE);
-#endif
-
-extern int inside[], around[];
-extern uint8_t *fragtbl[];

+ 0 - 175
sys/include/ufs/inode.h

@@ -1,175 +0,0 @@
-/*-
- * 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.
- *
- *	@(#)inode.h	8.9 (Berkeley) 5/14/95
- * $FreeBSD$
- */
-
-typedef struct ufs2_dinode ufs2_dinode;
-typedef struct ufsmount ufsmount;
-typedef struct vnode vnode;
-
-/*
- * This must agree with the definition in <ufs/ufs/dir.h>.
- */
-#define	doff_t		int32_t
-
-/*
- * The inode is used to describe each active (or recently active) file in the
- * UFS filesystem. It is composed of two types of information. The first part
- * is the information that is needed only while the file is active (such as
- * the identity of the file and linkage to speed its lookup). The second part
- * is the permanent meta-data associated with the file which is read in
- * from the permanent dinode from long term storage when the file becomes
- * active, and is put back when the file is no longer being used.
- *
- * An inode may only be changed while holding either the exclusive
- * vnode lock or the shared vnode lock and the vnode interlock. We use
- * the latter only for "read" and "get" operations that require
- * changing i_flag, or a timestamp. This locking protocol allows executing
- * those operations without having to upgrade the vnode lock from shared to
- * exclusive.
- */
-struct inode {
-	// TODO HARVEY Replace when snapshot code re-enabled
-	//TAILQ_ENTRY(inode) i_nextsnap; /* snapshot file list. */
-	vnode  *i_vnode;/* Vnode associated with this inode. */
-	ufsmount *i_ump;/* Ufsmount point associated with this inode. */
-	struct	 dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */
-	union {
-		struct dirhash *dirhash; /* Hashing for large directories. */
-		daddr_t *snapblklist;    /* Collect expunged snapshot blocks. */
-	} i_un;
-
-	/*
-	 * The real copy of the on-disk inode.
-	 */
-	ufs2_dinode *din2;	/* UFS2 on-disk dinode. */
-
-	ino_t	  i_number;	/* The identity of the inode. */
-	uint32_t i_flag;	/* flags, see below */
-	int	  i_effnlink;	/* i_nlink when I/O completes */
-
-
-	/*
-	 * Side effects; used during directory lookup.
-	 */
-	int32_t	  i_count;	/* Size of free slot in directory. */
-	doff_t	  i_endoff;	/* End of useful stuff in directory. */
-	doff_t	  i_diroff;	/* Offset in dir, where we found last entry. */
-	doff_t	  i_offset;	/* Offset of free space in directory. */
-
-	int	i_nextclustercg; /* last cg searched for cluster */
-
-	/*
-	 * Data for extended attribute modification.
- 	 */
-	uint8_t	  *i_ea_area;	/* Pointer to malloced copy of EA area */
-	unsigned  i_ea_len;	/* Length of i_ea_area */
-	int	  i_ea_error;	/* First errno in transaction */
-	int	  i_ea_refs;	/* Number of users of EA area */
-
-	/*
-	 * Copies from the on-disk dinode itself.
-	 */
-	uint64_t i_size;	/* File byte count. */
-	uint64_t i_gen;	/* Generation number. */
-	uint32_t i_flags;	/* Status flags (chflags). */
-	uint32_t i_uid;	/* File owner. */
-	uint32_t i_gid;	/* File group. */
-	uint16_t i_mode;	/* IFMT, permissions; see below. */
-	int16_t	  i_nlink;	/* File link count. */
-};
-/*
- * These flags are kept in i_flag.
- */
-#define	IN_ACCESS	0x0001		/* Access time update request. */
-#define	IN_CHANGE	0x0002		/* Inode change time update request. */
-#define	IN_UPDATE	0x0004		/* Modification time update request. */
-#define	IN_MODIFIED	0x0008		/* Inode has been modified. */
-#define	IN_NEEDSYNC	0x0010		/* Inode requires fsync. */
-#define	IN_LAZYMOD	0x0020		/* Modified, but don't write yet. */
-#define	IN_LAZYACCESS	0x0040		/* Process IN_ACCESS after the
-					   suspension finished */
-#define	IN_EA_LOCKED	0x0080
-#define	IN_EA_LOCKWAIT	0x0100
-
-#define	IN_TRUNCATED	0x0200		/* Journaled truncation pending. */
-
-#define	IN_UFS2		0x0400		/* UFS2 vs UFS1 */
-
-#define	i_dirhash i_un.dirhash
-#define	i_snapblklist i_un.snapblklist
-
-#define	ITOUMP(ip)	((ip)->i_ump)
-#define	ITODEV(ip)	(ITOUMP(ip)->um_dev)
-#define	ITODEVVP(ip)	(ITOUMP(ip)->um_devvp)
-#define	ITOFS(ip)	(ITOUMP(ip)->um_fs)
-#define	ITOVFS(ip)	((ip)->i_vnode->v_mount)
-
-static inline _Bool
-I_IS_UFS2(const struct inode *ip)
-{
-	return ((ip->i_flag & IN_UFS2) != 0);
-}
-
-#define	SHORTLINK(ip)	((caddr_t)(ip)->i_din2->di_db)
-#define	IS_SNAPSHOT(ip)		((ip)->i_flags & SF_SNAPSHOT)
-
-/*
- * Structure used to pass around logical block paths generated by
- * ufs_getlbns and used by truncate and bmap code.
- */
-typedef struct Indir {
-	ufs2_daddr_t in_lbn;		/* Logical block number. */
-	int	in_off;			/* Offset in buffer. */
-} Indir;
-
-/* Convert between inode pointers and vnode pointers. */
-// TODO HARVEY Just remove these 2 macros
-#define	VTOI(vp)	((inode *)(vp)->data)
-#define	ITOV(ip)	((ip)->i_vnode)
-
-/* Determine if soft dependencies are being done */
-#define	DOINGSOFTDEP(vp)   ((vp)->v_mount->mnt_flag & (MNT_SOFTDEP | MNT_SUJ))
-#define	MOUNTEDSOFTDEP(mp) ((mp)->mnt_flag & (MNT_SOFTDEP | MNT_SUJ))
-#define	DOINGSUJ(vp)	   ((vp)->v_mount->mnt_flag & MNT_SUJ)
-#define	MOUNTEDSUJ(mp)	   ((mp)->mnt_flag & MNT_SUJ)
-
-/* This overlays the fid structure (see mount.h). */
-struct ufid {
-	uint16_t ufid_len;	/* Length of structure. */
-	uint16_t ufid_pad;	/* Force 32-bit alignment. */
-	uint32_t  ufid_ino;	/* File number (ino). */
-	uint32_t  ufid_gen;	/* Generation number. */
-};

+ 0 - 117
sys/include/ufs/libufs.h

@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2002 Juli Mallett.  All rights reserved.
- *
- * This software was written by Juli Mallett <jmallett@FreeBSD.org> for the
- * FreeBSD project.  Redistribution and use in source and binary forms, with
- * or without modification, are permitted provided that the following
- * conditions are met:
- *
- * 1. Redistribution of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * 2. Redistribution 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * libufs structures.
- */
-
-/*
- * userland ufs disk.
- */
-typedef struct Uufsd {
-	const char *d_name;	/* disk name */
-	int d_ufs;		/* decimal UFS version */
-	int d_fd;		/* raw device file descriptor */
-	long d_bsize;		/* device bsize */
-	ufs2_daddr_t d_sblock;	/* superblock location */
-	struct csum *d_sbcsum;	/* Superblock summary info */
-	caddr_t d_inoblock;	/* inode block */
-	ino_t d_inomin;		/* low inode */
-	ino_t d_inomax;		/* high inode */
-	union {
-		Fs d_fs;	/* filesystem information */
-		char d_sb[MAXBSIZE];
-				/* superblock as buffer */
-	} d_sbunion;
-	union {
-		Cg d_cg;	/* cylinder group */
-		char d_buf[MAXBSIZE];
-				/* cylinder group storage */
-	} d_cgunion;
-	int d_ccg;		/* current cylinder group */
-	int d_lcg;		/* last cylinder group (in d_cg) */
-	const char *d_error;	/* human readable disk error */
-	int d_mine;		/* internal flags */
-#define	d_fs	d_sbunion.d_fs
-#define	d_sb	d_sbunion.d_sb
-#define	d_cg	d_cgunion.d_cg
-} Uufsd;
-
-
-/*
- * libufs prototypes.
- */
-
-/*
- * block.c
- */
-int32_t bread(Uufsd *, ufs2_daddr_t, void *, size_t);
-int32_t bwrite(Uufsd *, ufs2_daddr_t, const void *, size_t);
-int berase(Uufsd *disk, ufs2_daddr_t blockno, ufs2_daddr_t size);
-void libufserror(Uufsd *u, const char *str);
-
-/*
- * cgroup.c
- */
-ufs2_daddr_t cgballoc(Uufsd *);
-int cgbfree(Uufsd *, ufs2_daddr_t, long);
-ino_t cgialloc(Uufsd *);
-int cgread(Uufsd *);
-int cgread1(Uufsd *, int);
-int cgwrite(Uufsd *);
-int cgwrite1(Uufsd *, int);
-
-/*
- * inode.c
- */
-int getino(Uufsd *, void **, ino_t, int *);
-int putino(Uufsd *);
-
-/*
- * sblock.c
- */
-int sbread(Uufsd *);
-int sbwrite(Uufsd *, int);
-
-/*
- * type.c
- */
-int ufs_disk_close(Uufsd *);
-int ufs_disk_create(Uufsd *);
-int ufs_disk_write(Uufsd *);
-
-/*
- * libufs_subr.c
- */
-void	ffs_clrblock(Fs *, uint8_t *, ufs1_daddr_t);
-void	ffs_clusteracct(Fs *, Cg *, ufs1_daddr_t, int);
-void	ffs_fragacct(Fs *, int, uint32_t [], int);
-int	ffs_isblock(Fs *, uint8_t *, ufs1_daddr_t);
-int	ffs_isfreeblock(Fs *, uint8_t *, ufs1_daddr_t);
-void	ffs_setblock(Fs *, uint8_t *, ufs1_daddr_t);

+ 0 - 79
sys/include/ufs/libufsdat.h

@@ -1,79 +0,0 @@
-/*-
- * Copyright (c) 1991, 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.
- *
- *	@(#)queue.h	8.5 (Berkeley) 8/20/94
- * $FreeBSD$
- */
-
-typedef int64_t daddr_t;	/* disk address */
-typedef char *caddr_t;		/* core address */
-typedef int64_t off_t;		/* File offset */
-typedef uint32_t ino_t;		/* inode number */
-
-/*
- * The size of physical and logical block numbers and time fields in UFS.
- */
-typedef int32_t ufs1_daddr_t;
-typedef int64_t ufs2_daddr_t;
-typedef int64_t ufs_lbn_t;
-typedef int64_t ufs_time_t;
-
-/*
- * MAXBSIZE -	Filesystems are made out of blocks of at most MAXBSIZE bytes
- *		per block.  MAXBSIZE may be made larger without effecting
- *		any existing filesystems as long as it does not exceed MAXPHYS,
- *		and may be made smaller at the risk of not being able to use
- *		filesystems which require a block size exceeding MAXBSIZE.
- */
-#define MAXBSIZE	65536	/* must be power of 2 */
-
-#define MAXPHYS		(128 * 1024)	/* max raw I/O transfer size */
-
-#define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
-#define	DEV_BSIZE	(1<<DEV_BSHIFT)
-
-#define	NBBY	8		/* number of bits in a byte */
-
-#define	setbit(a,i)	(((unsigned char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY))
-#define	clrbit(a,i)	(((unsigned char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY)))
-#define	isclr(a,i)							\
-	((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
-
-/*
- * btodb() is messy and perhaps slow because `bytes' may be an off_t.  We
- * want to shift an unsigned type to avoid sign extension and we don't
- * want to widen `bytes' unnecessarily.  Assume that the result fits in
- * a daddr_t.
- */
-#define btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
-	(sizeof (bytes) > sizeof(long) \
-	 ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \
-	 : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT))
-
-#define dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
-	((off_t)(db) << DEV_BSHIFT)

+ 0 - 247
sys/include/ufs/quota.h

@@ -1,247 +0,0 @@
-/*-
- * Copyright (c) 1982, 1986, 1993
- *	The Regents of the University of California.  All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Robert Elz at The University of Melbourne.
- *
- * 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.
- *
- *	@(#)quota.h	8.3 (Berkeley) 8/19/94
- * $FreeBSD$
- */
-
-/*
- * Definitions for disk quotas imposed on the average user
- * (big brother finally hits UNIX).
- *
- * The following constants define the amount of time given a user before the
- * soft limits are treated as hard limits (usually resulting in an allocation
- * failure). The timer is started when the user crosses their soft limit, it
- * is reset when they go below their soft limit.
- */
-#define	MAX_IQ_TIME	(7*24*60*60)	/* seconds in 1 week */
-#define	MAX_DQ_TIME	(7*24*60*60)	/* seconds in 1 week */
-
-/*
- * The following constants define the usage of the quota file array in the
- * ufsmount structure and dquot array in the inode structure.  The semantics
- * of the elements of these arrays are defined in the routine getinoquota;
- * the remainder of the quota code treats them generically and need not be
- * inspected when changing the size of the array.
- */
-#define	MAXQUOTAS	2
-#define	USRQUOTA	0	/* element used for user quotas */
-#define	GRPQUOTA	1	/* element used for group quotas */
-
-/*
- * Definitions for the default names of the quotas files.
- */
-#define	INITQFNAMES { \
-	"user",		/* USRQUOTA */ \
-	"group",	/* GRPQUOTA */ \
-	"undefined", \
-}
-#define	QUOTAFILENAME	"quota"
-#define	QUOTAGROUP	"operator"
-
-/*
- * Command definitions for the 'quotactl' system call.  The commands are
- * broken into a main command defined below and a subcommand that is used
- * to convey the type of quota that is being manipulated (see above).
- */
-#define	SUBCMDMASK	0x00ff
-#define	SUBCMDSHIFT	8
-#define	QCMD(cmd, type)	(((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK))
-
-#define	Q_QUOTAON	0x0100	/* enable quotas */
-#define	Q_QUOTAOFF	0x0200	/* disable quotas */
-#define	Q_GETQUOTA32	0x0300	/* get limits and usage (32-bit version) */
-#define	Q_SETQUOTA32	0x0400	/* set limits and usage (32-bit version) */
-#define	Q_SETUSE32	0x0500	/* set usage (32-bit version) */
-#define	Q_SYNC		0x0600	/* sync disk copy of a filesystems quotas */
-#define	Q_GETQUOTA	0x0700	/* get limits and usage (64-bit version) */
-#define	Q_SETQUOTA	0x0800	/* set limits and usage (64-bit version) */
-#define	Q_SETUSE	0x0900	/* set usage (64-bit version) */
-#define	Q_GETQUOTASIZE	0x0A00	/* get bit-size of quota file fields */
-
-#if 0
-
-/*
- * The following structure defines the format of the disk quota file
- * (as it appears on disk) - the file is an array of these structures
- * indexed by user or group number.  The setquota system call establishes
- * the vnode for each quota file (a pointer is retained in the ufsmount
- * structure).
- */
-struct dqblk32 {
-	uint32_t dqb_bhardlimit;	/* absolute limit on disk blks alloc */
-	uint32_t dqb_bsoftlimit;	/* preferred limit on disk blks */
-	uint32_t dqb_curblocks;	/* current block count */
-	uint32_t dqb_ihardlimit;	/* maximum # allocated inodes + 1 */
-	uint32_t dqb_isoftlimit;	/* preferred inode limit */
-	uint32_t dqb_curinodes;	/* current # allocated inodes */
-	int32_t   dqb_btime;		/* time limit for excessive disk use */
-	int32_t   dqb_itime;		/* time limit for excessive files */
-};
-
-struct dqblk64 {
-	uint64_t dqb_bhardlimit;	/* absolute limit on disk blks alloc */
-	uint64_t dqb_bsoftlimit;	/* preferred limit on disk blks */
-	uint64_t dqb_curblocks;	/* current block count */
-	uint64_t dqb_ihardlimit;	/* maximum # allocated inodes + 1 */
-	uint64_t dqb_isoftlimit;	/* preferred inode limit */
-	uint64_t dqb_curinodes;	/* current # allocated inodes */
-	int64_t   dqb_btime;		/* time limit for excessive disk use */
-	int64_t   dqb_itime;		/* time limit for excessive files */
-};
-
-#define	dqblk dqblk64
-
-#define	Q_DQHDR64_MAGIC "QUOTA64"
-#define	Q_DQHDR64_VERSION 0x20081104
-
-struct dqhdr64 {
-	char	  dqh_magic[8];		/* Q_DQHDR64_MAGIC */
-	uint32_t  dqh_version;		/* Q_DQHDR64_VERSION */
-	uint32_t  dqh_hdrlen;		/* header length */
-	uint32_t  dqh_reclen;		/* record length */
-	char	  dqh_unused[44];	/* reserved for future extension */
-};
-
-/*
- * The following structure records disk usage for a user or group on a
- * filesystem. There is one allocated for each quota that exists on any
- * filesystem for the current user or group. A cache is kept of recently
- * used entries.
- * (h) protected by dqhlock
- */
-struct dquot {
-	LIST_ENTRY(dquot) dq_hash;	/* (h) hash list */
-	TAILQ_ENTRY(dquot) dq_freelist;	/* (h) free list */
-	struct mtx dq_lock;		/* lock for concurrency */
-	uint16_t dq_flags;		/* flags, see below */
-	uint16_t dq_type;		/* quota type of this dquot */
-	uint32_t dq_cnt;		/* (h) count of active references */
-	uint32_t dq_id;		/* identifier this applies to */
-	struct ufsmount *dq_ump;	/* (h) filesystem that this is
-					   taken from */
-	struct dqblk64 dq_dqb;		/* actual usage & quotas */
-};
-/*
- * Flag values.
- */
-#define	DQ_LOCK		0x01		/* this quota locked (no MODS) */
-#define	DQ_WANT		0x02		/* wakeup on unlock */
-#define	DQ_MOD		0x04		/* this quota modified since read */
-#define	DQ_FAKE		0x08		/* no limits here, just usage */
-#define	DQ_BLKS		0x10		/* has been warned about blk limit */
-#define	DQ_INODS	0x20		/* has been warned about inode limit */
-/*
- * Shorthand notation.
- */
-#define	dq_bhardlimit	dq_dqb.dqb_bhardlimit
-#define	dq_bsoftlimit	dq_dqb.dqb_bsoftlimit
-#define	dq_curblocks	dq_dqb.dqb_curblocks
-#define	dq_ihardlimit	dq_dqb.dqb_ihardlimit
-#define	dq_isoftlimit	dq_dqb.dqb_isoftlimit
-#define	dq_curinodes	dq_dqb.dqb_curinodes
-#define	dq_btime	dq_dqb.dqb_btime
-#define	dq_itime	dq_dqb.dqb_itime
-
-/*
- * If the system has never checked for a quota for this file, then it is
- * set to NODQUOT.  Once a write attempt is made the inode pointer is set
- * to reference a dquot structure.
- */
-#define	NODQUOT		nil
-
-/*
- * Flags to chkdq() and chkiq()
- */
-#define	FORCE	0x01	/* force usage changes independent of limits */
-#define	CHOWN	0x02	/* (advisory) change initiated by chown */
-
-/*
- * Macros to avoid subroutine calls to trivial functions.
- */
-#ifdef DIAGNOSTIC
-#define	DQREF(dq)	dqref(dq)
-#else
-#define	DQREF(dq)	(dq)->dq_cnt++
-#endif
-
-#define	DQI_LOCK(dq)	mtx_lock(&(dq)->dq_lock)
-#define	DQI_UNLOCK(dq)	mtx_unlock(&(dq)->dq_lock)
-
-#define	DQI_WAIT(dq, prio, msg) do {		\
-	while ((dq)->dq_flags & DQ_LOCK) {	\
-		(dq)->dq_flags |= DQ_WANT;	\
-		(void) msleep((dq),		\
-		    &(dq)->dq_lock, (prio), (msg), 0); \
-	}					\
-} while (0)
-
-#define	DQI_WAKEUP(dq) do {			\
-	if ((dq)->dq_flags & DQ_WANT)		\
-		wakeup((dq));			\
-	(dq)->dq_flags &= ~(DQ_WANT|DQ_LOCK);	\
-} while (0)
-
-struct inode;
-struct mount;
-struct thread;
-struct ucred;
-struct vnode;
-
-int	chkdq(struct inode *, int64_t, struct ucred *, int);
-int	chkiq(struct inode *, int, struct ucred *, int);
-void	dqinit(void);
-void	dqrele(struct vnode *, struct dquot *);
-void	dquninit(void);
-int	getinoquota(struct inode *);
-int	qsync(struct mount *);
-int	qsyncvp(struct vnode *);
-int	quotaoff(struct thread *, struct mount *, int);
-int	quotaon(struct thread *, struct mount *, int, void *);
-int	getquota32(struct thread *, struct mount *, uint64_t, int, void *);
-int	setquota32(struct thread *, struct mount *, uint64_t, int, void *);
-int	setuse32(struct thread *, struct mount *, uint64_t, int, void *);
-int	getquota(struct thread *, struct mount *, uint64_t, int, void *);
-int	setquota(struct thread *, struct mount *, uint64_t, int, void *);
-int	setuse(struct thread *, struct mount *, uint64_t, int, void *);
-int	getquotasize(struct thread *, struct mount *, uint64_t, int,
-			void *);
-vfs_quotactl_t ufs_quotactl;
-
-#ifdef SOFTUPDATES
-int	quotaref(struct vnode *, struct dquot **);
-void	quotarele(struct dquot **);
-void	quotaadj(struct dquot **, struct ufsmount *, int64_t);
-#endif /* SOFTUPDATES */
-
-int	quotactl(const char *, int, int, void *);
-
-#endif // 0

+ 0 - 124
sys/include/ufs/ufsmount.h

@@ -1,124 +0,0 @@
-/*-
- * Copyright (c) 1982, 1986, 1989, 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.
- *
- *	@(#)ufsmount.h	8.6 (Berkeley) 3/30/95
- * $FreeBSD$
- */
-
-#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_UFSMNT);
-#endif
-
-typedef struct Buf Buf;
-typedef struct Fs Fs;
-typedef struct inode inode;
-struct nameidata;
-struct taskqueue;
-struct timeval;
-typedef struct Ucred Ucred;
-struct uio;
-struct vnode;
-struct ufs_extattr_per_mount;
-struct jblocks;
-struct inodedep;
-struct MountPoint;
-
-//TAILQ_HEAD(inodedeplst, inodedep);
-//LIST_HEAD(bmsafemaphd, bmsafemap);
-
-/* This structure describes the UFS specific mount structure data. */
-// TODO HARVEY Maybe combine this with MountPoint?
-typedef struct ufsmount {
-	MountPoint	*um_mountp;			/* filesystem vfs structure */
-	//struct	cdev *um_dev;			/* device mounted */
-	//struct	g_consumer *um_cp;
-	//struct	bufobj *um_bo;			/* Buffer cache object */
-	//struct	vnode *um_devvp;		/* block device mounted vnode */
-	uint64_t	um_fstype;			/* type of filesystem */
-	Fs		*um_fs;				/* pointer to superblock */
-	//struct	ufs_extattr_per_mount um_extattr;	/* extended attrs */
-	uint64_t	um_nindir;			/* indirect ptrs per block */
-	uint64_t	um_bptrtodb;			/* indir ptr to disk block */
-	uint64_t	um_seqinc;			/* inc between seq blocks */
-	QLock um_lock;					/* Protects ufsmount & fs */
-	//pid_t	um_fsckpid;			/* PID permitted fsck sysctls */
-	//struct	mount_softdeps *um_softdep;	/* softdep mgmt structure */
-	//struct	vnode *um_quotas[MAXQUOTAS];	/* pointer to quota files */
-	//struct	ucred *um_cred[MAXQUOTAS];	/* quota file access cred */
-	//time_t	um_btime[MAXQUOTAS];		/* block quota time limit */
-	//time_t	um_itime[MAXQUOTAS];		/* inode quota time limit */
-	//char	um_qflags[MAXQUOTAS];		/* quota specific flags */
-	int64_t	um_savedmaxfilesize;		/* XXX - limit maxfilesize */
-	//int	um_candelete;			/* devvp supports TRIM */
-	//int	um_writesuspended;		/* suspension in progress */
-	//uint	um_trim_inflight;
-	//struct taskqueue *um_trim_tq;
-	int	(*um_balloc)(vnode *, off_t, int, Ucred *, int, Buf **);
-	int	(*um_blkatoff)(vnode *, off_t, char **, Buf **);
-	int	(*um_truncate)(vnode *, off_t, int, Ucred *);
-	int	(*um_update)(vnode *, int);
-	int	(*um_valloc)(vnode *, int, Ucred *, vnode **);
-	int	(*um_vfree)(vnode *, ino_t, int);
-	void	(*um_ifree)(ufsmount *, inode *);
-	int	(*um_rdonly)(inode *);
-	void	(*um_snapgone)(inode *);
-} ufsmount;
-
-/*#define	UFS_BALLOC(aa, bb, cc, dd, ee, ff) VFSTOUFS((aa)->v_mount)->um_balloc(aa, bb, cc, dd, ee, ff)
-#define	UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd)
-#define	UFS_TRUNCATE(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd)
-#define	UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb)
-#define	UFS_VALLOC(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd)
-#define	UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc)
-#define	UFS_IFREE(aa, bb) ((aa)->um_ifree(aa, bb))
-#define	UFS_RDONLY(aa) (ITOUMP(aa)->um_rdonly(aa))
-#define	UFS_SNAPGONE(aa) (ITOUMP(aa)->um_snapgone(aa))
-
-#define	UFS_LOCK(aa)	mtx_lock(&(aa)->um_lock)
-#define	UFS_UNLOCK(aa)	mtx_unlock(&(aa)->um_lock)
-#define	UFS_MTX(aa)	(&(aa)->um_lock)
-*/
-/*
- * Filesystem types
- */
-#define	UFS1	1
-#define	UFS2	2
-
-/*
- * Flags describing the state of quotas.
- */
-#define	QTF_OPENING	0x01			/* Q_QUOTAON in progress */
-#define	QTF_CLOSING	0x02			/* Q_QUOTAOFF in progress */
-#define	QTF_64BIT	0x04			/* 64-bit quota file */
-
-/*
- * Macros to access filesystem parameters in the ufsmount structure.
- * Used by ufs_bmap.
- */
-#define	blkptrtodb(ump, b)		((b) << (ump)->um_bptrtodb)
-#define	is_sequential(ump, a, b)	((b) == (a) + ump->um_seqinc)

+ 0 - 79
sys/src/9/ufs/README.acls

@@ -1,79 +0,0 @@
-$FreeBSD$
-
-  UFS Access Control Lists Copyright
-
-The UFS Access Control Lists implementation is copyright Robert Watson,
-and is made available under a Berkeley-style license.
-
-  About UFS Access Control Lists (ACLs)
-
-Access control lists allow the association of fine-grained discretionary
-access control information with files and directories, extending the
-base UNIX permission model in a (mostly) compatible way.  This
-implementation largely follows the POSIX.1e model, and relies on the
-availability of extended attributes to store extended components of
-the ACL, while maintaining the base permission information in the inode.
-
-  Using UFS Access Control Lists (ACLs)
-
-Support for UFS access control lists may be enabled by adding:
-
-	options UFS_ACL
-
-to your kernel configuration.  As ACLs rely on the availability of extended
-attributes, your file systems must have support for extended attributes.
-For UFS2, this is supported natively, so no further configuration is
-necessary.  For UFS1, you must also enable the optional extended attributes
-support documented in README.extattr.  A summary of the instructions
-and ACL-specific information follows.
-
-To enable support for ACLs on a file system, the 'acls' mount flag
-must be set for the file system.  This may be set using the tunefs
-'-a' flag:
-
-	tunefs -a enable /dev/md0a
-
-Or by using the mount-time flag:
-
-	mount -o acls /dev/md0a /mnt
-
-The flag may also be set in /etc/fstab.  Note that mounting a file
-system previously configured for ACLs without ACL-support will result
-in incorrect application of discretionary protections.  Likewise,
-mounting an ACL-enabled file system without kernel support for ACLs
-will result in incorrect application of discretionary protections.  If
-the kernel is not configured for ACL support, a warning will be
-printed by the kernel at mount-time.  For reliability purposes, it
-is recommended that the superblock flag be used instead of the
-mount-time flag, as this will avoid re-mount isses with the root file
-system.  For reliability and performance reasons, the use of ACLs on
-UFS1 is discouraged; UFS2 extended attributes provide a more reliable
-storage mechanism for ACLs.
-
-Currently, support for ACLs on UFS1 requires the use of UFS1 EAs, which may
-be enabled by adding:
-
-	options UFS_EXTATTR
-
-to your kernel configuration file and rebuilding.  Because of filesystem
-mount atomicity requirements, it is also recommended that:
-
-	options UFS_EXTATTR_AUTOSTART
-
-be added to the kernel so as to support the atomic enabling of the
-required extended attributes with the filesystem mount operation.  To
-enable ACLs, two extended attributes must be available in the
-EXTATTR_NAMESPACE_SYSTEM namespace: "posix1e.acl_access", which holds
-the access ACL, and "posix1e.acl_default" which holds the default ACL
-for directories.  If you're using UFS1 Extended Attributes, the following
-commands may be used to create the necessary EA backing files for
-ACLs in the filesystem root of each filesystem.  In these examples,
-the root filesystem is used; see README.extattr for more details.
-
-  mkdir -p /.attribute/system
-  cd /.attribute/system
-  extattrctl initattr -p / 388 posix1e.acl_access
-  extattrctl initattr -p / 388 posix1e.acl_default
-
-On the next mount of the root filesystem, the attributes will be
-automatically started, and ACLs will be enabled.

+ 0 - 91
sys/src/9/ufs/README.extattr

@@ -1,91 +0,0 @@
-$FreeBSD$
-
-  UFS Extended Attributes Copyright
-
-The UFS Extended Attributes implementation is copyright Robert Watson, and
-is made available under a Berkeley-style license.
-
-  About UFS Extended Attributes
-
-Extended attributes allow the association of additional arbitrary
-meta-data with files and directories.  Extended attributes are defined in
-the form name=value, where name is an nul-terminated string in the style
-of a filename, and value is a binary blob of zero or more bytes. The UFS
-extended attribute service layers support for extended attributes onto a
-backing file, in the style of the quota implementation, meaning that it
-requires no underlying format changes in the filesystem.  This design
-choice exchanges simplicity, usability and easy deployment for
-performance.  When defined, extended attribute names exist in a series of
-disjoint namespaces: currently, two namespaces are defined:
-EXTATTR_NAMESPACE_SYSTEM and EXTATTR_NAMESPACE_USER.  The primary
-distinction lies in the protection model: USER EAs are protected using the
-normal inode protections, whereas SYSTEM EAs require privilege to access
-or modify.
-
-  Using UFS Extended Attributes
-
-Support for UFS extended attributes is natively available in UFS2, and
-requires no special configuration.  For reliability, administrative,
-and performance reasons, if you plan to use extended attributes, it
-is recommended that you use UFS2 in preference to UFS1.
-
-Support for UFS extended attributes may be enabled for UFS1 by adding:
-
-	options UFS_EXTATTR
-
-to your kernel configuration file.  This allows UFS-based filesystems to
-support extended attributes, but requires manual administration of EAs
-using the extattrctl tool, including the starting of EA support for each
-filesystem, and the enabling of individual attributes for the file
-system.  The extattrctl utility may be used to initialize backing files
-before first use, to start and stop EA service on a filesystem, and to
-enable and disable named attributes.  The command lines for extattrctl
-take the following forms:
-
-  extattrctl start [path]
-  extattrctl stop [path]
-  extattrctl initattr [-f] [-p path] [attrsize] [attrfile]
-  extattrctl enable [path] [attrnamespace] [attrname] [attrfile]
-  extattrctl disable [path] [attrnamespace] [attrname]
-
-In each case, [path] is used to indicate the mounted filesystem on which
-to perform the operation.  [attrnamespace] refers to the namespace in
-which the attribute is being manipulated, and may be "system" or "user".  
-The [attrname] is the attribute name to use for the operation. The
-[attrfile] argument specifies the attribute backing file to use. When
-using the "initattr" function to initialize a backing file, the maximum
-size of attribute data must be defined in bytes using the [attrsize]
-field.  Optionally, the [-p path] argument may be used to indicate to
-extattrctl that it should pre-allocate space for EA data, rather than
-creating a sparse backing file.  This prevents attribute operations from
-failing in low disk-space conditions (which can be important when EAs are
-used for security purposes), but pre-allocation will consume space
-proportional to the product of the defined maximum attribute size and
-number of attributes on the specified filesystem.
-
-Manual configuration increases administrative overhead, but also
-introduces the possibility of race conditions during filesystem mount, if
-EAs are used to support other features, as starting the EAs manually is
-not atomic with the mount operation.  To address this problem, an
-additional kernel option may be defined to auto-start EAs on a UFS file
-system based on special directories at mount-time:
-
-	options UFS_EXTATTR_AUTOSTART
-
-If this option is defined, UFS will search for a ".attribute"
-sub-directory of the filesystem root during the mount operation.  If it
-is found, EA support will be started for the filesystem.  UFS will then
-search for "system" and "user" sub-directories of the ".attribute"
-directory for any potential backing files, and enable an EA for each valid
-backing file with the name of the backing file as the attribute name.  
-For example, by creating the following tree, the two EAs,
-posix1e.acl_access and posix1e.acl_default will be enabled in the system
-namespace of the root filesystem, reserving space for attribute data:
-
-  mkdir -p /.attribute/system
-  cd /.attribute/system
-  extattrctl initattr -p / 388 posix1e.acl_access
-  extattrctl initattr -p / 388 posix1e.acl_default
-
-On the next mount of the root filesystem, the attributes will be
-automatically started.

+ 0 - 42
sys/src/9/ufs/acl.h

@@ -1,42 +0,0 @@
-/*-
- * Copyright (c) 1999-2001 Robert N. M. Watson
- * All rights reserved.
- *
- * This software was developed by Robert Watson for the TrustedBSD Project.
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-/*
- * Developed by the TrustedBSD Project.
- * Support for POSIX.1e access control lists.
- */
-
-int	ufs_getacl_nfs4_internal(struct vnode *vp, struct acl *aclp, struct thread *td);
-int	ufs_setacl_nfs4_internal(struct vnode *vp, struct acl *aclp, struct thread *td);
-void	ufs_sync_acl_from_inode(struct inode *ip, struct acl *acl);
-void	ufs_sync_inode_from_acl(struct acl *acl, struct inode *ip);
-
-int	ufs_getacl(struct vop_getacl_args *);
-int	ufs_setacl(struct vop_setacl_args *);
-int	ufs_aclcheck(struct vop_aclcheck_args *);

+ 0 - 126
sys/src/9/ufs/dirhash.h

@@ -1,126 +0,0 @@
-/*-
- * Copyright (c) 2001 Ian Dowse.  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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-/*
- * For fast operations on large directories, we maintain a hash
- * that maps the file name to the offset of the directory entry within
- * the directory file.
- *
- * The hashing uses a dumb spillover to the next free slot on
- * collisions, so we must keep the utilisation low to avoid
- * long linear searches. Deleted entries that are not the last
- * in a chain must be marked DIRHASH_DEL.
- *
- * We also maintain information about free space in each block
- * to speed up creations.
- */
-#define	DIRHASH_EMPTY	(-1)	/* entry unused */
-#define	DIRHASH_DEL	(-2)	/* deleted entry; may be part of chain */
-
-#define	DIRALIGN	4
-#define	DH_NFSTATS	(DIRECTSIZ(UFS_MAXNAMLEN + 1) / DIRALIGN)
-				 /* max DIRALIGN words in a directory entry */
-
-/*
- * Dirhash uses a score mechanism to achieve a hybrid between a
- * least-recently-used and a least-often-used algorithm for entry
- * recycling. The score is incremented when a directory is used, and
- * decremented when the directory is a candidate for recycling. When
- * the score reaches zero, the hash is recycled. Hashes are linked
- * together on a TAILQ list, and hashes with higher scores filter
- * towards the tail (most recently used) end of the list.
- *
- * New hash entries are given an initial score of DH_SCOREINIT and are
- * placed at the most-recently-used end of the list. This helps a lot
- * in the worst-case case scenario where every directory access is
- * to a directory that is not hashed (i.e. the working set of hash
- * candidates is much larger than the configured memry limit). In this
- * case it limits the number of hash builds to 1/DH_SCOREINIT of the
- * number of accesses.
- */ 
-#define	DH_SCOREINIT	8	/* initial dh_score when dirhash built */
-#define	DH_SCOREMAX	64	/* max dh_score value */
-
-/*
- * The main hash table has 2 levels. It is an array of pointers to
- * blocks of DH_NBLKOFF offsets.
- */
-#define	DH_BLKOFFSHIFT	8
-#define	DH_NBLKOFF	(1 << DH_BLKOFFSHIFT)
-#define	DH_BLKOFFMASK	(DH_NBLKOFF - 1)
-
-#define	DH_ENTRY(dh, slot) \
-    ((dh)->dh_hash[(slot) >> DH_BLKOFFSHIFT][(slot) & DH_BLKOFFMASK])
-
-struct dirhash {
-	struct sx dh_lock;	/* protects all fields except list & score */
-	int	dh_refcount;
-
-	doff_t	**dh_hash;	/* the hash array (2-level) */
-	int	dh_narrays;	/* number of entries in dh_hash */
-	int	dh_hlen;	/* total slots in the 2-level hash array */
-	int	dh_hused;	/* entries in use */
-	int	dh_memreq;	/* Memory used. */
-
-	/* Free space statistics. XXX assumes DIRBLKSIZ is 512. */
-	uint8_t *dh_blkfree;	/* free DIRALIGN words in each dir block */
-	int	dh_nblk;	/* size of dh_blkfree array */
-	int	dh_dirblks;	/* number of DIRBLKSIZ blocks in dir */
-	int	dh_firstfree[DH_NFSTATS + 1]; /* first blk with N words free */
-
-	doff_t	dh_seqoff;	/* sequential access optimisation offset */
-
-	int	dh_score;	/* access count for this dirhash */
-
-	int	dh_onlist;	/* true if on the ufsdirhash_list chain */
-
-	time_t	dh_lastused;	/* time the dirhash was last read or written*/
-
-	/* Protected by ufsdirhash_mtx. */
-	TAILQ_ENTRY(dirhash) dh_list;	/* chain of all dirhashes */
-};
-
-
-/*
- * Dirhash functions.
- */
-void	ufsdirhash_init(void);
-void	ufsdirhash_uninit(void);
-int	ufsdirhash_build(struct inode *);
-doff_t	ufsdirhash_findfree(struct inode *, int, int *);
-doff_t	ufsdirhash_enduseful(struct inode *);
-int	ufsdirhash_lookup(struct inode *, char *, int, doff_t *, struct buf **,
-	    doff_t *);
-void	ufsdirhash_newblk(struct inode *, doff_t);
-void	ufsdirhash_add(struct inode *, struct direct *, doff_t);
-void	ufsdirhash_remove(struct inode *, struct direct *, doff_t);
-void	ufsdirhash_move(struct inode *, struct direct *, doff_t, doff_t);
-void	ufsdirhash_dirtrunc(struct inode *, doff_t);
-void	ufsdirhash_free(struct inode *);
-
-void	ufsdirhash_checkblock(struct inode *, char *, doff_t);
-

+ 0 - 134
sys/src/9/ufs/extattr.h

@@ -1,134 +0,0 @@
-/*-
- * Copyright (c) 1999-2001 Robert N. M. Watson
- * All rights reserved.
- *
- * This software was developed by Robert Watson for the TrustedBSD Project.
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-/*
- * Developed by the TrustedBSD Project.
- * Support for extended filesystem attributes.
- */
-
-#define	UFS_EXTATTR_MAGIC		0x00b5d5ec
-#define	UFS_EXTATTR_VERSION		0x00000003
-#define	UFS_EXTATTR_FSROOTSUBDIR	".attribute"
-#define	UFS_EXTATTR_SUBDIR_SYSTEM	"system"
-#define	UFS_EXTATTR_SUBDIR_USER		"user"
-#define	UFS_EXTATTR_MAXEXTATTRNAME	65	/* including null */
-
-#define	UFS_EXTATTR_ATTR_FLAG_INUSE	0x00000001	/* attr has been set */
-#define	UFS_EXTATTR_PERM_KERNEL		0x00000000
-#define	UFS_EXTATTR_PERM_ROOT		0x00000001
-#define	UFS_EXTATTR_PERM_OWNER		0x00000002
-#define	UFS_EXTATTR_PERM_ANYONE		0x00000003
-
-#define	UFS_EXTATTR_UEPM_INITIALIZED	0x00000001
-#define	UFS_EXTATTR_UEPM_STARTED	0x00000002
-
-#define	UFS_EXTATTR_CMD_START		0x00000001
-#define	UFS_EXTATTR_CMD_STOP		0x00000002
-#define	UFS_EXTATTR_CMD_ENABLE		0x00000003
-#define	UFS_EXTATTR_CMD_DISABLE		0x00000004
-
-struct ufs_extattr_fileheader {
-	uint	uef_magic;	/* magic number for sanity checking */
-	uint	uef_version;	/* version of attribute file */
-	uint	uef_size;	/* size of attributes, w/o header */
-};
-
-struct ufs_extattr_header {
-	uint	ueh_flags;	/* flags for attribute */
-	uint	ueh_len;	/* local defined length; <= uef_size */
-	uint32_t	ueh_i_gen;	/* generation number for sanity */
-	/* data follows the header */
-};
-
-/*
- * This structure defines the required fields of an extended-attribute header.
- */
-struct extattr {
-	uint32_t ea_length;	    /* length of this attribute */
-	uint8_t	ea_namespace;	    /* name space of this attribute */
-	uint8_t	ea_contentpadlen;   /* bytes of padding at end of attribute */
-	uint8_t	ea_namelength;	    /* length of attribute name */
-	char	ea_name[1];	    /* attribute name (NOT nul-terminated) */
-	/* padding, if any, to align attribute content to 8 byte boundary */
-	/* extended attribute content follows */
-};
-
-/*
- * These macros are used to access and manipulate an extended attribute:
- *
- * EXTATTR_NEXT(eap) returns a pointer to the next extended attribute
- *	following eap.
- * EXTATTR_CONTENT(eap) returns a pointer to the extended attribute
- *	content referenced by eap.
- * EXTATTR_CONTENT_SIZE(eap) returns the size of the extended attribute
- *	content referenced by eap.
- */
-#define	EXTATTR_NEXT(eap) \
-	((struct extattr *)(((uint8_t *)(eap)) + (eap)->ea_length))
-#define	EXTATTR_CONTENT(eap) \
-	(void *)(((uint8_t *)(eap)) + EXTATTR_BASE_LENGTH(eap))
-#define	EXTATTR_CONTENT_SIZE(eap) \
-	((eap)->ea_length - EXTATTR_BASE_LENGTH(eap) - (eap)->ea_contentpadlen)
-/* -1 below compensates for ea_name[1] */
-#define	EXTATTR_BASE_LENGTH(eap) \
-	roundup2((sizeof(struct extattr) - 1 + (eap)->ea_namelength), 8)
-
-struct vnode;
-LIST_HEAD(ufs_extattr_list_head, ufs_extattr_list_entry);
-struct ufs_extattr_list_entry {
-	LIST_ENTRY(ufs_extattr_list_entry)	uele_entries;
-	struct ufs_extattr_fileheader		uele_fileheader;
-	int	uele_attrnamespace;
-	char	uele_attrname[UFS_EXTATTR_MAXEXTATTRNAME];
-	struct vnode	*uele_backing_vnode;
-};
-
-struct ucred;
-struct ufs_extattr_per_mount {
-	struct sx	uepm_lock;
-	struct ufs_extattr_list_head	uepm_list;
-	struct ucred	*uepm_ucred;
-	int	uepm_flags;
-};
-
-struct vop_getextattr_args;
-struct vop_deleteextattr_args;
-struct vop_setextattr_args;
-
-void	ufs_extattr_uepm_init(struct ufs_extattr_per_mount *uepm);
-void	ufs_extattr_uepm_destroy(struct ufs_extattr_per_mount *uepm);
-int	ufs_extattr_start(struct mount *mp, struct thread *td);
-int	ufs_extattr_autostart(struct mount *mp, struct thread *td);
-int	ufs_extattr_stop(struct mount *mp, struct thread *td);
-int	ufs_extattrctl(struct mount *mp, int cmd, struct vnode *filename,
-	    int attrnamespace, const char *attrname);
-int	ufs_getextattr(struct vop_getextattr_args *ap);
-int	ufs_deleteextattr(struct vop_deleteextattr_args *ap);
-int	ufs_setextattr(struct vop_setextattr_args *ap);
-void	ufs_extattr_vnode_inactive(struct vnode *vp, struct thread *td);

File diff suppressed because it is too large
+ 0 - 3194
sys/src/9/ufs/ffs_alloc.c


+ 0 - 678
sys/src/9/ufs/ffs_balloc.c

@@ -1,678 +0,0 @@
-/*-
- * 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
- *
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
- *
- * Copyright (c) 1982, 1986, 1989, 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_balloc.c	8.8 (Berkeley) 6/16/95
- */
-
-#include "u.h"
-#include "port/lib.h"
-#include "mem.h"
-#include "dat.h"
-#include "fns.h"
-
-#include "ufs/ufsdat.h"
-#include <ufs/libufsdat.h>
-#include <ufs/freebsd_util.h>
-
-//#include <ufs/ufs/quota.h>
-//#include <ufs/ufs/inode.h>
-//#include <ufs/ufs/ufs_extern.h>
-//#include <ufs/ufs/extattr.h>
-//#include <ufs/ufs/ufsmount.h>
-
-//#include <ufs/ffs/fs.h>
-//#include <ufs/ffs/ffs_extern.h>
-
-
-/*
- * Balloc defines the structure of file system storage
- * by allocating the physical blocks on a device given
- * the inode and the logical block number in a file.
- * This is the allocation strategy for UFS2. Above is
- * the allocation strategy for UFS1.
- */
-int
-ffs_balloc_ufs2(vnode *vp, off_t startoffset, int size,
-    Ucred *cred, int flags, Buf **bpp)
-{
-	int error = 0;
-	print("HARVEY TODO: %s\n", __func__);
-#if 0
-	struct inode *ip;
-	struct ufs2_dinode *dp;
-	ufs_lbn_t lbn, lastlbn;
-	struct fs *fs;
-	struct buf *bp, *nbp;
-	struct ufsmount *ump;
-	struct indir indirs[UFS_NIADDR + 2];
-	ufs2_daddr_t nb, newb, *bap, pref;
-	ufs2_daddr_t *allocib, *blkp, *allocblk, allociblk[UFS_NIADDR + 1];
-	ufs2_daddr_t *lbns_remfree, lbns[UFS_NIADDR + 1];
-	int deallocated, osize, nsize, num, i, error;
-	int unwindidx = -1;
-	int saved_inbdflush;
-	static struct timeval lastfail;
-	static int curfail;
-	int gbflags, reclaimed;
-
-	ip = VTOI(vp);
-	dp = ip->i_din2;
-	fs = ITOFS(ip);
-	ump = ITOUMP(ip);
-	lbn = lblkno(fs, startoffset);
-	size = blkoff(fs, startoffset) + size;
-	reclaimed = 0;
-	if (size > fs->fs_bsize)
-		panic("ffs_balloc_ufs2: blk too big");
-	*bpp = nil;
-	if (lbn < 0)
-		return (EFBIG);
-	gbflags = (flags & BA_UNMAPPED) != 0 ? GB_UNMAPPED : 0;
-
-	if (DOINGSOFTDEP(vp))
-		softdep_prealloc(vp, MNT_WAIT);
-	
-	/*
-	 * Check for allocating external data.
-	 */
-	if (flags & IO_EXT) {
-		if (lbn >= UFS_NXADDR)
-			return (EFBIG);
-		/*
-		 * If the next write will extend the data into a new block,
-		 * and the data is currently composed of a fragment
-		 * this fragment has to be extended to be a full block.
-		 */
-		lastlbn = lblkno(fs, dp->di_extsize);
-		if (lastlbn < lbn) {
-			nb = lastlbn;
-			osize = sblksize(fs, dp->di_extsize, nb);
-			if (osize < fs->fs_bsize && osize > 0) {
-				UFS_LOCK(ump);
-				error = ffs_realloccg(ip, -1 - nb,
-				    dp->di_extb[nb],
-				    ffs_blkpref_ufs2(ip, lastlbn, (int)nb,
-				    &dp->di_extb[0]), osize,
-				    (int)fs->fs_bsize, flags, cred, &bp);
-				if (error)
-					return (error);
-				if (DOINGSOFTDEP(vp))
-					softdep_setup_allocext(ip, nb,
-					    dbtofsb(fs, bp->b_blkno),
-					    dp->di_extb[nb],
-					    fs->fs_bsize, osize, bp);
-				dp->di_extsize = smalllblktosize(fs, nb + 1);
-				dp->di_extb[nb] = dbtofsb(fs, bp->b_blkno);
-				bp->b_xflags |= BX_ALTDATA;
-				ip->i_flag |= IN_CHANGE;
-				if (flags & IO_SYNC)
-					bwrite(bp);
-				else
-					bawrite(bp);
-			}
-		}
-		/*
-		 * All blocks are direct blocks
-		 */
-		if (flags & BA_METAONLY)
-			panic("ffs_balloc_ufs2: BA_METAONLY for ext block");
-		nb = dp->di_extb[lbn];
-		if (nb != 0 && dp->di_extsize >= smalllblktosize(fs, lbn + 1)) {
-			error = bread_gb(vp, -1 - lbn, fs->fs_bsize, NOCRED,
-			    gbflags, &bp);
-			if (error) {
-				brelse(bp);
-				return (error);
-			}
-			bp->b_blkno = fsbtodb(fs, nb);
-			bp->b_xflags |= BX_ALTDATA;
-			*bpp = bp;
-			return (0);
-		}
-		if (nb != 0) {
-			/*
-			 * Consider need to reallocate a fragment.
-			 */
-			osize = fragroundup(fs, blkoff(fs, dp->di_extsize));
-			nsize = fragroundup(fs, size);
-			if (nsize <= osize) {
-				error = bread_gb(vp, -1 - lbn, osize, NOCRED,
-				    gbflags, &bp);
-				if (error) {
-					brelse(bp);
-					return (error);
-				}
-				bp->b_blkno = fsbtodb(fs, nb);
-				bp->b_xflags |= BX_ALTDATA;
-			} else {
-				UFS_LOCK(ump);
-				error = ffs_realloccg(ip, -1 - lbn,
-				    dp->di_extb[lbn],
-				    ffs_blkpref_ufs2(ip, lbn, (int)lbn,
-				    &dp->di_extb[0]), osize, nsize, flags,
-				    cred, &bp);
-				if (error)
-					return (error);
-				bp->b_xflags |= BX_ALTDATA;
-				if (DOINGSOFTDEP(vp))
-					softdep_setup_allocext(ip, lbn,
-					    dbtofsb(fs, bp->b_blkno), nb,
-					    nsize, osize, bp);
-			}
-		} else {
-			if (dp->di_extsize < smalllblktosize(fs, lbn + 1))
-				nsize = fragroundup(fs, size);
-			else
-				nsize = fs->fs_bsize;
-			UFS_LOCK(ump);
-			error = ffs_alloc(ip, lbn,
-			   ffs_blkpref_ufs2(ip, lbn, (int)lbn, &dp->di_extb[0]),
-			   nsize, flags, cred, &newb);
-			if (error)
-				return (error);
-			bp = getblk(vp, -1 - lbn, nsize, 0, 0, gbflags);
-			bp->b_blkno = fsbtodb(fs, newb);
-			bp->b_xflags |= BX_ALTDATA;
-			if (flags & BA_CLRBUF)
-				vfs_bio_clrbuf(bp);
-			if (DOINGSOFTDEP(vp))
-				softdep_setup_allocext(ip, lbn, newb, 0,
-				    nsize, 0, bp);
-		}
-		dp->di_extb[lbn] = dbtofsb(fs, bp->b_blkno);
-		ip->i_flag |= IN_CHANGE;
-		*bpp = bp;
-		return (0);
-	}
-	/*
-	 * If the next write will extend the file into a new block,
-	 * and the file is currently composed of a fragment
-	 * this fragment has to be extended to be a full block.
-	 */
-	lastlbn = lblkno(fs, ip->i_size);
-	if (lastlbn < UFS_NDADDR && lastlbn < lbn) {
-		nb = lastlbn;
-		osize = blksize(fs, ip, nb);
-		if (osize < fs->fs_bsize && osize > 0) {
-			UFS_LOCK(ump);
-			error = ffs_realloccg(ip, nb, dp->di_db[nb],
-			    ffs_blkpref_ufs2(ip, lastlbn, (int)nb,
-			    &dp->di_db[0]), osize, (int)fs->fs_bsize,
-			    flags, cred, &bp);
-			if (error)
-				return (error);
-			if (DOINGSOFTDEP(vp))
-				softdep_setup_allocdirect(ip, nb,
-				    dbtofsb(fs, bp->b_blkno),
-				    dp->di_db[nb],
-				    fs->fs_bsize, osize, bp);
-			ip->i_size = smalllblktosize(fs, nb + 1);
-			dp->di_size = ip->i_size;
-			dp->di_db[nb] = dbtofsb(fs, bp->b_blkno);
-			ip->i_flag |= IN_CHANGE | IN_UPDATE;
-			if (flags & IO_SYNC)
-				bwrite(bp);
-			else
-				bawrite(bp);
-		}
-	}
-	/*
-	 * The first UFS_NDADDR blocks are direct blocks
-	 */
-	if (lbn < UFS_NDADDR) {
-		if (flags & BA_METAONLY)
-			panic("ffs_balloc_ufs2: BA_METAONLY for direct block");
-		nb = dp->di_db[lbn];
-		if (nb != 0 && ip->i_size >= smalllblktosize(fs, lbn + 1)) {
-			error = bread_gb(vp, lbn, fs->fs_bsize, NOCRED,
-			    gbflags, &bp);
-			if (error) {
-				brelse(bp);
-				return (error);
-			}
-			bp->b_blkno = fsbtodb(fs, nb);
-			*bpp = bp;
-			return (0);
-		}
-		if (nb != 0) {
-			/*
-			 * Consider need to reallocate a fragment.
-			 */
-			osize = fragroundup(fs, blkoff(fs, ip->i_size));
-			nsize = fragroundup(fs, size);
-			if (nsize <= osize) {
-				error = bread_gb(vp, lbn, osize, NOCRED,
-				    gbflags, &bp);
-				if (error) {
-					brelse(bp);
-					return (error);
-				}
-				bp->b_blkno = fsbtodb(fs, nb);
-			} else {
-				UFS_LOCK(ump);
-				error = ffs_realloccg(ip, lbn, dp->di_db[lbn],
-				    ffs_blkpref_ufs2(ip, lbn, (int)lbn,
-				    &dp->di_db[0]), osize, nsize, flags,
-				    cred, &bp);
-				if (error)
-					return (error);
-				if (DOINGSOFTDEP(vp))
-					softdep_setup_allocdirect(ip, lbn,
-					    dbtofsb(fs, bp->b_blkno), nb,
-					    nsize, osize, bp);
-			}
-		} else {
-			if (ip->i_size < smalllblktosize(fs, lbn + 1))
-				nsize = fragroundup(fs, size);
-			else
-				nsize = fs->fs_bsize;
-			UFS_LOCK(ump);
-			error = ffs_alloc(ip, lbn,
-			    ffs_blkpref_ufs2(ip, lbn, (int)lbn,
-				&dp->di_db[0]), nsize, flags, cred, &newb);
-			if (error)
-				return (error);
-			bp = getblk(vp, lbn, nsize, 0, 0, gbflags);
-			bp->b_blkno = fsbtodb(fs, newb);
-			if (flags & BA_CLRBUF)
-				vfs_bio_clrbuf(bp);
-			if (DOINGSOFTDEP(vp))
-				softdep_setup_allocdirect(ip, lbn, newb, 0,
-				    nsize, 0, bp);
-		}
-		dp->di_db[lbn] = dbtofsb(fs, bp->b_blkno);
-		ip->i_flag |= IN_CHANGE | IN_UPDATE;
-		*bpp = bp;
-		return (0);
-	}
-	/*
-	 * Determine the number of levels of indirection.
-	 */
-	pref = 0;
-	if ((error = ufs_getlbns(vp, lbn, indirs, &num)) != 0)
-		return(error);
-#ifdef INVARIANTS
-	if (num < 1)
-		panic ("ffs_balloc_ufs2: ufs_getlbns returned indirect block");
-#endif
-	saved_inbdflush = curthread_pflags_set(TDP_INBDFLUSH);
-	/*
-	 * Fetch the first indirect block allocating if necessary.
-	 */
-	--num;
-	nb = dp->di_ib[indirs[0].in_off];
-	allocib = nil;
-	allocblk = allociblk;
-	lbns_remfree = lbns;
-	if (nb == 0) {
-		UFS_LOCK(ump);
-		pref = ffs_blkpref_ufs2(ip, lbn, -indirs[0].in_off - 1,
-		    (ufs2_daddr_t *)0);
-		if ((error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize,
-		    flags, cred, &newb)) != 0) {
-			curthread_pflags_restore(saved_inbdflush);
-			return (error);
-		}
-		pref = newb + fs->fs_frag;
-		nb = newb;
-		MPASS(allocblk < allociblk + nitems(allociblk));
-		MPASS(lbns_remfree < lbns + nitems(lbns));
-		*allocblk++ = nb;
-		*lbns_remfree++ = indirs[1].in_lbn;
-		bp = getblk(vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0,
-		    GB_UNMAPPED);
-		bp->b_blkno = fsbtodb(fs, nb);
-		vfs_bio_clrbuf(bp);
-		if (DOINGSOFTDEP(vp)) {
-			softdep_setup_allocdirect(ip,
-			    UFS_NDADDR + indirs[0].in_off, newb, 0,
-			    fs->fs_bsize, 0, bp);
-			bdwrite(bp);
-		} else if ((flags & IO_SYNC) == 0 && DOINGASYNC(vp)) {
-			if (bp->b_bufsize == fs->fs_bsize)
-				bp->b_flags |= B_CLUSTEROK;
-			bdwrite(bp);
-		} else {
-			if ((error = bwrite(bp)) != 0)
-				goto fail;
-		}
-		allocib = &dp->di_ib[indirs[0].in_off];
-		*allocib = nb;
-		ip->i_flag |= IN_CHANGE | IN_UPDATE;
-	}
-	/*
-	 * Fetch through the indirect blocks, allocating as necessary.
-	 */
-retry:
-	for (i = 1;;) {
-		error = bread(vp,
-		    indirs[i].in_lbn, (int)fs->fs_bsize, NOCRED, &bp);
-		if (error) {
-			brelse(bp);
-			goto fail;
-		}
-		bap = (ufs2_daddr_t *)bp->b_data;
-		nb = bap[indirs[i].in_off];
-		if (i == num)
-			break;
-		i += 1;
-		if (nb != 0) {
-			bqrelse(bp);
-			continue;
-		}
-		UFS_LOCK(ump);
-		/*
-		 * If parent indirect has just been allocated, try to cluster
-		 * immediately following it.
-		 */
-		if (pref == 0)
-			pref = ffs_blkpref_ufs2(ip, lbn, i - num - 1,
-			    (ufs2_daddr_t *)0);
-		if ((error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize,
-		    flags | IO_BUFLOCKED, cred, &newb)) != 0) {
-			brelse(bp);
-			if (DOINGSOFTDEP(vp) && ++reclaimed == 1) {
-				UFS_LOCK(ump);
-				softdep_request_cleanup(fs, vp, cred,
-				    FLUSH_BLOCKS_WAIT);
-				UFS_UNLOCK(ump);
-				goto retry;
-			}
-			if (ppsratecheck(&lastfail, &curfail, 1)) {
-				ffs_fserr(fs, ip->i_number, "filesystem full");
-				uprintf("\n%s: write failed, filesystem "
-				    "is full\n", fs->fs_fsmnt);
-			}
-			goto fail;
-		}
-		pref = newb + fs->fs_frag;
-		nb = newb;
-		MPASS(allocblk < allociblk + nitems(allociblk));
-		MPASS(lbns_remfree < lbns + nitems(lbns));
-		*allocblk++ = nb;
-		*lbns_remfree++ = indirs[i].in_lbn;
-		nbp = getblk(vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0,
-		    GB_UNMAPPED);
-		nbp->b_blkno = fsbtodb(fs, nb);
-		vfs_bio_clrbuf(nbp);
-		if (DOINGSOFTDEP(vp)) {
-			softdep_setup_allocindir_meta(nbp, ip, bp,
-			    indirs[i - 1].in_off, nb);
-			bdwrite(nbp);
-		} else if ((flags & IO_SYNC) == 0 && DOINGASYNC(vp)) {
-			if (nbp->b_bufsize == fs->fs_bsize)
-				nbp->b_flags |= B_CLUSTEROK;
-			bdwrite(nbp);
-		} else {
-			if ((error = bwrite(nbp)) != 0) {
-				brelse(bp);
-				goto fail;
-			}
-		}
-		bap[indirs[i - 1].in_off] = nb;
-		if (allocib == nil && unwindidx < 0)
-			unwindidx = i - 1;