From 8eac82d05cb9490b00a5d741823ace54104f8364 Mon Sep 17 00:00:00 2001 From: tsutsui Date: Tue, 8 May 2012 14:28:55 +0000 Subject: [PATCH] Move bfs_file_setsize() from bfs.c to sysvbfs_vnops.c (and rename it to sysvbfs_file_setsize()) because it's actually part of vnode ops and bfs.c is also pulled by standalone bootloaders which don't want vnode header mess. --- sys/fs/sysvbfs/bfs.c | 20 ++------------------ sys/fs/sysvbfs/bfs.h | 3 +-- sys/fs/sysvbfs/sysvbfs_vnops.c | 27 ++++++++++++++++++++++----- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/sys/fs/sysvbfs/bfs.c b/sys/fs/sysvbfs/bfs.c index f2e86cc9a3f4..0f7d521e815e 100644 --- a/sys/fs/sysvbfs/bfs.c +++ b/sys/fs/sysvbfs/bfs.c @@ -1,4 +1,4 @@ -/* $NetBSD: bfs.c,v 1.14 2012/03/18 02:40:55 christos Exp $ */ +/* $NetBSD: bfs.c,v 1.15 2012/05/08 14:28:55 tsutsui Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: bfs.c,v 1.14 2012/03/18 02:40:55 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: bfs.c,v 1.15 2012/05/08 14:28:55 tsutsui Exp $"); #define BFS_DEBUG #include @@ -57,7 +57,6 @@ MALLOC_JUSTDEFINE(M_BFS, "sysvbfs core", "sysvbfs internal structures"); #define __FREE(a, s, t) free(a) #endif #include -#include #ifdef BFS_DEBUG #define DPRINTF(on, fmt, args...) if (on) printf(fmt, ##args) @@ -507,21 +506,6 @@ bfs_file_lookup(const struct bfs *bfs, const char *fname, int *start, int *end, return true; } -void -bfs_file_setsize(struct vnode *v, size_t size) -{ - struct sysvbfs_node *bnode = v->v_data; - struct bfs_inode *inode = bnode->inode; - - bnode->size = size; - uvm_vnp_setsize(v, bnode->size); - inode->end_sector = bnode->data_block + - (ROUND_SECTOR(bnode->size) >> DEV_BSHIFT) - 1; - inode->eof_offset_byte = bnode->data_block * DEV_BSIZE + - bnode->size - 1; - bnode->update_mtime = true; -} - bool bfs_dirent_lookup_by_inode(const struct bfs *bfs, int inode, struct bfs_dirent **dirent) diff --git a/sys/fs/sysvbfs/bfs.h b/sys/fs/sysvbfs/bfs.h index 48819b43c96b..d6d6ff460015 100644 --- a/sys/fs/sysvbfs/bfs.h +++ b/sys/fs/sysvbfs/bfs.h @@ -1,4 +1,4 @@ -/* $NetBSD: bfs.h,v 1.6 2012/03/18 02:40:55 christos Exp $ */ +/* $NetBSD: bfs.h,v 1.7 2012/05/08 14:28:55 tsutsui Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -155,7 +155,6 @@ int bfs_file_rename(struct bfs *, const char *, const char *); bool bfs_file_lookup(const struct bfs *, const char *, int *, int *, size_t *); size_t bfs_file_size(const struct bfs_inode *); -void bfs_file_setsize(struct vnode *, size_t); bool bfs_dump(const struct bfs *); diff --git a/sys/fs/sysvbfs/sysvbfs_vnops.c b/sys/fs/sysvbfs/sysvbfs_vnops.c index 7b63cd8f75c1..bfc0da418c5c 100644 --- a/sys/fs/sysvbfs/sysvbfs_vnops.c +++ b/sys/fs/sysvbfs/sysvbfs_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: sysvbfs_vnops.c,v 1.44 2012/04/29 22:53:59 chs Exp $ */ +/* $NetBSD: sysvbfs_vnops.c,v 1.45 2012/05/08 14:28:55 tsutsui Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.44 2012/04/29 22:53:59 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.45 2012/05/08 14:28:55 tsutsui Exp $"); #include #include @@ -60,6 +60,8 @@ __KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.44 2012/04/29 22:53:59 chs Exp $ MALLOC_JUSTDEFINE(M_SYSVBFS_VNODE, "sysvbfs vnode", "sysvbfs vnode structures"); MALLOC_DECLARE(M_BFS); +static void sysvbfs_file_setsize(struct vnode *, size_t); + int sysvbfs_lookup(void *arg) { @@ -373,7 +375,7 @@ sysvbfs_setattr(void *arg) case VREG: if (vp->v_mount->mnt_flag & MNT_RDONLY) return EROFS; - bfs_file_setsize(vp, vap->va_size); + sysvbfs_file_setsize(vp, vap->va_size); break; default: return EOPNOTSUPP; @@ -479,7 +481,7 @@ sysvbfs_write(void *arg) return 0; if (bnode->size < uio->uio_offset + uio->uio_resid) { - bfs_file_setsize(v, uio->uio_offset + uio->uio_resid); + sysvbfs_file_setsize(v, uio->uio_offset + uio->uio_resid); extended = true; } @@ -492,7 +494,7 @@ sysvbfs_write(void *arg) DPRINTF("%s: write %ldbyte\n", __func__, sz); } if (err) - bfs_file_setsize(v, bnode->size - uio->uio_resid); + sysvbfs_file_setsize(v, bnode->size - uio->uio_resid); VN_KNOTE(v, NOTE_WRITE | (extended ? NOTE_EXTEND : 0)); @@ -893,3 +895,18 @@ sysvbfs_update(struct vnode *vp, const struct timespec *acc, return 0; } + +static void +sysvbfs_file_setsize(struct vnode *v, size_t size) +{ + struct sysvbfs_node *bnode = v->v_data; + struct bfs_inode *inode = bnode->inode; + + bnode->size = size; + uvm_vnp_setsize(v, bnode->size); + inode->end_sector = bnode->data_block + + (ROUND_SECTOR(bnode->size) >> DEV_BSHIFT) - 1; + inode->eof_offset_byte = bnode->data_block * DEV_BSIZE + + bnode->size - 1; + bnode->update_mtime = true; +}