DiskTool - Usability fixes
authorJohn Hodge <[email protected]>
Tue, 17 Jul 2012 05:37:20 +0000 (13:37 +0800)
committerJohn Hodge <[email protected]>
Tue, 17 Jul 2012 05:37:20 +0000 (13:37 +0800)
Tools/DiskTool/src/actions.c
Tools/DiskTool/src/helpers.c
Tools/DiskTool/src/main.c

index d1fb703..e63ae61 100644 (file)
@@ -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);
index f326677..f9e3bc4 100644 (file)
@@ -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;
 }
index c3c4166..0758fc2 100644 (file)
@@ -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;
                        }
                        

UCC git Repository :: git.ucc.asn.au