@@ -47,11 +47,13 @@ func init() {
4747 mountCmd .Flags ().String ("pem-db" , "" , "AEA pem DB JSON file" )
4848 mountCmd .Flags ().StringP ("mount-point" , "m" , "" , "Custom mount point (default: /tmp/<dmg>.mount)" )
4949 mountCmd .Flags ().String ("ident" , "" , "Identity Variant to select specific RestoreRamDisk (e.g. 'Erase', 'Upgrade', 'Recovery')" )
50+ mountCmd .Flags ().BoolP ("detach" , "d" , false , "Mount without blocking (leave mounted in background)" )
5051 viper .BindPFlag ("mount.key" , mountCmd .Flags ().Lookup ("key" ))
5152 viper .BindPFlag ("mount.lookup" , mountCmd .Flags ().Lookup ("lookup" ))
5253 viper .BindPFlag ("mount.pem-db" , mountCmd .Flags ().Lookup ("pem-db" ))
5354 viper .BindPFlag ("mount.mount-point" , mountCmd .Flags ().Lookup ("mount-point" ))
5455 viper .BindPFlag ("mount.ident" , mountCmd .Flags ().Lookup ("ident" ))
56+ viper .BindPFlag ("mount.detach" , mountCmd .Flags ().Lookup ("detach" ))
5557}
5658
5759// mountCmd represents the mount command
@@ -79,6 +81,9 @@ var mountCmd = &cobra.Command{
7981
8082 # Mount a RestoreRamDisk by identity (defaults to the first if not specified)
8183 $ ipsw mount rdisk iPhone.ipsw --ident Erase
84+
85+ # Mount in background without blocking (detach mode)
86+ $ ipsw mount fs iPhone.ipsw --detach
8287 ` ),
8388 ValidArgsFunction : func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
8489 if len (args ) == 0 {
@@ -98,6 +103,7 @@ var mountCmd = &cobra.Command{
98103 pemDB := viper .GetString ("mount.pem-db" )
99104 mountPoint := viper .GetString ("mount.mount-point" )
100105 ident := viper .GetString ("mount.ident" )
106+ detach := viper .GetBool ("mount.detach" )
101107 // validate flags
102108 if len (key ) > 0 && lookupKeys {
103109 return fmt .Errorf ("cannot use --key AND --lookup flags together" )
@@ -157,13 +163,18 @@ var mountCmd = &cobra.Command{
157163 log .Infof ("Mounted %s DMG %s" , args [0 ], filepath .Base (mctx .DmgPath ))
158164 }
159165
160- // block until user hits ctrl-c
161- done := make (chan os.Signal , 1 )
162- signal .Notify (done , syscall .SIGINT , syscall .SIGTERM )
163- utils .Indent (log .Info , 2 )(fmt .Sprintf ("Press Ctrl+C to unmount '%s' ..." , mctx .MountPoint ))
164- <- done
165-
166- utils .Indent (log .Info , 2 )(fmt .Sprintf ("Unmounting %s" , mctx .MountPoint ))
167- return mctx .Unmount ()
166+ if detach {
167+ utils .Indent (log .Info , 2 )(fmt .Sprintf ("Detaching, run `hdiutil detach %s` to unmount manually" , mctx .MountPoint ))
168+ return nil
169+ } else {
170+ // block until user hits ctrl-c
171+ done := make (chan os.Signal , 1 )
172+ signal .Notify (done , syscall .SIGINT , syscall .SIGTERM )
173+ utils .Indent (log .Info , 2 )(fmt .Sprintf ("Press Ctrl+C to unmount '%s' ..." , mctx .MountPoint ))
174+ <- done
175+
176+ utils .Indent (log .Info , 2 )(fmt .Sprintf ("Unmounting %s" , mctx .MountPoint ))
177+ return mctx .Unmount ()
178+ }
168179 },
169180}
0 commit comments