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.
This commit is contained in:
tsutsui 2012-05-08 14:28:55 +00:00
parent e90a004d0c
commit 8eac82d05c
3 changed files with 25 additions and 25 deletions

View File

@ -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. * Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
__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 #define BFS_DEBUG
#include <sys/param.h> #include <sys/param.h>
@ -57,7 +57,6 @@ MALLOC_JUSTDEFINE(M_BFS, "sysvbfs core", "sysvbfs internal structures");
#define __FREE(a, s, t) free(a) #define __FREE(a, s, t) free(a)
#endif #endif
#include <fs/sysvbfs/bfs.h> #include <fs/sysvbfs/bfs.h>
#include <fs/sysvbfs/sysvbfs.h>
#ifdef BFS_DEBUG #ifdef BFS_DEBUG
#define DPRINTF(on, fmt, args...) if (on) printf(fmt, ##args) #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; 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 bool
bfs_dirent_lookup_by_inode(const struct bfs *bfs, int inode, bfs_dirent_lookup_by_inode(const struct bfs *bfs, int inode,
struct bfs_dirent **dirent) struct bfs_dirent **dirent)

View File

@ -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. * 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 *, bool bfs_file_lookup(const struct bfs *, const char *, int *, int *,
size_t *); size_t *);
size_t bfs_file_size(const struct bfs_inode *); size_t bfs_file_size(const struct bfs_inode *);
void bfs_file_setsize(struct vnode *, size_t);
bool bfs_dump(const struct bfs *); bool bfs_dump(const struct bfs *);

View File

@ -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. * Copyright (c) 2004 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__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 <sys/param.h> #include <sys/param.h>
#include <sys/kernel.h> #include <sys/kernel.h>
@ -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_JUSTDEFINE(M_SYSVBFS_VNODE, "sysvbfs vnode", "sysvbfs vnode structures");
MALLOC_DECLARE(M_BFS); MALLOC_DECLARE(M_BFS);
static void sysvbfs_file_setsize(struct vnode *, size_t);
int int
sysvbfs_lookup(void *arg) sysvbfs_lookup(void *arg)
{ {
@ -373,7 +375,7 @@ sysvbfs_setattr(void *arg)
case VREG: case VREG:
if (vp->v_mount->mnt_flag & MNT_RDONLY) if (vp->v_mount->mnt_flag & MNT_RDONLY)
return EROFS; return EROFS;
bfs_file_setsize(vp, vap->va_size); sysvbfs_file_setsize(vp, vap->va_size);
break; break;
default: default:
return EOPNOTSUPP; return EOPNOTSUPP;
@ -479,7 +481,7 @@ sysvbfs_write(void *arg)
return 0; return 0;
if (bnode->size < uio->uio_offset + uio->uio_resid) { 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; extended = true;
} }
@ -492,7 +494,7 @@ sysvbfs_write(void *arg)
DPRINTF("%s: write %ldbyte\n", __func__, sz); DPRINTF("%s: write %ldbyte\n", __func__, sz);
} }
if (err) 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)); VN_KNOTE(v, NOTE_WRITE | (extended ? NOTE_EXTEND : 0));
@ -893,3 +895,18 @@ sysvbfs_update(struct vnode *vp, const struct timespec *acc,
return 0; 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;
}