1
0

dnix-traverse.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. compile using : c++ dnix-traverse.cpp -o dnix-traverse
  3. Program to list and extract files from a DNIX FS. Should also be able to write to a DNIX file system. Possibly even add boot code and other things.
  4. */
  5. #include <stdio.h>
  6. #include <unistd.h>
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9. #include <time.h>
  10. typedef unsigned long daddr_t;
  11. #pragma pack(push, 1)
  12. #include "../dnix-headers/diskpar.h"
  13. #include "../dnix-headers/inode.h"
  14. #include "../dnix-headers/sysfile.h"
  15. #include "../dnix-headers/dir.h"
  16. #pragma pack(pop)
  17. class DnixFs {
  18. struct sysfptr dnixPartitionInfo;
  19. FILE * image;
  20. public:
  21. DnixFs( FILE * image);
  22. };
  23. struct sysfptr {
  24. daddr_t vdsp; /* Pointer to volume descriptor block */
  25. daddr_t vdspn; /* 1:s complement of previous item */
  26. daddr_t cleanfl; /* Volume clean flag */
  27. time_t timestamp; /* Timestamp */
  28. daddr_t x[124]; /* Reserved */
  29. };
  30. DixFs:DnixFs(FILE * img) {
  31. char buffer[26];
  32. image = img;
  33. // Read the partition info
  34. fread ( (void * ) dnixPartitionInfo, 512, 1 image);
  35. strftime(buffer, 26, "%Y-%m-%d %H:%M:%S", localtime(dnixPartitionInfo.timestamp))
  36. printf ("Pointer to volume descriptor block: %08lX", dnixPartitionInfo.vdsp);
  37. printf ("1:s complement of previous item: %08lX", dnixPartitionInfo.vdspn);
  38. printf ("Volume clean flag: %08lX", dnixPartitionInfo.cleanfl);
  39. printf ("Timestamp %s", buffer);
  40. }
  41. int main (int argc, char ** argv) {
  42. FILE * image_file;
  43. int opt;
  44. printf("1\n");
  45. while ((opt = getopt(argc, argv, "d:")) != -1) {
  46. switch (opt) {
  47. case 'd':
  48. printf("1");
  49. image_file = fopen (optarg, "r");
  50. if (image_file == NULL) {
  51. perror ("Failure opening file.");
  52. exit(EXIT_FAILURE);
  53. }
  54. break;
  55. default: /* '?' */
  56. fprintf(stderr, "Usage: %s [-d disk-image-file]\n", argv[0]);
  57. exit(EXIT_FAILURE);
  58. }
  59. }
  60. }