From: John Hodge Date: Sat, 14 Jul 2012 12:26:40 +0000 (+0800) Subject: DiskTool - Autodetection of filesystems and better debugging X-Git-Tag: rel0.15~611^2~31 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=151e0400c6cf69d71a51e49bc75fac3d7bdfc2f7;p=tpg%2Facess2.git DiskTool - Autodetection of filesystems and better debugging --- diff --git a/AcessNative/acesskernel_src/nativefs.c b/AcessNative/acesskernel_src/nativefs.c index e51f2862..7c20b69e 100644 --- a/AcessNative/acesskernel_src/nativefs.c +++ b/AcessNative/acesskernel_src/nativefs.c @@ -48,9 +48,9 @@ tVFS_NodeType gNativeFS_DirNodeType = { .Close = NativeFS_Close }; tVFS_Driver gNativeFS_Driver = { - "nativefs", 0, - NativeFS_Mount, NativeFS_Unmount, - NULL, + .Name = "nativefs", + .InitDevice = NativeFS_Mount, + .Unmount = NativeFS_Unmount }; // === CODE === diff --git a/Tools/DiskTool/src/Makefile b/Tools/DiskTool/src/Makefile index b2325672..a1282ac1 100644 --- a/Tools/DiskTool/src/Makefile +++ b/Tools/DiskTool/src/Makefile @@ -19,7 +19,7 @@ K_OBJ += vfs/nodecache.o vfs/mount.o vfs/memfile.o # vfs/select.o K_OBJ += vfs/fs/root.o vfs/fs/devfs.o K_OBJ += drvutil_disk.o drv/proc.o # Modules -MODULES := Storage/LVM Filesystems/FAT Filesystems/Ext2 +MODULES := Storage/LVM Filesystems/FAT Filesystems/Ext2 Filesystems/NTFS # Local kernel soruces (same as above, but located in same directory as Makefile) L_OBJ = vfs_handles.o threads.o nativefs.o time.o actions.o # Native Sources (compiled as usual) diff --git a/Tools/DiskTool/src/actions.c b/Tools/DiskTool/src/actions.c index 377608de..d1fb7034 100644 --- a/Tools/DiskTool/src/actions.c +++ b/Tools/DiskTool/src/actions.c @@ -65,10 +65,13 @@ void DiskTool_Cleanup(void) int DiskTool_RegisterLVM(const char *Identifier, const char *Path) { int fd = DiskTool_int_TranslateOpen(Path, VFS_OPENFLAG_READ|VFS_OPENFLAG_WRITE); - if(fd == -1) + if(fd == -1) { + Log_Notice("DiskTool", "Can't open '%s' for LVM %s", Path, Identifier); return -1; + } VFS_Seek(fd, 0, SEEK_END); LVM_AddVolume( &gDiskTool_VolumeType, Identifier, (void*)(tVAddr)fd, 512, VFS_Tell(fd)/512); + Log_Debug("DiskTool", "Registered '%s' for LVM %s", Path, Identifier); return 0; } @@ -89,7 +92,7 @@ int DiskTool_MountImage(const char *Identifier, const char *Path) // Call mount VFS_MkDir(mountpoint); // TODO: Detect filesystem? - return VFS_Mount(tpath, mountpoint, "fat", ""); + return VFS_Mount(tpath, mountpoint, "", ""); } int DiskTool_Copy(const char *Source, const char *Destination) @@ -145,13 +148,11 @@ int DiskTool_ListDirectory(const char *Directory) int DiskTool_LVM_Read(void *Handle, Uint64 Block, size_t BlockCount, void *Dest) { - VFS_ReadAt( (int)(tVAddr)Handle, Block*512, BlockCount*512, Dest); - return 0; + return VFS_ReadAt( (int)(tVAddr)Handle, Block*512, BlockCount*512, Dest) / 512; } int DiskTool_LVM_Write(void *Handle, Uint64 Block, size_t BlockCount, const void *Dest) { - VFS_WriteAt( (int)(tVAddr)Handle, Block*512, BlockCount*512, Dest); - return 0; + return VFS_WriteAt( (int)(tVAddr)Handle, Block*512, BlockCount*512, Dest) / 512; } void DiskTool_LVM_Cleanup(void *Handle) { diff --git a/Tools/DiskTool/src/logging.c b/Tools/DiskTool/src/logging.c index fde90552..2b03c6ff 100644 --- a/Tools/DiskTool/src/logging.c +++ b/Tools/DiskTool/src/logging.c @@ -7,6 +7,7 @@ #include #include #include +#include #define LOGHDR(col,type) fprintf(stderr, "\e["col"m[%-8.8s]"type" ", Ident) #define LOGTAIL() fprintf(stderr, "\e[0m\n") @@ -22,7 +23,7 @@ // === CODE === void Log_KernelPanic(const char *Ident, const char *Message, ...) { PUTERR("35", "k") - exit(-1); + abort(); } void Log_Panic(const char *Ident, const char *Message, ...) PUTERR("34", "p") @@ -116,6 +117,9 @@ void Debug_TraceEnter(const char *Function, const char *Format, ...) case 'x': fprintf(stderr, "0x%x", va_arg(args,unsigned int)); break; + case 'X': + fprintf(stderr, "0x%"PRIx64, va_arg(args,uint64_t)); + break; default: va_arg(args,uintptr_t); fprintf(stderr, "?"); @@ -177,6 +181,9 @@ void Debug_TraceLeave(const char *Function, char Type, ...) case 'x': fprintf(stderr, " 0x%x", va_arg(args, unsigned int)); break; + case 'X': + fprintf(stderr, " 0x%"PRIx64, va_arg(args,uint64_t)); + break; case 's': fprintf(stderr, " \"%s\"", va_arg(args, const char *)); break; diff --git a/Tools/DiskTool/src/main.c b/Tools/DiskTool/src/main.c index 823bb2b1..c3c4166d 100644 --- a/Tools/DiskTool/src/main.c +++ b/Tools/DiskTool/src/main.c @@ -68,6 +68,8 @@ int main(int argc, char *argv[]) i += 2; continue ; } + + fprintf(stderr, "Unknown command '%s'\n", argv[i]); } DiskTool_Cleanup();