Implement cgwrite1(3) function which stored a given cylinder group on disk.

Sponsored by:	home.pl
This commit is contained in:
Pawel Jakub Dawidek 2006-10-31 21:21:48 +00:00
parent 9cd394ea96
commit cf4652e74b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=163835
5 changed files with 38 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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 ,

View File

@ -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