From: John Hodge Date: Tue, 17 Jul 2012 05:37:20 +0000 (+0800) Subject: DiskTool - Usability fixes X-Git-Tag: rel0.15~611^2~27 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=48025ef1ac8dd0445bc6a07fbc6c1ac9cb07991e;p=tpg%2Facess2.git DiskTool - Usability fixes --- diff --git a/Tools/DiskTool/src/actions.c b/Tools/DiskTool/src/actions.c index d1fb7034..e63ae612 100644 --- a/Tools/DiskTool/src/actions.c +++ b/Tools/DiskTool/src/actions.c @@ -95,6 +95,11 @@ int DiskTool_MountImage(const char *Identifier, const char *Path) return VFS_Mount(tpath, mountpoint, "", ""); } +int DiskTool_MkDir(const char *Directory) +{ + return -1; +} + int DiskTool_Copy(const char *Source, const char *Destination) { int src = DiskTool_int_TranslateOpen(Source, VFS_OPENFLAG_READ); diff --git a/Tools/DiskTool/src/helpers.c b/Tools/DiskTool/src/helpers.c index f3266775..f9e3bc4a 100644 --- a/Tools/DiskTool/src/helpers.c +++ b/Tools/DiskTool/src/helpers.c @@ -22,12 +22,21 @@ size_t DiskTool_int_TranslatePath(char *Buffer, const char *Path) if( Path[0] == '#' ) { - if(Buffer) + len = strlen(Path+1); + if(Buffer) { strcpy(Buffer, Path+1); - return strlen(Path) - 1; + } } - - if( colon ) + else if( Path[0] == ':' ) + { + len = strlen("/Devices/LVM/"); + len += strlen(Path+1); + if(Buffer) { + strcpy(Buffer, "/Devices/LVM/"); + strcat(Buffer, Path+1); + } + } + else if( colon ) { const char *pos; for(pos = Path; pos < colon; pos ++) @@ -43,23 +52,23 @@ size_t DiskTool_int_TranslatePath(char *Buffer, const char *Path) strncat(Buffer+strlen("/Mount/"), Path, colon - Path); strcat(Buffer, colon + 1); } - return len; } + else + { + native_path: + if( !gsWorkingDirectory[0] ) { + getcwd(gsWorkingDirectory, 1024); + } -native_path: - - if( !gsWorkingDirectory[0] ) { - getcwd(gsWorkingDirectory, 1024); - } - - len = strlen("/Native"); - len += strlen( gsWorkingDirectory ) + 1; - len += strlen(Path); - if( Buffer ) { - strcpy(Buffer, "/Native"); - strcat(Buffer, gsWorkingDirectory); - strcat(Buffer, "/"); - strcat(Buffer, Path); + len = strlen("/Native"); + len += strlen( gsWorkingDirectory ) + 1; + len += strlen(Path); + if( Buffer ) { + strcpy(Buffer, "/Native"); + strcat(Buffer, gsWorkingDirectory); + strcat(Buffer, "/"); + strcat(Buffer, Path); + } } return len; } diff --git a/Tools/DiskTool/src/main.c b/Tools/DiskTool/src/main.c index c3c4166d..0758fc29 100644 --- a/Tools/DiskTool/src/main.c +++ b/Tools/DiskTool/src/main.c @@ -16,12 +16,12 @@ int main(int argc, char *argv[]) if( strcmp("mount", argv[i]) == 0 || strcmp("-i", argv[i]) == 0 ) { // Mount an image if( argc - i < 3 ) { - fprintf(stderr, "--image/-i takes 2 arguments (ident and path)\n"); + fprintf(stderr, "mount takes 2 arguments (image and mountpoint)\n"); exit(-1); } - if( DiskTool_MountImage(argv[i+1], argv[i+2]) ) { - fprintf(stderr, "Unable to mount '%s' as '%s'\n", argv[i+2], argv[i+1]); + if( DiskTool_MountImage(argv[i+2], argv[i+1]) ) { + fprintf(stderr, "Unable to mount '%s' as '%s'\n", argv[i+1], argv[i+2]); break; } @@ -32,12 +32,12 @@ int main(int argc, char *argv[]) if( strcmp("mountlvm", argv[i]) == 0 ) { if( argc - i < 3 ) { - fprintf(stderr, "mountlvm takes 2 arguments (ident and path)\n"); + fprintf(stderr, "mountlvm takes 2 arguments (iamge and ident)\n"); exit(-1); } - if( DiskTool_RegisterLVM(argv[i+1], argv[i+2]) ) { - fprintf(stderr, "Unable to register '%s' as LVM '%s'\n", argv[i+2], argv[i+1]); + if( DiskTool_RegisterLVM(argv[i+2], argv[i+1]) ) { + fprintf(stderr, "Unable to register '%s' as LVM '%s'\n", argv[i+1], argv[i+2]); break; }