Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/fs/tmpfs/tmpfs_vfsops.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/fs/tmpfs/tmpfs_vfsops.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.29.2.4 retrieving revision 1.30 diff -u -p -r1.29.2.4 -r1.30 --- src/sys/fs/tmpfs/tmpfs_vfsops.c 2008/02/18 21:06:40 1.29.2.4 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c 2007/11/06 19:50:55 1.30 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.29.2.4 2008/02/18 21:06:40 mjf Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.30 2007/11/06 19:50:55 ad Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -49,7 +49,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.29.2.4 2008/02/18 21:06:40 mjf Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.30 2007/11/06 19:50:55 ad Exp $"); #include #include @@ -60,20 +60,22 @@ __KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops #include #include -#include #include /* --------------------------------------------------------------------- */ -static int tmpfs_mount(struct mount *, const char *, void *, size_t *); -static int tmpfs_start(struct mount *, int); -static int tmpfs_unmount(struct mount *, int); +static int tmpfs_mount(struct mount *, const char *, void *, size_t *, + struct lwp *); +static int tmpfs_start(struct mount *, int, struct lwp *); +static int tmpfs_unmount(struct mount *, int, struct lwp *); static int tmpfs_root(struct mount *, struct vnode **); +static int tmpfs_quotactl(struct mount *, int, uid_t, void *, + struct lwp *); static int tmpfs_vget(struct mount *, ino_t, struct vnode **); static int tmpfs_fhtovp(struct mount *, struct fid *, struct vnode **); static int tmpfs_vptofh(struct vnode *, struct fid *, size_t *); -static int tmpfs_statvfs(struct mount *, struct statvfs *); -static int tmpfs_sync(struct mount *, int, kauth_cred_t); +static int tmpfs_statvfs(struct mount *, struct statvfs *, struct lwp *); +static int tmpfs_sync(struct mount *, int, kauth_cred_t, struct lwp *); static void tmpfs_init(void); static void tmpfs_done(void); static int tmpfs_snapshot(struct mount *, struct vnode *, @@ -82,9 +84,9 @@ static int tmpfs_snapshot(struct mount * /* --------------------------------------------------------------------- */ static int -tmpfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len) +tmpfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len, + struct lwp *l) { - struct lwp *l = curlwp; int error; ino_t nodes; size_t pages; @@ -102,10 +104,12 @@ tmpfs_mount(struct mount *mp, const char tmp = VFS_TO_TMPFS(mp); args->ta_version = TMPFS_ARGS_VERSION; + mutex_enter(&tmp->tm_lock); args->ta_nodes_max = tmp->tm_nodes_max; args->ta_size_max = tmp->tm_pages_max * PAGE_SIZE; - root = tmp->tm_root; + mutex_exit(&tmp->tm_lock); + args->ta_root_uid = root->tn_uid; args->ta_root_gid = root->tn_gid; args->ta_root_mode = root->tn_mode; @@ -138,16 +142,12 @@ tmpfs_mount(struct mount *mp, const char else pages = args->ta_size_max / PAGE_SIZE + (args->ta_size_max % PAGE_SIZE == 0 ? 0 : 1); - if (pages > INT_MAX) - pages = INT_MAX; KASSERT(pages > 0); if (args->ta_nodes_max <= 3) nodes = 3 + pages * PAGE_SIZE / 1024; else nodes = args->ta_nodes_max; - if (nodes > INT_MAX) - nodes = INT_MAX; KASSERT(nodes >= 3); /* Allocate the tmpfs mount structure and fill it. */ @@ -172,9 +172,8 @@ tmpfs_mount(struct mount *mp, const char /* Allocate the root node. */ error = tmpfs_alloc_node(tmp, VDIR, args->ta_root_uid, args->ta_root_gid, args->ta_root_mode & ALLPERMS, NULL, NULL, - VNOVAL, &root); + VNOVAL, l->l_proc, &root); KASSERT(error == 0 && root != NULL); - root->tn_links++; tmp->tm_root = root; mp->mnt_data = tmp; @@ -192,7 +191,8 @@ tmpfs_mount(struct mount *mp, const char /* --------------------------------------------------------------------- */ static int -tmpfs_start(struct mount *mp, int flags) +tmpfs_start(struct mount *mp, int flags, + struct lwp *l) { return 0; @@ -202,7 +202,7 @@ tmpfs_start(struct mount *mp, int flags) /* ARGSUSED2 */ static int -tmpfs_unmount(struct mount *mp, int mntflags) +tmpfs_unmount(struct mount *mp, int mntflags, struct lwp *l) { int error; int flags = 0; @@ -225,10 +225,7 @@ tmpfs_unmount(struct mount *mp, int mntf * a directory, we free all its directory entries. Note that after * freeing a node, it will automatically go to the available list, * so we will later have to iterate over it to release its items. */ - node = LIST_FIRST(&tmp->tm_nodes); - while (node != NULL) { - struct tmpfs_node *next; - + while ((node = LIST_FIRST(&tmp->tm_nodes)) != NULL) { if (node->tn_type == VDIR) { struct tmpfs_dirent *de; @@ -237,15 +234,14 @@ tmpfs_unmount(struct mount *mp, int mntf struct tmpfs_dirent *nde; nde = TAILQ_NEXT(de, td_entries); + KASSERT(de->td_node->tn_vnode == NULL); tmpfs_free_dirent(tmp, de, false); de = nde; node->tn_size -= sizeof(struct tmpfs_dirent); } } - next = LIST_NEXT(node, tn_entries); tmpfs_free_node(tmp, node); - node = next; } tmpfs_pool_destroy(&tmp->tm_dirent_pool); @@ -274,8 +270,19 @@ tmpfs_root(struct mount *mp, struct vnod /* --------------------------------------------------------------------- */ static int +tmpfs_quotactl(struct mount *mp, int cmd, uid_t uid, + void *arg, struct lwp *l) +{ + + printf("tmpfs_quotactl called; need for it unknown yet\n"); + return EOPNOTSUPP; +} + +/* --------------------------------------------------------------------- */ + +static int tmpfs_vget(struct mount *mp, ino_t ino, - struct vnode **vpp) + struct vnode **vpp) { printf("tmpfs_vget called; need for it unknown yet\n"); @@ -299,11 +306,13 @@ tmpfs_fhtovp(struct mount *mp, struct fi memcpy(&tfh, fhp, sizeof(struct tmpfs_fid)); - if (tfh.tf_id >= tmp->tm_nodes_max) + mutex_enter(&tmp->tm_lock); + if (tfh.tf_id >= tmp->tm_nodes_max) { + mutex_exit(&tmp->tm_lock); return EINVAL; + } found = false; - mutex_enter(&tmp->tm_lock); LIST_FOREACH(node, &tmp->tm_nodes, tn_entries) { if (node->tn_id == tfh.tf_id && node->tn_gen == tfh.tf_gen) { @@ -345,13 +354,15 @@ tmpfs_vptofh(struct vnode *vp, struct fi /* ARGSUSED2 */ static int -tmpfs_statvfs(struct mount *mp, struct statvfs *sbp) +tmpfs_statvfs(struct mount *mp, struct statvfs *sbp, struct lwp *l) { fsfilcnt_t freenodes; struct tmpfs_mount *tmp; tmp = VFS_TO_TMPFS(mp); + mutex_enter(&tmp->tm_lock); + sbp->f_iosize = sbp->f_frsize = sbp->f_bsize = PAGE_SIZE; sbp->f_blocks = TMPFS_PAGES_MAX(tmp); @@ -365,6 +376,8 @@ tmpfs_statvfs(struct mount *mp, struct s sbp->f_favail = sbp->f_ffree = freenodes; sbp->f_fresvd = 0; + mutex_exit(&tmp->tm_lock); + copy_statvfs_info(sbp, mp); return 0; @@ -375,7 +388,7 @@ tmpfs_statvfs(struct mount *mp, struct s /* ARGSUSED0 */ static int tmpfs_sync(struct mount *mp, int waitfor, - kauth_cred_t uc) + kauth_cred_t uc, struct lwp *l) { return 0; @@ -431,7 +444,7 @@ struct vfsops tmpfs_vfsops = { tmpfs_start, /* vfs_start */ tmpfs_unmount, /* vfs_unmount */ tmpfs_root, /* vfs_root */ - (void *)eopnotsupp, /* vfs_quotactl */ + tmpfs_quotactl, /* vfs_quotactl */ tmpfs_statvfs, /* vfs_statvfs */ tmpfs_sync, /* vfs_sync */ tmpfs_vget, /* vfs_vget */ @@ -444,8 +457,6 @@ struct vfsops tmpfs_vfsops = { tmpfs_snapshot, /* vfs_snapshot */ vfs_stdextattrctl, /* vfs_extattrctl */ (void *)eopnotsupp, /* vfs_suspendctl */ - genfs_renamelock_enter, - genfs_renamelock_exit, tmpfs_vnodeopv_descs, 0, /* vfs_refcount */ { NULL, NULL },