SuperCard Shell Essentials

 

DiskUtility

Page history last edited by DCS 3 yrs ago

DiskUtility

Verify/repair volumes without exiting SC using the 'diskutil' shell command.

See also: mount

See diskutil man page syntax details.

 

Two simple handlers to verify or repair permissions.

 

on mouseup
alert "diskutil" explain "Verify boot volume permissions?." with "cancel" or "verify"
if it is in "cancel" then return ""
--
put "diskutil verifyPermissions / " into cmd
-- trailing slash = boot volume mount point
alert sheet "verify report" explain shell(cmd)
end mouseup

on mouseup
alert "diskutil" explain "Repair boot volume permissions?." with "cancel" or "verify"
if it is in "cancel" then return ""
--
put "diskutil repairPermissions / ;" into cmd
--
alert sheet "repair report" explain shell(cmd)
end mouseup

 


Two handlers below verify volumes but are easily modified to repair.

 

Handler 1:

Ask user to choose disks to verify and display results in a list dialog.

on askDiskVerify
--ask user to select disks to verify
--verify permissions if  boot volume
--else verify volume
put "mount | " into cmd
--get list of mounted volumes
put "sed 1d | "  after cmd
--exclude first line entry... should be the boot disk
put "grep  '/dev/disk' | " after cmd
--trim away remote mounts, etc...
put "perl -pe 's|.* /Volumes/(.+) (.*|/Volumes/$1|g' ; " after cmd
--trim 'mount' info to human readable volume names
--one volume per line
--which disks?
ask list "boot volume" & cr & shell(merge(cmd)) prompt "Verify disks:" using selfilled with "cancel" or "select" return text
if it is in "cancel" then return ""
put it into disklist
--ask for user disk selection
------------------------------
put "" into cmd
--init next cmd
--verify boot permissions ?
if line 1 of disklist = "boot volume" then
delete line 1 of disklist
put "diskutil verifyPermissions /  2>&1 ; echo `•••••••••••`  ; "  after cmd
--verify boot disk permissions
--to repair rather than verify, change 'verifyPermissions' to 'repairPermissions'
end if
--verify remaining disks?
if disklist aint "" then
put "echo -n [[disklist]] | " after cmd
--inject disklist
put "tr `r` `n` | " after cmd
--convert cr to lf
put "perl -pe 's/^(.*)$/diskutil verifyvolume $1 2>&1 ; echo `•••••••••••` ; /' | " after cmd
--wrap command syntax around each volume identifier
--normal return + errors + additional trailing linefeed
--to repair rather than verify, change 'verifyVolume' to 'repairVolume'
put "awk '{ system($0) }' ; " after cmd
--execute diskutil command for each device
end if
ask list shell(merge(cmd))
--display diskutil messages & errors
end askDiskVerify

 

Handler 2:

Verify all disks excluding preset specified volumes and display results in a list dialog.

on diskVerify
--verify permissions if  boot volume
--else verify volume
--exclude volumes preset by user
put " /Volumes/120g1 " into excludeDisks
--exclude volumes known to have open fonts (active fonts, apps, whatever)
--to exclude more than one, separate list with a '|' 
--best to include leading/trailing spaces in volume intentifiers...
--put " /Volumes/120g1 | /Volumes/TigerBoot2 " into excludeDisks
put "diskutil verifyPermissions /  2>&1 ; echo ' ' ; "  into cmd
--verify boot disk permissions
put "mount | " &¬
"sed 1d | "  after cmd
--get list of mounts excluding firt entry... the boot disk
--trim exclusion preset  
if excludeDisks aint "" then
put "grep -iEv '[[excludeDisks]]' | " after cmd
end if
put "grep -o '/dev/disk....' | " after cmd
--trim to device indentifiers
put "perl -pe 's/^(.*)$/diskutil verifyvolume $1 2>&1 ; echo ` ` ; /' | " after cmd
--wrap syntax around each device identifier
put "awk '{ system($0) }' ; " after cmd
--execute command for each device
ask list shell(merge(cmd))
end diskverify

Comments (0)

You don't have permission to comment on this page.