summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/gnu/ext2fs/ext2_bmap.c61
-rw-r--r--sys/gnu/ext2fs/ext2_ihash.c41
-rw-r--r--sys/gnu/ext2fs/ext2_mount.h62
-rw-r--r--sys/gnu/ext2fs/inode.h117
-rw-r--r--sys/gnu/fs/ext2fs/ext2_bmap.c61
-rw-r--r--sys/gnu/fs/ext2fs/ext2_mount.h62
-rw-r--r--sys/gnu/fs/ext2fs/inode.h117
7 files changed, 216 insertions, 305 deletions
diff --git a/sys/gnu/ext2fs/ext2_bmap.c b/sys/gnu/ext2fs/ext2_bmap.c
index 7c43318..c079979 100644
--- a/sys/gnu/ext2fs/ext2_bmap.c
+++ b/sys/gnu/ext2fs/ext2_bmap.c
@@ -49,11 +49,9 @@
#include <sys/resourcevar.h>
#include <sys/stat.h>
-#include <ufs/ufs/extattr.h>
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-#include <ufs/ufs/ufsmount.h>
-#include <ufs/ufs/ufs_extern.h>
+#include <gnu/ext2fs/inode.h>
+#include <gnu/ext2fs/ext2_mount.h>
+#include <gnu/ext2fs/ext2_extern.h>
/*
* Bmap converts a the logical block number of a file to its physical block
@@ -61,7 +59,7 @@
* number to index into the array of block pointers described by the dinode.
*/
int
-ufs_bmap(ap)
+ext2_bmap(ap)
struct vop_bmap_args /* {
struct vnode *a_vp;
daddr_t a_bn;
@@ -83,7 +81,7 @@ ufs_bmap(ap)
if (ap->a_bnp == NULL)
return (0);
- error = ufs_bmaparray(ap->a_vp, ap->a_bn, &blkno,
+ error = ext2_bmaparray(ap->a_vp, ap->a_bn, &blkno,
ap->a_runp, ap->a_runb);
*ap->a_bnp = blkno;
return (error);
@@ -104,20 +102,20 @@ ufs_bmap(ap)
*/
int
-ufs_bmaparray(vp, bn, bnp, runp, runb)
+ext2_bmaparray(vp, bn, bnp, runp, runb)
struct vnode *vp;
- ufs_daddr_t bn;
- ufs_daddr_t *bnp;
+ daddr_t bn;
+ daddr_t *bnp;
int *runp;
int *runb;
{
struct inode *ip;
struct buf *bp;
- struct ufsmount *ump;
+ struct ext2mount *ump;
struct mount *mp;
struct vnode *devvp;
struct indir a[NIADDR+1], *ap;
- ufs_daddr_t daddr;
+ daddr_t daddr;
long metalbn;
int error, num, maxrun = 0;
int *nump;
@@ -125,7 +123,7 @@ ufs_bmaparray(vp, bn, bnp, runp, runb)
ap = NULL;
ip = VTOI(vp);
mp = vp->v_mount;
- ump = VFSTOUFS(mp);
+ ump = VFSTOEXT2(mp);
devvp = ump->um_devvp;
if (runp) {
@@ -140,29 +138,15 @@ ufs_bmaparray(vp, bn, bnp, runp, runb)
ap = a;
nump = &num;
- error = ufs_getlbns(vp, bn, ap, nump);
+ error = ext2_getlbns(vp, bn, ap, nump);
if (error)
return (error);
num = *nump;
if (num == 0) {
*bnp = blkptrtodb(ump, ip->i_db[bn]);
- /*
- * Since this is FFS independent code, we are out of
- * scope for the definitions of BLK_NOCOPY and
- * BLK_SNAP, but we do know that they will fall in
- * the range 1..um_seqinc, so we use that test and
- * return a request for a zeroed out buffer if attempts
- * are made to read a BLK_NOCOPY or BLK_SNAP block.
- */
- if ((ip->i_flags & SF_SNAPSHOT) &&
- ip->i_db[bn] > 0 && ip->i_db[bn] < ump->um_seqinc) {
+ if (*bnp == 0) {
*bnp = -1;
- } else if (*bnp == 0) {
- if (ip->i_flags & SF_SNAPSHOT)
- *bnp = blkptrtodb(ump, bn * ump->um_seqinc);
- else
- *bnp = -1;
} else if (runp) {
daddr_t bnb = bn;
for (++bn; bn < NDADDR && *runp < maxrun &&
@@ -221,13 +205,13 @@ ufs_bmaparray(vp, bn, bnp, runp, runb)
}
}
- daddr = ((ufs_daddr_t *)bp->b_data)[ap->in_off];
+ daddr = ((daddr_t *)bp->b_data)[ap->in_off];
if (num == 1 && daddr && runp) {
for (bn = ap->in_off + 1;
bn < MNINDIR(ump) && *runp < maxrun &&
is_sequential(ump,
- ((ufs_daddr_t *)bp->b_data)[bn - 1],
- ((ufs_daddr_t *)bp->b_data)[bn]);
+ ((daddr_t *)bp->b_data)[bn - 1],
+ ((daddr_t *)bp->b_data)[bn]);
++bn, ++*runp);
bn = ap->in_off;
if (runb && bn) {
@@ -254,10 +238,7 @@ ufs_bmaparray(vp, bn, bnp, runp, runb)
}
*bnp = blkptrtodb(ump, daddr);
if (*bnp == 0) {
- if (ip->i_flags & SF_SNAPSHOT)
- *bnp = blkptrtodb(ump, bn * ump->um_seqinc);
- else
- *bnp = -1;
+ *bnp = -1;
}
return (0);
}
@@ -272,18 +253,18 @@ ufs_bmaparray(vp, bn, bnp, runp, runb)
* once with the offset into the page itself.
*/
int
-ufs_getlbns(vp, bn, ap, nump)
+ext2_getlbns(vp, bn, ap, nump)
struct vnode *vp;
- ufs_daddr_t bn;
+ daddr_t bn;
struct indir *ap;
int *nump;
{
long blockcnt, metalbn, realbn;
- struct ufsmount *ump;
+ struct ext2mount *ump;
int i, numlevels, off;
int64_t qblockcnt;
- ump = VFSTOUFS(vp->v_mount);
+ ump = VFSTOEXT2(vp->v_mount);
if (nump)
*nump = 0;
numlevels = 0;
diff --git a/sys/gnu/ext2fs/ext2_ihash.c b/sys/gnu/ext2fs/ext2_ihash.c
index eda2ab4..d11d4dc 100644
--- a/sys/gnu/ext2fs/ext2_ihash.c
+++ b/sys/gnu/ext2fs/ext2_ihash.c
@@ -43,28 +43,27 @@
#include <sys/proc.h>
#include <sys/mutex.h>
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-#include <ufs/ufs/ufs_extern.h>
+#include <gnu/ext2fs/inode.h>
+#include <gnu/ext2fs/ext2_extern.h>
-static MALLOC_DEFINE(M_UFSIHASH, "UFS ihash", "UFS Inode hash tables");
+static MALLOC_DEFINE(M_EXT2IHASH, "EXT2 ihash", "EXT2 Inode hash tables");
/*
* Structures associated with inode cacheing.
*/
static LIST_HEAD(ihashhead, inode) *ihashtbl;
static u_long ihash; /* size of hash table - 1 */
#define INOHASH(device, inum) (&ihashtbl[(minor(device) + (inum)) & ihash])
-static struct mtx ufs_ihash_mtx;
+static struct mtx ext2_ihash_mtx;
/*
* Initialize inode hash table.
*/
void
-ufs_ihashinit()
+ext2_ihashinit()
{
- ihashtbl = hashinit(desiredvnodes, M_UFSIHASH, &ihash);
- mtx_init(&ufs_ihash_mtx, "ufs ihash", NULL, MTX_DEF);
+ ihashtbl = hashinit(desiredvnodes, M_EXT2IHASH, &ihash);
+ mtx_init(&ext2_ihash_mtx, "ext2 ihash", NULL, MTX_DEF);
}
/*
@@ -72,17 +71,17 @@ ufs_ihashinit()
* to it. If it is in core, return it, even if it is locked.
*/
struct vnode *
-ufs_ihashlookup(dev, inum)
+ext2_ihashlookup(dev, inum)
dev_t dev;
ino_t inum;
{
struct inode *ip;
- mtx_lock(&ufs_ihash_mtx);
+ mtx_lock(&ext2_ihash_mtx);
LIST_FOREACH(ip, INOHASH(dev, inum), i_hash)
if (inum == ip->i_number && dev == ip->i_dev)
break;
- mtx_unlock(&ufs_ihash_mtx);
+ mtx_unlock(&ext2_ihash_mtx);
if (ip)
return (ITOV(ip));
@@ -94,7 +93,7 @@ ufs_ihashlookup(dev, inum)
* to it. If it is in core, but locked, wait for it.
*/
int
-ufs_ihashget(dev, inum, flags, vpp)
+ext2_ihashget(dev, inum, flags, vpp)
dev_t dev;
ino_t inum;
int flags;
@@ -107,12 +106,12 @@ ufs_ihashget(dev, inum, flags, vpp)
*vpp = NULL;
loop:
- mtx_lock(&ufs_ihash_mtx);
+ mtx_lock(&ext2_ihash_mtx);
LIST_FOREACH(ip, INOHASH(dev, inum), i_hash) {
if (inum == ip->i_number && dev == ip->i_dev) {
vp = ITOV(ip);
mtx_lock(&vp->v_interlock);
- mtx_unlock(&ufs_ihash_mtx);
+ mtx_unlock(&ext2_ihash_mtx);
error = vget(vp, flags | LK_INTERLOCK, td);
if (error == ENOENT)
goto loop;
@@ -122,7 +121,7 @@ loop:
return (0);
}
}
- mtx_unlock(&ufs_ihash_mtx);
+ mtx_unlock(&ext2_ihash_mtx);
return (0);
}
@@ -130,7 +129,7 @@ loop:
* Insert the inode into the hash table, and return it locked.
*/
void
-ufs_ihashins(ip)
+ext2_ihashins(ip)
struct inode *ip;
{
struct thread *td = curthread; /* XXX */
@@ -139,24 +138,24 @@ ufs_ihashins(ip)
/* lock the inode, then put it on the appropriate hash list */
lockmgr(&ip->i_vnode->v_lock, LK_EXCLUSIVE, (struct mtx *)0, td);
- mtx_lock(&ufs_ihash_mtx);
+ mtx_lock(&ext2_ihash_mtx);
ipp = INOHASH(ip->i_dev, ip->i_number);
LIST_INSERT_HEAD(ipp, ip, i_hash);
ip->i_flag |= IN_HASHED;
- mtx_unlock(&ufs_ihash_mtx);
+ mtx_unlock(&ext2_ihash_mtx);
}
/*
* Remove the inode from the hash table.
*/
void
-ufs_ihashrem(ip)
+ext2_ihashrem(ip)
struct inode *ip;
{
- mtx_lock(&ufs_ihash_mtx);
+ mtx_lock(&ext2_ihash_mtx);
if (ip->i_flag & IN_HASHED) {
ip->i_flag &= ~IN_HASHED;
LIST_REMOVE(ip, i_hash);
}
- mtx_unlock(&ufs_ihash_mtx);
+ mtx_unlock(&ext2_ihash_mtx);
}
diff --git a/sys/gnu/ext2fs/ext2_mount.h b/sys/gnu/ext2fs/ext2_mount.h
index 12010a3..35f1fb7 100644
--- a/sys/gnu/ext2fs/ext2_mount.h
+++ b/sys/gnu/ext2fs/ext2_mount.h
@@ -34,13 +34,13 @@
* $FreeBSD$
*/
-#ifndef _UFS_UFS_UFSMOUNT_H_
-#define _UFS_UFS_UFSMOUNT_H_
+#ifndef _SYS_GNU_EXT2FS_EXT2_MOUNT_H_
+#define _SYS_GNU_EXT2FS_EXT2_MOUNT_H_
/*
- * Arguments to mount UFS-based filesystems
+ * Arguments to mount ext2fs filesystems
*/
-struct ufs_args {
+struct ext2_args {
char *fspec; /* block special device to mount */
struct export_args export; /* network export information */
};
@@ -48,67 +48,27 @@ struct ufs_args {
#ifdef _KERNEL
#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_UFSMNT);
+MALLOC_DECLARE(M_EXT2NODE);
#endif
-struct buf;
-struct inode;
-struct nameidata;
-struct timeval;
-struct ucred;
-struct uio;
struct vnode;
-struct ufs_extattr_per_mount;
-/* This structure describes the UFS specific mount structure data. */
-struct ufsmount {
+/* This structure describes the ext2fs specific mount structure data. */
+struct ext2mount {
struct mount *um_mountp; /* filesystem vfs structure */
dev_t um_dev; /* device mounted */
struct vnode *um_devvp; /* block device mounted vnode */
- union { /* pointer to superblock */
- struct fs *fs; /* FFS */
- struct ext2_sb_info *e2fs; /* EXT2FS */
- } ufsmount_u;
-#define um_fs ufsmount_u.fs
-#define um_e2fs ufsmount_u.e2fs
-#define um_e2fsb ufsmount_u.e2fs->s_es
+ struct ext2_sb_info *um_e2fs; /* EXT2FS */
+#define em_e2fsb um_e2fs->s_es
- struct vnode *um_quotas[MAXQUOTAS]; /* pointer to quota files */
- struct ucred *um_cred[MAXQUOTAS]; /* quota file access cred */
- struct ufs_extattr_per_mount um_extattr; /* extended attrs */
u_long um_nindir; /* indirect ptrs per block */
u_long um_bptrtodb; /* indir ptr to disk block */
u_long um_seqinc; /* inc between seq blocks */
- 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 */
- struct malloc_type *um_malloctype; /* The inodes malloctype */
- int um_i_effnlink_valid; /* i_effnlink valid? */
- int (*um_balloc)(struct vnode *, off_t, int, struct ucred *, int, struct buf **);
- int (*um_blkatoff)(struct vnode *, off_t, char **, struct buf **);
- int (*um_truncate)(struct vnode *, off_t, int, struct ucred *, struct thread *);
- int (*um_update)(struct vnode *, int);
- int (*um_valloc)(struct vnode *, int, struct ucred *, struct vnode **);
- int (*um_vfree)(struct vnode *, ino_t, int);
};
-#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, ee) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd, ee)
-#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)
-
-/*
- * Flags describing the state of quotas.
- */
-#define QTF_OPENING 0x01 /* Q_QUOTAON in progress */
-#define QTF_CLOSING 0x02 /* Q_QUOTAOFF in progress */
-
-/* Convert mount ptr to ufsmount ptr. */
-#define VFSTOUFS(mp) ((struct ufsmount *)((mp)->mnt_data))
+/* Convert mount ptr to ext2fsmount ptr. */
+#define VFSTOEXT2(mp) ((struct ext2mount *)((mp)->mnt_data))
/*
* Macros to access file system parameters in the ufsmount structure.
diff --git a/sys/gnu/ext2fs/inode.h b/sys/gnu/ext2fs/inode.h
index b18f431..c387532 100644
--- a/sys/gnu/ext2fs/inode.h
+++ b/sys/gnu/ext2fs/inode.h
@@ -39,17 +39,16 @@
* $FreeBSD$
*/
-#ifndef _UFS_UFS_INODE_H_
-#define _UFS_UFS_INODE_H_
+#ifndef _SYS_GNU_EXT2FS_INODE_H_
+#define _SYS_GNU_EXT2FS_INODE_H_
#include <sys/lock.h>
#include <sys/queue.h>
-#include <ufs/ufs/dinode.h>
-/*
- * The size of a logical block number.
- */
-typedef long ufs_lbn_t;
+#define ROOTINO ((ino_t)2)
+
+#define NDADDR 12 /* Direct addresses in inode. */
+#define NIADDR 3 /* Indirect addresses in inode. */
/*
* This must agree with the definition in <ufs/ufs/dir.h>.
@@ -58,30 +57,22 @@ typedef long ufs_lbn_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
+ * EXT2FS 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 {
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 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. */
- int i_effnlink; /* i_nlink when I/O completes */
-
- union { /* Associated filesystem. */
- struct fs *fs; /* FFS */
- struct ext2_sb_info *e2fs; /* EXT2FS */
- } inode_u;
-#define i_fs inode_u.fs
-#define i_e2fs inode_u.e2fs
- struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */
+
+ struct ext2_sb_info *i_e2fs; /* EXT2FS */
u_quad_t i_modrev; /* Revision level for NFS lease. */
struct lockf *i_lockf;/* Head of byte-level lock list. */
/*
@@ -93,33 +84,61 @@ struct inode {
doff_t i_offset; /* Offset of free space in directory. */
ino_t i_ino; /* Inode number of found directory. */
u_int32_t i_reclen; /* Size of found directory entry. */
- u_int32_t i_spare[3]; /* XXX actually non-spare (for ext2fs). */
- struct dirhash *i_dirhash; /* Hashing for large directories */
- /*
- * The on-disk dinode itself.
- */
- struct dinode i_din; /* 128 bytes of the on-disk dinode. */
+ u_int32_t i_block_group;
+ u_int32_t i_next_alloc_block;
+ u_int32_t i_next_alloc_goal;
+ u_int32_t i_prealloc_block;
+ u_int32_t i_prealloc_count;
+
+ /* Fields from struct dinode in UFS. */
+ u_int16_t i_mode; /* IFMT, permissions; see below. */
+ int16_t i_nlink; /* File link count. */
+ u_int64_t i_size; /* File byte count. */
+ int32_t i_atime; /* Last access time. */
+ int32_t i_atimensec; /* Last access time. */
+ int32_t i_mtime; /* Last modified time. */
+ int32_t i_mtimensec; /* Last modified time. */
+ int32_t i_ctime; /* Last inode change time. */
+ int32_t i_ctimensec; /* Last inode change time. */
+ daddr_t i_db[NDADDR]; /* Direct disk blocks. */
+ daddr_t i_ib[NIADDR]; /* Indirect disk blocks. */
+ u_int32_t i_flags; /* Status flags (chflags). */
+ int32_t i_blocks; /* Blocks actually held. */
+ int32_t i_gen; /* Generation number. */
+ u_int32_t i_uid; /* File owner. */
+ u_int32_t i_gid; /* File group. */
};
-#define i_atime i_din.di_atime
-#define i_atimensec i_din.di_atimensec
-#define i_blocks i_din.di_blocks
-#define i_ctime i_din.di_ctime
-#define i_ctimensec i_din.di_ctimensec
-#define i_db i_din.di_db
-#define i_flags i_din.di_flags
-#define i_gen i_din.di_gen
-#define i_gid i_din.di_gid
-#define i_ib i_din.di_ib
-#define i_mode i_din.di_mode
-#define i_mtime i_din.di_mtime
-#define i_mtimensec i_din.di_mtimensec
-#define i_nlink i_din.di_nlink
-#define i_rdev i_din.di_rdev
-#define i_shortlink i_din.di_shortlink
-#define i_size i_din.di_size
-#define i_uid i_din.di_uid
+/*
+ * 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 i_shortlink i_db
+#define i_rdev i_db[0]
+#define MAXSYMLINKLEN ((NDADDR + NIADDR) * sizeof(daddr_t))
+
+/* 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. */
/* These flags are kept in i_flag. */
#define IN_ACCESS 0x0001 /* Access time update request. */
@@ -137,7 +156,7 @@ struct inode {
* ufs_getlbns and used by truncate and bmap code.
*/
struct indir {
- ufs_daddr_t in_lbn; /* Logical block number. */
+ daddr_t in_lbn; /* Logical block number. */
int in_off; /* Offset in buffer. */
int in_exists; /* Flag if the block exists. */
};
@@ -146,10 +165,6 @@ struct indir {
#define VTOI(vp) ((struct inode *)(vp)->v_data)
#define ITOV(ip) ((ip)->i_vnode)
-/* Determine if soft dependencies are being done */
-#define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP)
-#define DOINGASYNC(vp) ((vp)->v_mount->mnt_flag & MNT_ASYNC)
-
/* This overlays the fid structure (see mount.h). */
struct ufid {
u_int16_t ufid_len; /* Length of structure. */
@@ -159,4 +174,4 @@ struct ufid {
};
#endif /* _KERNEL */
-#endif /* !_UFS_UFS_INODE_H_ */
+#endif /* !_SYS_GNU_EXT2FS_INODE_H_ */
diff --git a/sys/gnu/fs/ext2fs/ext2_bmap.c b/sys/gnu/fs/ext2fs/ext2_bmap.c
index 7c43318..c079979 100644
--- a/sys/gnu/fs/ext2fs/ext2_bmap.c
+++ b/sys/gnu/fs/ext2fs/ext2_bmap.c
@@ -49,11 +49,9 @@
#include <sys/resourcevar.h>
#include <sys/stat.h>
-#include <ufs/ufs/extattr.h>
-#include <ufs/ufs/quota.h>
-#include <ufs/ufs/inode.h>
-#include <ufs/ufs/ufsmount.h>
-#include <ufs/ufs/ufs_extern.h>
+#include <gnu/ext2fs/inode.h>
+#include <gnu/ext2fs/ext2_mount.h>
+#include <gnu/ext2fs/ext2_extern.h>
/*
* Bmap converts a the logical block number of a file to its physical block
@@ -61,7 +59,7 @@
* number to index into the array of block pointers described by the dinode.
*/
int
-ufs_bmap(ap)
+ext2_bmap(ap)
struct vop_bmap_args /* {
struct vnode *a_vp;
daddr_t a_bn;
@@ -83,7 +81,7 @@ ufs_bmap(ap)
if (ap->a_bnp == NULL)
return (0);
- error = ufs_bmaparray(ap->a_vp, ap->a_bn, &blkno,
+ error = ext2_bmaparray(ap->a_vp, ap->a_bn, &blkno,
ap->a_runp, ap->a_runb);
*ap->a_bnp = blkno;
return (error);
@@ -104,20 +102,20 @@ ufs_bmap(ap)
*/
int
-ufs_bmaparray(vp, bn, bnp, runp, runb)
+ext2_bmaparray(vp, bn, bnp, runp, runb)
struct vnode *vp;
- ufs_daddr_t bn;
- ufs_daddr_t *bnp;
+ daddr_t bn;
+ daddr_t *bnp;
int *runp;
int *runb;
{
struct inode *ip;
struct buf *bp;
- struct ufsmount *ump;
+ struct ext2mount *ump;
struct mount *mp;
struct vnode *devvp;
struct indir a[NIADDR+1], *ap;
- ufs_daddr_t daddr;
+ daddr_t daddr;
long metalbn;
int error, num, maxrun = 0;
int *nump;
@@ -125,7 +123,7 @@ ufs_bmaparray(vp, bn, bnp, runp, runb)
ap = NULL;
ip = VTOI(vp);
mp = vp->v_mount;
- ump = VFSTOUFS(mp);
+ ump = VFSTOEXT2(mp);
devvp = ump->um_devvp;
if (runp) {
@@ -140,29 +138,15 @@ ufs_bmaparray(vp, bn, bnp, runp, runb)
ap = a;
nump = &num;
- error = ufs_getlbns(vp, bn, ap, nump);
+ error = ext2_getlbns(vp, bn, ap, nump);
if (error)
return (error);
num = *nump;
if (num == 0) {
*bnp = blkptrtodb(ump, ip->i_db[bn]);
- /*
- * Since this is FFS independent code, we are out of
- * scope for the definitions of BLK_NOCOPY and
- * BLK_SNAP, but we do know that they will fall in
- * the range 1..um_seqinc, so we use that test and
- * return a request for a zeroed out buffer if attempts
- * are made to read a BLK_NOCOPY or BLK_SNAP block.
- */
- if ((ip->i_flags & SF_SNAPSHOT) &&
- ip->i_db[bn] > 0 && ip->i_db[bn] < ump->um_seqinc) {
+ if (*bnp == 0) {
*bnp = -1;
- } else if (*bnp == 0) {
- if (ip->i_flags & SF_SNAPSHOT)
- *bnp = blkptrtodb(ump, bn * ump->um_seqinc);
- else
- *bnp = -1;
} else if (runp) {
daddr_t bnb = bn;
for (++bn; bn < NDADDR && *runp < maxrun &&
@@ -221,13 +205,13 @@ ufs_bmaparray(vp, bn, bnp, runp, runb)
}
}
- daddr = ((ufs_daddr_t *)bp->b_data)[ap->in_off];
+ daddr = ((daddr_t *)bp->b_data)[ap->in_off];
if (num == 1 && daddr && runp) {
for (bn = ap->in_off + 1;
bn < MNINDIR(ump) && *runp < maxrun &&
is_sequential(ump,
- ((ufs_daddr_t *)bp->b_data)[bn - 1],
- ((ufs_daddr_t *)bp->b_data)[bn]);
+ ((daddr_t *)bp->b_data)[bn - 1],
+ ((daddr_t *)bp->b_data)[bn]);
++bn, ++*runp);
bn = ap->in_off;
if (runb && bn) {
@@ -254,10 +238,7 @@ ufs_bmaparray(vp, bn, bnp, runp, runb)
}
*bnp = blkptrtodb(ump, daddr);
if (*bnp == 0) {
- if (ip->i_flags & SF_SNAPSHOT)
- *bnp = blkptrtodb(ump, bn * ump->um_seqinc);
- else
- *bnp = -1;
+ *bnp = -1;
}
return (0);
}
@@ -272,18 +253,18 @@ ufs_bmaparray(vp, bn, bnp, runp, runb)
* once with the offset into the page itself.
*/
int
-ufs_getlbns(vp, bn, ap, nump)
+ext2_getlbns(vp, bn, ap, nump)
struct vnode *vp;
- ufs_daddr_t bn;
+ daddr_t bn;
struct indir *ap;
int *nump;
{
long blockcnt, metalbn, realbn;
- struct ufsmount *ump;
+ struct ext2mount *ump;
int i, numlevels, off;
int64_t qblockcnt;
- ump = VFSTOUFS(vp->v_mount);
+ ump = VFSTOEXT2(vp->v_mount);
if (nump)
*nump = 0;
numlevels = 0;
diff --git a/sys/gnu/fs/ext2fs/ext2_mount.h b/sys/gnu/fs/ext2fs/ext2_mount.h
index 12010a3..35f1fb7 100644
--- a/sys/gnu/fs/ext2fs/ext2_mount.h
+++ b/sys/gnu/fs/ext2fs/ext2_mount.h
@@ -34,13 +34,13 @@
* $FreeBSD$
*/
-#ifndef _UFS_UFS_UFSMOUNT_H_
-#define _UFS_UFS_UFSMOUNT_H_
+#ifndef _SYS_GNU_EXT2FS_EXT2_MOUNT_H_
+#define _SYS_GNU_EXT2FS_EXT2_MOUNT_H_
/*
- * Arguments to mount UFS-based filesystems
+ * Arguments to mount ext2fs filesystems
*/
-struct ufs_args {
+struct ext2_args {
char *fspec; /* block special device to mount */
struct export_args export; /* network export information */
};
@@ -48,67 +48,27 @@ struct ufs_args {
#ifdef _KERNEL
#ifdef MALLOC_DECLARE
-MALLOC_DECLARE(M_UFSMNT);
+MALLOC_DECLARE(M_EXT2NODE);
#endif
-struct buf;
-struct inode;
-struct nameidata;
-struct timeval;
-struct ucred;
-struct uio;
struct vnode;
-struct ufs_extattr_per_mount;
-/* This structure describes the UFS specific mount structure data. */
-struct ufsmount {
+/* This structure describes the ext2fs specific mount structure data. */
+struct ext2mount {
struct mount *um_mountp; /* filesystem vfs structure */
dev_t um_dev; /* device mounted */
struct vnode *um_devvp; /* block device mounted vnode */
- union { /* pointer to superblock */
- struct fs *fs; /* FFS */
- struct ext2_sb_info *e2fs; /* EXT2FS */
- } ufsmount_u;
-#define um_fs ufsmount_u.fs
-#define um_e2fs ufsmount_u.e2fs
-#define um_e2fsb ufsmount_u.e2fs->s_es
+ struct ext2_sb_info *um_e2fs; /* EXT2FS */
+#define em_e2fsb um_e2fs->s_es
- struct vnode *um_quotas[MAXQUOTAS]; /* pointer to quota files */
- struct ucred *um_cred[MAXQUOTAS]; /* quota file access cred */
- struct ufs_extattr_per_mount um_extattr; /* extended attrs */
u_long um_nindir; /* indirect ptrs per block */
u_long um_bptrtodb; /* indir ptr to disk block */
u_long um_seqinc; /* inc between seq blocks */
- 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 */
- struct malloc_type *um_malloctype; /* The inodes malloctype */
- int um_i_effnlink_valid; /* i_effnlink valid? */
- int (*um_balloc)(struct vnode *, off_t, int, struct ucred *, int, struct buf **);
- int (*um_blkatoff)(struct vnode *, off_t, char **, struct buf **);
- int (*um_truncate)(struct vnode *, off_t, int, struct ucred *, struct thread *);
- int (*um_update)(struct vnode *, int);
- int (*um_valloc)(struct vnode *, int, struct ucred *, struct vnode **);
- int (*um_vfree)(struct vnode *, ino_t, int);
};
-#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, ee) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd, ee)
-#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)
-
-/*
- * Flags describing the state of quotas.
- */
-#define QTF_OPENING 0x01 /* Q_QUOTAON in progress */
-#define QTF_CLOSING 0x02 /* Q_QUOTAOFF in progress */
-
-/* Convert mount ptr to ufsmount ptr. */
-#define VFSTOUFS(mp) ((struct ufsmount *)((mp)->mnt_data))
+/* Convert mount ptr to ext2fsmount ptr. */
+#define VFSTOEXT2(mp) ((struct ext2mount *)((mp)->mnt_data))
/*
* Macros to access file system parameters in the ufsmount structure.
diff --git a/sys/gnu/fs/ext2fs/inode.h b/sys/gnu/fs/ext2fs/inode.h
index b18f431..c387532 100644
--- a/sys/gnu/fs/ext2fs/inode.h
+++ b/sys/gnu/fs/ext2fs/inode.h
@@ -39,17 +39,16 @@
* $FreeBSD$
*/
-#ifndef _UFS_UFS_INODE_H_
-#define _UFS_UFS_INODE_H_
+#ifndef _SYS_GNU_EXT2FS_INODE_H_
+#define _SYS_GNU_EXT2FS_INODE_H_
#include <sys/lock.h>
#include <sys/queue.h>
-#include <ufs/ufs/dinode.h>
-/*
- * The size of a logical block number.
- */
-typedef long ufs_lbn_t;
+#define ROOTINO ((ino_t)2)
+
+#define NDADDR 12 /* Direct addresses in inode. */
+#define NIADDR 3 /* Indirect addresses in inode. */
/*
* This must agree with the definition in <ufs/ufs/dir.h>.
@@ -58,30 +57,22 @@ typedef long ufs_lbn_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
+ * EXT2FS 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 {
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 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. */
- int i_effnlink; /* i_nlink when I/O completes */
-
- union { /* Associated filesystem. */
- struct fs *fs; /* FFS */
- struct ext2_sb_info *e2fs; /* EXT2FS */
- } inode_u;
-#define i_fs inode_u.fs
-#define i_e2fs inode_u.e2fs
- struct dquot *i_dquot[MAXQUOTAS]; /* Dquot structures. */
+
+ struct ext2_sb_info *i_e2fs; /* EXT2FS */
u_quad_t i_modrev; /* Revision level for NFS lease. */
struct lockf *i_lockf;/* Head of byte-level lock list. */
/*
@@ -93,33 +84,61 @@ struct inode {
doff_t i_offset; /* Offset of free space in directory. */
ino_t i_ino; /* Inode number of found directory. */
u_int32_t i_reclen; /* Size of found directory entry. */
- u_int32_t i_spare[3]; /* XXX actually non-spare (for ext2fs). */
- struct dirhash *i_dirhash; /* Hashing for large directories */
- /*
- * The on-disk dinode itself.
- */
- struct dinode i_din; /* 128 bytes of the on-disk dinode. */
+ u_int32_t i_block_group;
+ u_int32_t i_next_alloc_block;
+ u_int32_t i_next_alloc_goal;
+ u_int32_t i_prealloc_block;
+ u_int32_t i_prealloc_count;
+
+ /* Fields from struct dinode in UFS. */
+ u_int16_t i_mode; /* IFMT, permissions; see below. */
+ int16_t i_nlink; /* File link count. */
+ u_int64_t i_size; /* File byte count. */
+ int32_t i_atime; /* Last access time. */
+ int32_t i_atimensec; /* Last access time. */
+ int32_t i_mtime; /* Last modified time. */
+ int32_t i_mtimensec; /* Last modified time. */
+ int32_t i_ctime; /* Last inode change time. */
+ int32_t i_ctimensec; /* Last inode change time. */
+ daddr_t i_db[NDADDR]; /* Direct disk blocks. */
+ daddr_t i_ib[NIADDR]; /* Indirect disk blocks. */
+ u_int32_t i_flags; /* Status flags (chflags). */
+ int32_t i_blocks; /* Blocks actually held. */
+ int32_t i_gen; /* Generation number. */
+ u_int32_t i_uid; /* File owner. */
+ u_int32_t i_gid; /* File group. */
};
-#define i_atime i_din.di_atime
-#define i_atimensec i_din.di_atimensec
-#define i_blocks i_din.di_blocks
-#define i_ctime i_din.di_ctime
-#define i_ctimensec i_din.di_ctimensec
-#define i_db i_din.di_db
-#define i_flags i_din.di_flags
-#define i_gen i_din.di_gen
-#define i_gid i_din.di_gid
-#define i_ib i_din.di_ib
-#define i_mode i_din.di_mode
-#define i_mtime i_din.di_mtime
-#define i_mtimensec i_din.di_mtimensec
-#define i_nlink i_din.di_nlink
-#define i_rdev i_din.di_rdev
-#define i_shortlink i_din.di_shortlink
-#define i_size i_din.di_size
-#define i_uid i_din.di_uid
+/*
+ * 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 i_shortlink i_db
+#define i_rdev i_db[0]
+#define MAXSYMLINKLEN ((NDADDR + NIADDR) * sizeof(daddr_t))
+
+/* 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. */
/* These flags are kept in i_flag. */
#define IN_ACCESS 0x0001 /* Access time update request. */
@@ -137,7 +156,7 @@ struct inode {
* ufs_getlbns and used by truncate and bmap code.
*/
struct indir {
- ufs_daddr_t in_lbn; /* Logical block number. */
+ daddr_t in_lbn; /* Logical block number. */
int in_off; /* Offset in buffer. */
int in_exists; /* Flag if the block exists. */
};
@@ -146,10 +165,6 @@ struct indir {
#define VTOI(vp) ((struct inode *)(vp)->v_data)
#define ITOV(ip) ((ip)->i_vnode)
-/* Determine if soft dependencies are being done */
-#define DOINGSOFTDEP(vp) ((vp)->v_mount->mnt_flag & MNT_SOFTDEP)
-#define DOINGASYNC(vp) ((vp)->v_mount->mnt_flag & MNT_ASYNC)
-
/* This overlays the fid structure (see mount.h). */
struct ufid {
u_int16_t ufid_len; /* Length of structure. */
@@ -159,4 +174,4 @@ struct ufid {
};
#endif /* _KERNEL */
-#endif /* !_UFS_UFS_INODE_H_ */
+#endif /* !_SYS_GNU_EXT2FS_INODE_H_ */
OpenPOWER on IntegriCloud