aboutsummaryrefslogtreecommitdiff
path: root/lib/libufs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libufs')
-rw-r--r--lib/libufs/Makefile1
-rw-r--r--lib/libufs/cgread.323
-rw-r--r--lib/libufs/cgroup.c14
-rw-r--r--lib/libufs/libufs.31
-rw-r--r--lib/libufs/libufs.h1
5 files changed, 38 insertions, 2 deletions
diff --git a/lib/libufs/Makefile b/lib/libufs/Makefile
index 855af175eead..8d1d9acf206b 100644
--- a/lib/libufs/Makefile
+++ b/lib/libufs/Makefile
@@ -9,6 +9,7 @@ INCS= libufs.h
MAN= bread.3 cgread.3 libufs.3 sbread.3 ufs_disk_close.3
MLINKS+= bread.3 bwrite.3
MLINKS+= cgread.3 cgread1.3
+MLINKS+= cgread.3 cgwrite1.3
MLINKS+= sbread.3 sbwrite.3
MLINKS+= ufs_disk_close.3 ufs_disk_fillout.3
MLINKS+= ufs_disk_close.3 ufs_disk_fillout_blank.3
diff --git a/lib/libufs/cgread.3 b/lib/libufs/cgread.3
index f98da40714b6..38edf17ea14f 100644
--- a/lib/libufs/cgread.3
+++ b/lib/libufs/cgread.3
@@ -4,6 +4,7 @@
.\" Manual page for libufs functions:
.\" cgread(3)
.\" cgread1(3)
+.\" cgwrite1(3)
.\"
.\" This file is in the public domain.
.\"
@@ -13,8 +14,8 @@
.Dt CGREAD 3
.Os
.Sh NAME
-.Nm cgread , cgread1
-.Nd read cylinder groups of UFS disks
+.Nm cgread , cgread1, cgwrite1
+.Nd read/write cylinder groups of UFS disks
.Sh LIBRARY
.Lb libufs
.Sh SYNOPSIS
@@ -28,6 +29,8 @@
.Fn cgread "struct uufsd *disk"
.Ft int
.Fn cgread1 "struct uufsd *disk" "int c"
+.Ft int
+.Fn cgwrite1 "struct uufsd *disk" "int c"
.Sh DESCRIPTION
The
.Fn cgread
@@ -60,6 +63,14 @@ with a cylinder group specifier equivalent to the value of the current
field, and then incrementing the
.Va d_ccg
field.
+.Pp
+The
+.Fn cgwrite1
+function stores cylinder group specified by
+.Fa c
+from
+.Va d_cg
+field of a userland UFS disk structure on disk.
.Sh RETURN VALUES
Both functions return 0 if there are no more cylinder groups to read,
1 if there are more cylinder groups, and \-1 on error.
@@ -75,8 +86,16 @@ The function
.Fn cgread1
has semantically identical failure conditions to those of
.Fn cgread .
+.Pp
+The function
+.Fn cgwrite1
+may fail and set
+.Va errno
+for any of the errors specified for the library function
+.Xr bwrite 3 .
.Sh SEE ALSO
.Xr bread 3 ,
+.Xr bwrite 3 ,
.Xr libufs 3
.Sh HISTORY
These functions first appeared as part of
diff --git a/lib/libufs/cgroup.c b/lib/libufs/cgroup.c
index d615b18dd32b..2185682e098f 100644
--- a/lib/libufs/cgroup.c
+++ b/lib/libufs/cgroup.c
@@ -71,3 +71,17 @@ cgread1(struct uufsd *disk, int c)
disk->d_lcg = c;
return (1);
}
+
+int
+cgwrite1(struct uufsd *disk, int c)
+{
+ struct fs *fs;
+
+ fs = &disk->d_fs;
+ if (bwrite(disk, fsbtodb(fs, cgtod(fs, c)),
+ disk->d_cgunion.d_buf, fs->fs_bsize) == -1) {
+ ERROR(disk, "unable to write cylinder group");
+ return (-1);
+ }
+ return (0);
+}
diff --git a/lib/libufs/libufs.3 b/lib/libufs/libufs.3
index ecdfb275f67a..6a2c7f6aa739 100644
--- a/lib/libufs/libufs.3
+++ b/lib/libufs/libufs.3
@@ -57,6 +57,7 @@ to a string describing the error.
.Xr bwrite 3 ,
.Xr cgread 3 ,
.Xr cgread1 3 ,
+.Xr cgwrite1 3 ,
.Xr sbread 3 ,
.Xr sbwrite 3 ,
.Xr ufs_disk_close 3 ,
diff --git a/lib/libufs/libufs.h b/lib/libufs/libufs.h
index 57062f9baa45..92ab3482a2f7 100644
--- a/lib/libufs/libufs.h
+++ b/lib/libufs/libufs.h
@@ -110,6 +110,7 @@ ssize_t bwrite(struct uufsd *, ufs2_daddr_t, const void *, size_t);
*/
int cgread(struct uufsd *);
int cgread1(struct uufsd *, int);
+int cgwrite1(struct uufsd *, int);
/*
* inode.c