Add d_sblockloc to libufs(3) disk structure to allow options to be added.
By making the disk block parameter used by the libufs(3) sbread(3) function visible, applications using sbread(3) can set their own addition options such as using the STDSB_NOHASHFAIL request to say that they want the superblock read to succeed even when the superblock checkhash is incorrect. While here also add an error message when a check-hash failure is detected.
This commit is contained in:
parent
bf24d17fda
commit
82e72f1d12
@ -65,6 +65,7 @@ struct uufsd {
|
||||
int d_ccg; /* current cylinder group */
|
||||
int d_lcg; /* last cylinder group (in d_cg) */
|
||||
const char *d_error; /* human readable disk error */
|
||||
off_t d_sblockloc; /* where to look for the superblock */
|
||||
int d_mine; /* internal flags */
|
||||
#define d_fs d_sbunion.d_fs
|
||||
#define d_sb d_sbunion.d_sb
|
||||
|
@ -49,21 +49,37 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <libufs.h>
|
||||
|
||||
static int handle_disk_read(struct uufsd *, struct fs *, int);
|
||||
|
||||
/*
|
||||
* Read the standard superblock.
|
||||
*/
|
||||
int
|
||||
sbread(struct uufsd *disk)
|
||||
{
|
||||
struct fs *fs;
|
||||
int error;
|
||||
|
||||
error = sbget(disk->d_fd, &fs, disk->d_sblockloc);
|
||||
return (handle_disk_read(disk, fs, error));
|
||||
}
|
||||
|
||||
static int
|
||||
handle_disk_read(struct uufsd *disk, struct fs *fs, int error)
|
||||
{
|
||||
|
||||
ERROR(disk, NULL);
|
||||
|
||||
if ((errno = sbget(disk->d_fd, &fs, STDSB)) != 0) {
|
||||
switch (errno) {
|
||||
if (error != 0) {
|
||||
switch (error) {
|
||||
case EIO:
|
||||
ERROR(disk, "non-existent or truncated superblock");
|
||||
break;
|
||||
case ENOENT:
|
||||
ERROR(disk, "no usable known superblock found");
|
||||
break;
|
||||
case EINTEGRITY:
|
||||
ERROR(disk, "superblock check-hash failure");
|
||||
break;
|
||||
case ENOSPC:
|
||||
ERROR(disk, "failed to allocate space for superblock "
|
||||
"information");
|
||||
|
@ -168,6 +168,7 @@ again: if ((ret = stat(name, &st)) < 0) {
|
||||
disk->d_ufs = 0;
|
||||
disk->d_error = NULL;
|
||||
disk->d_si = NULL;
|
||||
disk->d_sblockloc = STDSB;
|
||||
|
||||
if (oname != name) {
|
||||
name = strdup(name);
|
||||
|
Loading…
Reference in New Issue
Block a user