summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/share/media/nfs.subr
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-07-14 03:08:52 +0000
committerdteske <dteske@FreeBSD.org>2013-07-14 03:08:52 +0000
commite9ad9b489dd3d2b2dd4dd9f43ab1c04b9c00d98a (patch)
treea9511d0f643be26ac006b8084db35a955fc813f9 /usr.sbin/bsdconfig/share/media/nfs.subr
parentc6eaf899761fc14eab6497d13c5ac87c11300777 (diff)
downloadFreeBSD-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/nfs.subr')
-rw-r--r--usr.sbin/bsdconfig/share/media/nfs.subr14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.sbin/bsdconfig/share/media/nfs.subr b/usr.sbin/bsdconfig/share/media/nfs.subr
index 93089cb..9ce0467 100644
--- a/usr.sbin/bsdconfig/share/media/nfs.subr
+++ b/usr.sbin/bsdconfig/share/media/nfs.subr
@@ -208,19 +208,21 @@ f_media_init_nfs()
return $SUCCESS
}
-# f_media_get_nfs $device $file [$probe_only]
+# f_media_get_nfs $device $file [$probe_type]
#
# Returns data from $file on a mounted NFS device. Similar to cat(1). If
-# $probe_only is present and non-NULL, returns success if $file exists.
+# $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_nfs()
{
- local dev="$1" file="$2" probe_only="$3"
+ local dev="$1" file="$2" probe_type="$3"
- f_dprintf "f_media_get_nfs: dev=[%s] file=[%s] probe_only=%s" \
- "$dev" "$file" "$probe_only"
+ f_dprintf "f_media_get_nfs: dev=[%s] file=[%s] probe_type=%s" \
+ "$dev" "$file" "$probe_type"
- f_media_generic_get "$MOUNTPOINT" "$file" "$probe_only"
+ f_media_generic_get "$MOUNTPOINT" "$file" "$probe_type"
}
# f_media_shutdown_nfs $device
OpenPOWER on IntegriCloud