Skip to content

Commit e1ad160

Browse files
committed
feat: added --mount-point|-m flag to ipsw mount cmd to let you pick the mount location + docs update
1 parent 84f6854 commit e1ad160

File tree

46 files changed

+107
-78
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+107
-78
lines changed

api/server/routes/ipsw/ipsw.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ func getFsFiles(pemDB string) gin.HandlerFunc {
5757
pemDbPath = filepath.Clean(pemDB)
5858
}
5959
}
60+
61+
mountPointParam, _ := c.GetQuery("mount_point")
62+
if mountPointParam != "" {
63+
mountPointParam = filepath.Clean(mountPointParam)
64+
}
6065

6166
i, err := info.Parse(ipswPath)
6267
if err != nil {
@@ -99,7 +104,7 @@ func getFsFiles(pemDB string) gin.HandlerFunc {
99104

100105
// mount filesystem DMG
101106
utils.Indent(log.Info, 2)(fmt.Sprintf("Mounting %s", dmgPath))
102-
mountPoint, alreadyMounted, err := utils.MountDMG(dmgPath)
107+
mountPoint, alreadyMounted, err := utils.MountDMG(dmgPath, mountPointParam)
103108
if err != nil {
104109
if !errors.Is(err, utils.ErrMountResourceBusy) {
105110
c.AbortWithStatusJSON(http.StatusInternalServerError, types.GenericError{Error: fmt.Sprintf("failed to mount DMG: %v", err)})

api/server/routes/mount/mount.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ func AddRoutes(rg *gin.RouterGroup, pemDB string) {
5050
// description: path to AEA pem DB JSON file
5151
// required: false
5252
// type: string
53+
// + name: mount_point
54+
// in: query
55+
// description: custom mount point path
56+
// required: false
57+
// type: string
5358
// Responses:
5459
// 500: genericError
5560
// 200: mountReponse
@@ -69,12 +74,18 @@ func AddRoutes(rg *gin.RouterGroup, pemDB string) {
6974
pemDbPath = filepath.Clean(pemDB)
7075
}
7176
}
77+
78+
mountPointParam, _ := c.GetQuery("mount_point")
79+
if mountPointParam != "" {
80+
mountPointParam = filepath.Clean(mountPointParam)
81+
}
82+
7283
dmgType := c.Param("type")
7384
if !slices.Contains([]string{"app", "sys", "fs"}, dmgType) {
7485
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"error": "invalid dmg type: must be app, sys, or fs"})
7586
return
7687
}
77-
ctx, err := mount.DmgInIPSW(ipswPath, dmgType, pemDbPath, nil)
88+
ctx, err := mount.DmgInIPSW(ipswPath, dmgType, pemDbPath, nil, mountPointParam)
7889
if err != nil {
7990
if errors.Unwrap(err) == info.ErrorCryptexNotFound {
8091
c.AbortWithError(http.StatusNotFound, err)

cmd/ipsw/cmd/ia.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ var iaCmd = &cobra.Command{
7070
dmgPath := filepath.Join(outDir, "SharedSupport.dmg")
7171

7272
log.Debugf("Mounting %s", dmgPath)
73-
mountPoint, alreadyMounted, err := utils.MountDMG(dmgPath)
73+
mountPoint, alreadyMounted, err := utils.MountDMG(dmgPath, "")
7474
if err != nil {
7575
return fmt.Errorf("failed to mount DMG: %v", err)
7676
}

cmd/ipsw/cmd/mdevs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ var mdevsCmd = &cobra.Command{
118118
}
119119
// mount filesystem DMG
120120
log.Debugf("Mounting %s", dmgPath)
121-
mountPoint, alreadyMounted, err := utils.MountDMG(dmgPath)
121+
mountPoint, alreadyMounted, err := utils.MountDMG(dmgPath, "")
122122
if err != nil {
123123
return fmt.Errorf("failed to mount DMG: %v", err)
124124
}

cmd/ipsw/cmd/mount.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ func init() {
4545
mountCmd.Flags().StringP("key", "k", "", "DMG key")
4646
mountCmd.Flags().Bool("lookup", false, "Lookup DMG keys on theapplewiki.com")
4747
mountCmd.Flags().String("pem-db", "", "AEA pem DB JSON file")
48+
mountCmd.Flags().StringP("mount-point", "m", "", "Custom mount point (default: /tmp/<dmg>.mount)")
4849
viper.BindPFlag("mount.key", mountCmd.Flags().Lookup("key"))
4950
viper.BindPFlag("mount.lookup", mountCmd.Flags().Lookup("lookup"))
5051
viper.BindPFlag("mount.pem-db", mountCmd.Flags().Lookup("pem-db"))
52+
viper.BindPFlag("mount.mount-point", mountCmd.Flags().Lookup("mount-point"))
5153
}
5254

5355
// mountCmd represents the mount command
@@ -69,6 +71,9 @@ var mountCmd = &cobra.Command{
6971
7072
# Mount dyld shared cache (exc) DMG with AEA pem DB
7173
$ ipsw mount exc iPhone.ipsw --pem-db /path/to/pem.json
74+
75+
# Mount to a custom mount point
76+
$ ipsw mount fs iPhone.ipsw --mount-point /mnt/ios-filesystem
7277
`),
7378
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
7479
if len(args) == 0 {
@@ -86,6 +91,7 @@ var mountCmd = &cobra.Command{
8691
key := viper.GetString("mount.key")
8792
lookupKeys := viper.GetBool("mount.lookup")
8893
pemDB := viper.GetString("mount.pem-db")
94+
mountPoint := viper.GetString("mount.mount-point")
8995
// validate flags
9096
if len(key) > 0 && lookupKeys {
9197
return fmt.Errorf("cannot use --key AND --lookup flags together")
@@ -129,7 +135,7 @@ var mountCmd = &cobra.Command{
129135
keys = key
130136
}
131137

132-
mctx, err := mount.DmgInIPSW(args[1], args[0], pemDB, keys)
138+
mctx, err := mount.DmgInIPSW(args[1], args[0], pemDB, keys, mountPoint)
133139
if err != nil {
134140
return fmt.Errorf("failed to mount %s DMG: %v", args[0], err)
135141
}

cmd/ipsw/cmd/sb/sb_diff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ var sbDiffCmd = &cobra.Command{
126126
}
127127

128128
utils.Indent(log.Debug, 2)(fmt.Sprintf("Mounting FS %s", dmgPath))
129-
mountPoint, alreadyMounted, err := utils.MountDMG(dmgPath)
129+
mountPoint, alreadyMounted, err := utils.MountDMG(dmgPath, "")
130130
if err != nil {
131131
return fmt.Errorf("failed to mount DMG: %v", err)
132132
}

cmd/ipsw/cmd/wp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var wpCmd = &cobra.Command{
5959
pemDB := viper.GetString("wp.pem-db")
6060
// output := viper.GetString("wp.output")
6161

62-
ctx, err := mount.DmgInIPSW(filepath.Clean(args[0]), "fs", pemDB, nil)
62+
ctx, err := mount.DmgInIPSW(filepath.Clean(args[0]), "fs", pemDB, nil, "")
6363
if err != nil {
6464
return fmt.Errorf("failed to mount %s DMG: %v", args[0], err)
6565
}

internal/commands/device/mount.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func GetDDIInfo(c *DDIConfig) (info *DDIInfo, err error) {
182182
if info.ManifestPath == "" {
183183
// At this point we have a DMG path that needs to be mounted to find the BuildManifest.plist
184184
utils.Indent(log.Info, 2)(fmt.Sprintf("Mounting %s", c.DDIDmgPath))
185-
mountPoint, alreadyMounted, err := utils.MountDMG(c.DDIDmgPath)
185+
mountPoint, alreadyMounted, err := utils.MountDMG(c.DDIDmgPath, "")
186186
if err != nil {
187187
return nil, fmt.Errorf("failed to mount %s: %w", c.DDIDmgPath, err)
188188
}

internal/commands/dsc/dsc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ func GetUserAgent(f *dyld.File, sysVer *plist.SystemVersion) (string, error) {
765765
}
766766

767767
func OpenFromIPSW(ipswPath, pemDB string, driverKit, all bool) (*mount.Context, []*dyld.File, error) {
768-
ctx, err := mount.DmgInIPSW(ipswPath, "sys", pemDB, nil)
768+
ctx, err := mount.DmgInIPSW(ipswPath, "sys", pemDB, nil, "")
769769
if err != nil {
770770
return nil, nil, fmt.Errorf("failed to mount IPSW: %v", err)
771771
}

internal/commands/ent/ent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func scanEnts(ipswPath, dmgPath, dmgType, pemDbPath string) (map[string]string,
284284
}
285285

286286
utils.Indent(log.Debug, 2)(fmt.Sprintf("Mounting %s %s", dmgType, dmgPath))
287-
mountPoint, alreadyMounted, err := utils.MountDMG(dmgPath)
287+
mountPoint, alreadyMounted, err := utils.MountDMG(dmgPath, "")
288288
if err != nil {
289289
return nil, fmt.Errorf("failed to mount DMG: %v", err)
290290
}

0 commit comments

Comments
 (0)