8 #include <disktool_common.h>
11 int main(int argc, char *argv[])
14 for( int i = 1; i < argc; i ++ )
16 if( strcmp("mount", argv[i]) == 0 || strcmp("-i", argv[i]) == 0 ) {
19 fprintf(stderr, "--image/-i takes 2 arguments (ident and path)\n");
23 if( DiskTool_MountImage(argv[i+1], argv[i+2]) ) {
24 fprintf(stderr, "Unable to mount '%s' as '%s'\n", argv[i+2], argv[i+1]);
32 if( strcmp("mountlvm", argv[i]) == 0 ) {
35 fprintf(stderr, "mountlvm takes 2 arguments (ident and path)\n");
39 if( DiskTool_RegisterLVM(argv[i+1], argv[i+2]) ) {
40 fprintf(stderr, "Unable to register '%s' as LVM '%s'\n", argv[i+2], argv[i+1]);
48 if( strcmp("ls", argv[i]) == 0 ) {
50 fprintf(stderr, "ls 1 argument (path)\n");
54 DiskTool_ListDirectory(argv[i+1]);
59 if( strcmp("cp", argv[i]) == 0 ) {
62 fprintf(stderr, "cp takes 2 arguments (source and destination)\n");
66 DiskTool_Copy(argv[i+1], argv[i+2]);
78 // NOTE: This is in a native compiled file because it needs access to the real errno macro
79 int *Threads_GetErrno(void)
84 // TODO: Move into a helper lib?
85 void itoa(char *buf, uint64_t num, int base, int minLength, char pad)
87 char fmt[] = "%0ll*x";
90 case 8: fmt[5] = 'o'; break;
91 case 10: fmt[5] = 'd'; break;
92 case 16: fmt[5] = 'x'; break;
96 sprintf(buf, fmt+1, minLength, num);
99 sprintf(buf, fmt, minLength, num);
103 int strpos(const char *Str, char Ch)
105 const char *r = strchr(Str, Ch);
110 int strucmp(const char *s1, const char *s2)
112 return strcasecmp(s1, s2);
115 uint64_t DivMod64U(uint64_t value, uint64_t divisor, uint64_t *remainder)
118 *remainder = value % divisor;
119 return value / divisor;