* utils/mount.cc (main): Add --show-cygdrive-prefixes option.
(show_cygdrive_prefixes): New function. * utils/umount.cc (main): Add --remove-cygdrive-prefix option. (error): Change signature from 'char *' to 'const char *'. (remove_cygdrive_prefix): New function.
This commit is contained in:
		| @@ -1,3 +1,11 @@ | |||||||
|  | Thu Jul 27 22:54:28 2000  Jason Tishler <jt@dothill.com> | ||||||
|  |  | ||||||
|  | 	* utils/mount.cc (main): Add --show-cygdrive-prefixes option. | ||||||
|  | 	(show_cygdrive_prefixes): New function. | ||||||
|  | 	* utils/umount.cc (main): Add --remove_cygdrive_prefix option. | ||||||
|  | 	(error): Change signature from 'char *' to 'const char *'. | ||||||
|  | 	(remove_cygdrive_prefix): New function. | ||||||
|  |  | ||||||
| Thu Jul 13 22:24:00 2000  Corinna Vinschen <corinna@vinschen.de> | Thu Jul 13 22:24:00 2000  Corinna Vinschen <corinna@vinschen.de> | ||||||
|  |  | ||||||
| 	* mount.cc (mount_already_exists): Slightly rearrange. | 	* mount.cc (mount_already_exists): Slightly rearrange. | ||||||
|   | |||||||
| @@ -22,6 +22,7 @@ details. */ | |||||||
| #include <errno.h> | #include <errno.h> | ||||||
|  |  | ||||||
| static void show_mounts (void); | static void show_mounts (void); | ||||||
|  | static void show_cygdrive_prefixes (void); | ||||||
| static void change_cygdrive_prefix (const char *new_prefix, int flags); | static void change_cygdrive_prefix (const char *new_prefix, int flags); | ||||||
| static int mount_already_exists (const char *posix_path, int flags); | static int mount_already_exists (const char *posix_path, int flags); | ||||||
|  |  | ||||||
| @@ -96,6 +97,8 @@ usage (void) | |||||||
|  |  | ||||||
| [-bs] --change-cygdrive-prefix <posixpath> | [-bs] --change-cygdrive-prefix <posixpath> | ||||||
|     change the cygdrive path prefix to <posixpath> |     change the cygdrive path prefix to <posixpath> | ||||||
|  | --show-cygdrive-prefixes | ||||||
|  |     show user and/or system cygdrive path prefixes | ||||||
| --import-old-mounts | --import-old-mounts | ||||||
|     copy old registry mount table mounts into the current mount areas |     copy old registry mount table mounts into the current mount areas | ||||||
| ", progname); | ", progname); | ||||||
| @@ -136,6 +139,13 @@ main (int argc, const char **argv) | |||||||
| 	  cygwin_internal (CW_READ_V1_MOUNT_TABLES); | 	  cygwin_internal (CW_READ_V1_MOUNT_TABLES); | ||||||
| 	  exit (0); | 	  exit (0); | ||||||
| 	} | 	} | ||||||
|  |       else if (strcmp (argv[i], "--show-cygdrive-prefixes") == 0) | ||||||
|  | 	{ | ||||||
|  | 	  if ((i + 1) != argc) | ||||||
|  | 	    usage (); | ||||||
|  |  | ||||||
|  | 	  show_cygdrive_prefixes (); | ||||||
|  | 	} | ||||||
|       else if (strcmp (argv[i], "-b") == 0) |       else if (strcmp (argv[i], "-b") == 0) | ||||||
| 	flags |= MOUNT_BINARY; | 	flags |= MOUNT_BINARY; | ||||||
|       else if (strcmp (argv[i], "-t") == 0) |       else if (strcmp (argv[i], "-t") == 0) | ||||||
| @@ -252,3 +262,24 @@ change_cygdrive_prefix (const char *new_prefix, int flags) | |||||||
|    |    | ||||||
|   exit (0); |   exit (0); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /* show_cygdrive_prefixes: Show the user and/or cygdrive path prefixes */ | ||||||
|  | static void | ||||||
|  | show_cygdrive_prefixes () | ||||||
|  | { | ||||||
|  |   /* Get the Cygdrive user and system path prefixes */ | ||||||
|  |   char user[MAX_PATH]; | ||||||
|  |   char system[MAX_PATH]; | ||||||
|  |   cygwin_internal (CW_GET_CYGDRIVE_PREFIXES, user, system); | ||||||
|  |  | ||||||
|  |   /* Display the user and system cygdrive path prefixes, if necessary | ||||||
|  |      (ie, not empty) */ | ||||||
|  |   const char *format = "%-18s  %-11s\n"; | ||||||
|  |   printf (format, "Prefix", "Type"); | ||||||
|  |   if (strlen (user) > 0) | ||||||
|  |     printf (format, user, "user"); | ||||||
|  |   if (strlen (system) > 0) | ||||||
|  |     printf (format, system, "system"); | ||||||
|  |  | ||||||
|  |   exit (0); | ||||||
|  | } | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ static void remove_all_mounts (); | |||||||
| static void remove_all_automounts (); | static void remove_all_automounts (); | ||||||
| static void remove_all_user_mounts (); | static void remove_all_user_mounts (); | ||||||
| static void remove_all_system_mounts (); | static void remove_all_system_mounts (); | ||||||
|  | static void remove_cygdrive_prefix (int flags); | ||||||
|  |  | ||||||
| static const char *progname; | static const char *progname; | ||||||
|  |  | ||||||
| @@ -31,12 +32,13 @@ usage (void) | |||||||
|   fprintf (stderr, "--remove-all-mounts = remove all mounts\n"); |   fprintf (stderr, "--remove-all-mounts = remove all mounts\n"); | ||||||
|   fprintf (stderr, "--remove-auto-mounts = remove all automatically mounted mounts\n"); |   fprintf (stderr, "--remove-auto-mounts = remove all automatically mounted mounts\n"); | ||||||
|   fprintf (stderr, "--remove-user-mounts = remove all mounts in the current user mount registry area, including auto mounts\n"); |   fprintf (stderr, "--remove-user-mounts = remove all mounts in the current user mount registry area, including auto mounts\n"); | ||||||
|   fprintf (stderr, "--remove-system-mounts = Remove all mounts in the system-wide mount registry area\n"); |   fprintf (stderr, "--remove-system-mounts = remove all mounts in the system-wide mount registry area\n"); | ||||||
|  |   fprintf (stderr, "[-s] --remove-cygdrive-prefix = remove cygdrive path prefix\n"); | ||||||
|   exit (1); |   exit (1); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
| error (char *path) | error (const char *path) | ||||||
| { | { | ||||||
|   fprintf (stderr, "%s: %s: %s\n", progname, path, strerror (errno)); |   fprintf (stderr, "%s: %s: %s\n", progname, path, strerror (errno)); | ||||||
|   exit (1); |   exit (1); | ||||||
| @@ -81,6 +83,11 @@ main (int argc, char **argv) | |||||||
| 	  remove_all_automounts (); | 	  remove_all_automounts (); | ||||||
| 	  exit (0); | 	  exit (0); | ||||||
| 	} | 	} | ||||||
|  |       else if (strcmp (argv[i], "--remove-cygdrive-prefix") == 0) | ||||||
|  | 	{ | ||||||
|  | 	  remove_cygdrive_prefix (flags); | ||||||
|  | 	  exit (0); | ||||||
|  | 	} | ||||||
|       else |       else | ||||||
| 	usage (); | 	usage (); | ||||||
|     } |     } | ||||||
| @@ -182,3 +189,12 @@ remove_all_system_mounts () | |||||||
|  |  | ||||||
|   endmntent (m); |   endmntent (m); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /* remove_cygdrive_prefix: Remove cygdrive user or system path prefix. */ | ||||||
|  | static void | ||||||
|  | remove_cygdrive_prefix (int flags) | ||||||
|  | { | ||||||
|  |   int res = cygwin_umount(NULL, flags | MOUNT_AUTO); | ||||||
|  |   if (res) | ||||||
|  |     error ("remove_cygdrive_prefix"); | ||||||
|  | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user