ufs.subr (0bfd163f522701b486e066fa2e56624c02f5081a) | ufs.subr (d4ae33f0721c1b170fe37d97e395228ffcfb3f80) |
---|---|
1if [ ! "$_MEDIA_UFS_SUBR" ]; then _MEDIA_UFS_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: --- 53 unchanged lines hidden (view full) --- 62f_media_set_ufs() 63{ 64 local ufs 65 66 f_media_close 67 68 local devs ndevs 69 f_device_find "" $DEVICE_TYPE_UFS devs | 1if [ ! "$_MEDIA_UFS_SUBR" ]; then _MEDIA_UFS_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: --- 53 unchanged lines hidden (view full) --- 62f_media_set_ufs() 63{ 64 local ufs 65 66 f_media_close 67 68 local devs ndevs 69 f_device_find "" $DEVICE_TYPE_UFS devs |
70 ndevs=$( set -- $devs; echo $# ) | 70 f_count ndevs $devs |
71 72 if [ ${ndevs:=0} -eq 0 ]; then 73 f_variable_get_value $VAR_UFS_PATH \ 74 "$msg_enter_the_device_name_of_a_ufs_formatted_partition" 75 f_getvar $VAR_UFS_PATH ufs 76 [ "$ufs" ] || return $FAILURE 77 78 local fstype --- 33 unchanged lines hidden (view full) --- 112 113# f_media_init_ufs $device 114# 115# Initializes the UFS media device. Returns success if able to mount the UFS 116# partition device using mount(1). 117# 118f_media_init_ufs() 119{ | 71 72 if [ ${ndevs:=0} -eq 0 ]; then 73 f_variable_get_value $VAR_UFS_PATH \ 74 "$msg_enter_the_device_name_of_a_ufs_formatted_partition" 75 f_getvar $VAR_UFS_PATH ufs 76 [ "$ufs" ] || return $FAILURE 77 78 local fstype --- 33 unchanged lines hidden (view full) --- 112 113# f_media_init_ufs $device 114# 115# Initializes the UFS media device. Returns success if able to mount the UFS 116# partition device using mount(1). 117# 118f_media_init_ufs() 119{ |
120 local funcname=f_media_init_ufs |
|
120 local dev="$1" devname err 121 122 device_$dev get devname devname || return $FAILURE 123 f_dprintf "Init routine called for UFS device. devname=[%s]" \ 124 "$devname" 125 126 if [ "$UFS_MOUNTED" ]; then 127 f_dprintf "UFS device already mounted." 128 return $SUCCESS 129 fi 130 131 if [ ! -e "$devname" ]; then 132 f_show_msg "$msg_no_such_file_or_directory" \ 133 "f_media_init_ufs" "$devname" 134 return $FAILURE 135 fi 136 | 121 local dev="$1" devname err 122 123 device_$dev get devname devname || return $FAILURE 124 f_dprintf "Init routine called for UFS device. devname=[%s]" \ 125 "$devname" 126 127 if [ "$UFS_MOUNTED" ]; then 128 f_dprintf "UFS device already mounted." 129 return $SUCCESS 130 fi 131 132 if [ ! -e "$devname" ]; then 133 f_show_msg "$msg_no_such_file_or_directory" \ 134 "f_media_init_ufs" "$devname" 135 return $FAILURE 136 fi 137 |
137 if [ ! -e "$MOUNTPOINT" ] && 138 ! err=$( mkdir -p "$MOUNTPOINT" 2>&1 ) 139 then 140 f_dialog_msgbox "$err" 141 return $FAILURE | 138 if [ ! -e "$MOUNTPOINT" ]; then 139 f_eval_catch $funcname mkdir 'mkdir -p "%s"' "$MOUNTPOINT" || 140 return $FAILURE |
142 fi 143 | 141 fi 142 |
144 if ! err=$( mount "$devname" "$MOUNTPOINT" 2>&1 ) | 143 if ! f_eval_catch -dk err $funcname mount \ 144 'mount "%s" "%s"' "$devname" "$MOUNTPOINT" |
145 then 146 err="${err#mount: }"; err="${err#$devname : }" 147 f_show_msg "$msg_error_mounting_device" \ 148 "$devname" "$MOUNTPOINT" "$err" 149 return $FAILURE 150 fi 151 UFS_MOUNTED=1 152 return $SUCCESS --- 17 unchanged lines hidden (view full) --- 170} 171 172# f_media_shutdown_ufs $device 173# 174# Shuts down the UFS device using umount(8). Return status should be ignored. 175# 176f_media_shutdown_ufs() 177{ | 145 then 146 err="${err#mount: }"; err="${err#$devname : }" 147 f_show_msg "$msg_error_mounting_device" \ 148 "$devname" "$MOUNTPOINT" "$err" 149 return $FAILURE 150 fi 151 UFS_MOUNTED=1 152 return $SUCCESS --- 17 unchanged lines hidden (view full) --- 170} 171 172# f_media_shutdown_ufs $device 173# 174# Shuts down the UFS device using umount(8). Return status should be ignored. 175# 176f_media_shutdown_ufs() 177{ |
178 local funcname=f_media_shutdown_ufs |
|
178 local dev="$1" err 179 180 [ "$UFS_MOUNTED" ] || return $FAILURE 181 | 179 local dev="$1" err 180 181 [ "$UFS_MOUNTED" ] || return $FAILURE 182 |
182 if ! err=$( umount -f "$MOUNTPOINT" 2>&1 ); then | 183 if ! f_eval_catch -dk err $funcname umount \ 184 'umount -f "%s"' "$MOUNTPOINT" 185 then |
183 err="${err#umount: }"; err="${err#*: }" 184 f_show_msg "$msg_could_not_unmount_the_ufs_partition" \ 185 "$MOUNTPOINT" "$err" 186 else 187 UFS_MOUNTED= 188 fi 189} 190 191############################################################ MAIN 192 193f_dprintf "%s: Successfully loaded." media/ufs.subr 194 195fi # ! $_MEDIA_UFS_SUBR | 186 err="${err#umount: }"; err="${err#*: }" 187 f_show_msg "$msg_could_not_unmount_the_ufs_partition" \ 188 "$MOUNTPOINT" "$err" 189 else 190 UFS_MOUNTED= 191 fi 192} 193 194############################################################ MAIN 195 196f_dprintf "%s: Successfully loaded." media/ufs.subr 197 198fi # ! $_MEDIA_UFS_SUBR |