[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree
zrouter-src-freebsd at zrouter.org
zrouter-src-freebsd at zrouter.org
Fri Mar 2 15:39:30 UTC 2012
details: http://zrouter.org/hg/FreeBSD/head//rev/de99a27dd03c
changeset: 388:de99a27dd03c
user: ray at terran.dlink.ua
date: Fri Mar 02 17:12:32 2012 +0200
description:
Update to FreeBSD-HEAD @232391
diffstat:
head/sys/fs/cd9660/cd9660_vfsops.c | 4 +-
head/sys/fs/cd9660/cd9660_vnops.c | 6 +-
head/sys/fs/devfs/devfs.h | 4 +-
head/sys/fs/devfs/devfs_devs.c | 3 +-
head/sys/fs/devfs/devfs_rule.c | 37 ++-
head/sys/fs/devfs/devfs_vfsops.c | 62 ++++-
head/sys/fs/devfs/devfs_vnops.c | 8 +-
head/sys/fs/ext2fs/ext2_dinode.h | 6 +-
head/sys/fs/ext2fs/ext2_lookup.c | 5 +-
head/sys/fs/ext2fs/ext2fs.h | 31 +-
head/sys/fs/ext2fs/inode.h | 13 +-
head/sys/fs/fifofs/fifo.h | 3 +-
head/sys/fs/fifofs/fifo_vnops.c | 482 +++++----------------------------
head/sys/fs/msdosfs/msdosfs_denode.c | 6 +-
head/sys/fs/msdosfs/msdosfs_lookup.c | 8 +-
head/sys/fs/msdosfs/msdosfs_vnops.c | 10 +-
head/sys/fs/nfs/nfs_commonport.c | 5 +-
head/sys/fs/nfsclient/nfs_clbio.c | 35 +-
head/sys/fs/nfsclient/nfs_clport.c | 8 +-
head/sys/fs/nfsclient/nfs_clstate.c | 10 +-
head/sys/fs/nfsclient/nfs_clvfsops.c | 6 +-
head/sys/fs/nfsclient/nfs_clvnops.c | 9 +-
head/sys/fs/nfsserver/nfs_nfsdcache.c | 13 +-
head/sys/fs/nfsserver/nfs_nfsdport.c | 8 +-
head/sys/fs/nfsserver/nfs_nfsdstate.c | 4 +-
head/sys/fs/ntfs/ntfs.h | 4 +-
head/sys/fs/ntfs/ntfs_vfsops.c | 35 +-
head/sys/fs/nullfs/null_subr.c | 40 +-
head/sys/fs/nullfs/null_vfsops.c | 18 +-
head/sys/fs/nullfs/null_vnops.c | 23 +-
head/sys/fs/nwfs/nwfs_vnops.c | 4 +-
head/sys/fs/procfs/procfs.c | 4 +-
head/sys/fs/pseudofs/pseudofs.h | 10 +-
head/sys/fs/pseudofs/pseudofs_vnops.c | 5 +-
head/sys/fs/smbfs/smbfs_vnops.c | 4 +-
head/sys/fs/tmpfs/tmpfs_vnops.c | 9 +-
head/sys/fs/udf/udf_vnops.c | 5 +-
37 files changed, 394 insertions(+), 553 deletions(-)
diffs (2055 lines):
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/cd9660/cd9660_vfsops.c
--- a/head/sys/fs/cd9660/cd9660_vfsops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/cd9660/cd9660_vfsops.c Fri Mar 02 17:12:32 2012 +0200
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/cd9660/cd9660_vfsops.c 230249 2012-01-17 01:08:01Z mckusick $");
+__FBSDID("$FreeBSD: head/sys/fs/cd9660/cd9660_vfsops.c 231932 2012-02-20 09:56:14Z kevlo $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -205,7 +205,7 @@
struct vnode *devvp;
struct mount *mp;
{
- struct iso_mnt *isomp = (struct iso_mnt *)0;
+ struct iso_mnt *isomp = NULL;
struct buf *bp = NULL;
struct buf *pribp = NULL, *supbp = NULL;
struct cdev *dev;
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/cd9660/cd9660_vnops.c
--- a/head/sys/fs/cd9660/cd9660_vnops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/cd9660/cd9660_vnops.c Fri Mar 02 17:12:32 2012 +0200
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/fs/cd9660/cd9660_vnops.c 231949 2012-02-21 01:05:12Z kib $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -318,7 +318,7 @@
do {
lbn = lblkno(imp, uio->uio_offset);
on = blkoff(imp, uio->uio_offset);
- n = min((u_int)(imp->logical_block_size - on),
+ n = MIN((u_int)(imp->logical_block_size - on),
uio->uio_resid);
diff = (off_t)ip->i_size - uio->uio_offset;
if (diff <= 0)
@@ -343,7 +343,7 @@
} else
error = bread(vp, lbn, size, NOCRED, &bp);
}
- n = min(n, size - bp->b_resid);
+ n = MIN(n, size - bp->b_resid);
if (error) {
brelse(bp);
return (error);
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/devfs/devfs.h
--- a/head/sys/fs/devfs/devfs.h Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/devfs/devfs.h Fri Mar 02 17:12:32 2012 +0200
@@ -33,7 +33,7 @@
* @(#)kernfs.h 8.6 (Berkeley) 3/29/95
* From: FreeBSD: src/sys/miscfs/kernfs/kernfs.h 1.14
*
- * $FreeBSD$
+ * $FreeBSD: head/sys/fs/devfs/devfs.h 231265 2012-02-09 10:09:12Z mm $
*/
#ifndef _FS_DEVFS_DEVFS_H_
@@ -182,6 +182,8 @@
void devfs_rules_cleanup(struct devfs_mount *);
int devfs_rules_ioctl(struct devfs_mount *, u_long, caddr_t,
struct thread *);
+void devfs_ruleset_set(devfs_rsnum rsnum, struct devfs_mount *dm);
+void devfs_ruleset_apply(struct devfs_mount *dm);
int devfs_allocv(struct devfs_dirent *, struct mount *, int,
struct vnode **);
char *devfs_fqpn(char *, struct devfs_mount *, struct devfs_dirent *,
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/devfs/devfs_devs.c
--- a/head/sys/fs/devfs/devfs_devs.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/devfs/devfs_devs.c Fri Mar 02 17:12:32 2012 +0200
@@ -25,7 +25,7 @@
*
* From: FreeBSD: src/sys/miscfs/kernfs/kernfs_vfsops.c 1.36
*
- * $FreeBSD: head/sys/fs/devfs/devfs_devs.c 226041 2011-10-05 16:50:15Z kib $
+ * $FreeBSD: head/sys/fs/devfs/devfs_devs.c 231379 2012-02-10 12:40:50Z ed $
*/
#include <sys/param.h>
@@ -133,7 +133,6 @@
cdev = &cdp->cdp_c;
- cdev->si_name = cdev->__si_namebuf;
LIST_INIT(&cdev->si_children);
vfs_timestamp(&ts);
cdev->si_atime = cdev->si_mtime = cdev->si_ctime = ts;
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/devfs/devfs_rule.c
--- a/head/sys/fs/devfs/devfs_rule.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/devfs/devfs_rule.c Fri Mar 02 17:12:32 2012 +0200
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/sys/fs/devfs/devfs_rule.c 227489 2011-11-13 17:06:33Z eadler $
+ * $FreeBSD: head/sys/fs/devfs/devfs_rule.c 231265 2012-02-09 10:09:12Z mm $
*/
/*
@@ -771,3 +771,38 @@
devfs_ruleset_reap(ds);
}
}
+
+/*
+ * Make rsnum the active ruleset for dm (locked)
+ */
+void
+devfs_ruleset_set(devfs_rsnum rsnum, struct devfs_mount *dm)
+{
+
+ sx_assert(&dm->dm_lock, SX_XLOCKED);
+
+ sx_xlock(&sx_rules);
+ devfs_ruleset_use(rsnum, dm);
+ sx_xunlock(&sx_rules);
+}
+
+/*
+ * Apply the current active ruleset on a mount
+ */
+void
+devfs_ruleset_apply(struct devfs_mount *dm)
+{
+ struct devfs_ruleset *ds;
+
+ sx_assert(&dm->dm_lock, SX_XLOCKED);
+
+ sx_xlock(&sx_rules);
+ if (dm->dm_ruleset == 0) {
+ sx_xunlock(&sx_rules);
+ return;
+ }
+ ds = devfs_ruleset_bynum(dm->dm_ruleset);
+ if (ds != NULL)
+ devfs_ruleset_applydm(ds, dm);
+ sx_xunlock(&sx_rules);
+}
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/devfs/devfs_vfsops.c
--- a/head/sys/fs/devfs/devfs_vfsops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/devfs/devfs_vfsops.c Fri Mar 02 17:12:32 2012 +0200
@@ -31,7 +31,7 @@
* @(#)kernfs_vfsops.c 8.10 (Berkeley) 5/14/95
* From: FreeBSD: src/sys/miscfs/kernfs/kernfs_vfsops.c 1.36
*
- * $FreeBSD$
+ * $FreeBSD: head/sys/fs/devfs/devfs_vfsops.c 232307 2012-02-29 16:16:36Z mm $
*/
#include <sys/param.h>
@@ -44,6 +44,7 @@
#include <sys/sx.h>
#include <sys/vnode.h>
#include <sys/limits.h>
+#include <sys/jail.h>
#include <fs/devfs/devfs.h>
@@ -56,6 +57,10 @@
static vfs_root_t devfs_root;
static vfs_statfs_t devfs_statfs;
+static const char *devfs_opts[] = {
+ "from", "export", "ruleset", NULL
+};
+
/*
* Mount the filesystem
*/
@@ -65,15 +70,60 @@
int error;
struct devfs_mount *fmp;
struct vnode *rvp;
+ struct thread *td = curthread;
+ int injail, rsnum;
if (devfs_unr == NULL)
devfs_unr = new_unrhdr(0, INT_MAX, NULL);
error = 0;
- if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS))
+ if (mp->mnt_flag & MNT_ROOTFS)
return (EOPNOTSUPP);
+ if (!prison_allow(td->td_ucred, PR_ALLOW_MOUNT_DEVFS))
+ return (EPERM);
+
+ rsnum = 0;
+ injail = jailed(td->td_ucred);
+
+ if (mp->mnt_optnew != NULL) {
+ if (vfs_filteropt(mp->mnt_optnew, devfs_opts))
+ return (EINVAL);
+
+ if (vfs_flagopt(mp->mnt_optnew, "export", NULL, 0))
+ return (EOPNOTSUPP);
+
+ if (vfs_getopt(mp->mnt_optnew, "ruleset", NULL, NULL) == 0 &&
+ (vfs_scanopt(mp->mnt_optnew, "ruleset", "%d",
+ &rsnum) != 1 || rsnum < 0 || rsnum > 65535)) {
+ vfs_mount_error(mp, "%s",
+ "invalid ruleset specification");
+ return (EINVAL);
+ }
+
+ if (injail && rsnum != 0 &&
+ rsnum != td->td_ucred->cr_prison->pr_devfs_rsnum)
+ return (EPERM);
+ }
+
+ /* jails enforce their ruleset */
+ if (injail)
+ rsnum = td->td_ucred->cr_prison->pr_devfs_rsnum;
+
+ if (mp->mnt_flag & MNT_UPDATE) {
+ if (rsnum != 0) {
+ fmp = mp->mnt_data;
+ if (fmp != NULL) {
+ sx_xlock(&fmp->dm_lock);
+ devfs_ruleset_set((devfs_rsnum)rsnum, fmp);
+ devfs_ruleset_apply(fmp);
+ sx_xunlock(&fmp->dm_lock);
+ }
+ }
+ return (0);
+ }
+
fmp = malloc(sizeof *fmp, M_DEVFS, M_WAITOK | M_ZERO);
fmp->dm_idx = alloc_unr(devfs_unr);
sx_init(&fmp->dm_lock, "devfsmount");
@@ -101,6 +151,12 @@
return (error);
}
+ if (rsnum != 0) {
+ sx_xlock(&fmp->dm_lock);
+ devfs_ruleset_set((devfs_rsnum)rsnum, fmp);
+ sx_xunlock(&fmp->dm_lock);
+ }
+
VOP_UNLOCK(rvp, 0);
vfs_mountedfrom(mp, "devfs");
@@ -186,4 +242,4 @@
.vfs_unmount = devfs_unmount,
};
-VFS_SET(devfs_vfsops, devfs, VFCF_SYNTHETIC);
+VFS_SET(devfs_vfsops, devfs, VFCF_SYNTHETIC | VFCF_JAIL);
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/devfs/devfs_vnops.c
--- a/head/sys/fs/devfs/devfs_vnops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/devfs/devfs_vnops.c Fri Mar 02 17:12:32 2012 +0200
@@ -31,7 +31,7 @@
* @(#)kernfs_vnops.c 8.15 (Berkeley) 5/21/95
* From: FreeBSD: src/sys/miscfs/kernfs/kernfs_vnops.c 1.43
*
- * $FreeBSD: head/sys/fs/devfs/devfs_vnops.c 228361 2011-12-09 17:49:34Z jhb $
+ * $FreeBSD: head/sys/fs/devfs/devfs_vnops.c 231949 2012-02-21 01:05:12Z kib $
*/
/*
@@ -1156,7 +1156,8 @@
devfs_read_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td)
{
struct cdev *dev;
- int ioflag, error, ref, resid;
+ int ioflag, error, ref;
+ ssize_t resid;
struct cdevsw *dsw;
struct file *fpop;
@@ -1634,7 +1635,8 @@
devfs_write_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td)
{
struct cdev *dev;
- int error, ioflag, ref, resid;
+ int error, ioflag, ref;
+ ssize_t resid;
struct cdevsw *dsw;
struct file *fpop;
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/ext2fs/ext2_dinode.h
--- a/head/sys/fs/ext2fs/ext2_dinode.h Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/ext2fs/ext2_dinode.h Fri Mar 02 17:12:32 2012 +0200
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/sys/fs/ext2fs/ext2_dinode.h 221126 2011-04-27 18:15:34Z jhb $
+ * $FreeBSD: head/sys/fs/ext2fs/ext2_dinode.h 231168 2012-02-07 22:31:28Z pfg $
*/
#ifndef _FS_EXT2FS_EXT2_DINODE_H_
@@ -70,7 +70,7 @@
uint16_t e2di_uid; /* 2: Owner UID */
uint32_t e2di_size; /* 4: Size (in bytes) */
uint32_t e2di_atime; /* 8: Access time */
- uint32_t e2di_ctime; /* 12: Create time */
+ uint32_t e2di_ctime; /* 12: Change time */
uint32_t e2di_mtime; /* 16: Modification time */
uint32_t e2di_dtime; /* 20: Deletion time */
uint16_t e2di_gid; /* 24: Owner GID */
@@ -89,6 +89,8 @@
uint16_t e2di_uid_high; /* 120: Owner UID top 16 bits */
uint16_t e2di_gid_high; /* 122: Owner GID top 16 bits */
uint32_t e2di_linux_reserved3; /* 124 */
+ uint16_t e2di_extra_isize;
+ uint16_t e2di_pad1;
};
#endif /* !_FS_EXT2FS_EXT2_DINODE_H_ */
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/ext2fs/ext2_lookup.c
--- a/head/sys/fs/ext2fs/ext2_lookup.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/ext2fs/ext2_lookup.c Fri Mar 02 17:12:32 2012 +0200
@@ -38,7 +38,7 @@
* SUCH DAMAGE.
*
* @(#)ufs_lookup.c 8.6 (Berkeley) 4/1/94
- * $FreeBSD: head/sys/fs/ext2fs/ext2_lookup.c 228583 2011-12-16 15:47:43Z pfg $
+ * $FreeBSD: head/sys/fs/ext2fs/ext2_lookup.c 231949 2012-02-21 01:05:12Z kib $
*/
#include <sys/param.h>
@@ -1001,7 +1001,8 @@
off_t off;
struct dirtemplate dbuf;
struct ext2fs_direct_2 *dp = (struct ext2fs_direct_2 *)&dbuf;
- int error, count, namlen;
+ int error, namlen;
+ ssize_t count;
#define MINDIRSIZ (sizeof(struct dirtemplate) / 2)
for (off = 0; off < ip->i_size; off += dp->e2d_reclen) {
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/ext2fs/ext2fs.h
--- a/head/sys/fs/ext2fs/ext2fs.h Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/ext2fs/ext2fs.h Fri Mar 02 17:12:32 2012 +0200
@@ -4,7 +4,7 @@
* Aug 1995, Godmar Back (gback at cs.utah.edu)
* University of Utah, Department of Computer Science
*
- * $FreeBSD: head/sys/fs/ext2fs/ext2fs.h 228583 2011-12-16 15:47:43Z pfg $
+ * $FreeBSD: head/sys/fs/ext2fs/ext2fs.h 231168 2012-02-07 22:31:28Z pfg $
*/
/*-
* Copyright (c) 2009 Aditya Sarawgi
@@ -123,7 +123,22 @@
char e3fs_reserved_char_pad;
uint32_t e3fs_default_mount_opts;
uint32_t e3fs_first_meta_bg; /* First metablock block group */
- uint32_t reserved2[190]; /* Padding to the end of the block */
+ uint32_t e3fs_mkfs_time; /* when the fs was created */
+ uint32_t e3fs_jnl_blks[17]; /* backup of the journal inode */
+ uint32_t e4fs_bcount_hi; /* block count */
+ uint32_t e4fs_rbcount_hi; /* reserved blocks count */
+ uint32_t e4fs_fbcount_hi; /* free blocks count */
+ uint16_t e4fs_min_extra_isize;/* all inodes have at least some bytes */
+ uint16_t e4fs_want_extra_isize; /* new inodes should reserve some bytes */
+ uint32_t e4fs_flags; /* miscellaneous flags */
+ uint16_t e4fs_raid_stride; /* RAID stride */
+ uint16_t e4fs_mmpintv; /* number of seconds to wait in MMP checking */
+ uint64_t e4fs_mmpblk; /* block for multi-mount protection */
+ uint32_t e4fs_raid_stripe_wid;/* blocks on all data disks (N * stride) */
+ uint8_t e4fs_log_gpf; /* FLEX_BG group size */
+ uint8_t e4fs_char_pad2;
+ uint16_t e4fs_pad;
+ uint32_t reserved2[162]; /* Padding to the end of the block */
};
@@ -139,15 +154,15 @@
uint32_t e2fs_bsize; /* Block size */
uint32_t e2fs_bshift; /* calc of logical block no */
int32_t e2fs_bmask; /* calc of block offset */
- int32_t e2fs_bpg; /* Number of blocks per group */
+ int32_t e2fs_bpg; /* Number of blocks per group */
int64_t e2fs_qbmask; /* = s_blocksize -1 */
uint32_t e2fs_fsbtodb; /* Shift to get disk block */
- uint32_t e2fs_ipg; /* Number of inodes per group */
- uint32_t e2fs_ipb; /* Number of inodes per block */
+ uint32_t e2fs_ipg; /* Number of inodes per group */
+ uint32_t e2fs_ipb; /* Number of inodes per block */
uint32_t e2fs_itpg; /* Number of inode table per group */
uint32_t e2fs_fsize; /* Size of fragments per block */
- uint32_t e2fs_fpb; /* Number of fragments per block */
- uint32_t e2fs_fpg; /* Number of fragments per group */
+ uint32_t e2fs_fpb; /* Number of fragments per block */
+ uint32_t e2fs_fpg; /* Number of fragments per group */
uint32_t e2fs_dbpg; /* Number of descriptor blocks per group */
uint32_t e2fs_descpb; /* Number of group descriptors per block */
uint32_t e2fs_gdbcount; /* Number of group descriptors */
@@ -161,7 +176,7 @@
char e2fs_wasvalid; /* valid at mount time */
off_t e2fs_maxfilesize;
struct ext2_gd *e2fs_gd; /* Group Descriptors */
- int32_t e2fs_maxcontig; /* max number of contiguous blks */
+ int32_t e2fs_maxcontig; /* max number of contiguous blks */
int32_t e2fs_contigsumsize; /* size of cluster summary array */
int32_t *e2fs_maxcluster; /* max cluster in each cyl group */
struct csum *e2fs_clustersum; /* cluster summary in each cyl group */
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/ext2fs/inode.h
--- a/head/sys/fs/ext2fs/inode.h Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/ext2fs/inode.h Fri Mar 02 17:12:32 2012 +0200
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* @(#)inode.h 8.9 (Berkeley) 5/14/95
- * $FreeBSD: head/sys/fs/ext2fs/inode.h 221166 2011-04-28 14:27:17Z jhb $
+ * $FreeBSD: head/sys/fs/ext2fs/inode.h 231168 2012-02-07 22:31:28Z pfg $
*/
#ifndef _FS_EXT2FS_INODE_H_
@@ -85,11 +85,13 @@
int16_t i_nlink; /* File link count. */
uint64_t i_size; /* File byte count. */
int32_t i_atime; /* Last access time. */
+ int32_t i_mtime; /* Last modified time. */
+ int32_t i_ctime; /* Last inode change time. */
+ int32_t i_birthtime; /* Inode creation time. */
+ int32_t i_mtimensec; /* Last modified 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. */
+ int32_t i_birthnsec; /* Inode creation time. */
int32_t i_db[NDADDR]; /* Direct disk blocks. */
int32_t i_ib[NIADDR]; /* Indirect disk blocks. */
uint32_t i_flags; /* Status flags (chflags). */
@@ -158,9 +160,6 @@
#define VTOI(vp) ((struct inode *)(vp)->v_data)
#define ITOV(ip) ((ip)->i_vnode)
-/* Check whether the MNTK_ASYNC flag has been set for a mount point */
-#define DOINGASYNC(vp) ((vp)->v_mount->mnt_kern_flag & MNTK_ASYNC)
-
/* This overlays the fid structure (see mount.h). */
struct ufid {
uint16_t ufid_len; /* Length of structure. */
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/fifofs/fifo.h
--- a/head/sys/fs/fifofs/fifo.h Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/fifofs/fifo.h Fri Mar 02 17:12:32 2012 +0200
@@ -27,12 +27,13 @@
* SUCH DAMAGE.
*
* @(#)fifo.h 8.6 (Berkeley) 5/21/95
- * $FreeBSD$
+ * $FreeBSD: head/sys/fs/fifofs/fifo.h 232055 2012-02-23 18:37:30Z kmacy $
*/
/*
* Prototypes for fifo operations on vnodes.
*/
+int fifo_iseof(struct file *);
int fifo_vnoperate(struct vop_generic_args *);
int fifo_printinfo(struct vnode *);
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/fifofs/fifo_vnops.c
--- a/head/sys/fs/fifofs/fifo_vnops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/fifofs/fifo_vnops.c Fri Mar 02 17:12:32 2012 +0200
@@ -2,6 +2,7 @@
* Copyright (c) 1990, 1993, 1995
* The Regents of the University of California.
* Copyright (c) 2005 Robert N. M. Watson
+ * Copyright (c) 2012 Giovanni Trematerra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,7 +30,7 @@
* SUCH DAMAGE.
*
* @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95
- * $FreeBSD: head/sys/fs/fifofs/fifo_vnops.c 228263 2011-12-04 19:25:49Z kib $
+ * $FreeBSD: head/sys/fs/fifofs/fifo_vnops.c 232055 2012-02-23 18:37:30Z kmacy $
*/
#include <sys/param.h>
@@ -42,11 +43,10 @@
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/malloc.h>
-#include <sys/poll.h>
+#include <sys/selinfo.h>
+#include <sys/pipe.h>
#include <sys/proc.h>
#include <sys/signalvar.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
#include <sys/sx.h>
#include <sys/systm.h>
#include <sys/un.h>
@@ -54,43 +54,19 @@
#include <sys/vnode.h>
#include <fs/fifofs/fifo.h>
-static fo_rdwr_t fifo_read_f;
-static fo_rdwr_t fifo_write_f;
-static fo_ioctl_t fifo_ioctl_f;
-static fo_poll_t fifo_poll_f;
-static fo_kqfilter_t fifo_kqfilter_f;
-static fo_stat_t fifo_stat_f;
-static fo_close_t fifo_close_f;
-static fo_truncate_t fifo_truncate_f;
-
-struct fileops fifo_ops_f = {
- .fo_read = fifo_read_f,
- .fo_write = fifo_write_f,
- .fo_truncate = fifo_truncate_f,
- .fo_ioctl = fifo_ioctl_f,
- .fo_poll = fifo_poll_f,
- .fo_kqfilter = fifo_kqfilter_f,
- .fo_stat = fifo_stat_f,
- .fo_close = fifo_close_f,
- .fo_chmod = vn_chmod,
- .fo_chown = vn_chown,
- .fo_flags = DFLAG_PASSABLE
-};
-
/*
* This structure is associated with the FIFO vnode and stores
* the state associated with the FIFO.
* Notes about locking:
- * - fi_readsock and fi_writesock are invariant since init time.
- * - fi_readers and fi_writers are vnode lock protected.
- * - fi_wgen is fif_mtx lock protected.
+ * - fi_pipe is invariant since init time.
+ * - fi_readers and fi_writers are protected by the vnode lock.
+ * - fi_wgen is protected by the pipe mutex.
*/
struct fifoinfo {
- struct socket *fi_readsock;
- struct socket *fi_writesock;
- long fi_readers;
- long fi_writers;
- int fi_wgen;
+ struct pipe *fi_pipe;
+ long fi_readers;
+ long fi_writers;
+ int fi_wgen;
};
static vop_print_t fifo_print;
@@ -99,29 +75,6 @@
static vop_pathconf_t fifo_pathconf;
static vop_advlock_t fifo_advlock;
-static void filt_fifordetach(struct knote *kn);
-static int filt_fiforead(struct knote *kn, long hint);
-static void filt_fifowdetach(struct knote *kn);
-static int filt_fifowrite(struct knote *kn, long hint);
-static void filt_fifodetach_notsup(struct knote *kn);
-static int filt_fifo_notsup(struct knote *kn, long hint);
-
-static struct filterops fiforead_filtops = {
- .f_isfd = 1,
- .f_detach = filt_fifordetach,
- .f_event = filt_fiforead,
-};
-static struct filterops fifowrite_filtops = {
- .f_isfd = 1,
- .f_detach = filt_fifowdetach,
- .f_event = filt_fifowrite,
-};
-static struct filterops fifo_notsup_filtops = {
- .f_isfd = 1,
- .f_detach = filt_fifodetach_notsup,
- .f_event = filt_fifo_notsup,
-};
-
struct vop_vector fifo_specops = {
.vop_default = &default_vnodeops,
@@ -150,22 +103,19 @@
.vop_write = VOP_PANIC,
};
-struct mtx fifo_mtx;
-MTX_SYSINIT(fifo, &fifo_mtx, "fifo mutex", MTX_DEF);
-
/*
* Dispose of fifo resources.
*/
static void
fifo_cleanup(struct vnode *vp)
{
- struct fifoinfo *fip = vp->v_fifoinfo;
+ struct fifoinfo *fip;
ASSERT_VOP_ELOCKED(vp, "fifo_cleanup");
+ fip = vp->v_fifoinfo;
if (fip->fi_readers == 0 && fip->fi_writers == 0) {
vp->v_fifoinfo = NULL;
- (void)soclose(fip->fi_readsock);
- (void)soclose(fip->fi_writesock);
+ pipe_dtor(fip->fi_pipe);
free(fip, M_VNODE);
}
}
@@ -185,101 +135,80 @@
struct file *a_fp;
} */ *ap;
{
- struct vnode *vp = ap->a_vp;
+ struct vnode *vp;
+ struct file *fp;
+ struct thread *td;
struct fifoinfo *fip;
- struct thread *td = ap->a_td;
- struct ucred *cred = ap->a_cred;
- struct file *fp = ap->a_fp;
- struct socket *rso, *wso;
+ struct pipe *fpipe;
int error;
+ vp = ap->a_vp;
+ fp = ap->a_fp;
+ td = ap->a_td;
ASSERT_VOP_ELOCKED(vp, "fifo_open");
if (fp == NULL)
return (EINVAL);
if ((fip = vp->v_fifoinfo) == NULL) {
+ error = pipe_named_ctor(&fpipe, td);
+ if (error != 0)
+ return (error);
fip = malloc(sizeof(*fip), M_VNODE, M_WAITOK);
- error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, cred, td);
- if (error)
- goto fail1;
- fip->fi_readsock = rso;
- error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0, cred, td);
- if (error)
- goto fail2;
- fip->fi_writesock = wso;
- error = soconnect2(wso, rso);
- /* Close the direction we do not use, so we can get POLLHUP. */
- if (error == 0)
- error = soshutdown(rso, SHUT_WR);
- if (error) {
- (void)soclose(wso);
-fail2:
- (void)soclose(rso);
-fail1:
- free(fip, M_VNODE);
- return (error);
- }
+ fip->fi_pipe = fpipe;
fip->fi_wgen = fip->fi_readers = fip->fi_writers = 0;
- wso->so_snd.sb_lowat = PIPE_BUF;
- SOCKBUF_LOCK(&rso->so_rcv);
- rso->so_rcv.sb_state |= SBS_CANTRCVMORE;
- SOCKBUF_UNLOCK(&rso->so_rcv);
- KASSERT(vp->v_fifoinfo == NULL,
- ("fifo_open: v_fifoinfo race"));
+ KASSERT(vp->v_fifoinfo == NULL, ("fifo_open: v_fifoinfo race"));
vp->v_fifoinfo = fip;
}
+ fpipe = fip->fi_pipe;
+ KASSERT(fpipe != NULL, ("fifo_open: pipe is NULL"));
/*
- * Use the fifo_mtx lock here, in addition to the vnode lock,
+ * Use the pipe mutex here, in addition to the vnode lock,
* in order to allow vnode lock dropping before msleep() calls
* and still avoiding missed wakeups.
*/
- mtx_lock(&fifo_mtx);
+ PIPE_LOCK(fpipe);
if (ap->a_mode & FREAD) {
fip->fi_readers++;
if (fip->fi_readers == 1) {
- SOCKBUF_LOCK(&fip->fi_writesock->so_snd);
- fip->fi_writesock->so_snd.sb_state &= ~SBS_CANTSENDMORE;
- SOCKBUF_UNLOCK(&fip->fi_writesock->so_snd);
- if (fip->fi_writers > 0) {
+ fpipe->pipe_state &= ~PIPE_EOF;
+ if (fip->fi_writers > 0)
wakeup(&fip->fi_writers);
- sowwakeup(fip->fi_writesock);
- }
}
fp->f_seqcount = fip->fi_wgen - fip->fi_writers;
}
if (ap->a_mode & FWRITE) {
if ((ap->a_mode & O_NONBLOCK) && fip->fi_readers == 0) {
- mtx_unlock(&fifo_mtx);
+ PIPE_UNLOCK(fpipe);
if (fip->fi_writers == 0)
fifo_cleanup(vp);
return (ENXIO);
}
fip->fi_writers++;
if (fip->fi_writers == 1) {
- SOCKBUF_LOCK(&fip->fi_readsock->so_rcv);
- fip->fi_readsock->so_rcv.sb_state &= ~SBS_CANTRCVMORE;
- SOCKBUF_UNLOCK(&fip->fi_readsock->so_rcv);
- if (fip->fi_readers > 0) {
+ fpipe->pipe_state &= ~PIPE_EOF;
+ if (fip->fi_readers > 0)
wakeup(&fip->fi_readers);
- sorwakeup(fip->fi_readsock);
- }
}
}
if ((ap->a_mode & O_NONBLOCK) == 0) {
if ((ap->a_mode & FREAD) && fip->fi_writers == 0) {
VOP_UNLOCK(vp, 0);
- error = msleep(&fip->fi_readers, &fifo_mtx,
+ error = msleep(&fip->fi_readers, PIPE_MTX(fpipe),
PDROP | PCATCH | PSOCK, "fifoor", 0);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
if (error) {
fip->fi_readers--;
if (fip->fi_readers == 0) {
- socantsendmore(fip->fi_writesock);
+ PIPE_LOCK(fpipe);
+ fpipe->pipe_state |= PIPE_EOF;
+ if (fpipe->pipe_state & PIPE_WANTW)
+ wakeup(fpipe);
+ PIPE_UNLOCK(fpipe);
fifo_cleanup(vp);
}
return (error);
}
- mtx_lock(&fifo_mtx);
+ PIPE_LOCK(fpipe);
/*
* We must have got woken up because we had a writer.
* That (and not still having one) is the condition
@@ -288,16 +217,18 @@
}
if ((ap->a_mode & FWRITE) && fip->fi_readers == 0) {
VOP_UNLOCK(vp, 0);
- error = msleep(&fip->fi_writers, &fifo_mtx,
+ error = msleep(&fip->fi_writers, PIPE_MTX(fpipe),
PDROP | PCATCH | PSOCK, "fifoow", 0);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
if (error) {
fip->fi_writers--;
if (fip->fi_writers == 0) {
- socantrcvmore(fip->fi_readsock);
- mtx_lock(&fifo_mtx);
+ PIPE_LOCK(fpipe);
+ fpipe->pipe_state |= PIPE_EOF;
+ if (fpipe->pipe_state & PIPE_WANTR)
+ wakeup(fpipe);
fip->fi_wgen++;
- mtx_unlock(&fifo_mtx);
+ PIPE_UNLOCK(fpipe);
fifo_cleanup(vp);
}
return (error);
@@ -307,82 +238,13 @@
* a reader. That (and not still having one)
* is the condition that we must wait for.
*/
- mtx_lock(&fifo_mtx);
+ PIPE_LOCK(fpipe);
}
}
- mtx_unlock(&fifo_mtx);
+ PIPE_UNLOCK(fpipe);
KASSERT(fp != NULL, ("can't fifo/vnode bypass"));
KASSERT(fp->f_ops == &badfileops, ("not badfileops in fifo_open"));
- finit(fp, fp->f_flag, DTYPE_FIFO, fip, &fifo_ops_f);
- return (0);
-}
-
-static void
-filt_fifordetach(struct knote *kn)
-{
- struct socket *so = (struct socket *)kn->kn_hook;
-
- SOCKBUF_LOCK(&so->so_rcv);
- knlist_remove(&so->so_rcv.sb_sel.si_note, kn, 1);
- if (knlist_empty(&so->so_rcv.sb_sel.si_note))
- so->so_rcv.sb_flags &= ~SB_KNOTE;
- SOCKBUF_UNLOCK(&so->so_rcv);
-}
-
-static int
-filt_fiforead(struct knote *kn, long hint)
-{
- struct socket *so = (struct socket *)kn->kn_hook;
-
- SOCKBUF_LOCK_ASSERT(&so->so_rcv);
- kn->kn_data = so->so_rcv.sb_cc;
- if (so->so_rcv.sb_state & SBS_CANTRCVMORE) {
- kn->kn_flags |= EV_EOF;
- return (1);
- } else {
- kn->kn_flags &= ~EV_EOF;
- return (kn->kn_data > 0);
- }
-}
-
-static void
-filt_fifowdetach(struct knote *kn)
-{
- struct socket *so = (struct socket *)kn->kn_hook;
-
- SOCKBUF_LOCK(&so->so_snd);
- knlist_remove(&so->so_snd.sb_sel.si_note, kn, 1);
- if (knlist_empty(&so->so_snd.sb_sel.si_note))
- so->so_snd.sb_flags &= ~SB_KNOTE;
- SOCKBUF_UNLOCK(&so->so_snd);
-}
-
-static int
-filt_fifowrite(struct knote *kn, long hint)
-{
- struct socket *so = (struct socket *)kn->kn_hook;
-
- SOCKBUF_LOCK_ASSERT(&so->so_snd);
- kn->kn_data = sbspace(&so->so_snd);
- if (so->so_snd.sb_state & SBS_CANTSENDMORE) {
- kn->kn_flags |= EV_EOF;
- return (1);
- } else {
- kn->kn_flags &= ~EV_EOF;
- return (kn->kn_data >= so->so_snd.sb_lowat);
- }
-}
-
-static void
-filt_fifodetach_notsup(struct knote *kn)
-{
-
-}
-
-static int
-filt_fifo_notsup(struct knote *kn, long hint)
-{
-
+ finit(fp, fp->f_flag, DTYPE_FIFO, fpipe, &pipeops);
return (0);
}
@@ -399,26 +261,33 @@
struct thread *a_td;
} */ *ap;
{
- struct vnode *vp = ap->a_vp;
- struct fifoinfo *fip = vp->v_fifoinfo;
+ struct vnode *vp;
+ struct fifoinfo *fip;
+ struct pipe *cpipe;
+ vp = ap->a_vp;
+ fip = vp->v_fifoinfo;
+ cpipe = fip->fi_pipe;
ASSERT_VOP_ELOCKED(vp, "fifo_close");
- if (fip == NULL) {
- printf("fifo_close: no v_fifoinfo %p\n", vp);
- return (0);
- }
if (ap->a_fflag & FREAD) {
fip->fi_readers--;
- if (fip->fi_readers == 0)
- socantsendmore(fip->fi_writesock);
+ if (fip->fi_readers == 0) {
+ PIPE_LOCK(cpipe);
+ cpipe->pipe_state |= PIPE_EOF;
+ if (cpipe->pipe_state & PIPE_WANTW)
+ wakeup(cpipe);
+ PIPE_UNLOCK(cpipe);
+ }
}
if (ap->a_fflag & FWRITE) {
fip->fi_writers--;
if (fip->fi_writers == 0) {
- socantrcvmore(fip->fi_readsock);
- mtx_lock(&fifo_mtx);
+ PIPE_LOCK(cpipe);
+ cpipe->pipe_state |= PIPE_EOF;
+ if (cpipe->pipe_state & PIPE_WANTR)
+ wakeup(cpipe);
fip->fi_wgen++;
- mtx_unlock(&fifo_mtx);
+ PIPE_UNLOCK(cpipe);
}
}
fifo_cleanup(vp);
@@ -504,212 +373,15 @@
return (ap->a_flags & F_FLOCK ? EOPNOTSUPP : EINVAL);
}
-static int
-fifo_close_f(struct file *fp, struct thread *td)
+int
+fifo_iseof(struct file *fp)
{
+ struct fifoinfo *fip;
- return (vnops.fo_close(fp, td));
+ KASSERT(fp->f_vnode != NULL, ("fifo_iseof: no vnode info"));
+ KASSERT(fp->f_vnode->v_fifoinfo != NULL, ("fifo_iseof: no fifoinfo"));
+ fip = fp->f_vnode->v_fifoinfo;
+ PIPE_LOCK_ASSERT(fip->fi_pipe, MA_OWNED);
+ return (fp->f_seqcount == fip->fi_wgen);
}
-/*
- * The implementation of ioctl() for named fifos is complicated by the fact
- * that we permit O_RDWR fifo file descriptors, meaning that the actions of
- * ioctls may have to be applied to both the underlying sockets rather than
- * just one. The original implementation simply forward the ioctl to one
- * or both sockets based on fp->f_flag. We now consider each ioctl
- * separately, as the composition effect requires careful ordering.
- *
- * We do not blindly pass all ioctls through to the socket in order to avoid
- * providing unnecessary ioctls that might be improperly depended on by
- * applications (such as socket-specific, routing, and interface ioctls).
- *
- * Unlike sys_pipe.c, fifos do not implement the deprecated TIOCSPGRP and
- * TIOCGPGRP ioctls. Earlier implementations of fifos did forward SIOCSPGRP
- * and SIOCGPGRP ioctls, so we might need to re-add those here.
- */
-static int
-fifo_ioctl_f(struct file *fp, u_long com, void *data, struct ucred *cred,
- struct thread *td)
-{
- struct fifoinfo *fi;
- struct file filetmp; /* Local, so need not be locked. */
- int error;
-
- error = ENOTTY;
- fi = fp->f_data;
-
- switch (com) {
- case FIONBIO:
- /*
- * Non-blocking I/O is implemented at the fifo layer using
- * MSG_NBIO, so does not need to be forwarded down the stack.
- */
- return (0);
-
- case FIOASYNC:
- case FIOSETOWN:
- case FIOGETOWN:
- /*
- * These socket ioctls don't have any ordering requirements,
- * so are called in an arbitrary order, and only on the
- * sockets indicated by the file descriptor rights.
- *
- * XXXRW: If O_RDWR and the read socket accepts an ioctl but
- * the write socket doesn't, the socketpair is left in an
- * inconsistent state.
- */
- if (fp->f_flag & FREAD) {
- filetmp.f_data = fi->fi_readsock;
- filetmp.f_cred = cred;
- error = soo_ioctl(&filetmp, com, data, cred, td);
- if (error)
- return (error);
- }
- if (fp->f_flag & FWRITE) {
- filetmp.f_data = fi->fi_writesock;
- filetmp.f_cred = cred;
- error = soo_ioctl(&filetmp, com, data, cred, td);
- }
- return (error);
-
- case FIONREAD:
- /*
- * FIONREAD will return 0 for non-readable descriptors, and
- * the results of FIONREAD on the read socket for readable
- * descriptors.
- */
- if (!(fp->f_flag & FREAD)) {
- *(int *)data = 0;
- return (0);
- }
- filetmp.f_data = fi->fi_readsock;
- filetmp.f_cred = cred;
- return (soo_ioctl(&filetmp, com, data, cred, td));
-
- default:
- return (ENOTTY);
- }
-}
-
-/*
- * Because fifos are now a file descriptor layer object, EVFILT_VNODE is not
- * implemented. Likely, fifo_kqfilter() should be removed, and
- * fifo_kqfilter_f() should know how to forward the request to the underling
- * vnode using f_vnode in the file descriptor here.
- */
-static int
-fifo_kqfilter_f(struct file *fp, struct knote *kn)
-{
- struct fifoinfo *fi;
- struct socket *so;
- struct sockbuf *sb;
-
- fi = fp->f_data;
-
- /*
- * If a filter is requested that is not supported by this file
- * descriptor, don't return an error, but also don't ever generate an
- * event.
- */
- if ((kn->kn_filter == EVFILT_READ) && !(fp->f_flag & FREAD)) {
- kn->kn_fop = &fifo_notsup_filtops;
- return (0);
- }
-
- if ((kn->kn_filter == EVFILT_WRITE) && !(fp->f_flag & FWRITE)) {
- kn->kn_fop = &fifo_notsup_filtops;
- return (0);
- }
-
- switch (kn->kn_filter) {
- case EVFILT_READ:
- kn->kn_fop = &fiforead_filtops;
- so = fi->fi_readsock;
- sb = &so->so_rcv;
- break;
- case EVFILT_WRITE:
- kn->kn_fop = &fifowrite_filtops;
- so = fi->fi_writesock;
- sb = &so->so_snd;
- break;
- default:
- return (EINVAL);
- }
-
- kn->kn_hook = (caddr_t)so;
-
- SOCKBUF_LOCK(sb);
- knlist_add(&sb->sb_sel.si_note, kn, 1);
- sb->sb_flags |= SB_KNOTE;
- SOCKBUF_UNLOCK(sb);
-
- return (0);
-}
-
-static int
-fifo_poll_f(struct file *fp, int events, struct ucred *cred, struct thread *td)
-{
- struct fifoinfo *fip;
- struct file filetmp;
- int levents, revents = 0;
-
- fip = fp->f_data;
- levents = events &
- (POLLIN | POLLINIGNEOF | POLLPRI | POLLRDNORM | POLLRDBAND);
- if ((fp->f_flag & FREAD) && levents) {
- filetmp.f_data = fip->fi_readsock;
- filetmp.f_cred = cred;
- mtx_lock(&fifo_mtx);
- if (fp->f_seqcount == fip->fi_wgen)
- levents |= POLLINIGNEOF;
- mtx_unlock(&fifo_mtx);
- revents |= soo_poll(&filetmp, levents, cred, td);
- }
- levents = events & (POLLOUT | POLLWRNORM | POLLWRBAND);
- if ((fp->f_flag & FWRITE) && levents) {
- filetmp.f_data = fip->fi_writesock;
- filetmp.f_cred = cred;
- revents |= soo_poll(&filetmp, levents, cred, td);
- }
- return (revents);
-}
-
-static int
-fifo_read_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td)
-{
- struct fifoinfo *fip;
- int sflags;
-
- fip = fp->f_data;
- KASSERT(uio->uio_rw == UIO_READ,("fifo_read mode"));
- if (uio->uio_resid == 0)
- return (0);
- sflags = (fp->f_flag & FNONBLOCK) ? MSG_NBIO : 0;
- return (soreceive(fip->fi_readsock, NULL, uio, NULL, NULL, &sflags));
-}
-
-static int
-fifo_stat_f(struct file *fp, struct stat *sb, struct ucred *cred, struct thread *td)
-{
-
- return (vnops.fo_stat(fp, sb, cred, td));
-}
-
-static int
-fifo_truncate_f(struct file *fp, off_t length, struct ucred *cred, struct thread *td)
-{
-
- return (vnops.fo_truncate(fp, length, cred, td));
-}
-
-static int
-fifo_write_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td)
-{
- struct fifoinfo *fip;
- int sflags;
-
- fip = fp->f_data;
- KASSERT(uio->uio_rw == UIO_WRITE,("fifo_write mode"));
- sflags = (fp->f_flag & FNONBLOCK) ? MSG_NBIO : 0;
- return (sosend(fip->fi_writesock, NULL, uio, 0, NULL, sflags, td));
-}
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/msdosfs/msdosfs_denode.c
--- a/head/sys/fs/msdosfs/msdosfs_denode.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/msdosfs/msdosfs_denode.c Fri Mar 02 17:12:32 2012 +0200
@@ -1,4 +1,4 @@
-/* $FreeBSD: head/sys/fs/msdosfs/msdosfs_denode.c 227817 2011-11-22 13:30:36Z kib $ */
+/* $FreeBSD: head/sys/fs/msdosfs/msdosfs_denode.c 231998 2012-02-22 13:01:17Z kib $ */
/* $NetBSD: msdosfs_denode.c,v 1.28 1998/02/10 14:10:00 mrg Exp $ */
/*-
@@ -431,7 +431,7 @@
if (allerror)
printf("detrunc(): vtruncbuf error %d\n", allerror);
#endif
- error = deupdat(dep, !(DETOV(dep)->v_mount->mnt_flag & MNT_ASYNC));
+ error = deupdat(dep, !DOINGASYNC((DETOV(dep))));
if (error != 0 && allerror == 0)
allerror = error;
#ifdef MSDOSFS_DEBUG
@@ -510,7 +510,7 @@
}
dep->de_FileSize = length;
dep->de_flag |= DE_UPDATE | DE_MODIFIED;
- return (deupdat(dep, !(DETOV(dep)->v_mount->mnt_flag & MNT_ASYNC)));
+ return (deupdat(dep, !DOINGASYNC(DETOV(dep))));
}
/*
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/msdosfs/msdosfs_lookup.c
--- a/head/sys/fs/msdosfs/msdosfs_lookup.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/msdosfs/msdosfs_lookup.c Fri Mar 02 17:12:32 2012 +0200
@@ -1,4 +1,4 @@
-/* $FreeBSD: head/sys/fs/msdosfs/msdosfs_lookup.c 227817 2011-11-22 13:30:36Z kib $ */
+/* $FreeBSD: head/sys/fs/msdosfs/msdosfs_lookup.c 231998 2012-02-22 13:01:17Z kib $ */
/* $NetBSD: msdosfs_lookup.c,v 1.37 1997/11/17 15:36:54 ws Exp $ */
/*-
@@ -690,7 +690,7 @@
while (--ddep->de_fndcnt >= 0) {
if (!(ddep->de_fndoffset & pmp->pm_crbomask)) {
- if (DETOV(ddep)->v_mount->mnt_flag & MNT_ASYNC)
+ if (DOINGASYNC(DETOV(ddep)))
bdwrite(bp);
else if ((error = bwrite(bp)) != 0)
return error;
@@ -720,7 +720,7 @@
}
}
- if (DETOV(ddep)->v_mount->mnt_flag & MNT_ASYNC)
+ if (DOINGASYNC(DETOV(ddep)))
bdwrite(bp);
else if ((error = bwrite(bp)) != 0)
return error;
@@ -1022,7 +1022,7 @@
|| ep->deAttributes != ATTR_WIN95)
break;
}
- if (DETOV(pdep)->v_mount->mnt_flag & MNT_ASYNC)
+ if (DOINGASYNC(DETOV(pdep)))
bdwrite(bp);
else if ((error = bwrite(bp)) != 0)
return error;
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/msdosfs/msdosfs_vnops.c
--- a/head/sys/fs/msdosfs/msdosfs_vnops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/msdosfs/msdosfs_vnops.c Fri Mar 02 17:12:32 2012 +0200
@@ -1,4 +1,4 @@
-/* $FreeBSD$ */
+/* $FreeBSD: head/sys/fs/msdosfs/msdosfs_vnops.c 231998 2012-02-22 13:01:17Z kib $ */
/* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */
/*-
@@ -543,7 +543,7 @@
int error = 0;
int blsize;
int isadir;
- int orig_resid;
+ ssize_t orig_resid;
u_int n;
u_long diff;
u_long on;
@@ -643,7 +643,7 @@
{
int n;
int croffset;
- int resid;
+ ssize_t resid;
u_long osize;
int error = 0;
u_long count;
@@ -1249,7 +1249,7 @@
putushort(dotdotp->deStartCluster, dp->de_StartCluster);
if (FAT32(pmp))
putushort(dotdotp->deHighClust, dp->de_StartCluster >> 16);
- if (fvp->v_mount->mnt_flag & MNT_ASYNC)
+ if (DOINGASYNC(fvp))
bdwrite(bp);
else if ((error = bwrite(bp)) != 0) {
/* XXX should downgrade to ro here, fs is corrupt */
@@ -1383,7 +1383,7 @@
putushort(denp[1].deHighClust, pdep->de_StartCluster >> 16);
}
- if (ap->a_dvp->v_mount->mnt_flag & MNT_ASYNC)
+ if (DOINGASYNC(ap->a_dvp))
bdwrite(bp);
else if ((error = bwrite(bp)) != 0)
goto bad;
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/nfs/nfs_commonport.c
--- a/head/sys/fs/nfs/nfs_commonport.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/nfs/nfs_commonport.c Fri Mar 02 17:12:32 2012 +0200
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfs/nfs_commonport.c 229956 2012-01-11 02:46:42Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/nfs/nfs_commonport.c 231805 2012-02-16 02:19:53Z rmacklem $");
/*
* Functions that need to be different for different versions of BSD
@@ -109,9 +109,6 @@
* Definition of mutex locks.
* newnfsd_mtx is used in nfsrvd_nfsd() to protect the nfs socket list
* and assorted other nfsd structures.
- * Giant is used to protect the nfsd list and count, which is just
- * updated when nfsd's start/stop and is grabbed for nfsrvd_dorpc()
- * for the VFS ops.
*/
struct mtx newnfsd_mtx;
struct mtx nfs_sockl_mutex;
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/nfsclient/nfs_clbio.c
--- a/head/sys/fs/nfsclient/nfs_clbio.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/nfsclient/nfs_clbio.c Fri Mar 02 17:12:32 2012 +0200
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clbio.c 230605 2012-01-27 02:46:12Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clbio.c 232327 2012-03-01 03:53:07Z rmacklem $");
#include "opt_kdtrace.h"
@@ -570,7 +570,7 @@
n = 0;
if (on < bcount)
- n = min((unsigned)(bcount - on), uio->uio_resid);
+ n = MIN((unsigned)(bcount - on), uio->uio_resid);
break;
case VLNK:
NFSINCRGLOBAL(newnfsstats.biocache_readlinks);
@@ -589,7 +589,7 @@
return (error);
}
}
- n = min(uio->uio_resid, NFS_MAXPATHLEN - bp->b_resid);
+ n = MIN(uio->uio_resid, NFS_MAXPATHLEN - bp->b_resid);
on = 0;
break;
case VDIR:
@@ -757,8 +757,8 @@
struct iovec iov;
do_sync:
while (uiop->uio_resid > 0) {
- size = min(uiop->uio_resid, wsize);
- size = min(uiop->uio_iov->iov_len, size);
+ size = MIN(uiop->uio_resid, wsize);
+ size = MIN(uiop->uio_iov->iov_len, size);
iov.iov_base = uiop->uio_iov->iov_base;
iov.iov_len = size;
uio.uio_iov = &iov;
@@ -806,8 +806,8 @@
* in NFS directio access.
*/
while (uiop->uio_resid > 0) {
- size = min(uiop->uio_resid, wsize);
- size = min(uiop->uio_iov->iov_len, size);
+ size = MIN(uiop->uio_resid, wsize);
+ size = MIN(uiop->uio_iov->iov_len, size);
bp = getpbuf(&ncl_pbuf_freecnt);
t_uio = malloc(sizeof(struct uio), M_NFSDIRECTIO, M_WAITOK);
t_iov = malloc(sizeof(struct iovec), M_NFSDIRECTIO, M_WAITOK);
@@ -820,7 +820,21 @@
t_uio->uio_segflg = UIO_SYSSPACE;
t_uio->uio_rw = UIO_WRITE;
t_uio->uio_td = td;
- bcopy(uiop->uio_iov->iov_base, t_iov->iov_base, size);
+ KASSERT(uiop->uio_segflg == UIO_USERSPACE ||
+ uiop->uio_segflg == UIO_SYSSPACE,
+ ("nfs_directio_write: Bad uio_segflg"));
+ if (uiop->uio_segflg == UIO_USERSPACE) {
+ error = copyin(uiop->uio_iov->iov_base,
+ t_iov->iov_base, size);
+ if (error != 0)
+ goto err_free;
+ } else
+ /*
+ * UIO_SYSSPACE may never happen, but handle
+ * it just in case it does.
+ */
+ bcopy(uiop->uio_iov->iov_base, t_iov->iov_base,
+ size);
bp->b_flags |= B_DIRECT;
bp->b_iocmd = BIO_WRITE;
if (cred != NOCRED) {
@@ -831,6 +845,7 @@
bp->b_caller1 = (void *)t_uio;
bp->b_vp = vp;
error = ncl_asyncio(nmp, bp, NOCRED, td);
+err_free:
if (error) {
free(t_iov->iov_base, M_NFSDIRECTIO);
free(t_iov, M_NFSDIRECTIO);
@@ -1023,7 +1038,7 @@
NFSINCRGLOBAL(newnfsstats.biocache_writes);
lbn = uio->uio_offset / biosize;
on = uio->uio_offset & (biosize-1);
- n = min((unsigned)(biosize - on), uio->uio_resid);
+ n = MIN((unsigned)(biosize - on), uio->uio_resid);
again:
/*
* Handle direct append and file extension cases, calculate
@@ -1572,7 +1587,7 @@
* writes, but that is not possible any longer.
*/
int nread = bp->b_bcount - uiop->uio_resid;
- int left = uiop->uio_resid;
+ ssize_t left = uiop->uio_resid;
if (left > 0)
bzero((char *)bp->b_data + nread, left);
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/nfsclient/nfs_clport.c
--- a/head/sys/fs/nfsclient/nfs_clport.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/nfsclient/nfs_clport.c Fri Mar 02 17:12:32 2012 +0200
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clport.c 230605 2012-01-27 02:46:12Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clport.c 231852 2012-02-17 02:39:58Z bz $");
#include "opt_inet6.h"
#include "opt_kdtrace.h"
@@ -976,7 +976,8 @@
sad.sin_len = sizeof (struct sockaddr_in);
sad.sin_addr.s_addr = sin->sin_addr.s_addr;
CURVNET_SET(CRED_TO_VNET(nmp->nm_sockreq.nr_cred));
- rt = rtalloc1((struct sockaddr *)&sad, 0, 0UL);
+ rt = rtalloc1_fib((struct sockaddr *)&sad, 0, 0UL,
+ curthread->td_proc->p_fibnum);
if (rt != NULL) {
if (rt->rt_ifp != NULL &&
rt->rt_ifa != NULL &&
@@ -1001,7 +1002,8 @@
sad6.sin6_len = sizeof (struct sockaddr_in6);
sad6.sin6_addr = sin6->sin6_addr;
CURVNET_SET(CRED_TO_VNET(nmp->nm_sockreq.nr_cred));
- rt = rtalloc1((struct sockaddr *)&sad6, 0, 0UL);
+ rt = rtalloc1_fib((struct sockaddr *)&sad6, 0, 0UL,
+ curthread->td_proc->p_fibnum);
if (rt != NULL) {
if (rt->rt_ifp != NULL &&
rt->rt_ifa != NULL &&
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/nfsclient/nfs_clstate.c
--- a/head/sys/fs/nfsclient/nfs_clstate.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/nfsclient/nfs_clstate.c Fri Mar 02 17:12:32 2012 +0200
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clstate.c 228217 2011-12-03 02:27:26Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clstate.c 231133 2012-02-07 16:32:43Z rmacklem $");
/*
* These functions implement the client side state handling for NFSv4.
@@ -559,8 +559,12 @@
NFSUNLOCKCLSTATE();
return (ENOENT);
}
- /* for read aheads or write behinds, use the open cred */
- newnfs_copycred(&op->nfso_cred, cred);
+ /*
+ * For read aheads or write behinds, use the open cred.
+ * A read ahead or write behind is indicated by p == NULL.
+ */
+ if (p == NULL)
+ newnfs_copycred(&op->nfso_cred, cred);
}
/*
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/nfsclient/nfs_clvfsops.c
--- a/head/sys/fs/nfsclient/nfs_clvfsops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/nfsclient/nfs_clvfsops.c Fri Mar 02 17:12:32 2012 +0200
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clvfsops.c 230803 2012-01-31 03:58:26Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clvfsops.c 231852 2012-02-17 02:39:58Z bz $");
#include "opt_bootp.h"
@@ -459,10 +459,10 @@
sin.sin_len = sizeof(sin);
/* XXX MRT use table 0 for this sort of thing */
CURVNET_SET(TD_TO_VNET(td));
- error = rtrequest(RTM_ADD, (struct sockaddr *)&sin,
+ error = rtrequest_fib(RTM_ADD, (struct sockaddr *)&sin,
(struct sockaddr *)&nd->mygateway,
(struct sockaddr *)&mask,
- RTF_UP | RTF_GATEWAY, NULL);
+ RTF_UP | RTF_GATEWAY, NULL, RT_DEFAULT_FIB);
CURVNET_RESTORE();
if (error)
panic("nfs_mountroot: RTM_ADD: %d", error);
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/nfsclient/nfs_clvnops.c
--- a/head/sys/fs/nfsclient/nfs_clvnops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/nfsclient/nfs_clvnops.c Fri Mar 02 17:12:32 2012 +0200
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clvnops.c 230552 2012-01-25 20:48:20Z kib $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsclient/nfs_clvnops.c 231949 2012-02-21 01:05:12Z kib $");
/*
* vnode op calls for Sun NFS version 2, 3 and 4
@@ -1042,7 +1042,7 @@
if ((error = VOP_ACCESS(dvp, VEXEC, cnp->cn_cred, td)) != 0)
return (error);
- error = cache_lookup_times(dvp, vpp, cnp, &nctime, &ncticks);
+ error = cache_lookup(dvp, vpp, cnp, &nctime, &ncticks);
if (error > 0 && error != ENOENT)
return (error);
if (error == -1) {
@@ -1376,7 +1376,7 @@
if (ret && !error)
error = ret;
}
- if (vp->v_mount->mnt_kern_flag & MNTK_ASYNC)
+ if (DOINGASYNC(vp))
*iomode = NFSWRITE_FILESYNC;
if (error && NFS_ISV4(vp))
error = nfscl_maperr(uiop->uio_td, error, (uid_t)0, (gid_t)0);
@@ -2177,7 +2177,8 @@
struct vnode *vp = ap->a_vp;
struct nfsnode *np = VTONFS(vp);
struct uio *uio = ap->a_uio;
- int tresid, error = 0;
+ ssize_t tresid;
+ int error = 0;
struct vattr vattr;
if (vp->v_type != VDIR)
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/nfsserver/nfs_nfsdcache.c
--- a/head/sys/fs/nfsserver/nfs_nfsdcache.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/nfsserver/nfs_nfsdcache.c Fri Mar 02 17:12:32 2012 +0200
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsserver/nfs_nfsdcache.c 224086 2011-07-16 08:51:09Z zack $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsserver/nfs_nfsdcache.c 232050 2012-02-23 16:47:05Z rmacklem $");
/*
* Here is the basic algorithm:
@@ -336,9 +336,8 @@
nfsaddr_match(NETFAMILY(rp), &rp->rc_haddr, nd->nd_nam)) {
if ((rp->rc_flag & RC_LOCKED) != 0) {
rp->rc_flag |= RC_WANTED;
- NFSUNLOCKCACHE();
- (void) tsleep((caddr_t)rp, PZERO - 1,
- "nfsrc", 10 * hz);
+ (void)mtx_sleep(rp, NFSCACHEMUTEXPTR,
+ (PZERO - 1) | PDROP, "nfsrc", 10 * hz);
goto loop;
}
if (rp->rc_flag == 0)
@@ -622,8 +621,8 @@
rp = hitrp;
if ((rp->rc_flag & RC_LOCKED) != 0) {
rp->rc_flag |= RC_WANTED;
- NFSUNLOCKCACHE();
- (void) tsleep((caddr_t)rp, PZERO-1, "nfsrc", 10 * hz);
+ (void)mtx_sleep(rp, NFSCACHEMUTEXPTR,
+ (PZERO - 1) | PDROP, "nfsrc", 10 * hz);
goto tryagain;
}
if (rp->rc_flag == 0)
@@ -694,7 +693,7 @@
NFSCACHELOCKREQUIRED();
while ((rp->rc_flag & RC_LOCKED) != 0) {
rp->rc_flag |= RC_WANTED;
- (void) nfsmsleep((caddr_t)rp, NFSCACHEMUTEXPTR, PZERO - 1,
+ (void)mtx_sleep(rp, NFSCACHEMUTEXPTR, PZERO - 1,
"nfsrc", 0);
}
rp->rc_flag |= RC_LOCKED;
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/nfsserver/nfs_nfsdport.c
--- a/head/sys/fs/nfsserver/nfs_nfsdport.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/nfsserver/nfs_nfsdport.c Fri Mar 02 17:12:32 2012 +0200
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsserver/nfs_nfsdport.c 228560 2011-12-16 00:58:41Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsserver/nfs_nfsdport.c 231805 2012-02-16 02:19:53Z rmacklem $");
#include <sys/capability.h>
@@ -319,11 +319,7 @@
}
/*
- * Set up nameidata for a lookup() call and do it
- * For the cases where we are crossing mount points
- * (looking up the public fh path or the v4 root path when
- * not using a pseudo-root fs), set/release the Giant lock,
- * as required.
+ * Set up nameidata for a lookup() call and do it.
*/
int
nfsvno_namei(struct nfsrv_descript *nd, struct nameidata *ndp,
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/nfsserver/nfs_nfsdstate.c
--- a/head/sys/fs/nfsserver/nfs_nfsdstate.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/nfsserver/nfs_nfsdstate.c Fri Mar 02 17:12:32 2012 +0200
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/nfsserver/nfs_nfsdstate.c 230100 2012-01-14 04:04:58Z rmacklem $");
+__FBSDID("$FreeBSD: head/sys/fs/nfsserver/nfs_nfsdstate.c 231949 2012-02-21 01:05:12Z kib $");
#ifndef APPLEKEXT
#include <fs/nfs/nfsport.h>
@@ -3962,7 +3962,7 @@
struct nfst_rec *tsp;
int error, i, tryagain;
off_t off = 0;
- int aresid, len;
+ ssize_t aresid, len;
struct timeval curtime;
/*
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/ntfs/ntfs.h
--- a/head/sys/fs/ntfs/ntfs.h Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/ntfs/ntfs.h Fri Mar 02 17:12:32 2012 +0200
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/sys/fs/ntfs/ntfs.h 224290 2011-07-24 17:43:09Z mckusick $
+ * $FreeBSD: head/sys/fs/ntfs/ntfs.h 232100 2012-02-24 07:30:44Z kevlo $
*/
/*#define NTFS_DEBUG 1*/
@@ -36,7 +36,7 @@
#pragma pack(1)
#define BBSIZE 1024
#define BBOFF ((off_t)(0))
-#define BBLOCK ((daddr_t)(0))
+#define BBLOCK 0
#define NTFS_MFTINO 0
#define NTFS_VOLUMEINO 3
#define NTFS_ATTRDEFINO 4
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/ntfs/ntfs_vfsops.c
--- a/head/sys/fs/ntfs/ntfs_vfsops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/ntfs/ntfs_vfsops.c Fri Mar 02 17:12:32 2012 +0200
@@ -25,7 +25,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/sys/fs/ntfs/ntfs_vfsops.c 230249 2012-01-17 01:08:01Z mckusick $
+ * $FreeBSD: head/sys/fs/ntfs/ntfs_vfsops.c 232100 2012-02-24 07:30:44Z kevlo $
*/
@@ -33,6 +33,7 @@
#include <sys/systm.h>
#include <sys/namei.h>
#include <sys/conf.h>
+#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/kernel.h>
#include <sys/vnode.h>
@@ -66,8 +67,6 @@
MALLOC_DEFINE(M_NTFSFNODE,"ntfs_fnode", "NTFS fnode information");
MALLOC_DEFINE(M_NTFSDIR,"ntfs_dir", "NTFS dir buffer");
-struct sockaddr;
-
static int ntfs_mountfs(register struct vnode *, struct mount *,
struct thread *);
static int ntfs_calccfree(struct ntfsmount *ntmp, cn_t *cfreep);
@@ -150,13 +149,16 @@
};
static int
-ntfs_mount (struct mount *mp)
+ntfs_mount(struct mount *mp)
{
- int err = 0, error;
- struct vnode *devvp;
+ int err = 0, error;
+ accmode_t accmode;
+ struct vnode *devvp;
struct nameidata ndp;
+ struct thread *td;
char *from;
+ td = curthread;
if (vfs_filteropt(mp->mnt_optnew, ntfs_opts))
return (EINVAL);
@@ -183,7 +185,7 @@
* Not an update, or updating the name: look up the name
* and verify that it refers to a sensible block device.
*/
- NDINIT(&ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, from, curthread);
+ NDINIT(&ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE, from, td);
err = namei(&ndp);
if (err) {
/* can't get devvp!*/
@@ -197,6 +199,21 @@
return (err);
}
+ /*
+ * If mount by non-root, then verify that user has necessary
+ * permissions on the device.
+ */
+ accmode = VREAD;
+ if ((mp->mnt_flag & MNT_RDONLY) == 0)
+ accmode |= VWRITE;
+ err = VOP_ACCESS(devvp, accmode, td->td_ucred, td);
+ if (err)
+ err = priv_check(td, PRIV_VFS_MOUNT_PERM);
+ if (err) {
+ vput(devvp);
+ return (err);
+ }
+
if (mp->mnt_flag & MNT_UPDATE) {
#if 0
/*
@@ -230,7 +247,7 @@
/* Save "mounted from" info for mount point (NULL pad)*/
vfs_mountedfrom(mp, from);
- err = ntfs_mountfs(devvp, mp, curthread);
+ err = ntfs_mountfs(devvp, mp, td);
}
if (err) {
vrele(devvp);
@@ -243,7 +260,7 @@
/* XXX: missing NDFREE(&ndp, ...) */
success:
- return(err);
+ return (err);
}
/*
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/nullfs/null_subr.c
--- a/head/sys/fs/nullfs/null_subr.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/nullfs/null_subr.c Fri Mar 02 17:12:32 2012 +0200
@@ -31,7 +31,7 @@
*
* @(#)null_subr.c 8.7 (Berkeley) 5/14/95
*
- * $FreeBSD: head/sys/fs/nullfs/null_subr.c 230304 2012-01-18 11:23:46Z rea $
+ * $FreeBSD: head/sys/fs/nullfs/null_subr.c 232383 2012-03-02 09:48:46Z kib $
*/
#include <sys/param.h>
@@ -169,17 +169,26 @@
}
static void
+null_destroy_proto(struct vnode *vp, void *xp)
+{
+
+ lockmgr(&vp->v_lock, LK_EXCLUSIVE, NULL);
+ VI_LOCK(vp);
+ vp->v_data = NULL;
+ vp->v_vnlock = &vp->v_lock;
+ vp->v_op = &dead_vnodeops;
+ VI_UNLOCK(vp);
+ vgone(vp);
+ vput(vp);
+ free(xp, M_NULLFSNODE);
+}
+
+static void
null_insmntque_dtr(struct vnode *vp, void *xp)
{
vput(((struct null_node *)xp)->null_lowervp);
- vp->v_data = NULL;
- vp->v_vnlock = &vp->v_lock;
- free(xp, M_NULLFSNODE);
- vp->v_op = &dead_vnodeops;
- (void) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
- vgone(vp);
- vput(vp);
+ null_destroy_proto(vp, xp);
}
/*
@@ -200,7 +209,11 @@
struct vnode *vp;
int error;
- ASSERT_VOP_LOCKED(lowervp, "lowervp");
+ /*
+ * The insmntque1() call below requires the exclusive lock on
+ * the nullfs vnode.
+ */
+ ASSERT_VOP_ELOCKED(lowervp, "lowervp");
KASSERT(lowervp->v_usecount >= 1, ("Unreferenced vnode %p\n", lowervp));
/* Lookup the hash firstly */
@@ -213,12 +226,9 @@
/*
* We do not serialize vnode creation, instead we will check for
* duplicates later, when adding new vnode to hash.
- *
* Note that duplicate can only appear in hash if the lowervp is
* locked LK_SHARED.
- */
-
- /*
+ *
* Do the MALLOC before the getnewvnode since doing so afterward
* might cause a bogus v_data pointer to get dereferenced
* elsewhere if MALLOC should block.
@@ -250,9 +260,7 @@
*vpp = null_hashins(mp, xp);
if (*vpp != NULL) {
vrele(lowervp);
- vp->v_vnlock = &vp->v_lock;
- xp->null_lowervp = NULL;
- vrele(vp);
+ null_destroy_proto(vp, xp);
return (0);
}
*vpp = vp;
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/nullfs/null_vfsops.c
--- a/head/sys/fs/nullfs/null_vfsops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/nullfs/null_vfsops.c Fri Mar 02 17:12:32 2012 +0200
@@ -32,7 +32,7 @@
* @(#)null_vfsops.c 8.2 (Berkeley) 1/21/94
*
* @(#)lofs_vfsops.c 1.2 (Berkeley) 6/18/92
- * $FreeBSD: head/sys/fs/nullfs/null_vfsops.c 229431 2012-01-03 21:09:07Z kib $
+ * $FreeBSD: head/sys/fs/nullfs/null_vfsops.c 232305 2012-02-29 15:18:53Z kib $
*/
/*
@@ -50,6 +50,7 @@
#include <sys/namei.h>
#include <sys/proc.h>
#include <sys/vnode.h>
+#include <sys/jail.h>
#include <fs/nullfs/null.h>
@@ -75,12 +76,16 @@
struct vnode *lowerrootvp, *vp;
struct vnode *nullm_rootvp;
struct null_mount *xmp;
+ struct thread *td = curthread;
char *target;
int isvnunlocked = 0, len;
struct nameidata nd, *ndp = &nd;
NULLFSDEBUG("nullfs_mount(mp = %p)\n", (void *)mp);
+ if (!prison_allow(td->td_ucred, PR_ALLOW_MOUNT_NULLFS))
+ return (EPERM);
+
if (mp->mnt_flag & MNT_ROOTFS)
return (EOPNOTSUPP);
/*
@@ -180,7 +185,8 @@
MNT_IUNLOCK(mp);
}
MNT_ILOCK(mp);
- mp->mnt_kern_flag |= lowerrootvp->v_mount->mnt_kern_flag & MNTK_MPSAFE;
+ mp->mnt_kern_flag |= lowerrootvp->v_mount->mnt_kern_flag &
+ (MNTK_MPSAFE | MNTK_SHARED_WRITES);
MNT_IUNLOCK(mp);
mp->mnt_data = xmp;
vfs_getnewfsid(mp);
@@ -307,6 +313,12 @@
struct vnode **vpp;
{
int error;
+
+ KASSERT((flags & LK_TYPE_MASK) != 0,
+ ("nullfs_vget: no lock requested"));
+ flags &= ~LK_TYPE_MASK;
+ flags |= LK_EXCLUSIVE;
+
error = VFS_VGET(MOUNTTONULLMOUNT(mp)->nullm_vfs, ino, flags, vpp);
if (error)
return (error);
@@ -357,4 +369,4 @@
.vfs_vget = nullfs_vget,
};
-VFS_SET(null_vfsops, nullfs, VFCF_LOOPBACK);
+VFS_SET(null_vfsops, nullfs, VFCF_LOOPBACK | VFCF_JAIL);
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/nullfs/null_vnops.c
--- a/head/sys/fs/nullfs/null_vnops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/nullfs/null_vnops.c Fri Mar 02 17:12:32 2012 +0200
@@ -36,7 +36,7 @@
* ...and...
* @(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project
*
- * $FreeBSD: head/sys/fs/nullfs/null_vnops.c 229431 2012-01-03 21:09:07Z kib $
+ * $FreeBSD: head/sys/fs/nullfs/null_vnops.c 232303 2012-02-29 15:15:36Z kib $
*/
/*
@@ -697,12 +697,18 @@
static int
null_reclaim(struct vop_reclaim_args *ap)
{
- struct vnode *vp = ap->a_vp;
- struct null_node *xp = VTONULL(vp);
- struct vnode *lowervp = xp->null_lowervp;
+ struct vnode *vp;
+ struct null_node *xp;
+ struct vnode *lowervp;
- if (lowervp)
- null_hashrem(xp);
+ vp = ap->a_vp;
+ xp = VTONULL(vp);
+ lowervp = xp->null_lowervp;
+
+ KASSERT(lowervp != NULL && vp->v_vnlock != &vp->v_lock,
+ ("Reclaiming inclomplete null vnode %p", vp));
+
+ null_hashrem(xp);
/*
* Use the interlock to protect the clearing of v_data to
* prevent faults in null_lock().
@@ -713,10 +719,7 @@
vp->v_object = NULL;
vp->v_vnlock = &vp->v_lock;
VI_UNLOCK(vp);
- if (lowervp)
- vput(lowervp);
- else
- panic("null_reclaim: reclaiming a node with no lowervp");
+ vput(lowervp);
free(xp, M_NULLFSNODE);
return (0);
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/nwfs/nwfs_vnops.c
--- a/head/sys/fs/nwfs/nwfs_vnops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/nwfs/nwfs_vnops.c Fri Mar 02 17:12:32 2012 +0200
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: head/sys/fs/nwfs/nwfs_vnops.c 231088 2012-02-06 17:00:28Z jhb $
*/
#include <sys/param.h>
#include <sys/systm.h>
@@ -853,7 +853,7 @@
if (error)
return ENOENT;
- error = cache_lookup(dvp, vpp, cnp);
+ error = cache_lookup(dvp, vpp, cnp, NULL, NULL);
NCPVNDEBUG("cache_lookup returned %d\n", error);
if (error > 0)
return error;
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/procfs/procfs.c
--- a/head/sys/fs/procfs/procfs.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/procfs/procfs.c Fri Mar 02 17:12:32 2012 +0200
@@ -37,7 +37,7 @@
*
* @(#)procfs_vfsops.c 8.7 (Berkeley) 5/10/95
*
- * $FreeBSD: head/sys/fs/procfs/procfs.c 230132 2012-01-15 13:23:18Z uqs $
+ * $FreeBSD: head/sys/fs/procfs/procfs.c 232278 2012-02-29 00:30:18Z mm $
*/
#include <sys/param.h>
@@ -209,4 +209,4 @@
return (0);
}
-PSEUDOFS(procfs, 1);
+PSEUDOFS(procfs, 1, PR_ALLOW_MOUNT_PROCFS);
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/pseudofs/pseudofs.h
--- a/head/sys/fs/pseudofs/pseudofs.h Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/pseudofs/pseudofs.h Fri Mar 02 17:12:32 2012 +0200
@@ -25,12 +25,14 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $FreeBSD: head/sys/fs/pseudofs/pseudofs.h 230249 2012-01-17 01:08:01Z mckusick $
+ * $FreeBSD: head/sys/fs/pseudofs/pseudofs.h 232278 2012-02-29 00:30:18Z mm $
*/
#ifndef _PSEUDOFS_H_INCLUDED
#define _PSEUDOFS_H_INCLUDED
+#include <sys/jail.h>
+
/*
* Opaque structures
*/
@@ -271,7 +273,7 @@
/*
* Now for some initialization magic...
*/
-#define PSEUDOFS(name, version) \
+#define PSEUDOFS(name, version, jflag) \
\
static struct pfs_info name##_info = { \
#name, \
@@ -281,6 +283,8 @@
\
static int \
_##name##_mount(struct mount *mp) { \
+ if (jflag && !prison_allow(curthread->td_ucred, jflag)) \
+ return (EPERM); \
return pfs_mount(&name##_info, mp); \
} \
\
@@ -303,7 +307,7 @@
.vfs_uninit = _##name##_uninit, \
.vfs_unmount = pfs_unmount, \
}; \
-VFS_SET(name##_vfsops, name, VFCF_SYNTHETIC); \
+VFS_SET(name##_vfsops, name, VFCF_SYNTHETIC | (jflag ? VFCF_JAIL : 0)); \
MODULE_VERSION(name, version); \
MODULE_DEPEND(name, pseudofs, 1, 1, 1);
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/pseudofs/pseudofs_vnops.c
--- a/head/sys/fs/pseudofs/pseudofs_vnops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/pseudofs/pseudofs_vnops.c Fri Mar 02 17:12:32 2012 +0200
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/pseudofs/pseudofs_vnops.c 230132 2012-01-15 13:23:18Z uqs $");
+__FBSDID("$FreeBSD: head/sys/fs/pseudofs/pseudofs_vnops.c 231949 2012-02-21 01:05:12Z kib $");
#include "opt_pseudofs.h"
@@ -589,7 +589,8 @@
struct proc *proc;
struct sbuf *sb = NULL;
int error, locked;
- unsigned int buflen, offset, resid;
+ off_t offset;
+ ssize_t buflen, resid;
PFS_TRACE(("%s", pn->pn_name));
pfs_assert_not_owned(pn);
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/smbfs/smbfs_vnops.c
--- a/head/sys/fs/smbfs/smbfs_vnops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/smbfs/smbfs_vnops.c Fri Mar 02 17:12:32 2012 +0200
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/sys/fs/smbfs/smbfs_vnops.c 229272 2012-01-02 12:12:10Z ed $
+ * $FreeBSD: head/sys/fs/smbfs/smbfs_vnops.c 231088 2012-02-06 17:00:28Z jhb $
*/
#include <sys/param.h>
#include <sys/systm.h>
@@ -1131,7 +1131,7 @@
if (error)
return ENOENT;
- error = cache_lookup(dvp, vpp, cnp);
+ error = cache_lookup(dvp, vpp, cnp, NULL, NULL);
SMBVDEBUG("cache_lookup returned %d\n", error);
if (error > 0)
return error;
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/tmpfs/tmpfs_vnops.c
--- a/head/sys/fs/tmpfs/tmpfs_vnops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/tmpfs/tmpfs_vnops.c Fri Mar 02 17:12:32 2012 +0200
@@ -34,7 +34,7 @@
* tmpfs vnode interface.
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/fs/tmpfs/tmpfs_vnops.c 230180 2012-01-16 00:26:49Z alc $");
+__FBSDID("$FreeBSD: head/sys/fs/tmpfs/tmpfs_vnops.c 231669 2012-02-14 11:24:24Z tijl $");
#include <sys/param.h>
#include <sys/fcntl.h>
@@ -54,8 +54,6 @@
#include <vm/vm_page.h>
#include <vm/vm_pager.h>
-#include <machine/_inttypes.h>
-
#include <fs/fifofs/fifo.h>
#include <fs/tmpfs/tmpfs_vnops.h>
#include <fs/tmpfs/tmpfs.h>
@@ -1471,10 +1469,9 @@
printf("tag VT_TMPFS, tmpfs_node %p, flags 0x%x, links %d\n",
node, node->tn_flags, node->tn_links);
- printf("\tmode 0%o, owner %d, group %d, size %" PRIdMAX
- ", status 0x%x\n",
+ printf("\tmode 0%o, owner %d, group %d, size %jd, status 0x%x\n",
node->tn_mode, node->tn_uid, node->tn_gid,
- (uintmax_t)node->tn_size, node->tn_status);
+ (intmax_t)node->tn_size, node->tn_status);
if (vp->v_type == VFIFO)
fifo_printinfo(vp);
diff -r e8250b8e4ab7 -r de99a27dd03c head/sys/fs/udf/udf_vnops.c
--- a/head/sys/fs/udf/udf_vnops.c Fri Mar 02 17:11:55 2012 +0200
+++ b/head/sys/fs/udf/udf_vnops.c Fri Mar 02 17:12:32 2012 +0200
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD: head/sys/fs/udf/udf_vnops.c 227293 2011-11-07 06:44:47Z ed $
+ * $FreeBSD: head/sys/fs/udf/udf_vnops.c 231949 2012-02-21 01:05:12Z kib $
*/
/* udf_vnops.c */
@@ -439,8 +439,9 @@
uint8_t *data;
daddr_t lbn, rablock;
off_t diff, fsize;
+ ssize_t n;
int error = 0;
- long size, n, on;
+ long size, on;
if (uio->uio_resid == 0)
return (0);
More information about the Zrouter-src-freebsd
mailing list