-#ifdef WITH_NTFS_3G
- char tmpdir[strlen(dir) + 50];
- tmpdir[0] = '\0';
-
- /* Check to see if a block device file was specified. If so,
- * create a NTFS filesystem on it. */
- struct stat stbuf;
-
- ret = stat(dir, &stbuf);
- if (ret != 0)
- imagex_error_with_errno("Failed to stat `%s'", dir);
- if (S_ISBLK(stbuf.st_mode) || S_ISREG(stbuf.st_mode)) {
- extract_flags |= WIMLIB_EXTRACT_FLAG_NTFS;
-
- const char *dev = dir;
- printf("Making NTFS filesystem on `%s'\n", dev);
-
- char mkntfs_cmdline[sizeof("mkntfs ") + strlen(mkntfs_args) +
- sizeof(" ") + strlen(dev)];
- sprintf(mkntfs_cmdline, "mkntfs %s %s", mkntfs_args, dev);
- puts(mkntfs_cmdline);
- ret = system(mkntfs_cmdline);
- if (ret == -1) {
- imagex_error_with_errno("Failed to execute the "
- "`mkntfs' program");
- return -1;
- } else if (ret > 0) {
- imagex_error("`mkntfs' exited with failure status");
- imagex_error("Note: You can pass additional arguments "
- "to `mkntfs' using the --mkntfs-args "
- "argument");
- return -1;
- }
- sprintf(tmpdir, "/tmp/imagex-%d-ntfsmount-%s-XXXXXX",
- getpid(), dev);
- dir = mkdtemp(tmpdir);
- if (!dir) {
- imagex_error_with_errno("Failed to create "
- "temporary directory "
- "`%s'", tmpdir);
- }
- char ntfs_3g_cmdline[sizeof("ntfs-3g ") + strlen(dev) +
- sizeof(" ") + strlen(dir)];
- sprintf(ntfs_3g_cmdline, "ntfs-3g %s %s", dev, dir);
- puts(ntfs_3g_cmdline);
- ret = system(ntfs_3g_cmdline);
- if (ret == -1) {
- imagex_error_with_errno("Failed to execute the "
- "`ntfs-3g' program");
- ret = -1;
- goto out_rm_tmpdir;
- } else if (ret > 0) {
- imagex_error("`ntfs-3g' exited with failure status");
- ret = -1;
- goto out_rm_tmpdir;
- }
- }
-#endif
-