Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/chs-ubc2]: src/sys/ufs/ufs add ufs_balloc_range().
details: https://anonhg.NetBSD.org/src/rev/5465c8181ae4
branches: chs-ubc2
changeset: 471374:5465c8181ae4
user: chs <chs%NetBSD.org@localhost>
date: Sun Jul 04 01:54:19 1999 +0000
description:
add ufs_balloc_range().
diffstat:
sys/ufs/ufs/ufs_extern.h | 3 +-
sys/ufs/ufs/ufs_inode.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 55 insertions(+), 2 deletions(-)
diffs (82 lines):
diff -r dfc2d21b9193 -r 5465c8181ae4 sys/ufs/ufs/ufs_extern.h
--- a/sys/ufs/ufs/ufs_extern.h Sun Jul 04 01:54:05 1999 +0000
+++ b/sys/ufs/ufs/ufs_extern.h Sun Jul 04 01:54:19 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_extern.h,v 1.17 1999/02/26 23:44:50 wrstuden Exp $ */
+/* $NetBSD: ufs_extern.h,v 1.17.4.1 1999/07/04 01:54:19 chs Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -116,6 +116,7 @@
/* ufs_inode.c */
void ufs_init __P((void));
int ufs_reclaim __P((struct vnode *, struct proc *));
+int ufs_balloc_range __P((struct vnode *, off_t, off_t, struct ucred *, int));
/* ufs_lookup.c */
void ufs_dirbad __P((struct inode *, doff_t, char *));
diff -r dfc2d21b9193 -r 5465c8181ae4 sys/ufs/ufs/ufs_inode.c
--- a/sys/ufs/ufs/ufs_inode.c Sun Jul 04 01:54:05 1999 +0000
+++ b/sys/ufs/ufs/ufs_inode.c Sun Jul 04 01:54:19 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_inode.c,v 1.13 1999/03/05 21:09:50 mycroft Exp $ */
+/* $NetBSD: ufs_inode.c,v 1.13.4.1 1999/07/04 01:54:31 chs Exp $ */
/*
* Copyright (c) 1991, 1993
@@ -146,3 +146,55 @@
#endif
return (0);
}
+
+/*
+ * Allocate a range of blocks in a file.
+ */
+
+int
+ufs_balloc_range(vp, off, len, cred, flags)
+ struct vnode *vp;
+ off_t off, len;
+ struct ucred *cred;
+ int flags;
+{
+ struct inode *ip = VTOI(vp);
+ int bshift, bsize, delta, error;
+
+ bshift = vp->v_mount->mnt_fs_bshift;
+ bsize = 1 << bshift;
+
+ /*
+ * adjust off to be block-aligned.
+ */
+
+ delta = off & (bsize - 1);
+ off -= delta;
+ len += delta;
+
+ /*
+ * allocate the range a block at a time.
+ */
+
+ while (len > 0) {
+ bsize = min(bsize, len);
+
+ if ((error = VOP_BALLOC(vp, off, bsize, cred, flags, NULL))) {
+ return error;
+ }
+
+ /*
+ * increase file size now.
+ * ffs_balloc() needs to know in the case where we loop here.
+ */
+
+ if (ip->i_ffs_size < off + bsize) {
+ ip->i_ffs_size = off + bsize;
+ uvm_vnp_setsize(ITOV(ip), ip->i_ffs_size);
+ }
+
+ len -= bsize;
+ off += bsize;
+ }
+ return 0;
+}
Home |
Main Index |
Thread Index |
Old Index