]> wimlib.net Git - wimlib/blobdiff - programs/imagex.c
Implement user-specified staging directory
[wimlib] / programs / imagex.c
index 61a93fbef260e509120f702d36b3f70b1472f156..f2757820fcaeea7a1b3670a4f53113c151a13f81 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "wimlib.h"
 #include "config.h"
+
+#include "wimlib.h"
+
+#include <errno.h>
 #include <getopt.h>
-#include <stdlib.h>
-#include <stdarg.h>
 #include <glob.h>
-#include <string.h>
-#include <errno.h>
+#include <inttypes.h>
 #include <libgen.h>
 #include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <inttypes.h>
 
 #define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
 
 #define for_opt(c, opts) while ((c = getopt_long_only(argc, (char**)argv, "", \
                                opts, NULL)) != -1)
 
-
 enum imagex_op_type {
        APPEND,
        APPLY,
@@ -97,7 +98,8 @@ static const char *usage_strings[] = {
 "                    [--ref=\"GLOB\"]\n",
 [MOUNTRW] =
 "imagex mountrw WIMFILE [IMAGE_NUM | IMAGE_NAME] DIRECTORY\n"
-"                      [--check] [--debug] [--streams-interface=INTERFACE]\n",
+"                      [--check] [--debug] [--streams-interface=INTERFACE]\n"
+"                      [--staging-dir=DIR]\n",
 [OPTIMIZE] =
 "imagex optimize WIMFILE [--check] [--recompress]\n",
 [SPLIT] =
@@ -165,10 +167,11 @@ static const struct option join_options[] = {
 };
 
 static const struct option mount_options[] = {
-       {"check", no_argument, NULL, 'c'},
-       {"debug", no_argument, NULL, 'd'},
+       {"check",             no_argument,       NULL, 'c'},
+       {"debug",             no_argument,       NULL, 'd'},
        {"streams-interface", required_argument, NULL, 's'},
-       {"ref",      required_argument, NULL, 'r'},
+       {"ref",               required_argument, NULL, 'r'},
+       {"staging-dir",       required_argument, NULL, 'D'},
        {NULL, 0, NULL, 0},
 };
 
@@ -610,7 +613,6 @@ static int imagex_apply(int argc, const char **argv)
                        goto out;
        }
 
-#ifdef WITH_NTFS_3G
        struct stat stbuf;
 
        ret = stat(target, &stbuf);
@@ -627,7 +629,6 @@ static int imagex_apply(int argc, const char **argv)
                        goto out;
                }
        }
-#endif
 
        ret = wimlib_extract_image(w, image, target, extract_flags,
                                   additional_swms, num_additional_swms,
@@ -733,7 +734,6 @@ static int imagex_capture_or_append(int argc, const char **argv)
        if (ret != 0)
                goto out;
 
-#ifdef WITH_NTFS_3G
        struct stat stbuf;
 
        ret = stat(source, &stbuf);
@@ -750,7 +750,7 @@ static int imagex_capture_or_append(int argc, const char **argv)
                        goto out;
                }
        }
-#endif
+
        ret = wimlib_add_image(w, source, name, config_str, config_len,
                               add_image_flags, imagex_progress_func);
 
@@ -1388,6 +1388,7 @@ static int imagex_mount_rw_or_ro(int argc, const char **argv)
        const char *swm_glob = NULL;
        WIMStruct **additional_swms = NULL;
        unsigned num_additional_swms = 0;
+       const char *staging_dir = NULL;
 
        if (strcmp(argv[0], "mountrw") == 0)
                mount_flags |= WIMLIB_MOUNT_FLAG_READWRITE;
@@ -1415,6 +1416,9 @@ static int imagex_mount_rw_or_ro(int argc, const char **argv)
                case 'r':
                        swm_glob = optarg;
                        break;
+               case 'D':
+                       staging_dir = optarg;
+                       break;
                default:
                        goto mount_usage;
                }
@@ -1466,7 +1470,7 @@ static int imagex_mount_rw_or_ro(int argc, const char **argv)
        }
 
        ret = wimlib_mount_image(w, image, dir, mount_flags, additional_swms,
-                                num_additional_swms, NULL);
+                                num_additional_swms, staging_dir);
        if (ret != 0) {
                imagex_error("Failed to mount image %d from `%s' on `%s'",
                             image, wimfile, dir);