1if [ ! "$_MEDIA_USB_SUBR" ]; then _MEDIA_USB_SUBR=1 2# 3# Copyright (c) 2012-2013 Devin Teske 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# |
27# $FreeBSD: head/usr.sbin/bsdconfig/share/media/usb.subr 264840 2014-04-23 22:04:04Z dteske $ |
28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." media/usb.subr 34f_include $BSDCFG_SHARE/device.subr 35f_include $BSDCFG_SHARE/dialog.subr --- 21 unchanged lines hidden (view full) --- 57 58 local devs ndevs 59 f_device_find "" $DEVICE_TYPE_USB devs 60 f_count ndevs $devs 61 62 if [ ${ndevs:=0} -eq 0 ]; then 63 f_show_msg "$msg_no_usb_devices_found" 64 return $FAILURE |
65 elif [ $ndevs -eq 1 ]; then 66 f_struct_copy $devs device_media 67 else 68 local dev |
69 local title="$msg_choose_a_usb_drive" 70 local prompt="$msg_please_select_a_usb_drive" |
71 local hline= |
72 |
73 dev=$( f_device_menu \ 74 "$title" "$prompt" "$hline" $DEVICE_TYPE_USB \ |
75 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD ) || 76 return $FAILURE |
77 |
78 f_struct_copy "$dev" device_media |
79 fi 80 81 f_struct device_media && 82 device_media unset private 83 84 if f_interactive; then 85 local name 86 f_struct device_media get name name --- 8 unchanged lines hidden (view full) --- 95# Initializes the USB media device. Returns success if able to mount the USB 96# disk device using mount(8). 97# 98f_media_init_usb() 99{ 100 local funcname=f_media_init_usb 101 local dev="$1" devname err 102 |
103 $dev get devname devname || return $FAILURE |
104 f_dprintf "Init routine called for USB device. devname=[%s]" \ 105 "$devname" 106 107 if [ "$USB_MOUNTED" ]; then 108 f_dprintf "USB device already mounted." 109 return $SUCCESS 110 fi 111 --- 20 unchanged lines hidden (view full) --- 132# Returns data from $file on a mounted USB disk device. Similar to cat(1). If 133# $probe_type is present and non-NULL, returns success if $file exists. If 134# $probe_type is equal to $PROBE_SIZE, prints the size of $file in bytes to 135# standard-out. 136# 137f_media_get_usb() 138{ 139 local dev="$1" file="$2" probe_type="$3" |
140 local name |
141 |
142 $dev get name name |
143 f_dprintf "f_media_get_usb: dev=[%s] file=[%s] probe_type=%s" \ |
144 "$name" "$file" "$probe_type" |
145 146 f_media_generic_get "$MOUNTPOINT" "$file" "$probe_type" 147} 148 149# f_media_shutdown_usb $device 150# 151# Shuts down the USB disk device using umount(8). Return status should be 152# ignored. --- 24 unchanged lines hidden --- |