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.
This commit is contained in:
dholland 2013-06-08 02:04:31 +00:00
parent ba39e0d4ed
commit eb628b88b7
6 changed files with 241 additions and 178 deletions

View File

@ -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 INCSDIR= /usr/include/ufs/lfs
INCS= lfs.h lfs_extern.h INCS= lfs.h lfs_inode.h lfs_extern.h
.include <bsd.kinc.mk> .include <bsd.kinc.mk>

View File

@ -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. * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc.
@ -180,6 +180,19 @@ typedef struct lfs_res_blk {
#define LFS_N_BPP 2 #define LFS_N_BPP 2
#define LFS_N_SEG 2 #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 * "struct buf" associated definitions
*/ */

218
sys/ufs/lfs/lfs_inode.h Normal file
View File

@ -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_ */

View File

@ -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 */ /* from NetBSD: dir.h,v 1.21 2009/07/22 04:49:19 dholland Exp */
/* /*
@ -40,14 +40,6 @@
#ifndef _UFS_LFS_ULFS_DIR_H_ #ifndef _UFS_LFS_ULFS_DIR_H_
#define _UFS_LFS_ULFS_DIR_H_ #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 * A directory consists of some number of blocks of DIRBLKSIZ
* bytes, where DIRBLKSIZ is chosen such that it can be transferred * bytes, where DIRBLKSIZ is chosen such that it can be transferred

View File

@ -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 */ /* 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_ #define _UFS_LFS_ULFS_INODE_H_
#include <sys/vnode.h> #include <sys/vnode.h>
#include <ufs/lfs/lfs_inode.h>
#include <ufs/lfs/ulfs_dinode.h> #include <ufs/lfs/ulfs_dinode.h>
#include <ufs/lfs/ulfs_dir.h> #include <ufs/lfs/ulfs_dir.h>
#include <ufs/lfs/ulfs_quotacommon.h> #include <ufs/lfs/ulfs_quotacommon.h>
#include <miscfs/genfs/genfs_node.h>
/*
* 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 */
#if defined(_KERNEL) #if defined(_KERNEL)
/* /*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ulfs_quotacommon.h,v 1.3 2013/06/06 00:49:28 dholland Exp $ */ /* $NetBSD: ulfs_quotacommon.h,v 1.4 2013/06/08 02:04:31 dholland Exp $ */
/* from NetBSD: quota.h,v 1.30 2012/08/26 02:32:14 dholland Exp */ /* from NetBSD: quota.h,v 1.30 2012/08/26 02:32:14 dholland Exp */
/* /*
@ -38,22 +38,14 @@
#ifndef _UFS_LFS_ULFS_QUOTACOMMON_H_ #ifndef _UFS_LFS_ULFS_QUOTACOMMON_H_
#define _UFS_LFS_ULFS_QUOTACOMMON_H_ #define _UFS_LFS_ULFS_QUOTACOMMON_H_
#include <ufs/lfs/lfs.h>
#include <ufs/lfs/lfs_inode.h>
/* /*
* These definitions are common to the original disk quota implementation * These definitions are common to the original disk quota implementation
* (quota1) and the newer implementation (quota2) * (quota1) and the newer implementation (quota2)
*/ */
/*
* 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 */
/* /*
* Initializer for the strings corresponding to the quota ID types. * Initializer for the strings corresponding to the quota ID types.
* (in quota1 these are also the default names of the quota files) * (in quota1 these are also the default names of the quota files)