Changeset 69612 in vbox for trunk/src/VBox/Devices/EFI/Firmware
- Timestamp:
- Nov 8, 2017 12:09:43 PM (7 years ago)
- Location:
- trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxFsDxe/test
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxFsDxe/test/fsw_posix.c
r48674 r69612 85 85 86 86 // open underlying file/device 87 pvol->fd = open(path, O_RDONLY , 0);87 pvol->fd = open(path, O_RDONLY | O_BINARY, 0); 88 88 if (pvol->fd < 0) { 89 89 fprintf(stderr, "fsw_posix_mount: %s: %s\n", path, strerror(errno)); … … 226 226 */ 227 227 228 struct dirent * fsw_posix_readdir(struct fsw_posix_dir *dir)229 { 230 fsw_status_t status;231 struct fsw_dnode *dno;232 static struct direntdent;228 struct fsw_posix_dirent * fsw_posix_readdir(struct fsw_posix_dir *dir) 229 { 230 fsw_status_t status; 231 struct fsw_dnode *dno; 232 static struct fsw_posix_dirent dent; 233 233 234 234 // get next entry from file system … … 248 248 // fill dirent structure 249 249 dent.d_fileno = dno->dnode_id; 250 dent.d_reclen = 8 + dno->name.size + 1;250 //dent.d_reclen = 8 + dno->name.size + 1; 251 251 switch (dno->type) { 252 252 case FSW_DNODE_TYPE_FILE: … … 374 374 block_offset = (off_t)phys_bno * vol->phys_blocksize; 375 375 seek_result = lseek(pvol->fd, block_offset, SEEK_SET); 376 if (seek_result != block_offset) 376 if (seek_result != block_offset) { 377 fprintf(stderr, "fsw_posix_read_block: failed to seek to block %u (offset %u)\n", phys_bno, block_offset); 377 378 return FSW_IO_ERROR; 379 } 378 380 read_result = read(pvol->fd, buffer, vol->phys_blocksize); 379 if (read_result != vol->phys_blocksize) 381 if (read_result != vol->phys_blocksize) { 382 fprintf(stderr, "fsw_posix_read_block: failed to read %u bytes at %u\n", vol->phys_blocksize, block_offset); 380 383 return FSW_IO_ERROR; 384 } 381 385 382 386 return FSW_SUCCESS; -
trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxFsDxe/test/fsw_posix.h
r48674 r69612 43 43 #include <fcntl.h> 44 44 #include <sys/types.h> 45 #include <sys/dir.h>46 45 47 46 … … 80 79 81 80 81 #define NAME_MAX 4096 82 83 #define DT_UNKNOWN 'u' 84 #define DT_REG 'r' 85 #define DT_DIR 'd' 86 #define DT_LNK 'l' 87 88 89 /** 90 * POSIX Host: Private structure for an open directory. 91 */ 92 93 struct fsw_posix_dirent { 94 char d_attr; /* file's attribute */ 95 unsigned d_type; 96 unsigned short int d_time; /* file's time */ 97 unsigned short int d_date; /* file's date */ 98 long d_size; /* file's size */ 99 char d_name[NAME_MAX+1]; /* file's name */ 100 unsigned d_fileno; /* file number/inode */ 101 }; 102 typedef struct fsw_posix_dirent DIR; 103 82 104 /* functions */ 83 105 … … 91 113 92 114 struct fsw_posix_dir * fsw_posix_opendir(struct fsw_posix_volume *pvol, const char *path); 93 struct dirent * fsw_posix_readdir(struct fsw_posix_dir *dir);115 struct fsw_posix_dirent * fsw_posix_readdir(struct fsw_posix_dir *dir); 94 116 void fsw_posix_rewinddir(struct fsw_posix_dir *dir); 95 117 int fsw_posix_closedir(struct fsw_posix_dir *dir); -
trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxFsDxe/test/lslr.c
r48674 r69612 53 53 { 54 54 struct fsw_posix_dir *dir; 55 struct dirent *dent;55 struct fsw_posix_dirent *dent; 56 56 int i; 57 57 char subpath[4096]; … … 65 65 for (i = 0; i < level*2; i++) 66 66 fputc(' ', stdout); 67 printf("% d%s\n", dent->d_type, dent->d_name);67 printf("%c %s\n", dent->d_type, dent->d_name); 68 68 69 69 if (dent->d_type == DT_DIR) { … … 123 123 } 124 124 125 //listdir(vol, "/System/Library/Extensions/udf.kext/", 0);125 listdir(vol, "/System/Library/CoreServices", 0); 126 126 //listdir(vol, "/System/Library/Extensions/AppleACPIPlatform.kext/", 0); 127 127 //listdir(vol, "/System/Library/Extensions/", 0); 128 catfile(vol, "/System/Library/ Extensions/AppleHPET.kext/Contents/Info.plist");128 catfile(vol, "/System/Library/CoreServices/SystemVersion.plist"); 129 129 //listdir(vol, "/", 0); 130 130 -
trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxFsDxe/test/lsroot.c
r48674 r69612 48 48 struct fsw_posix_volume *vol; 49 49 struct fsw_posix_dir *dir; 50 struct dirent *dent;50 struct fsw_posix_dirent *dent; 51 51 52 if (argc != 2) {53 printf("Usage: lsroot <file/device> \n");52 if (argc != 3) { 53 printf("Usage: lsroot <file/device> <directory>\n"); 54 54 return 1; 55 55 } … … 63 63 } 64 64 //dir = fsw_posix_opendir(vol, "/drivers/net/"); 65 dir = fsw_posix_opendir(vol, "/");65 dir = fsw_posix_opendir(vol, argv[2]); 66 66 if (dir == NULL) { 67 67 printf("opendir call failed.\n"); … … 69 69 } 70 70 while ((dent = fsw_posix_readdir(dir)) != NULL) { 71 printf(" - %s\n", dent->d_name);71 printf("%c %s\n", dent->d_type, dent->d_name); 72 72 } 73 73 fsw_posix_closedir(dir);
Note:
See TracChangeset
for help on using the changeset viewer.