From 064fbe7e1847b9c81b97a86fa2308575364b6b73 Mon Sep 17 00:00:00 2001 From: jmmv Date: Thu, 16 Feb 2006 14:57:50 +0000 Subject: [PATCH] Do not use unnamed structures/unions without instances; they break the build under vax because of gcc 2.95. Found by he@. --- sys/fs/tmpfs/tmpfs.h | 23 +++++----- sys/fs/tmpfs/tmpfs_subr.c | 87 ++++++++++++++++++++----------------- sys/fs/tmpfs/tmpfs_vfsops.c | 8 ++-- sys/fs/tmpfs/tmpfs_vnops.c | 43 +++++++++--------- 4 files changed, 85 insertions(+), 76 deletions(-) diff --git a/sys/fs/tmpfs/tmpfs.h b/sys/fs/tmpfs/tmpfs.h index 84019ebb6b0d..da85aa93c590 100644 --- a/sys/fs/tmpfs/tmpfs.h +++ b/sys/fs/tmpfs/tmpfs.h @@ -1,7 +1,7 @@ -/* $NetBSD: tmpfs.h,v 1.14 2006/02/10 16:00:02 christos Exp $ */ +/* $NetBSD: tmpfs.h,v 1.15 2006/02/16 14:57:50 jmmv Exp $ */ /* - * Copyright (c) 2005 The NetBSD Foundation, Inc. + * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -168,7 +168,7 @@ struct tmpfs_node { /* Valid when tn_type == VBLK || tn_type == VCHR. */ struct { dev_t tn_rdev; - }; + } tn_dev; /* Valid when tn_type == VDIR. */ struct { @@ -193,16 +193,16 @@ struct tmpfs_node { * point where readdir starts returning values. */ off_t tn_readdir_lastn; struct tmpfs_dirent * tn_readdir_lastp; - }; + } tn_dir; /* Valid when tn_type == VLNK. */ - struct { + struct tn_lnk { /* The link's target, allocated from a string pool. */ char * tn_link; - }; + } tn_lnk; /* Valid when tn_type == VREG. */ - struct { + struct tn_reg { /* The contents of regular files stored in a tmpfs * file system are represented by a single anonymous * memory object (aobj, for short). The aobj provides @@ -214,8 +214,8 @@ struct tmpfs_node { * a position within the file is accessed. */ struct uvm_object * tn_aobj; size_t tn_aobj_pages; - }; - }; + } tn_reg; + } tn_spec; }; LIST_HEAD(tmpfs_node_list, tmpfs_node); @@ -360,8 +360,9 @@ int tmpfs_truncate(struct vnode *, off_t); #define TMPFS_VALIDATE_DIR(node) \ KASSERT((node)->tn_type == VDIR); \ KASSERT((node)->tn_size % sizeof(struct tmpfs_dirent) == 0); \ - KASSERT((node)->tn_readdir_lastp == NULL || \ - TMPFS_DIRCOOKIE((node)->tn_readdir_lastp) == (node)->tn_readdir_lastn); + KASSERT((node)->tn_spec.tn_dir.tn_readdir_lastp == NULL || \ + TMPFS_DIRCOOKIE((node)->tn_spec.tn_dir.tn_readdir_lastp) == \ + (node)->tn_spec.tn_dir.tn_readdir_lastn); /* --------------------------------------------------------------------- */ diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index de0615a50062..4b7a659ea239 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -1,7 +1,7 @@ -/* $NetBSD: tmpfs_subr.c,v 1.17 2005/12/11 12:24:29 christos Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.18 2006/02/16 14:57:50 jmmv Exp $ */ /* - * Copyright (c) 2005 The NetBSD Foundation, Inc. + * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.17 2005/12/11 12:24:29 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.18 2006/02/16 14:57:50 jmmv Exp $"); #include #include @@ -143,16 +143,17 @@ tmpfs_alloc_node(struct tmpfs_mount *tmp, enum vtype type, switch (nnode->tn_type) { case VBLK: case VCHR: - nnode->tn_rdev = rdev; + nnode->tn_spec.tn_dev.tn_rdev = rdev; break; case VDIR: - TAILQ_INIT(&nnode->tn_dir); - nnode->tn_parent = (parent == NULL) ? nnode : parent; - nnode->tn_readdir_lastn = 0; - nnode->tn_readdir_lastp = NULL; + TAILQ_INIT(&nnode->tn_spec.tn_dir.tn_dir); + nnode->tn_spec.tn_dir.tn_parent = + (parent == NULL) ? nnode : parent; + nnode->tn_spec.tn_dir.tn_readdir_lastn = 0; + nnode->tn_spec.tn_dir.tn_readdir_lastp = NULL; nnode->tn_links++; - nnode->tn_parent->tn_links++; + nnode->tn_spec.tn_dir.tn_parent->tn_links++; break; case VFIFO: @@ -163,19 +164,20 @@ tmpfs_alloc_node(struct tmpfs_mount *tmp, enum vtype type, case VLNK: KASSERT(strlen(target) < MAXPATHLEN); nnode->tn_size = strlen(target); - nnode->tn_link = tmpfs_str_pool_get(&tmp->tm_str_pool, - nnode->tn_size, 0); - if (nnode->tn_link == NULL) { + nnode->tn_spec.tn_lnk.tn_link = + tmpfs_str_pool_get(&tmp->tm_str_pool, nnode->tn_size, 0); + if (nnode->tn_spec.tn_lnk.tn_link == NULL) { nnode->tn_type = VNON; tmpfs_free_node(tmp, nnode); return ENOSPC; } - memcpy(nnode->tn_link, target, nnode->tn_size); + memcpy(nnode->tn_spec.tn_lnk.tn_link, target, nnode->tn_size); break; case VREG: - nnode->tn_aobj = uao_create(INT32_MAX - PAGE_SIZE, 0); - nnode->tn_aobj_pages = 0; + nnode->tn_spec.tn_reg.tn_aobj = + uao_create(INT32_MAX - PAGE_SIZE, 0); + nnode->tn_spec.tn_reg.tn_aobj_pages = 0; break; default: @@ -231,15 +233,15 @@ tmpfs_free_node(struct tmpfs_mount *tmp, struct tmpfs_node *node) break; case VLNK: - tmpfs_str_pool_put(&tmp->tm_str_pool, node->tn_link, - node->tn_size); + tmpfs_str_pool_put(&tmp->tm_str_pool, + node->tn_spec.tn_lnk.tn_link, node->tn_size); pages = 0; break; case VREG: - if (node->tn_aobj != NULL) - uao_detach(node->tn_aobj); - pages = node->tn_aobj_pages; + if (node->tn_spec.tn_reg.tn_aobj != NULL) + uao_detach(node->tn_spec.tn_reg.tn_aobj); + pages = node->tn_spec.tn_reg.tn_aobj_pages; break; default: @@ -372,7 +374,7 @@ tmpfs_alloc_vp(struct mount *mp, struct tmpfs_node *node, struct vnode **vpp) /* FALLTHROUGH */ case VCHR: vp->v_op = tmpfs_specop_p; - nvp = checkalias(vp, node->tn_rdev, mp); + nvp = checkalias(vp, node->tn_spec.tn_dev.tn_rdev, mp); if (nvp != NULL) { /* Discard unneeded vnode, but save its inode. */ nvp->v_data = vp->v_data; @@ -398,7 +400,7 @@ tmpfs_alloc_vp(struct mount *mp, struct tmpfs_node *node, struct vnode **vpp) break; case VDIR: - vp->v_flag = node->tn_parent == node ? VROOT : 0; + vp->v_flag = node->tn_spec.tn_dir.tn_parent == node ? VROOT : 0; break; case VFIFO: @@ -546,7 +548,7 @@ tmpfs_dir_attach(struct vnode *vp, struct tmpfs_dirent *de) dnode = VP_TO_TMPFS_DIR(vp); - TAILQ_INSERT_TAIL(&dnode->tn_dir, de, td_entries); + TAILQ_INSERT_TAIL(&dnode->tn_spec.tn_dir.tn_dir, de, td_entries); dnode->tn_size += sizeof(struct tmpfs_dirent); dnode->tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_CHANGED | \ TMPFS_NODE_MODIFIED; @@ -569,12 +571,12 @@ tmpfs_dir_detach(struct vnode *vp, struct tmpfs_dirent *de) dnode = VP_TO_TMPFS_DIR(vp); - if (dnode->tn_readdir_lastp == de) { - dnode->tn_readdir_lastn = 0; - dnode->tn_readdir_lastp = NULL; + if (dnode->tn_spec.tn_dir.tn_readdir_lastp == de) { + dnode->tn_spec.tn_dir.tn_readdir_lastn = 0; + dnode->tn_spec.tn_dir.tn_readdir_lastp = NULL; } - TAILQ_REMOVE(&dnode->tn_dir, de, td_entries); + TAILQ_REMOVE(&dnode->tn_spec.tn_dir.tn_dir, de, td_entries); dnode->tn_size -= sizeof(struct tmpfs_dirent); dnode->tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_CHANGED | \ TMPFS_NODE_MODIFIED; @@ -605,7 +607,7 @@ tmpfs_dir_lookup(struct tmpfs_node *node, struct componentname *cnp) node->tn_status |= TMPFS_NODE_ACCESSED; found = 0; - TAILQ_FOREACH(de, &node->tn_dir, td_entries) { + TAILQ_FOREACH(de, &node->tn_spec.tn_dir.tn_dir, td_entries) { KASSERT(cnp->cn_namelen < 0xffff); if (de->td_namelen == (uint16_t)cnp->cn_namelen && memcmp(de->td_name, cnp->cn_nameptr, de->td_namelen) == 0) { @@ -673,7 +675,7 @@ tmpfs_dir_getdotdotdent(struct tmpfs_node *node, struct uio *uio) TMPFS_VALIDATE_DIR(node); KASSERT(uio->uio_offset == TMPFS_DIRCOOKIE_DOTDOT); - dent.d_fileno = node->tn_parent->tn_id; + dent.d_fileno = node->tn_spec.tn_dir.tn_parent->tn_id; dent.d_type = DT_DIR; dent.d_namlen = 2; dent.d_name[0] = '.'; @@ -688,7 +690,7 @@ tmpfs_dir_getdotdotdent(struct tmpfs_node *node, struct uio *uio) if (error == 0) { struct tmpfs_dirent *de; - de = TAILQ_FIRST(&node->tn_dir); + de = TAILQ_FIRST(&node->tn_spec.tn_dir.tn_dir); if (de == NULL) uio->uio_offset = TMPFS_DIRCOOKIE_EOF; else @@ -711,12 +713,12 @@ tmpfs_dir_lookupbycookie(struct tmpfs_node *node, off_t cookie) { struct tmpfs_dirent *de; - if (cookie == node->tn_readdir_lastn && - node->tn_readdir_lastp != NULL) { - return node->tn_readdir_lastp; + if (cookie == node->tn_spec.tn_dir.tn_readdir_lastn && + node->tn_spec.tn_dir.tn_readdir_lastp != NULL) { + return node->tn_spec.tn_dir.tn_readdir_lastp; } - TAILQ_FOREACH(de, &node->tn_dir, td_entries) { + TAILQ_FOREACH(de, &node->tn_spec.tn_dir.tn_dir, td_entries) { if (TMPFS_DIRCOOKIE(de) == cookie) { break; } @@ -822,11 +824,12 @@ tmpfs_dir_getdents(struct tmpfs_node *node, struct uio *uio, off_t *cntp) /* Update the offset and cache. */ if (de == NULL) { uio->uio_offset = TMPFS_DIRCOOKIE_EOF; - node->tn_readdir_lastn = 0; - node->tn_readdir_lastp = NULL; + node->tn_spec.tn_dir.tn_readdir_lastn = 0; + node->tn_spec.tn_dir.tn_readdir_lastp = NULL; } else { - node->tn_readdir_lastn = uio->uio_offset = TMPFS_DIRCOOKIE(de); - node->tn_readdir_lastp = de; + node->tn_spec.tn_dir.tn_readdir_lastn = uio->uio_offset = + TMPFS_DIRCOOKIE(de); + node->tn_spec.tn_dir.tn_readdir_lastp = de; } node->tn_status |= TMPFS_NODE_ACCESSED; @@ -864,7 +867,7 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize) * its own. */ oldsize = node->tn_size; oldpages = round_page(oldsize) / PAGE_SIZE; - KASSERT(oldpages == node->tn_aobj_pages); + KASSERT(oldpages == node->tn_spec.tn_reg.tn_aobj_pages); newpages = round_page(newsize) / PAGE_SIZE; if (newpages > oldpages && @@ -873,7 +876,7 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize) goto out; } - node->tn_aobj_pages = newpages; + node->tn_spec.tn_reg.tn_aobj_pages = newpages; tmp->tm_pages_used += (newpages - oldpages); node->tn_size = newsize; @@ -886,7 +889,9 @@ tmpfs_reg_resize(struct vnode *vp, off_t newsize) */ if (newpages < oldpages) { - struct uvm_object *uobj = node->tn_aobj; + struct uvm_object *uobj; + + uobj = node->tn_spec.tn_reg.tn_aobj; simple_lock(&uobj->vmobjlock); uao_dropswap_range(uobj, newpages, oldpages); diff --git a/sys/fs/tmpfs/tmpfs_vfsops.c b/sys/fs/tmpfs/tmpfs_vfsops.c index 02860140249b..b73c4a0d4990 100644 --- a/sys/fs/tmpfs/tmpfs_vfsops.c +++ b/sys/fs/tmpfs/tmpfs_vfsops.c @@ -1,7 +1,7 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.10 2005/12/11 12:24:29 christos Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.11 2006/02/16 14:57:50 jmmv Exp $ */ /* - * Copyright (c) 2005 The NetBSD Foundation, Inc. + * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -49,7 +49,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.10 2005/12/11 12:24:29 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.11 2006/02/16 14:57:50 jmmv Exp $"); #include #include @@ -231,7 +231,7 @@ tmpfs_unmount(struct mount *mp, int mntflags, struct lwp *l) if (node->tn_type == VDIR) { struct tmpfs_dirent *de; - de = TAILQ_FIRST(&node->tn_dir); + de = TAILQ_FIRST(&node->tn_spec.tn_dir.tn_dir); while (de != NULL) { struct tmpfs_dirent *nde; diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 5e95f1bfb999..ba5436ee61bb 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -1,7 +1,7 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.20 2006/01/26 20:07:34 jmmv Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.21 2006/02/16 14:57:50 jmmv Exp $ */ /* - * Copyright (c) 2005 The NetBSD Foundation, Inc. + * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.20 2006/01/26 20:07:34 jmmv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.21 2006/02/16 14:57:50 jmmv Exp $"); #include #include @@ -157,20 +157,22 @@ tmpfs_lookup(void *v) /* We cannot be requesting the parent directory of the root node. */ KASSERT(IMPLIES(dnode->tn_type == VDIR && - dnode->tn_parent == dnode, !(cnp->cn_flags & ISDOTDOT))); + dnode->tn_spec.tn_dir.tn_parent == dnode, + !(cnp->cn_flags & ISDOTDOT))); if (cnp->cn_flags & ISDOTDOT) { VOP_UNLOCK(dvp, 0); /* Allocate a new vnode on the matching entry. */ - error = tmpfs_alloc_vp(dvp->v_mount, dnode->tn_parent, vpp); + error = tmpfs_alloc_vp(dvp->v_mount, + dnode->tn_spec.tn_dir.tn_parent, vpp); if (cnp->cn_flags & LOCKPARENT && cnp->cn_flags & ISLASTCN) { if (vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY) != 0) cnp->cn_flags |= PDIRUNLOCK; } - dnode->tn_parent->tn_lookup_dirent = NULL; + dnode->tn_spec.tn_dir.tn_parent->tn_lookup_dirent = NULL; } else if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') { VREF(dvp); *vpp = dvp; @@ -434,7 +436,7 @@ tmpfs_getattr(void *v) vap->va_gen = node->tn_gen; vap->va_flags = node->tn_flags; vap->va_rdev = (vp->v_type == VBLK || vp->v_type == VCHR) ? - node->tn_rdev : VNOVAL; + node->tn_spec.tn_dev.tn_rdev : VNOVAL; vap->va_bytes = round_page(node->tn_size); vap->va_filerev = VNOVAL; vap->va_vaflags = 0; @@ -535,7 +537,7 @@ tmpfs_read(void *v) node->tn_status |= TMPFS_NODE_ACCESSED; - uobj = node->tn_aobj; + uobj = node->tn_spec.tn_reg.tn_aobj; flags = UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0; error = 0; while (error == 0 && uio->uio_resid > 0) { @@ -602,7 +604,7 @@ tmpfs_write(void *v) goto out; } - uobj = node->tn_aobj; + uobj = node->tn_spec.tn_reg.tn_aobj; flags = UBC_WANT_UNMAP(vp) ? UBC_UNMAP : 0; error = 0; while (error == 0 && uio->uio_resid > 0) { @@ -880,17 +882,17 @@ tmpfs_rename(void *v) * directory being moved. Otherwise, we'd end up * with stale nodes. */ n = tdnode; - while (n != n->tn_parent) { + while (n != n->tn_spec.tn_dir.tn_parent) { if (n == fnode) { error = EINVAL; goto out_locked; } - n = n->tn_parent; + n = n->tn_spec.tn_dir.tn_parent; } /* Adjust the parent pointer. */ TMPFS_VALIDATE_DIR(fnode); - de->td_node->tn_parent = tdnode; + de->td_node->tn_spec.tn_dir.tn_parent = tdnode; /* As a result of changing the target of the '..' * entry, the link count of the source and target @@ -1008,7 +1010,7 @@ tmpfs_rmdir(void *v) tmp = VFS_TO_TMPFS(dvp->v_mount); dnode = VP_TO_TMPFS_DIR(dvp); node = VP_TO_TMPFS_DIR(vp); - KASSERT(node->tn_parent == dnode); + KASSERT(node->tn_spec.tn_dir.tn_parent == dnode); /* Get the directory entry associated with node (vp). This was * filled by tmpfs_lookup while looking up the entry. */ @@ -1036,8 +1038,8 @@ tmpfs_rmdir(void *v) node->tn_links--; node->tn_status |= TMPFS_NODE_ACCESSED | TMPFS_NODE_CHANGED | \ TMPFS_NODE_MODIFIED; - node->tn_parent->tn_links--; - node->tn_parent->tn_status |= TMPFS_NODE_ACCESSED | \ + node->tn_spec.tn_dir.tn_parent->tn_links--; + node->tn_spec.tn_dir.tn_parent->tn_status |= TMPFS_NODE_ACCESSED | \ TMPFS_NODE_CHANGED | TMPFS_NODE_MODIFIED; /* Notify modification of parent directory and release it. */ @@ -1159,7 +1161,8 @@ outok: off = TMPFS_DIRCOOKIE_DOTDOT; } else { if (off == TMPFS_DIRCOOKIE_DOTDOT) { - de = TAILQ_FIRST(&node->tn_dir); + de = TAILQ_FIRST(&node->tn_spec. + tn_dir.tn_dir); } else if (de != NULL) { de = TAILQ_NEXT(de, td_entries); } else { @@ -1203,8 +1206,8 @@ tmpfs_readlink(void *v) node = VP_TO_TMPFS_NODE(vp); - error = uiomove(node->tn_link, MIN(node->tn_size, uio->uio_resid), - uio); + error = uiomove(node->tn_spec.tn_lnk.tn_link, + MIN(node->tn_size, uio->uio_resid), uio); node->tn_status |= TMPFS_NODE_ACCESSED; KASSERT(VOP_ISLOCKED(vp)); @@ -1383,7 +1386,7 @@ tmpfs_getpages(void *v) LOCK_ASSERT(simple_lock_held(&vp->v_interlock)); node = VP_TO_TMPFS_NODE(vp); - uobj = node->tn_aobj; + uobj = node->tn_spec.tn_reg.tn_aobj; /* We currently don't rely on PGO_PASTEOF. */ @@ -1440,7 +1443,7 @@ tmpfs_putpages(void *v) return 0; } - uobj = node->tn_aobj; + uobj = node->tn_spec.tn_reg.tn_aobj; simple_unlock(&vp->v_interlock); simple_lock(&uobj->vmobjlock);