Dear folks,

I'd like to add a function implementing fsck/fsutil.c's blockcheck()
    char *blockcheck(const char *origname);

as

    char *canonical_rdev(char *buf, size_t buflen, const char *origname,
                int *flags);

that returns a canonical raw device name when passed a device name in one of
the following ways:
        /dev/ld0
        name="UUID"
        name="ROOT.x"
        /dev/dk1
        /some/mountpoint
        some/file/name

or a softlink to any of these. It could return various flags that might be of
interest. At a minimum it needs to return if the device is the root device as
the current users of blockcheck() rely on it.
Usable flags could be:
        IS_ROOT       (is a byproduct)
        NOTEXISTING   (saves a stat)
        NODEV         (no device)
with a possibly interesting
        IS_UNIQUE     (no aliases exist in /dev/)

The goal is to have a uniform code that accepts all ways to specify a raw
device. Currently every program has its own logic and oddities/omissions like
fsck_ffs does accept files but fsck_msdos only grocks raw devices etc.

If it fails, a second call can be made prepending `/dev/' to the name so `dk0'
could be accepted then too. Thus could be made a feature but the current code
does not take that into account.

What are your thoughts about this?

With regards,
Reinoud



The current blockcheck() is called from:
    sbin/fsck/fsutil.h
    sbin/fsck/fsck.c
    sbin/fsck/fsutil.c
    sbin/fsck/preen.c
    sbin/fsck_ext2fs/main.c
    sbin/fsck_ffs/main.c
    sbin/fsck_lfs/main.c
    sbin/fsck_v7fs/fsck_v7fs.c
    usr.sbin/quotacheck/quotacheck.c

Reply via email to