return 0;
}
+int DiskTool_Cat(const char *File)
+{
+ int src = DiskTool_int_TranslateOpen(File, VFS_OPENFLAG_READ);
+ if( src == -1 ) {
+ Log_Error("DiskTool", "Unable to open %s for reading", File);
+ return -1;
+ }
+
+ char buf[1024];
+ size_t len, total = 0;
+ while( (len = VFS_Read(src, sizeof(buf), buf)) == sizeof(buf) ) {
+ _fwrite_stdout(len, buf);
+ total += len;
+ }
+ _fwrite_stdout(len, buf);
+ total += len;
+
+ Log_Notice("DiskTool", "%i bytes from %s", total, File);
+
+ VFS_Close(src);
+ return 0;
+}
+
int DiskTool_LVM_Read(void *Handle, Uint64 Block, size_t BlockCount, void *Dest)
{
return VFS_ReadAt( (int)(tVAddr)Handle, Block*512, BlockCount*512, Dest) / 512;
extern int DiskTool_MountImage(const char *Identifier, const char *Path);
extern int DiskTool_Copy(const char *Source, const char *Destination);
extern int DiskTool_ListDirectory(const char *Directory);
+extern int DiskTool_Cat(const char *File);
extern size_t DiskTool_int_TranslatePath(char *Buffer, const char *Path);
+extern size_t _fwrite_stdout(size_t bytes, const void *data);
+
#endif
if( strcmp("mountlvm", argv[i]) == 0 || strcmp("lvm", argv[i]) == 0 ) {
if( argc - i < 3 ) {
- fprintf(stderr, "mountlvm takes 2 arguments (iamge and ident)\n");
+ fprintf(stderr, "lvm takes 2 arguments (iamge and ident)\n");
exit(-1);
}
if( strcmp("ls", argv[i]) == 0 ) {
if( argc - i < 2 ) {
- fprintf(stderr, "ls 1 argument (path)\n");
+ fprintf(stderr, "ls takes 1 argument (path)\n");
break;
}
i += 2;
continue ;
}
+
+ if( strcmp("cat", argv[i]) == 0 ) {
+
+ if( argc - 1 < 2 ) {
+ fprintf(stderr, "cat takes 1 argument (path)\n");
+ break;
+ }
+
+ DiskTool_Cat(argv[i+1]);
+
+ i += 1;
+ continue;
+ }
fprintf(stderr, "Unknown command '%s'\n", argv[i]);
}
return value / divisor;
}
+size_t _fwrite_stdout(size_t bytes, const void *data)
+{
+ return fwrite(data, bytes, 1, stdout);
+}