Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/lfs Split the definitions suitable for userland out ...



details:   https://anonhg.NetBSD.org/src/rev/efcd24092cb4
branches:  trunk
changeset: 787237:efcd24092cb4
user:      dholland <dholland%NetBSD.org@localhost>
date:      Sat Jun 08 02:04:31 2013 +0000

description:
Split the definitions suitable for userland out of ulfs_inode.h into
lfs_inode.h. Since fsck_lfs, newfs_lfs, and lfs_cleanerd want to reuse
the inode structure for their own internal use, and some of them share
parts of the kernel code as well, the best way forward is to provide a
relatively sanitized header that doesn't bring in stray material.

Shuffle a few other definitions around so that lfs_inode.h depends
only on lfs.h.

Install lfs_inode.h into /usr/include.

diffstat:

 sys/ufs/lfs/Makefile           |    4 +-
 sys/ufs/lfs/lfs.h              |   15 ++-
 sys/ufs/lfs/lfs_inode.h        |  218 +++++++++++++++++++++++++++++++++++++++++
 sys/ufs/lfs/ulfs_dir.h         |   10 +-
 sys/ufs/lfs/ulfs_inode.h       |  156 +----------------------------
 sys/ufs/lfs/ulfs_quotacommon.h |   16 +--
 6 files changed, 241 insertions(+), 178 deletions(-)

diffs (truncated from 498 to 300 lines):

diff -r 657621bc1e9a -r efcd24092cb4 sys/ufs/lfs/Makefile
--- a/sys/ufs/lfs/Makefile      Sat Jun 08 00:37:33 2013 +0000
+++ b/sys/ufs/lfs/Makefile      Sat Jun 08 02:04:31 2013 +0000
@@ -1,7 +1,7 @@
-#      $NetBSD: Makefile,v 1.1 1998/06/12 23:23:12 cgd Exp $
+#      $NetBSD: Makefile,v 1.2 2013/06/08 02:04:31 dholland Exp $
 
 INCSDIR= /usr/include/ufs/lfs
 
-INCS=  lfs.h lfs_extern.h
+INCS=  lfs.h lfs_inode.h lfs_extern.h
 
 .include <bsd.kinc.mk>
diff -r 657621bc1e9a -r efcd24092cb4 sys/ufs/lfs/lfs.h
--- a/sys/ufs/lfs/lfs.h Sat Jun 08 00:37:33 2013 +0000
+++ b/sys/ufs/lfs/lfs.h Sat Jun 08 02:04:31 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lfs.h,v 1.141 2013/06/06 00:52:14 dholland Exp $       */
+/*     $NetBSD: lfs.h,v 1.142 2013/06/08 02:04:31 dholland Exp $       */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@@ -181,6 +181,19 @@
 #define LFS_N_SEG      2
 
 /*
+ * Directories
+ */
+
+/*
+ * 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        lfs_doff_t      int32_t
+#define        MAXDIRSIZE      (0x7fffffff)
+
+/*
  * "struct buf" associated definitions
  */
 
diff -r 657621bc1e9a -r efcd24092cb4 sys/ufs/lfs/lfs_inode.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/ufs/lfs/lfs_inode.h   Sat Jun 08 02:04:31 2013 +0000
@@ -0,0 +1,218 @@
+/*     $NetBSD: lfs_inode.h,v 1.1 2013/06/08 02:04:31 dholland Exp $   */
+/*  from NetBSD: ulfs_inode.h,v 1.5 2013/06/06 00:51:50 dholland Exp  */
+/*  from NetBSD: inode.h,v 1.64 2012/11/19 00:36:21 jakllsch Exp  */
+
+/*
+ * 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
+ */
+
+#ifndef _UFS_LFS_LFS_INODE_H_
+#define        _UFS_LFS_LFS_INODE_H_
+
+/*
+ * Some of the userlevel code (fsck, newfs, lfs_cleanerd) wants to use
+ * the in-memory inode structure in a faked-up kernel environment.
+ * This header file provides a reasonably sanitized version of the
+ * structures and definitions needed for that purpose.
+ */
+
+#include <miscfs/genfs/genfs_node.h>
+#include <ufs/lfs/lfs.h>
+
+/*
+ * The following constants define the usage of the quota file array in the
+ * ulfsmount structure and dquot array in the inode structure.  The semantics
+ * of the elements of these arrays are defined in the routine lfs_getinoquota;
+ * the remainder of the quota code treats them generically and need not be
+ * inspected when changing the size of the array.
+ */
+#define        ULFS_MAXQUOTAS  2
+#define        ULFS_USRQUOTA   0       /* element used for user quotas */
+#define        ULFS_GRPQUOTA   1       /* element used for group quotas */
+
+/*
+ * Lookup result state (other than the result inode). This is
+ * currently stashed in the vnode between VOP_LOOKUP and directory
+ * operation VOPs, which is gross.
+ *
+ * XXX ulr_diroff is a lookup hint from the previos call of VOP_LOOKUP.
+ * probably it should not be here.
+ */
+struct ulfs_lookup_results {
+       int32_t   ulr_count;    /* Size of free slot in directory. */
+       doff_t    ulr_endoff;   /* End of useful stuff in directory. */
+       doff_t    ulr_diroff;   /* Offset in dir, where we found last entry. */
+       doff_t    ulr_offset;   /* Offset of free space in directory. */
+       u_int32_t ulr_reclen;   /* Size of found directory entry. */
+};
+
+/* notyet XXX */
+#define ULFS_CHECK_CRAPCOUNTER(dp) ((void)(dp)->i_crapcounter)
+
+/*
+ * Per-filesystem inode extensions.
+ */
+struct lfs_inode_ext;
+
+/*
+ * The inode is used to describe each active (or recently active) file in the
+ * ULFS 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.
+ */
+struct inode {
+       struct genfs_node i_gnode;
+       LIST_ENTRY(inode) i_hash;/* Hash chain. */
+       TAILQ_ENTRY(inode) i_nextsnap; /* snapshot file list. */
+       struct  vnode *i_vnode; /* Vnode associated with this inode. */
+       struct  ulfsmount *i_ump; /* Mount point associated with this inode. */
+       struct  vnode *i_devvp; /* Vnode for block I/O. */
+       u_int32_t i_flag;       /* flags, see below */
+       dev_t     i_dev;        /* Device associated with the inode. */
+       ino_t     i_number;     /* The identity of the inode. */
+
+       union {                 /* Associated filesystem. */
+               struct  lfs *lfs;       /* LFS */
+       } inode_u;
+#define        i_lfs   inode_u.lfs
+
+       void    *i_unused1;     /* Unused. */
+       struct   dquot *i_dquot[ULFS_MAXQUOTAS]; /* Dquot structures. */
+       u_quad_t i_modrev;      /* Revision level for NFS lease. */
+       struct   lockf *i_lockf;/* Head of byte-level lock list. */
+
+       /*
+        * Side effects; used during (and after) directory lookup.
+        * XXX should not be here.
+        */
+       struct ulfs_lookup_results i_crap;
+       unsigned i_crapcounter; /* serial number for i_crap */
+
+       /*
+        * Inode extensions
+        */
+       union {
+               /* Other extensions could go here... */
+               struct  lfs_inode_ext *lfs;
+       } inode_ext;
+       /*
+        * Copies from the on-disk dinode itself.
+        *
+        * These fields are currently only used by LFS.
+        */
+       u_int16_t i_mode;       /* IFMT, permissions; see below. */
+       int16_t   i_nlink;      /* File link count. */
+       u_int64_t i_size;       /* File byte count. */
+       u_int32_t i_flags;      /* Status flags (chflags). */
+       int32_t   i_gen;        /* Generation number. */
+       u_int32_t i_uid;        /* File owner. */
+       u_int32_t i_gid;        /* File group. */
+       u_int16_t i_omode;      /* Old mode, for ulfs_reclaim. */
+
+       struct dirhash *i_dirhash;      /* Hashing for large directories */
+
+       /*
+        * The on-disk dinode itself.
+        */
+       union {
+               struct  ulfs1_dinode *ffs1_din; /* 128 bytes of the on-disk dinode. */
+               struct  ulfs2_dinode *ffs2_din;
+       } i_din;
+};
+
+#define        i_ffs1_atime            i_din.ffs1_din->di_atime
+#define        i_ffs1_atimensec        i_din.ffs1_din->di_atimensec
+#define        i_ffs1_blocks           i_din.ffs1_din->di_blocks
+#define        i_ffs1_ctime            i_din.ffs1_din->di_ctime
+#define        i_ffs1_ctimensec        i_din.ffs1_din->di_ctimensec
+#define        i_ffs1_db               i_din.ffs1_din->di_db
+#define        i_ffs1_flags            i_din.ffs1_din->di_flags
+#define        i_ffs1_gen              i_din.ffs1_din->di_gen
+#define        i_ffs1_gid              i_din.ffs1_din->di_gid
+#define        i_ffs1_ib               i_din.ffs1_din->di_ib
+#define        i_ffs1_mode             i_din.ffs1_din->di_mode
+#define        i_ffs1_mtime            i_din.ffs1_din->di_mtime
+#define        i_ffs1_mtimensec        i_din.ffs1_din->di_mtimensec
+#define        i_ffs1_nlink            i_din.ffs1_din->di_nlink
+#define        i_ffs1_rdev             i_din.ffs1_din->di_rdev
+#define        i_ffs1_size             i_din.ffs1_din->di_size
+#define        i_ffs1_uid              i_din.ffs1_din->di_uid
+#define        i_ffs1_ouid             i_din.ffs1_din->di_u.oldids[0]
+#define        i_ffs1_ogid             i_din.ffs1_din->di_u.oldids[1]
+
+#define        i_ffs2_atime            i_din.ffs2_din->di_atime
+#define        i_ffs2_atimensec        i_din.ffs2_din->di_atimensec
+#define        i_ffs2_birthtime        i_din.ffs2_din->di_birthtime
+#define        i_ffs2_birthnsec        i_din.ffs2_din->di_birthnsec
+#define        i_ffs2_blocks           i_din.ffs2_din->di_blocks
+#define        i_ffs2_blksize          i_din.ffs2_din->di_blksize
+#define        i_ffs2_ctime            i_din.ffs2_din->di_ctime
+#define        i_ffs2_ctimensec        i_din.ffs2_din->di_ctimensec
+#define        i_ffs2_db               i_din.ffs2_din->di_db
+#define        i_ffs2_flags            i_din.ffs2_din->di_flags
+#define        i_ffs2_gen              i_din.ffs2_din->di_gen
+#define        i_ffs2_gid              i_din.ffs2_din->di_gid
+#define        i_ffs2_ib               i_din.ffs2_din->di_ib
+#define        i_ffs2_mode             i_din.ffs2_din->di_mode
+#define        i_ffs2_mtime            i_din.ffs2_din->di_mtime
+#define        i_ffs2_mtimensec        i_din.ffs2_din->di_mtimensec
+#define        i_ffs2_nlink            i_din.ffs2_din->di_nlink
+#define        i_ffs2_rdev             i_din.ffs2_din->di_rdev
+#define        i_ffs2_size             i_din.ffs2_din->di_size
+#define        i_ffs2_uid              i_din.ffs2_din->di_uid
+#define        i_ffs2_kernflags        i_din.ffs2_din->di_kernflags
+#define        i_ffs2_extsize          i_din.ffs2_din->di_extsize
+#define        i_ffs2_extb             i_din.ffs2_din->di_extb
+
+/* 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          /* Inode was written to; update mtime. */
+#define        IN_MODIFY       0x2000          /* Modification time update request. */
+#define        IN_MODIFIED     0x0008          /* Inode has been modified. */
+#define        IN_ACCESSED     0x0010          /* Inode has been accessed. */
+/* #define     IN_UNUSED       0x0020 */       /* unused, was IN_RENAME */
+#define        IN_SHLOCK       0x0040          /* File has shared lock. */
+#define        IN_EXLOCK       0x0080          /* File has exclusive lock. */
+#define        IN_CLEANING     0x0100          /* LFS: file is being cleaned */
+#define        IN_ADIROP       0x0200          /* LFS: dirop in progress */
+#define        IN_SPACECOUNTED 0x0400          /* Blocks to be freed in free count. */
+#define        IN_PAGING       0x1000          /* LFS: file is on paging queue */
+#define IN_CDIROP       0x4000          /* LFS: dirop completed pending i/o */
+
+#endif /* _UFS_LFS_LFS_INODE_H_ */
diff -r 657621bc1e9a -r efcd24092cb4 sys/ufs/lfs/ulfs_dir.h
--- a/sys/ufs/lfs/ulfs_dir.h    Sat Jun 08 00:37:33 2013 +0000
+++ b/sys/ufs/lfs/ulfs_dir.h    Sat Jun 08 02:04:31 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ulfs_dir.h,v 1.3 2013/06/06 01:25:25 dholland Exp $    */
+/*     $NetBSD: ulfs_dir.h,v 1.4 2013/06/08 02:04:31 dholland Exp $    */
 /*  from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp  */
 
 /*
@@ -41,14 +41,6 @@
 #define        _UFS_LFS_ULFS_DIR_H_
 
 /*
- * Theoretically, directories can be more than 2Gb in length; however, in
- * practice this seems unlikely. So, we define the type doff_t as a 32-bit
- * quantity to keep down the cost of doing lookup on a 32-bit machine.
- */
-#define        doff_t          int32_t
-#define        MAXDIRSIZE      (0x7fffffff)
-
-/*
  * A directory consists of some number of blocks of DIRBLKSIZ
  * bytes, where DIRBLKSIZ is chosen such that it can be transferred
  * to disk in a single atomic operation (e.g. 512 bytes on most machines).
diff -r 657621bc1e9a -r efcd24092cb4 sys/ufs/lfs/ulfs_inode.h
--- a/sys/ufs/lfs/ulfs_inode.h  Sat Jun 08 00:37:33 2013 +0000
+++ b/sys/ufs/lfs/ulfs_inode.h  Sat Jun 08 02:04:31 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ulfs_inode.h,v 1.5 2013/06/06 00:51:50 dholland Exp $  */
+/*     $NetBSD: ulfs_inode.h,v 1.6 2013/06/08 02:04:31 dholland Exp $  */
 /*  from NetBSD: inode.h,v 1.64 2012/11/19 00:36:21 jakllsch Exp  */
 
 /*
@@ -41,163 +41,11 @@
 #define        _UFS_LFS_ULFS_INODE_H_
 



Home | Main Index | Thread Index | Old Index