aboutsummaryrefslogtreecommitdiff
path: root/sys/ufs
diff options
context:
space:
mode:
Diffstat (limited to 'sys/ufs')
-rw-r--r--sys/ufs/dinode.h11
-rw-r--r--sys/ufs/dir.h9
-rw-r--r--sys/ufs/fs.h28
-rw-r--r--sys/ufs/inode.h53
-rw-r--r--sys/ufs/lockf.h16
-rw-r--r--sys/ufs/mfs_vfsops.c10
-rw-r--r--sys/ufs/mfs_vnops.c12
-rw-r--r--sys/ufs/mfsiom.h6
-rw-r--r--sys/ufs/mfsnode.h11
-rw-r--r--sys/ufs/quota.h33
-rw-r--r--sys/ufs/ufs_alloc.c11
-rw-r--r--sys/ufs/ufs_bmap.c4
-rw-r--r--sys/ufs/ufs_disksubr.c13
-rw-r--r--sys/ufs/ufs_inode.c18
-rw-r--r--sys/ufs/ufs_lockf.c13
-rw-r--r--sys/ufs/ufs_lookup.c31
-rw-r--r--sys/ufs/ufs_quota.c50
-rw-r--r--sys/ufs/ufs_subr.c10
-rw-r--r--sys/ufs/ufs_tables.c3
-rw-r--r--sys/ufs/ufs_vfsops.c56
-rw-r--r--sys/ufs/ufs_vnops.c67
-rw-r--r--sys/ufs/ufsmount.h10
22 files changed, 376 insertions, 99 deletions
diff --git a/sys/ufs/dinode.h b/sys/ufs/dinode.h
index 51ea7c7e813a..064948d7e86c 100644
--- a/sys/ufs/dinode.h
+++ b/sys/ufs/dinode.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)dinode.h 7.10 (Berkeley) 5/8/91
- * $Id: dinode.h,v 1.3 1993/10/16 18:17:35 rgrimes Exp $
+ * $Id: dinode.h,v 1.5 1993/12/19 22:51:07 alm Exp $
*/
+#ifndef _UFS_DINODE_H_
+#define _UFS_DINODE_H_ 1
+
/*
* A dinode contains all the meta-data associated with a UFS file.
* This structure defines the on-disk format of a dinode.
@@ -49,7 +52,10 @@ struct dinode {
short di_nlink; /* 2: number of links to file */
uid_t di_uid; /* 4: owner's user id */
gid_t di_gid; /* 6: owner's group id */
- u_quad di_qsize; /* 8: number of bytes in file */
+ union {
+ u_quad_t v;
+ u_long val[2];
+ } di_qsize; /* 8: number of bytes in file */
time_t di_atime; /* 16: time last accessed */
long di_atspare;
time_t di_mtime; /* 24: time last modified */
@@ -102,3 +108,4 @@ struct dinode {
((((di).di_mode & IFMT) == IFLNK) && \
((di).di_size <= MAXFASTLINK) && \
((di).di_size == (di).di_spare[0]))
+#endif /* _UFS_DINODE_H_ */
diff --git a/sys/ufs/dir.h b/sys/ufs/dir.h
index f98d206be7ca..963ead42dec9 100644
--- a/sys/ufs/dir.h
+++ b/sys/ufs/dir.h
@@ -1,4 +1,11 @@
/*
+ * Copyright (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.
+ */
+/*
* Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
* All rights reserved.
*
@@ -31,7 +38,7 @@
* SUCH DAMAGE.
*
* from: @(#)dir.h 7.10 (Berkeley) 3/25/91
- * $Id: dir.h,v 1.2 1993/10/16 18:17:37 rgrimes Exp $
+ * $Id: dir.h,v 1.2.4.1 1994/05/04 07:59:08 rgrimes Exp $
*/
#ifndef _DIR_H_
diff --git a/sys/ufs/fs.h b/sys/ufs/fs.h
index 477699cb4a00..5b5022870b74 100644
--- a/sys/ufs/fs.h
+++ b/sys/ufs/fs.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)fs.h 7.12 (Berkeley) 5/8/91
- * $Id: fs.h,v 1.2 1993/10/16 18:17:38 rgrimes Exp $
+ * $Id: fs.h,v 1.6 1993/12/19 22:51:09 alm Exp $
*/
+#ifndef _UFS_FS_H_
+#define _UFS_FS_H_ 1
+
/*
* Each disk drive contains some number of file systems.
* A file system consists of a number of cylinder groups.
@@ -210,8 +213,14 @@ struct fs
short fs_opostbl[16][8]; /* old rotation block list head */
long fs_sparecon[55]; /* reserved for future constants */
long fs_state; /* validate fs_clean field */
- quad fs_qbmask; /* ~fs_bmask - for use with quad size */
- quad fs_qfmask; /* ~fs_fmask - for use with quad size */
+ union {
+ quad_t v;
+ long val[2];
+ } fs_qbmask; /* ~fs_bmask - for use with quad size */
+ union {
+ quad_t v;
+ long val[2];
+ } fs_qfmask; /* ~fs_fmask - for use with quad size */
long fs_postblformat; /* format of positional layout tables */
long fs_nrpos; /* number of rotaional positions */
long fs_postbloff; /* (short) rotation block list head */
@@ -439,3 +448,16 @@ struct ocg {
* NINDIR is the number of indirects in a file system block.
*/
#define NINDIR(fs) ((fs)->fs_nindir)
+
+#ifdef KERNEL
+
+extern void fserr(struct fs *, int /*uid_t*/, const char *);
+extern void fragacct(struct fs *, int, long *, int);
+extern int isblock(struct fs *, u_char *, daddr_t);
+extern void clrblock(struct fs *, u_char *, daddr_t);
+extern void setblock(struct fs *, u_char *, daddr_t);
+extern ino_t dirpref(struct fs *);
+extern daddr_t mapsearch(struct fs *, struct cg *, daddr_t, int);
+
+#endif /* KERNEL */
+#endif /* _UFS_FS_H_ */
diff --git a/sys/ufs/inode.h b/sys/ufs/inode.h
index 2f6da627e075..88fbd6795b98 100644
--- a/sys/ufs/inode.h
+++ b/sys/ufs/inode.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)inode.h 7.17 (Berkeley) 5/8/91
- * $Id: inode.h,v 1.3 1993/10/16 18:17:40 rgrimes Exp $
+ * $Id: inode.h,v 1.6 1993/12/19 00:55:37 wollman Exp $
*/
+#ifndef _UFS_INODE_H_
+#define _UFS_INODE_H_ 1
+
#ifdef KERNEL
#include "../ufs/dinode.h"
#else
@@ -121,7 +124,7 @@ extern int vttoif_tab[];
#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
-u_long nextgennumber; /* next generation number to assign */
+extern u_long nextgennumber; /* next generation number to assign */
extern ino_t dirpref();
@@ -227,8 +230,52 @@ int ufs_unlock __P((struct vnode *vp));
int ufs_bmap __P((struct vnode *vp, daddr_t bn, struct vnode **vpp,
daddr_t *bnp));
int ufs_strategy __P((struct buf *bp));
-int ufs_print __P((struct vnode *vp));
+void ufs_print __P((struct vnode *vp));
int ufs_islocked __P((struct vnode *vp));
int ufs_advlock __P((struct vnode *vp, caddr_t id, int op, struct flock *fl,
int flags));
+
+extern void blkfree(struct inode *, daddr_t, off_t);
+extern void ifree(struct inode *, ino_t, int);
+extern void iput(struct inode *);
+extern void ilock(struct inode *);
+extern void iunlock(struct inode *);
+extern void dirbad(struct inode *, off_t, char *);
+
+extern int alloc(struct inode *, daddr_t, daddr_t, int, daddr_t *);
+extern int realloccg(struct inode *, off_t, daddr_t, int, int, struct buf **);
+extern int ialloc(struct inode *, ino_t, int, struct ucred *, struct inode **);
+extern daddr_t blkpref(struct inode *, daddr_t, int, daddr_t *);
+extern u_long hashalloc(struct inode *, int, long, int,
+ u_long (*)(struct inode *, int, long, int));
+extern daddr_t fragextend(struct inode *, int, long, int, int);
+extern daddr_t alloccg(struct inode *, int, daddr_t, int);
+
+struct cg; /* I really don't want to know why */
+struct direct; /* this header is required by NFS... */
+
+extern daddr_t alloccgblk(struct fs *, struct cg *, daddr_t);
+extern ino_t ialloccg(struct inode *, int, daddr_t, int);
+extern int ufs_lookup(struct vnode *, struct nameidata *, struct proc *);
+extern int dirbadentry(struct direct *, int);
+extern int direnter(struct inode *, struct nameidata *);
+extern int dirremove(struct nameidata *);
+extern int dirrewrite(struct inode *, struct inode *, struct nameidata *);
+extern int blkatoff(struct inode *, off_t, char **, struct buf **);
+extern int dirempty(struct inode *, ino_t, struct ucred *);
+extern int checkpath(struct inode *, struct inode *, struct ucred *);
+
+extern void ufs_init(void);
+extern int iget(struct inode *, ino_t, struct inode **);
+extern int ufs_inactive(struct vnode *, struct proc *);
+extern int ufs_reclaim(struct vnode *);
+extern int iupdat(struct inode *, struct timeval *, struct timeval *,
+ int);
+extern int itrunc(struct inode *, u_long, int);
+extern int indirtrunc(struct inode *, daddr_t, daddr_t, int, long *);
+
+extern int bmap(struct inode *, daddr_t, daddr_t *);
+extern int balloc(struct inode *, daddr_t, int, struct buf **, int);
+
#endif /* KERNEL */
+#endif /* _UFS_INODE_H_ */
diff --git a/sys/ufs/lockf.h b/sys/ufs/lockf.h
index dc8b99d1df26..43c7158c4225 100644
--- a/sys/ufs/lockf.h
+++ b/sys/ufs/lockf.h
@@ -34,9 +34,12 @@
* SUCH DAMAGE.
*
* from: @(#)lockf.h 7.1 (Berkeley) 2/1/91
- * $Id: lockf.h,v 1.3 1993/10/20 07:31:36 davidg Exp $
+ * $Id: lockf.h,v 1.5 1993/12/19 00:55:40 wollman Exp $
*/
+#ifndef _UFS_LOCKF_H_
+#define _UFS_LOCKF_H_ 1
+
/*
* The lockf structure is a kernel structure which contains all the
* information associated with a byte range lock. The lockf structures
@@ -63,10 +66,17 @@ struct lockf {
/*
* Public lock manipulation routines
*/
-extern struct lockf *lf_remove(); /* Remove a lock */
-extern struct lockf *lf_getblock(); /* Return the first blocking lock */
+extern int lf_advlock(struct lockf **, u_long, caddr_t, int, struct flock *,
+ int);
+extern int lf_setlock(struct lockf *);
+extern int lf_clearlock(struct lockf *);
+extern int lf_getlock(struct lockf *, struct flock *);
+extern struct lockf *lf_getblock(struct lockf *);
+extern int lf_findoverlap(struct lockf *, struct lockf *, int,
+ struct lockf ***, struct lockf **);
#ifdef LOCKF_DEBUG
extern int lockf_debug;
#endif LOCKF_DEBUG
#endif KERNEL
+#endif /* _UFS_LOCKF_H_ */
diff --git a/sys/ufs/mfs_vfsops.c b/sys/ufs/mfs_vfsops.c
index 5a28439a55c0..d2026ca123b8 100644
--- a/sys/ufs/mfs_vfsops.c
+++ b/sys/ufs/mfs_vfsops.c
@@ -31,10 +31,11 @@
* SUCH DAMAGE.
*
* from: @(#)mfs_vfsops.c 7.19 (Berkeley) 4/16/91
- * $Id: mfs_vfsops.c,v 1.3 1993/10/16 18:17:42 rgrimes Exp $
+ * $Id: mfs_vfsops.c,v 1.6 1993/12/19 00:55:41 wollman Exp $
*/
#include "param.h"
+#include "systm.h"
#include "time.h"
#include "kernel.h"
#include "proc.h"
@@ -63,7 +64,7 @@ int mfs_statfs();
int ufs_sync();
int ufs_fhtovp();
int ufs_vptofh();
-int mfs_init();
+void mfs_init();
struct vfsops mfs_vfsops = {
mfs_mount,
@@ -84,6 +85,7 @@ struct vfsops mfs_vfsops = {
* mount system call
*/
/* ARGSUSED */
+int
mfs_mount(mp, path, data, ndp, p)
register struct mount *mp;
char *path;
@@ -137,6 +139,8 @@ mfs_mount(mp, path, data, ndp, p)
&size);
bzero(mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
(void) mfs_statfs(mp, &mp->mnt_stat);
+ if ((args.flags & MFSMNT_SIGPPID) && (p->p_pptr != initproc))
+ (void)psignal(p->p_pptr, SIGUSR1);
return (0);
}
@@ -151,6 +155,7 @@ int mfs_pri = PWAIT | PCATCH; /* XXX prob. temp */
* address space.
*/
/* ARGSUSED */
+int
mfs_start(mp, flags, p)
struct mount *mp;
int flags;
@@ -185,6 +190,7 @@ mfs_start(mp, flags, p)
/*
* Get file system statistics.
*/
+int
mfs_statfs(mp, sbp, p)
struct mount *mp;
struct statfs *sbp;
diff --git a/sys/ufs/mfs_vnops.c b/sys/ufs/mfs_vnops.c
index d0c5ff8ed5dd..eed2ec8b6f37 100644
--- a/sys/ufs/mfs_vnops.c
+++ b/sys/ufs/mfs_vnops.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)mfs_vnops.c 7.22 (Berkeley) 4/16/91
- * $Id: mfs_vnops.c,v 1.2 1993/10/16 18:17:44 rgrimes Exp $
+ * $Id: mfs_vnops.c,v 1.3 1993/11/25 01:38:25 wollman Exp $
*/
#include "param.h"
@@ -94,6 +94,7 @@ struct vnodeops mfs_vnodeops = {
* so we can tell when we are doing I/O to ourself.
*/
/* ARGSUSED */
+int
mfs_open(vp, mode, cred, p)
register struct vnode *vp;
int mode;
@@ -112,6 +113,7 @@ mfs_open(vp, mode, cred, p)
* Ioctl operation.
*/
/* ARGSUSED */
+int
mfs_ioctl(vp, com, data, fflag, cred, p)
struct vnode *vp;
int com;
@@ -127,6 +129,7 @@ mfs_ioctl(vp, com, data, fflag, cred, p)
/*
* Pass I/O requests to the memory filesystem process.
*/
+int
mfs_strategy(bp)
register struct buf *bp;
{
@@ -152,6 +155,7 @@ mfs_strategy(bp)
*
* Trivial since buffer has already been mapping into KVA space.
*/
+void
mfs_doio(bp, base)
register struct buf *bp;
caddr_t base;
@@ -169,6 +173,7 @@ mfs_doio(bp, base)
/*
* This is a noop, simply returning what one has been given.
*/
+int
mfs_bmap(vp, bn, vpp, bnp)
struct vnode *vp;
daddr_t bn;
@@ -187,6 +192,7 @@ mfs_bmap(vp, bn, vpp, bnp)
* Memory filesystem close routine
*/
/* ARGSUSED */
+int
mfs_close(vp, flag, cred, p)
register struct vnode *vp;
int flag;
@@ -232,6 +238,7 @@ mfs_close(vp, flag, cred, p)
* Memory filesystem inactive routine
*/
/* ARGSUSED */
+int
mfs_inactive(vp, p)
struct vnode *vp;
struct proc *p;
@@ -245,6 +252,7 @@ mfs_inactive(vp, p)
/*
* Print out the contents of an mfsnode.
*/
+void
mfs_print(vp)
struct vnode *vp;
{
@@ -257,6 +265,7 @@ mfs_print(vp)
/*
* Block device bad operation
*/
+int
mfs_badop()
{
@@ -267,6 +276,7 @@ mfs_badop()
/*
* Memory based filesystem initialization.
*/
+void
mfs_init()
{
diff --git a/sys/ufs/mfsiom.h b/sys/ufs/mfsiom.h
index 0980bb286812..ba85169789fd 100644
--- a/sys/ufs/mfsiom.h
+++ b/sys/ufs/mfsiom.h
@@ -31,8 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)mfsiom.h 7.2 (Berkeley) 6/28/90
- * $Id: mfsiom.h,v 1.2 1993/10/16 18:17:45 rgrimes Exp $
+ * $Id: mfsiom.h,v 1.3 1993/11/07 17:53:41 wollman Exp $
*/
+#ifndef _UFS_MFSIOM_H_
+#define _UFS_MFSIOM_H_ 1
+
#define MFS_MAPREG (MAXPHYS/NBPG + 2) /* Kernel mapping pte's */
#define MFS_MAPSIZE 10 /* Size of alloc map for pte's */
+#endif /* _UFS_MFSIOM_H_ */
diff --git a/sys/ufs/mfsnode.h b/sys/ufs/mfsnode.h
index 9cd1c29e4845..186a0804d9a5 100644
--- a/sys/ufs/mfsnode.h
+++ b/sys/ufs/mfsnode.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)mfsnode.h 7.3 (Berkeley) 4/16/91
- * $Id: mfsnode.h,v 1.2 1993/10/16 18:17:46 rgrimes Exp $
+ * $Id: mfsnode.h,v 1.4 1993/11/25 01:38:26 wollman Exp $
*/
+#ifndef _UFS_MFSNODE_H_
+#define _UFS_MFSNODE_H_ 1
+
/*
* This structure defines the control data for the memory
* based file system.
@@ -185,7 +188,7 @@ int mfs_bmap __P((
daddr_t *bnp));
int mfs_strategy __P((
struct buf *bp));
-int mfs_print __P((
+void mfs_print __P((
struct vnode *vp));
#define mfs_islocked ((int (*) __P(( \
struct vnode *vp))) nullop)
@@ -195,3 +198,7 @@ int mfs_print __P((
int op, \
struct flock *fl, \
int flags))) mfs_badop)
+
+void mfs_doio(struct buf *, caddr_t);
+
+#endif /* _UFS_MFSNODE_H_ */
diff --git a/sys/ufs/quota.h b/sys/ufs/quota.h
index afcb865b13d3..99edf7c1cf29 100644
--- a/sys/ufs/quota.h
+++ b/sys/ufs/quota.h
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)quota.h 7.9 (Berkeley) 2/22/91
- * $Id: quota.h,v 1.2 1993/10/16 18:17:47 rgrimes Exp $
+ * $Id: quota.h,v 1.3 1993/11/25 01:38:27 wollman Exp $
*/
#ifndef _QUOTA_
@@ -60,9 +60,11 @@
* 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 */
+enum quotatype {
+ USRQUOTA = 0, /* element used for user quotas */
+ GRPQUOTA = 1, /* element used for group quotas */
+ MAXQUOTAS = 2
+};
/*
* Definitions for the default names of the quotas files.
@@ -171,6 +173,29 @@ struct dquot {
#define DQREF(dq) dqref(dq)
#endif /* DIAGNOSTIC */
+struct inode; struct ucred; struct mount; struct vnode;
+
+int getinoquota(struct inode *);
+int chkdq(struct inode *, long, struct ucred *, int);
+int chkdqchg(struct inode *, long, struct ucred *, enum quotatype);
+int chkiq(struct inode *, long, struct ucred *, int);
+int chkiqchg(struct inode *, long, struct ucred *, enum quotatype);
+#ifdef DIAGNOSTIC
+void chkdquot(struct inode *);
+#endif
+int quotaon(struct proc *, struct mount *, enum quotatype, caddr_t);
+int quotaoff(struct proc *, struct mount *, enum quotatype);
+int getquota(struct mount *, u_long, enum quotatype, caddr_t);
+int setquota(struct mount *, u_long, enum quotatype, caddr_t);
+int setuse(struct mount *, u_long, enum quotatype, caddr_t);
+int qsync(struct mount *);
+void dqinit(void);
+int dqget(struct vnode *, u_long, struct ufsmount *, enum quotatype, struct dquot **);
+void dqref(struct dquot *);
+void dqrele(struct vnode *, struct dquot *);
+int dqsync(struct vnode *, struct dquot *);
+void dqflush(struct vnode *);
+
#else
#include <sys/cdefs.h>
diff --git a/sys/ufs/ufs_alloc.c b/sys/ufs/ufs_alloc.c
index 8c43640403aa..a3aa55268c5c 100644
--- a/sys/ufs/ufs_alloc.c
+++ b/sys/ufs/ufs_alloc.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)ufs_alloc.c 7.26 (Berkeley) 5/2/91
- * $Id: ufs_alloc.c,v 1.2 1993/10/16 18:17:49 rgrimes Exp $
+ * $Id: ufs_alloc.c,v 1.4 1993/12/19 00:55:42 wollman Exp $
*/
#include "param.h"
@@ -46,6 +46,7 @@
#include "inode.h"
#include "fs.h"
+/* XXX */
extern u_long hashalloc();
extern ino_t ialloccg();
extern daddr_t alloccg();
@@ -75,6 +76,7 @@ extern unsigned char *fragtbl[];
* 2) quadradically rehash into other cylinder groups, until an
* available block is located.
*/
+int
alloc(ip, lbn, bpref, size, bnp)
register struct inode *ip;
daddr_t lbn, bpref;
@@ -136,6 +138,7 @@ nospace:
* the original block. Failing that, the regular block allocator is
* invoked to get an appropriate block.
*/
+int
realloccg(ip, lbprev, bpref, osize, nsize, bpp)
register struct inode *ip;
off_t lbprev;
@@ -288,6 +291,7 @@ nospace:
* 2) quadradically rehash into other cylinder groups, until an
* available inode is located.
*/
+int
ialloc(pip, ipref, mode, cred, ipp)
register struct inode *pip;
ino_t ipref;
@@ -867,6 +871,7 @@ gotit:
* free map. If a fragment is deallocated, a possible
* block reassembly is checked.
*/
+void
blkfree(ip, bno, size)
register struct inode *ip;
daddr_t bno;
@@ -969,6 +974,7 @@ blkfree(ip, bno, size)
*
* The specified inode is placed back in the free map.
*/
+void
ifree(ip, ino, mode)
struct inode *ip;
ino_t ino;
@@ -1091,10 +1097,11 @@ mapsearch(fs, cgp, bpref, allocsiz)
* The form of the error message is:
* fs: error message
*/
+void
fserr(fs, uid, cp)
struct fs *fs;
uid_t uid;
- char *cp;
+ const char *cp;
{
log(LOG_ERR, "uid %d on %s: %s\n", uid, fs->fs_fsmnt, cp);
diff --git a/sys/ufs/ufs_bmap.c b/sys/ufs/ufs_bmap.c
index 09f2bc6afca3..a023ddfcef85 100644
--- a/sys/ufs/ufs_bmap.c
+++ b/sys/ufs/ufs_bmap.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)ufs_bmap.c 7.13 (Berkeley) 5/8/91
- * $Id: ufs_bmap.c,v 1.2 1993/10/16 18:17:51 rgrimes Exp $
+ * $Id: ufs_bmap.c,v 1.3 1993/11/25 01:38:30 wollman Exp $
*/
#include "param.h"
@@ -51,6 +51,7 @@
* is done by using the logical block number to index into
* the array of block pointers described by the dinode.
*/
+int
bmap(ip, bn, bnp)
register struct inode *ip;
register daddr_t bn;
@@ -126,6 +127,7 @@ bmap(ip, bn, bnp)
* by allocating the physical blocks on a device given
* the inode and the logical block number in a file.
*/
+int
balloc(ip, bn, size, bpp, flags)
register struct inode *ip;
register daddr_t bn;
diff --git a/sys/ufs/ufs_disksubr.c b/sys/ufs/ufs_disksubr.c
index 09cb4d96c042..e80b67e371b1 100644
--- a/sys/ufs/ufs_disksubr.c
+++ b/sys/ufs/ufs_disksubr.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91
- * $Id: ufs_disksubr.c,v 1.3 1993/10/08 21:00:37 rgrimes Exp $
+ * $Id: ufs_disksubr.c,v 1.5 1993/12/19 00:55:43 wollman Exp $
*/
#include "param.h"
@@ -167,7 +167,7 @@ insert:
char *
readdisklabel(dev, strat, lp, dp, bdp, bpp)
dev_t dev;
- int (*strat)();
+ d_strategy_t *strat;
register struct disklabel *lp;
struct dos_partition *dp;
struct dkbad *bdp;
@@ -321,6 +321,7 @@ done:
* Check new disk label for sensibility
* before setting it.
*/
+int
setdisklabel(olp, nlp, openmask, dp)
register struct disklabel *olp, *nlp;
u_long openmask;
@@ -335,7 +336,7 @@ setdisklabel(olp, nlp, openmask, dp)
return(EINVAL);
/* special case to allow disklabel to be invalidated */
- if (nlp->d_magic == 0xffffffff) {
+ if (nlp->d_magic == 0xffffffffUL) {
*olp = *nlp;
return (0);
}
@@ -376,9 +377,10 @@ setdisklabel(olp, nlp, openmask, dp)
/*
* Write disk label back to device after modification.
*/
+int
writedisklabel(dev, strat, lp, dp)
dev_t dev;
- int (*strat)();
+ d_strategy_t *strat;
register struct disklabel *lp;
struct dos_partition *dp;
{
@@ -464,6 +466,7 @@ done:
/*
* Compute checksum for disk label.
*/
+int
dkcksum(lp)
register struct disklabel *lp;
{
@@ -563,7 +566,7 @@ diskerr(bp, dname, what, pri, blkdone, lp)
if (pri != LOG_PRINTF) {
log(pri, "");
- pr = addlog;
+ pr = (int (*)(const char *, ...))addlog; /* XXX FIXME! */
} else
pr = printf;
(*pr)("%s%d%c: %s %sing fsbn ", dname, unit, partname, what,
diff --git a/sys/ufs/ufs_inode.c b/sys/ufs/ufs_inode.c
index 5f8a9f377ec6..6a2f5e084c6c 100644
--- a/sys/ufs/ufs_inode.c
+++ b/sys/ufs/ufs_inode.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)ufs_inode.c 7.40 (Berkeley) 5/8/91
- * $Id: ufs_inode.c,v 1.3 1993/10/16 18:17:52 rgrimes Exp $
+ * $Id: ufs_inode.c,v 1.6 1993/11/25 01:38:33 wollman Exp $
*/
#include "param.h"
@@ -56,6 +56,8 @@
#define INOHASH(dev,ino) (((unsigned)((dev)+(ino)))%INOHSZ)
#endif
+u_long nextgennumber; /* next generation number to assign */
+
union ihead {
union ihead *ih_head[2];
struct inode *ih_chain[2];
@@ -66,6 +68,7 @@ int prtactive; /* 1 => print out reclaim of active vnodes */
/*
* Initialize hash links for inodes.
*/
+void
ufs_init()
{
register int i;
@@ -91,6 +94,7 @@ ufs_init()
* return the inode locked. Detection and handling of mount
* points must be done by the calling routine.
*/
+int
iget(xp, ino, ipp)
struct inode *xp;
ino_t ino;
@@ -115,7 +119,7 @@ loop:
continue;
if ((ip->i_flag&ILOCKED) != 0) {
ip->i_flag |= IWANT;
- sleep((caddr_t)ip, PINOD);
+ tsleep((caddr_t)ip, PINOD, "iget", 0);
goto loop;
}
if (vget(ITOV(ip)))
@@ -242,6 +246,7 @@ loop:
/*
* Unlock and decrement the reference count of an inode structure.
*/
+void
iput(ip)
register struct inode *ip;
{
@@ -256,6 +261,7 @@ iput(ip)
* Last reference to an inode, write the inode out and if necessary,
* truncate and deallocate the file.
*/
+int
ufs_inactive(vp, p)
struct vnode *vp;
struct proc *p;
@@ -301,6 +307,7 @@ ufs_inactive(vp, p)
/*
* Reclaim an inode so that it can be used for other purposes.
*/
+int
ufs_reclaim(vp)
register struct vnode *vp;
{
@@ -344,6 +351,7 @@ ufs_reclaim(vp)
* time is always taken from the current time. If waitfor is set,
* then wait for the disk write of the inode to complete.
*/
+int
iupdat(ip, ta, tm, waitfor)
register struct inode *ip;
struct timeval *ta, *tm;
@@ -392,6 +400,7 @@ iupdat(ip, ta, tm, waitfor)
*
* NB: triple indirect blocks are untested.
*/
+int
itrunc(oip, length, flags)
register struct inode *oip;
u_long length;
@@ -583,6 +592,7 @@ done:
*
* NB: triple indirect blocks are untested.
*/
+int
indirtrunc(ip, bn, lastbn, level, countp)
register struct inode *ip;
daddr_t bn, lastbn;
@@ -673,6 +683,7 @@ indirtrunc(ip, bn, lastbn, level, countp)
/*
* Lock an inode. If its already locked, set the WANT bit and sleep.
*/
+void
ilock(ip)
register struct inode *ip;
{
@@ -682,7 +693,7 @@ ilock(ip)
if (ip->i_spare0 == curproc->p_pid)
panic("locking against myself");
ip->i_spare1 = curproc->p_pid;
- (void) sleep((caddr_t)ip, PINOD);
+ (void) tsleep((caddr_t)ip, PINOD, "ilock", 0);
}
ip->i_spare1 = 0;
ip->i_spare0 = curproc->p_pid;
@@ -692,6 +703,7 @@ ilock(ip)
/*
* Unlock an inode. If WANT bit is on, wakeup.
*/
+void
iunlock(ip)
register struct inode *ip;
{
diff --git a/sys/ufs/ufs_lockf.c b/sys/ufs/ufs_lockf.c
index 98aeb8f9d714..ab089def48f6 100644
--- a/sys/ufs/ufs_lockf.c
+++ b/sys/ufs/ufs_lockf.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)ufs_lockf.c 7.7 (Berkeley) 7/2/91
- * $Id: ufs_lockf.c,v 1.5 1993/10/25 03:19:43 davidg Exp $
+ * $Id: ufs_lockf.c,v 1.7 1993/12/19 00:55:44 wollman Exp $
*/
#include "param.h"
@@ -51,10 +51,14 @@
#include "inode.h"
+static void lf_addblock(struct lockf *, struct lockf *);
+static void lf_split(struct lockf *, struct lockf *);
+static void lf_wakelock(struct lockf *);
/*
* Advisory record locking support
*/
+int
lf_advlock(head, size, id, op, fl, flags)
struct lockf **head;
u_long size;
@@ -157,6 +161,7 @@ int lockf_debug = 0;
/*
* Set a byte-range lock.
*/
+int
lf_setlock(lock)
register struct lockf *lock;
{
@@ -402,6 +407,7 @@ lf_setlock(lock)
* Generally, find the lock (or an overlap to that lock)
* and remove it (or shrink it), then wakeup anyone we can.
*/
+int
lf_clearlock(unlock)
register struct lockf *unlock;
{
@@ -470,6 +476,7 @@ lf_clearlock(unlock)
* Check whether there is a blocking lock,
* and if so return its process identifier.
*/
+int
lf_getlock(lock, fl)
register struct lockf *lock;
register struct flock *fl;
@@ -534,6 +541,7 @@ lf_getblock(lock)
* NOTE: this returns only the FIRST overlapping lock. There
* may be more than one.
*/
+int
lf_findoverlap(lf, lock, type, prev, overlap)
register struct lockf *lf;
struct lockf *lock;
@@ -642,6 +650,7 @@ lf_findoverlap(lf, lock, type, prev, overlap)
/*
* Add a lock to the end of the blocked list.
*/
+static void
lf_addblock(lock, blocked)
struct lockf *lock;
struct lockf *blocked;
@@ -670,6 +679,7 @@ lf_addblock(lock, blocked)
* Split a lock and a contained region into
* two or three locks as necessary.
*/
+static void
lf_split(lock1, lock2)
register struct lockf *lock1;
register struct lockf *lock2;
@@ -716,6 +726,7 @@ lf_split(lock1, lock2)
/*
* Wakeup a blocklist
*/
+static void
lf_wakelock(listhead)
struct lockf *listhead;
{
diff --git a/sys/ufs/ufs_lookup.c b/sys/ufs/ufs_lookup.c
index c557e4e3bec3..06c1cb27314d 100644
--- a/sys/ufs/ufs_lookup.c
+++ b/sys/ufs/ufs_lookup.c
@@ -1,4 +1,11 @@
/*
+ * Copyright (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.
+ */
+/*
* Copyright (c) 1989 The Regents of the University of California.
* All rights reserved.
*
@@ -31,7 +38,7 @@
* SUCH DAMAGE.
*
* from: @(#)ufs_lookup.c 7.33 (Berkeley) 5/19/91
- * $Id: ufs_lookup.c,v 1.4 1993/10/16 18:17:55 rgrimes Exp $
+ * $Id: ufs_lookup.c,v 1.6.2.1 1994/05/04 07:59:10 rgrimes Exp $
*/
#include "param.h"
@@ -88,6 +95,7 @@ int dirchk = 0;
*
* NOTE: (LOOKUP | LOCKPARENT) currently returns the parent inode unlocked.
*/
+int
ufs_lookup(vdp, ndp, p)
register struct vnode *vdp;
register struct nameidata *ndp;
@@ -97,15 +105,15 @@ ufs_lookup(vdp, ndp, p)
register struct fs *fs; /* file system that directory is in */
struct buf *bp = 0; /* a buffer of directory entries */
register struct direct *ep; /* the current directory entry */
- int entryoffsetinblock; /* offset of ep in bp's buffer */
+ int entryoffsetinblock = 0; /* offset of ep in bp's buffer */
enum {NONE, COMPACT, FOUND} slotstatus;
int slotoffset = -1; /* offset of area with free space */
- int slotsize; /* size of area at slotoffset */
- int slotfreespace; /* amount of space free in slot */
- int slotneeded; /* size of the entry we're seeking */
+ int slotsize = 0; /* size of area at slotoffset */
+ int slotfreespace = 0; /* amount of space free in slot */
+ int slotneeded = 0; /* size of the entry we're seeking */
int numdirpasses; /* strategy for directory search */
int endsearch; /* offset to end directory search */
- int prevoff; /* ndp->ni_ufs.ufs_offset of previous entry */
+ int prevoff = 0; /* ndp->ni_ufs.ufs_offset of previous entry */
struct inode *pdp; /* saved dp during symlink work */
struct inode *tdp; /* returned by iget */
off_t enduseful; /* pointer past last used dir slot */
@@ -127,6 +135,8 @@ ufs_lookup(vdp, ndp, p)
*/
if ((dp->i_mode&IFMT) != IFDIR)
return (ENOTDIR);
+ if (dp->i_nlink < 1)
+ return (EINVAL);
if (error = ufs_access(vdp, VEXEC, ndp->ni_cred, p))
return (error);
@@ -539,7 +549,7 @@ found:
return (0);
}
-
+void
dirbad(ip, offset, how)
struct inode *ip;
off_t offset;
@@ -560,6 +570,7 @@ dirbad(ip, offset, how)
* name is not longer than MAXNAMLEN
* name must be as long as advertised, and null terminated
*/
+int
dirbadentry(ep, entryoffsetinblock)
register struct direct *ep;
int entryoffsetinblock;
@@ -584,6 +595,7 @@ dirbadentry(ep, entryoffsetinblock)
* Remaining parameters (ndp->ni_ufs.ufs_offset, ndp->ni_ufs.ufs_count)
* indicate how the space for the new entry is to be obtained.
*/
+int
direnter(ip, ndp)
struct inode *ip;
register struct nameidata *ndp;
@@ -720,6 +732,7 @@ direnter(ip, ndp)
* the space of the now empty record by adding the record size
* to the size of the previous entry.
*/
+int
dirremove(ndp)
register struct nameidata *ndp;
{
@@ -758,6 +771,7 @@ dirremove(ndp)
* supplied. The parameters describing the directory entry are
* set up by a call to namei.
*/
+int
dirrewrite(dp, ip, ndp)
struct inode *dp, *ip;
struct nameidata *ndp;
@@ -780,6 +794,7 @@ dirrewrite(dp, ip, ndp)
* is non-zero, fill it in with a pointer to the
* remaining space in the directory.
*/
+int
blkatoff(ip, offset, res, bpp)
struct inode *ip;
off_t offset;
@@ -813,6 +828,7 @@ blkatoff(ip, offset, res, bpp)
*
* NB: does not handle corrupted directories.
*/
+int
dirempty(ip, parentino, cred)
register struct inode *ip;
ino_t parentino;
@@ -863,6 +879,7 @@ dirempty(ip, parentino, cred)
* Target is supplied locked, source is unlocked.
* The target is always iput() before returning.
*/
+int
checkpath(source, target, cred)
struct inode *source, *target;
struct ucred *cred;
diff --git a/sys/ufs/ufs_quota.c b/sys/ufs/ufs_quota.c
index d38dae185a89..74feec16fdf8 100644
--- a/sys/ufs/ufs_quota.c
+++ b/sys/ufs/ufs_quota.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)ufs_quota.c 7.11 (Berkeley) 6/21/91
- * $Id: ufs_quota.c,v 1.2 1993/10/16 18:17:57 rgrimes Exp $
+ * $Id: ufs_quota.c,v 1.4 1993/11/25 01:38:37 wollman Exp $
*/
#include "param.h"
@@ -65,6 +65,7 @@ static char *quotatypes[] = INITQFNAMES;
* MAXQUOTAS value in quotas.h should be increased, and the
* additional dquots set up here.
*/
+int
getinoquota(ip)
register struct inode *ip;
{
@@ -97,6 +98,7 @@ getinoquota(ip)
/*
* Update disk usage, and take corrective action.
*/
+int
chkdq(ip, change, cred, flags)
register struct inode *ip;
long change;
@@ -119,7 +121,7 @@ chkdq(ip, change, cred, flags)
continue;
while (dq->dq_flags & DQ_LOCK) {
dq->dq_flags |= DQ_WANT;
- sleep((caddr_t)dq, PINOD+1);
+ tsleep((caddr_t)dq, PINOD+1, "chkdq", 0);
}
ncurblocks = dq->dq_curblocks + change;
if (ncurblocks >= 0)
@@ -144,7 +146,7 @@ chkdq(ip, change, cred, flags)
continue;
while (dq->dq_flags & DQ_LOCK) {
dq->dq_flags |= DQ_WANT;
- sleep((caddr_t)dq, PINOD+1);
+ tsleep((caddr_t)dq, PINOD+1, "chkdq", 0);
}
dq->dq_curblocks += change;
dq->dq_flags |= DQ_MOD;
@@ -156,11 +158,12 @@ chkdq(ip, change, cred, flags)
* Check for a valid change to a users allocation.
* Issue an error message if appropriate.
*/
+int
chkdqchg(ip, change, cred, type)
struct inode *ip;
long change;
struct ucred *cred;
- int type;
+ enum quotatype type;
{
register struct dquot *dq = ip->i_dquot[type];
long ncurblocks = dq->dq_curblocks + change;
@@ -208,6 +211,7 @@ chkdqchg(ip, change, cred, type)
/*
* Check the inode limit, applying corrective action.
*/
+int
chkiq(ip, change, cred, flags)
register struct inode *ip;
long change;
@@ -230,7 +234,7 @@ chkiq(ip, change, cred, flags)
continue;
while (dq->dq_flags & DQ_LOCK) {
dq->dq_flags |= DQ_WANT;
- sleep((caddr_t)dq, PINOD+1);
+ tsleep((caddr_t)dq, PINOD+1, "chkiq", 0);
}
ncurinodes = dq->dq_curinodes + change;
if (ncurinodes >= 0)
@@ -255,7 +259,7 @@ chkiq(ip, change, cred, flags)
continue;
while (dq->dq_flags & DQ_LOCK) {
dq->dq_flags |= DQ_WANT;
- sleep((caddr_t)dq, PINOD+1);
+ tsleep((caddr_t)dq, PINOD+1, "chkiq", 0);
}
dq->dq_curinodes += change;
dq->dq_flags |= DQ_MOD;
@@ -267,11 +271,12 @@ chkiq(ip, change, cred, flags)
* Check for a valid change to a users allocation.
* Issue an error message if appropriate.
*/
+int
chkiqchg(ip, change, cred, type)
struct inode *ip;
long change;
struct ucred *cred;
- int type;
+ enum quotatype type;
{
register struct dquot *dq = ip->i_dquot[type];
long ncurinodes = dq->dq_curinodes + change;
@@ -322,6 +327,7 @@ chkiqchg(ip, change, cred, type)
* it is an error for a file to change size and not
* to have a dquot structure associated with it.
*/
+void
chkdquot(ip)
register struct inode *ip;
{
@@ -347,10 +353,11 @@ chkdquot(ip)
/*
* Q_QUOTAON - set up a quota file for a particular file system.
*/
+int
quotaon(p, mp, type, fname)
struct proc *p;
struct mount *mp;
- register int type;
+ enum quotatype type;
caddr_t fname;
{
register struct ufsmount *ump = VFSTOUFS(mp);
@@ -426,10 +433,11 @@ again:
/*
* Q_QUOTAOFF - turn off disk quotas for a filesystem.
*/
+int
quotaoff(p, mp, type)
struct proc *p;
struct mount *mp;
- register int type;
+ enum quotatype type;
{
register struct vnode *vp;
struct vnode *qvp, *nextvp;
@@ -478,10 +486,11 @@ again:
/*
* Q_GETQUOTA - return current values in a dqblk structure.
*/
+int
getquota(mp, id, type, addr)
struct mount *mp;
u_long id;
- int type;
+ enum quotatype type;
caddr_t addr;
{
struct dquot *dq;
@@ -497,10 +506,11 @@ getquota(mp, id, type, addr)
/*
* Q_SETQUOTA - assign an entire dqblk structure.
*/
+int
setquota(mp, id, type, addr)
struct mount *mp;
u_long id;
- int type;
+ enum quotatype type;
caddr_t addr;
{
register struct dquot *dq;
@@ -516,7 +526,7 @@ setquota(mp, id, type, addr)
dq = ndq;
while (dq->dq_flags & DQ_LOCK) {
dq->dq_flags |= DQ_WANT;
- sleep((caddr_t)dq, PINOD+1);
+ tsleep((caddr_t)dq, PINOD+1, "setquota", 0);
}
/*
* Copy all but the current values.
@@ -555,10 +565,11 @@ setquota(mp, id, type, addr)
/*
* Q_SETUSE - set current inode and block usage.
*/
+int
setuse(mp, id, type, addr)
struct mount *mp;
u_long id;
- int type;
+ enum quotatype type;
caddr_t addr;
{
register struct dquot *dq;
@@ -574,7 +585,7 @@ setuse(mp, id, type, addr)
dq = ndq;
while (dq->dq_flags & DQ_LOCK) {
dq->dq_flags |= DQ_WANT;
- sleep((caddr_t)dq, PINOD+1);
+ tsleep((caddr_t)dq, PINOD+1, "setuse", 0);
}
/*
* Reset time limit if have a soft limit and were
@@ -600,6 +611,7 @@ setuse(mp, id, type, addr)
/*
* Q_SYNC - sync quota files to disk.
*/
+int
qsync(mp)
struct mount *mp;
{
@@ -669,6 +681,7 @@ long numdquot, desireddquot = DQUOTINC;
/*
* Initialize the quota system.
*/
+void
dqinit()
{
register union dqhead *dhp;
@@ -690,11 +703,12 @@ dqinit()
* Obtain a dquot structure for the specified identifier and quota file
* reading the information from the file if necessary.
*/
+int
dqget(vp, id, ump, type, dqp)
struct vnode *vp;
u_long id;
register struct ufsmount *ump;
- register int type;
+ enum quotatype type;
struct dquot **dqp;
{
register struct dquot *dq;
@@ -820,6 +834,7 @@ dqget(vp, id, ump, type, dqp)
/*
* Obtain a reference to a dquot.
*/
+void
dqref(dq)
struct dquot *dq;
{
@@ -830,6 +845,7 @@ dqref(dq)
/*
* Release a reference to a dquot.
*/
+void
dqrele(vp, dq)
struct vnode *vp;
register struct dquot *dq;
@@ -859,6 +875,7 @@ dqrele(vp, dq)
/*
* Update the disk quota in the quota file.
*/
+int
dqsync(vp, dq)
struct vnode *vp;
register struct dquot *dq;
@@ -878,7 +895,7 @@ dqsync(vp, dq)
VOP_LOCK(dqvp);
while (dq->dq_flags & DQ_LOCK) {
dq->dq_flags |= DQ_WANT;
- sleep((caddr_t)dq, PINOD+2);
+ tsleep((caddr_t)dq, PINOD+2, "dqsync", 0);
if ((dq->dq_flags & DQ_MOD) == 0) {
if (vp != dqvp)
VOP_UNLOCK(dqvp);
@@ -909,6 +926,7 @@ dqsync(vp, dq)
/*
* Flush all entries from the cache for a particular vnode.
*/
+void
dqflush(vp)
register struct vnode *vp;
{
diff --git a/sys/ufs/ufs_subr.c b/sys/ufs/ufs_subr.c
index 04c004e18b05..04b159fbb9cc 100644
--- a/sys/ufs/ufs_subr.c
+++ b/sys/ufs/ufs_subr.c
@@ -31,11 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)ufs_subr.c 7.13 (Berkeley) 6/28/90
- * $Id: ufs_subr.c,v 1.2 1993/10/16 18:17:59 rgrimes Exp $
+ * $Id: ufs_subr.c,v 1.4 1993/12/19 00:55:45 wollman Exp $
*/
#ifdef KERNEL
#include "param.h"
+#include "systm.h"
#include "../ufs/fs.h"
#else
#include <sys/param.h>
@@ -50,6 +51,7 @@ extern u_char *fragtbl[];
* Update the frsum fields to reflect addition or deletion
* of some frags.
*/
+void
fragacct(fs, fragmap, fraglist, cnt)
struct fs *fs;
int fragmap;
@@ -85,6 +87,7 @@ fragacct(fs, fragmap, fraglist, cnt)
*
* check if a block is available
*/
+int
isblock(fs, cp, h)
struct fs *fs;
unsigned char *cp;
@@ -113,6 +116,7 @@ isblock(fs, cp, h)
/*
* take a block out of the map
*/
+void
clrblock(fs, cp, h)
struct fs *fs;
u_char *cp;
@@ -140,6 +144,7 @@ clrblock(fs, cp, h)
/*
* put a block into the map
*/
+void
setblock(fs, cp, h)
struct fs *fs;
unsigned char *cp;
@@ -171,6 +176,7 @@ setblock(fs, cp, h)
* C definitions of special instructions.
* Normally expanded with inline.
*/
+int
scanc(size, cp, table, mask)
u_int size;
register u_char *cp, table[];
@@ -185,6 +191,7 @@ scanc(size, cp, table, mask)
#endif
#if !defined(vax) && !defined(tahoe) && !defined(hp300)
+int
skpc(mask, size, cp)
register u_char mask;
u_int size;
@@ -197,6 +204,7 @@ skpc(mask, size, cp)
return (end - cp);
}
+int
locc(mask, size, cp)
register u_char mask;
u_int size;
diff --git a/sys/ufs/ufs_tables.c b/sys/ufs/ufs_tables.c
index 04b3a33b1ca9..5c704214fe08 100644
--- a/sys/ufs/ufs_tables.c
+++ b/sys/ufs/ufs_tables.c
@@ -31,11 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)ufs_tables.c 7.4 (Berkeley) 6/28/90
- * $Id: ufs_tables.c,v 1.2 1993/10/16 18:18:00 rgrimes Exp $
+ * $Id: ufs_tables.c,v 1.3 1993/12/19 00:55:46 wollman Exp $
*/
#ifdef KERNEL
#include "param.h"
+#include "systm.h"
#else
#include <sys/param.h>
#endif
diff --git a/sys/ufs/ufs_vfsops.c b/sys/ufs/ufs_vfsops.c
index 8265be2d0874..5eaaf387e572 100644
--- a/sys/ufs/ufs_vfsops.c
+++ b/sys/ufs/ufs_vfsops.c
@@ -1,4 +1,11 @@
/*
+ * Copyright (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.
+ */
+/*
* Copyright (c) 1989, 1991 The Regents of the University of California.
* All rights reserved.
*
@@ -31,7 +38,7 @@
* SUCH DAMAGE.
*
* from: @(#)ufs_vfsops.c 7.56 (Berkeley) 6/28/91
- * $Id: ufs_vfsops.c,v 1.4 1993/10/16 18:18:01 rgrimes Exp $
+ * $Id: ufs_vfsops.c,v 1.6.2.1 1994/05/04 07:59:13 rgrimes Exp $
*/
#include "param.h"
@@ -55,6 +62,8 @@
#include "ufsmount.h"
#include "inode.h"
+int mountfs(struct vnode *, struct mount *, struct proc *);
+
struct vfsops ufs_vfsops = {
ufs_mount,
ufs_start,
@@ -80,6 +89,7 @@ int doforce = 1;
*/
#define ROOTNAME "root_device"
+int
ufs_mountroot()
{
register struct mount *mp;
@@ -130,6 +140,7 @@ ufs_mountroot()
*
* mount system call
*/
+int
ufs_mount(mp, path, data, ndp, p)
register struct mount *mp;
char *path;
@@ -139,7 +150,7 @@ ufs_mount(mp, path, data, ndp, p)
{
struct vnode *devvp;
struct ufs_args args;
- struct ufsmount *ump;
+ struct ufsmount *ump = 0;
register struct fs *fs;
u_int size;
int error;
@@ -219,6 +230,7 @@ ufs_mount(mp, path, data, ndp, p)
/*
* Common code for mount and mountroot
*/
+int
mountfs(devvp, mp, p)
register struct vnode *devvp;
struct mount *mp;
@@ -337,6 +349,7 @@ out:
* Nothing to do at the moment.
*/
/* ARGSUSED */
+int
ufs_start(mp, flags, p)
struct mount *mp;
int flags;
@@ -349,6 +362,7 @@ ufs_start(mp, flags, p)
/*
* unmount system call
*/
+int
ufs_unmount(mp, mntflags, p)
struct mount *mp;
int mntflags;
@@ -401,6 +415,7 @@ ufs_unmount(mp, mntflags, p)
/*
* Check to see if a filesystem is mounted on a block device.
*/
+int
mountedon(vp)
register struct vnode *vp;
{
@@ -423,6 +438,7 @@ mountedon(vp)
/*
* Return root of a filesystem
*/
+int
ufs_root(mp, vpp)
struct mount *mp;
struct vnode **vpp;
@@ -446,6 +462,7 @@ ufs_root(mp, vpp)
/*
* Do operations associated with quotas
*/
+int
ufs_quotactl(mp, cmds, uid, arg, p)
struct mount *mp;
int cmds;
@@ -516,6 +533,7 @@ ufs_quotactl(mp, cmds, uid, arg, p)
/*
* Get file system statistics.
*/
+int
ufs_statfs(mp, sbp, p)
struct mount *mp;
register struct statfs *sbp;
@@ -556,6 +574,7 @@ int syncprt = 0;
*
* Note: we are always called with the filesystem marked `MPBUSY'.
*/
+int
ufs_sync(mp, waitfor)
struct mount *mp;
int waitfor;
@@ -622,6 +641,7 @@ loop:
/*
* Write a superblock and associated information back to disk.
*/
+int
sbupdate(mp, waitfor)
struct ufsmount *mp;
int waitfor;
@@ -659,36 +679,6 @@ sbupdate(mp, waitfor)
}
/*
- * Print out statistics on the current allocation of the buffer pool.
- * Can be enabled to print out on every ``sync'' by setting "syncprt"
- * above.
- */
-bufstats()
-{
- int s, i, j, count;
- register struct buf *bp, *dp;
- int counts[MAXBSIZE/CLBYTES+1];
- static char *bname[BQUEUES] = { "LOCKED", "LRU", "AGE", "EMPTY" };
-
- for (bp = bfreelist, i = 0; bp < &bfreelist[BQUEUES]; bp++, i++) {
- count = 0;
- for (j = 0; j <= MAXBSIZE/CLBYTES; j++)
- counts[j] = 0;
- s = splbio();
- for (dp = bp->av_forw; dp != bp; dp = dp->av_forw) {
- counts[dp->b_bufsize/CLBYTES]++;
- count++;
- }
- splx(s);
- printf("%s: total-%d", bname[i], count);
- for (j = 0; j <= MAXBSIZE/CLBYTES; j++)
- if (counts[j] != 0)
- printf(", %d-%d", j * CLBYTES, counts[j]);
- printf("\n");
- }
-}
-
-/*
* File handle to vnode
*
* Have to be really careful about stale file handles:
@@ -697,6 +687,7 @@ bufstats()
* - check for an unallocated inode (i_mode == 0)
* - check that the generation number matches
*/
+int
ufs_fhtovp(mp, fhp, vpp)
register struct mount *mp;
struct fid *fhp;
@@ -743,6 +734,7 @@ ufs_fhtovp(mp, fhp, vpp)
* Vnode pointer to File handle
*/
/* ARGSUSED */
+int
ufs_vptofh(vp, fhp)
struct vnode *vp;
struct fid *fhp;
diff --git a/sys/ufs/ufs_vnops.c b/sys/ufs/ufs_vnops.c
index 4c254ad0d546..096cb1f3a338 100644
--- a/sys/ufs/ufs_vnops.c
+++ b/sys/ufs/ufs_vnops.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)ufs_vnops.c 7.64 (Berkeley) 5/16/91
- * $Id: ufs_vnops.c,v 1.5.2.1 1993/11/13 22:52:24 rgrimes Exp $
+ * $Id: ufs_vnops.c,v 1.14 1994/01/19 21:09:26 jtc Exp $
*/
#include "param.h"
@@ -56,9 +56,18 @@
#include "dir.h"
#include "fs.h"
+/* Get the current value of _POSIX_CHOWN_RESTRICTED */
+#include "sys/unistd.h" /* make sure to get sys/ version. */
+
+static int maknode(int, struct nameidata *, struct inode **);
+
+/* XXX - don't want to change ucred.h again */
+extern int groupmember(int /*gid_t*/, struct ucred *);
+
/*
* Create a regular file
*/
+int
ufs_create(ndp, vap, p)
struct nameidata *ndp;
struct vattr *vap;
@@ -77,6 +86,7 @@ ufs_create(ndp, vap, p)
* Mknod vnode call
*/
/* ARGSUSED */
+int
ufs_mknod(ndp, vap, cred, p)
struct nameidata *ndp;
struct ucred *cred;
@@ -115,6 +125,7 @@ ufs_mknod(ndp, vap, cred, p)
* Nothing to do.
*/
/* ARGSUSED */
+int
ufs_open(vp, mode, cred, p)
struct vnode *vp;
int mode;
@@ -131,6 +142,7 @@ ufs_open(vp, mode, cred, p)
* Update the times on the inode.
*/
/* ARGSUSED */
+int
ufs_close(vp, fflag, cred, p)
struct vnode *vp;
int fflag;
@@ -149,6 +161,7 @@ ufs_close(vp, fflag, cred, p)
* The mode is shifted to select the owner/group/other fields. The
* super user is granted all permissions.
*/
+int
ufs_access(vp, mode, cred, p)
struct vnode *vp;
register int mode;
@@ -200,6 +213,7 @@ found:
}
/* ARGSUSED */
+int
ufs_getattr(vp, vap, cred, p)
struct vnode *vp;
register struct vattr *vap;
@@ -223,7 +237,7 @@ ufs_getattr(vp, vap, cred, p)
vap->va_size = ip->i_size;
vap->va_size_rsv = 0;
#else
- vap->va_qsize = ip->i_din.di_qsize;
+ vap->va_qsize.v = ip->i_din.di_qsize.v;
#endif
vap->va_atime.tv_sec = ip->i_atime;
vap->va_atime.tv_usec = 0;
@@ -249,6 +263,7 @@ ufs_getattr(vp, vap, cred, p)
/*
* Set attribute vnode op. called from several syscalls
*/
+int
ufs_setattr(vp, vap, cred, p)
register struct vnode *vp;
register struct vattr *vap;
@@ -281,7 +296,9 @@ ufs_setattr(vp, vap, cred, p)
}
if (vap->va_atime.tv_sec != VNOVAL || vap->va_mtime.tv_sec != VNOVAL) {
if (cred->cr_uid != ip->i_uid &&
- (error = suser(cred, &p->p_acflag)))
+ (error = suser(cred, &p->p_acflag)) &&
+ ((vap->va_vaflags & VA_UTIMES_NULL) == 0 ||
+ (error = VOP_ACCESS(vp, VWRITE, cred, p))))
return (error);
if (vap->va_atime.tv_sec != VNOVAL)
ip->i_flag |= IACC;
@@ -300,7 +317,7 @@ ufs_setattr(vp, vap, cred, p)
if (cred->cr_uid == 0) {
ip->i_flags = vap->va_flags;
} else {
- ip->i_flags &= 0xffff0000;
+ ip->i_flags &= 0xffff0000ul;
ip->i_flags |= (vap->va_flags & 0xffff);
}
ip->i_flag |= ICHG;
@@ -312,6 +329,7 @@ ufs_setattr(vp, vap, cred, p)
* Change the mode on a file.
* Inode must be locked before calling.
*/
+int
chmod1(vp, mode, p)
register struct vnode *vp;
register int mode;
@@ -342,6 +360,7 @@ chmod1(vp, mode, p)
* Perform chown operation on inode ip;
* inode must be locked prior to call.
*/
+int
chown1(vp, uid, gid, p)
register struct vnode *vp;
uid_t uid;
@@ -367,10 +386,16 @@ chown1(vp, uid, gid, p)
* of the file, or are not a member of the target group,
* the caller must be superuser or the call fails.
*/
+#ifdef _POSIX_CHOWN_RESTRICTED
if ((cred->cr_uid != ip->i_uid || uid != ip->i_uid ||
!groupmember((gid_t)gid, cred)) &&
(error = suser(cred, &p->p_acflag)))
return (error);
+#else
+ if ((cred->cr_uid != ip->i_uid || !groupmember((gid_t)gid, cred))
+ && (error = suser(cred, &p->p_acflag)))
+ return error;
+#endif
ouid = ip->i_uid;
ogid = ip->i_gid;
#ifdef QUOTA
@@ -448,6 +473,7 @@ good:
* Vnode op for reading.
*/
/* ARGSUSED */
+int
ufs_read(vp, uio, ioflag, cred)
struct vnode *vp;
register struct uio *uio;
@@ -510,6 +536,7 @@ ufs_read(vp, uio, ioflag, cred)
/*
* Vnode op for writing.
*/
+int
ufs_write(vp, uio, ioflag, cred)
register struct vnode *vp;
struct uio *uio;
@@ -566,7 +593,9 @@ ufs_write(vp, uio, ioflag, cred)
if (ioflag & IO_SYNC)
flags = B_SYNC;
- (void) vnode_pager_uncache(vp);
+ if ((ioflag & IO_PAGER) == 0)
+ (void) vnode_pager_uncache(vp);
+
do {
lbn = lblkno(fs, uio->uio_offset);
on = blkoff(fs, uio->uio_offset);
@@ -607,6 +636,7 @@ ufs_write(vp, uio, ioflag, cred)
}
/* ARGSUSED */
+int
ufs_ioctl(vp, com, data, fflag, cred, p)
struct vnode *vp;
int com;
@@ -620,6 +650,7 @@ ufs_ioctl(vp, com, data, fflag, cred, p)
}
/* ARGSUSED */
+int
ufs_select(vp, which, fflags, cred, p)
struct vnode *vp;
int which, fflags;
@@ -639,6 +670,7 @@ ufs_select(vp, which, fflags, cred, p)
* NB Currently unsupported.
*/
/* ARGSUSED */
+int
ufs_mmap(vp, fflags, cred, p)
struct vnode *vp;
int fflags;
@@ -653,6 +685,7 @@ ufs_mmap(vp, fflags, cred, p)
* Synch an open file.
*/
/* ARGSUSED */
+int
ufs_fsync(vp, fflags, cred, waitfor, p)
struct vnode *vp;
int fflags;
@@ -674,6 +707,7 @@ ufs_fsync(vp, fflags, cred, waitfor, p)
* Nothing to do, so just return.
*/
/* ARGSUSED */
+int
ufs_seek(vp, oldoff, newoff, cred)
struct vnode *vp;
off_t oldoff, newoff;
@@ -688,6 +722,7 @@ ufs_seek(vp, oldoff, newoff, cred)
* Hard to avoid races here, especially
* in unlinking directories.
*/
+int
ufs_remove(ndp, p)
struct nameidata *ndp;
struct proc *p;
@@ -713,6 +748,7 @@ ufs_remove(ndp, p)
/*
* link vnode call
*/
+int
ufs_link(vp, ndp, p)
register struct vnode *vp;
register struct nameidata *ndp;
@@ -771,6 +807,7 @@ ufs_link(vp, ndp, p)
* is different from the source, patch the ".." entry in the
* directory.
*/
+int
ufs_rename(fndp, tndp, p)
register struct nameidata *fndp, *tndp;
struct proc *p;
@@ -1085,6 +1122,7 @@ struct dirtemplate mastertemplate = {
/*
* Mkdir system call
*/
+int
ufs_mkdir(ndp, vap, p)
struct nameidata *ndp;
struct vattr *vap;
@@ -1200,6 +1238,7 @@ bad:
/*
* Rmdir system call.
*/
+int
ufs_rmdir(ndp, p)
register struct nameidata *ndp;
struct proc *p;
@@ -1264,6 +1303,7 @@ out:
/*
* symlink -- make a symbolic link
*/
+int
ufs_symlink(ndp, vap, target, p)
struct nameidata *ndp;
struct vattr *vap;
@@ -1296,6 +1336,7 @@ ufs_symlink(ndp, vap, target, p)
/*
* Vnode op for read and write
*/
+int
ufs_readdir(vp, uio, cred, eofflagp)
struct vnode *vp;
register struct uio *uio;
@@ -1323,6 +1364,7 @@ ufs_readdir(vp, uio, cred, eofflagp)
/*
* Return target name of a symbolic link
*/
+int
ufs_readlink(vp, uiop, cred)
struct vnode *vp;
struct uio *uiop;
@@ -1340,6 +1382,7 @@ ufs_readlink(vp, uiop, cred)
* done. If a buffer has been saved in anticipation of a CREATE, delete it.
*/
/* ARGSUSED */
+int
ufs_abortop(ndp)
struct nameidata *ndp;
{
@@ -1352,6 +1395,7 @@ ufs_abortop(ndp)
/*
* Lock an inode.
*/
+int
ufs_lock(vp)
struct vnode *vp;
{
@@ -1364,6 +1408,7 @@ ufs_lock(vp)
/*
* Unlock an inode.
*/
+int
ufs_unlock(vp)
struct vnode *vp;
{
@@ -1378,6 +1423,7 @@ ufs_unlock(vp)
/*
* Check for a locked inode.
*/
+int
ufs_islocked(vp)
struct vnode *vp;
{
@@ -1390,6 +1436,7 @@ ufs_islocked(vp)
/*
* Get access to bmap
*/
+int
ufs_bmap(vp, bn, vpp, bnp)
struct vnode *vp;
daddr_t bn;
@@ -1411,6 +1458,7 @@ ufs_bmap(vp, bn, vpp, bnp)
*/
int checkoverlap = 0;
+int
ufs_strategy(bp)
register struct buf *bp;
{
@@ -1468,6 +1516,7 @@ ufs_strategy(bp)
/*
* Print out the contents of an inode.
*/
+void
ufs_print(vp)
struct vnode *vp;
{
@@ -1491,6 +1540,7 @@ ufs_print(vp)
/*
* Read wrapper for special devices.
*/
+int
ufsspec_read(vp, uio, ioflag, cred)
struct vnode *vp;
struct uio *uio;
@@ -1508,6 +1558,7 @@ ufsspec_read(vp, uio, ioflag, cred)
/*
* Write wrapper for special devices.
*/
+int
ufsspec_write(vp, uio, ioflag, cred)
struct vnode *vp;
struct uio *uio;
@@ -1527,6 +1578,7 @@ ufsspec_write(vp, uio, ioflag, cred)
*
* Update the times on the inode then do device close.
*/
+int
ufsspec_close(vp, fflag, cred, p)
struct vnode *vp;
int fflag;
@@ -1544,6 +1596,7 @@ ufsspec_close(vp, fflag, cred, p)
/*
* Read wrapper for fifo's
*/
+int
ufsfifo_read(vp, uio, ioflag, cred)
struct vnode *vp;
struct uio *uio;
@@ -1561,6 +1614,7 @@ ufsfifo_read(vp, uio, ioflag, cred)
/*
* Write wrapper for fifo's.
*/
+int
ufsfifo_write(vp, uio, ioflag, cred)
struct vnode *vp;
struct uio *uio;
@@ -1580,6 +1634,7 @@ ufsfifo_write(vp, uio, ioflag, cred)
*
* Update the times on the inode then do device close.
*/
+int
ufsfifo_close(vp, fflag, cred, p)
struct vnode *vp;
int fflag;
@@ -1597,6 +1652,7 @@ ufsfifo_close(vp, fflag, cred, p)
/*
* Allocate a new inode.
*/
+static int
maknode(mode, ndp, ipp)
int mode;
register struct nameidata *ndp;
@@ -1674,6 +1730,7 @@ bad:
/*
* Advisory record locking support
*/
+int
ufs_advlock(vp, id, op, fl, flags)
struct vnode *vp;
caddr_t id;
diff --git a/sys/ufs/ufsmount.h b/sys/ufs/ufsmount.h
index 6eca1bd4e493..ecde1f2bcefb 100644
--- a/sys/ufs/ufsmount.h
+++ b/sys/ufs/ufsmount.h
@@ -31,9 +31,12 @@
* SUCH DAMAGE.
*
* from: @(#)ufsmount.h 7.9 (Berkeley) 5/8/91
- * $Id: ufsmount.h,v 1.2 1993/10/16 18:18:05 rgrimes Exp $
+ * $Id: ufsmount.h,v 1.4 1993/11/25 01:38:41 wollman Exp $
*/
+#ifndef _UFS_UFSMOUNT_H_
+#define _UFS_UFSMOUNT_H_ 1
+
/*
* This structure describes the UFS specific mount structure data.
*/
@@ -59,7 +62,6 @@ struct ufsmount {
* Convert mount ptr to ufsmount ptr.
*/
#define VFSTOUFS(mp) ((struct ufsmount *)((mp)->mnt_data))
-#endif /* KERNEL */
/*
* Prototypes for UFS mount operations
@@ -75,4 +77,6 @@ int ufs_statfs __P((struct mount *mp, struct statfs *sbp, struct proc *p));
int ufs_sync __P((struct mount *mp, int waitfor));
int ufs_fhtovp __P((struct mount *mp, struct fid *fhp, struct vnode **vpp));
int ufs_vptofh __P((struct vnode *vp, struct fid *fhp));
-int ufs_init __P(());
+void ufs_init __P(());
+#endif /* KERNEL */
+#endif /* _UFS_UFSMOUNT_H_ */