8 #include <disktool_common.h>
11 int main(int argc, char *argv[])
14 for( int i = 1; i < argc; i ++ )
16 if( strcmp("--image", 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("ls", argv[i]) == 0 ) {
34 fprintf(stderr, "ls 1 argument (path)\n");
38 DiskTool_ListDirectory(argv[i+1]);
44 // NOTE: This is in a native compiled file because it needs access to the real errno macro
45 int *Threads_GetErrno(void)
50 // TODO: Move into a helper lib?
51 void itoa(char *buf, uint64_t num, int base, int minLength, char pad)
53 char fmt[] = "%0ll*x";
56 case 8: fmt[5] = 'o'; break;
57 case 10: fmt[5] = 'd'; break;
58 case 16: fmt[5] = 'x'; break;
62 sprintf(buf, fmt+1, minLength, num);
65 sprintf(buf, fmt, minLength, num);
69 int strpos(const char *Str, char Ch)
71 const char *r = strchr(Str, Ch);
76 int strucmp(const char *s1, const char *s2)
78 return strcasecmp(s1, s2);
81 int64_t DivUp(int64_t value, int64_t divisor)
83 return (value + divisor - 1) / divisor;
86 int64_t timestamp(int sec, int min, int hr, int day, int month, int year)