Re: [PATCH 1/2] common/rc: add functions to check or write objects under /sys/fs

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On 5/27/16 1:05 PM, Eric Sandeen wrote:

> So maybe something like this (not tested)
> 
> + /* Test for the existence of a sysfs entry at /sys/fs/$FSTYP/$DEV/$ENTRY */
> +_require_fs_sys_fs()
> +{
> +        local dev=$1
> +        local target=$2
> +        local dname=""
> +        local tmp_mnt=`mktemp -d`
> +
> +        if [ ! -b "$dev" -o -z "$target" ];then
> +	        echo "Usage: _require_fs_sys_fs <device> <sysfs_path>"
> +                exit 1
> +        fi
> +
> +        dname=$(basename $(readlink -f $dev))
> +        _mount -t $FSTYP `_common_dev_mount_options` $dev $tmp_mnt
> +        if [ ! -e /sys/fs/${FSTYP}/${dname}/$target ];then
> +                umount $tmp_mnt
> +                rm -f $tmp_mnt
> +                _notrun "/sys/fs/${FSTYP}/${dname}/$target: No such file or directory"
> +        fi
> +        umount $SCRATCH_MNT
> +        rm -f $tmp_mnt
> +}
> 
> and it would work for either SCRATCH or TEST?

I guess nothing guarantees that the device is already mkfs'd, at least
for scratch, so maybe it also needs to catch a mount failure,
with a message about "could not mount; mkfs first in your test?"
or something like that.

-Eric
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux