diff options
author | dteske <dteske@FreeBSD.org> | 2013-07-14 03:08:52 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2013-07-14 03:08:52 +0000 |
commit | e9ad9b489dd3d2b2dd4dd9f43ab1c04b9c00d98a (patch) | |
tree | a9511d0f643be26ac006b8084db35a955fc813f9 /usr.sbin/bsdconfig/share/media/directory.subr | |
parent | c6eaf899761fc14eab6497d13c5ac87c11300777 (diff) | |
download | FreeBSD-src-e9ad9b489dd3d2b2dd4dd9f43ab1c04b9c00d98a.zip FreeBSD-src-e9ad9b489dd3d2b2dd4dd9f43ab1c04b9c00d98a.tar.gz |
Re-implement $probe_only aspect of f_media_get_TYPE() (where TYPE is cdrom,
nfs, ftp, http, httpproxy, etc.) and f_device_get() (abstract method for
calling aforementioned f_media_get_TYPE()).
Previously, if $probe_only was present and non-NULL, the TYPE functions
would check for $file and exit with an appropriate error status (success if
the file exists and readable, failure otherwise).
While this has been retained, a pair of globals has been introduced:
$PROBE_EXIST and $PROBE_SIZE (see `/usr/share/bsdconfig/media/common.subr')
The $PROBE_EXIST global can be used where you need the functionality of
simply testing for existence (previously the _only_ functionality).
Meanwhile, the new $PROBE_SIZE global can be used to cause the TYPE function
to print the size of the file (in bytes) on standard-out (or -1) if not
found or an error occurs. NOTE: If an error occurs, it is logged with the
dprintf function, which is visible with `-d' flag or debug=1.
In many cases, where you need to get the size of a file _and_ check for its
existence, you can use the return status of a $PROBE_SIZE call.
Diffstat (limited to 'usr.sbin/bsdconfig/share/media/directory.subr')
-rw-r--r-- | usr.sbin/bsdconfig/share/media/directory.subr | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/usr.sbin/bsdconfig/share/media/directory.subr b/usr.sbin/bsdconfig/share/media/directory.subr index 3efa991..3f46293 100644 --- a/usr.sbin/bsdconfig/share/media/directory.subr +++ b/usr.sbin/bsdconfig/share/media/directory.subr @@ -115,21 +115,22 @@ f_media_init_directory() return $SUCCESS } -# f_media_get_directory $device $file [$probe_only] +# f_media_get_directory $device $file [$probe_type] # # Returns data from $file in the existing/current filesystem. Similar to -# cat(1). If $probe_only is present and non-NULL, returns success if $file -# exists. +# cat(1). If $probe_type is present and non-NULL, returns success if $file +# exists. If $probe_type is equal to $PROBE_SIZE, prints the size of $file in +# bytes to standard-out. # f_media_get_directory() { - local dev="$1" file="$2" probe_only="$3" path + local dev="$1" file="$2" probe_type="$3" path - f_dprintf "f_media_get_directory: dev=[%s] file=[%s] probe_only=%s" \ - "$dev" "$file" "$probe_only" + f_dprintf "f_media_get_directory: dev=[%s] file=[%s] probe_type=%s" \ + "$dev" "$file" "$probe_type" device_$dev get private path - f_media_generic_get "$path" "$file" "$probe_only" + f_media_generic_get "$path" "$file" "$probe_type" } # f_media_shutdown_directory $device |