VirtualBox

Ignore:
Timestamp:
Nov 8, 2017 12:09:43 PM (7 years ago)
Author:
vboxsync
Message:

Touched up test code.

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  
    8585
    8686    // open underlying file/device
    87     pvol->fd = open(path, O_RDONLY, 0);
     87    pvol->fd = open(path, O_RDONLY | O_BINARY, 0);
    8888    if (pvol->fd < 0) {
    8989        fprintf(stderr, "fsw_posix_mount: %s: %s\n", path, strerror(errno));
     
    226226 */
    227227
    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 dirent dent;
     228struct 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;
    233233
    234234    // get next entry from file system
     
    248248    // fill dirent structure
    249249    dent.d_fileno = dno->dnode_id;
    250     dent.d_reclen = 8 + dno->name.size + 1;
     250    //dent.d_reclen = 8 + dno->name.size + 1;
    251251    switch (dno->type) {
    252252        case FSW_DNODE_TYPE_FILE:
     
    374374    block_offset = (off_t)phys_bno * vol->phys_blocksize;
    375375    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);
    377378        return FSW_IO_ERROR;
     379    }
    378380    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);
    380383        return FSW_IO_ERROR;
     384    }
    381385
    382386    return FSW_SUCCESS;
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxFsDxe/test/fsw_posix.h

    r48674 r69612  
    4343#include <fcntl.h>
    4444#include <sys/types.h>
    45 #include <sys/dir.h>
    4645
    4746
     
    8079
    8180
     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
     93struct 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};
     102typedef struct fsw_posix_dirent DIR;
     103
    82104/* functions */
    83105
     
    91113
    92114struct 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);
     115struct fsw_posix_dirent * fsw_posix_readdir(struct fsw_posix_dir *dir);
    94116void fsw_posix_rewinddir(struct fsw_posix_dir *dir);
    95117int fsw_posix_closedir(struct fsw_posix_dir *dir);
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxFsDxe/test/lslr.c

    r48674 r69612  
    5353{
    5454    struct fsw_posix_dir *dir;
    55     struct dirent *dent;
     55    struct fsw_posix_dirent *dent;
    5656    int i;
    5757    char subpath[4096];
     
    6565        for (i = 0; i < level*2; i++)
    6666            fputc(' ', stdout);
    67         printf("%d  %s\n", dent->d_type, dent->d_name);
     67        printf("%c  %s\n", dent->d_type, dent->d_name);
    6868
    6969        if (dent->d_type == DT_DIR) {
     
    123123    }
    124124
    125     //listdir(vol, "/System/Library/Extensions/udf.kext/", 0);
     125    listdir(vol, "/System/Library/CoreServices", 0);
    126126    //listdir(vol, "/System/Library/Extensions/AppleACPIPlatform.kext/", 0);
    127127    //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");
    129129    //listdir(vol, "/", 0);
    130130
  • trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxFsDxe/test/lsroot.c

    r48674 r69612  
    4848    struct fsw_posix_volume *vol;
    4949    struct fsw_posix_dir *dir;
    50     struct dirent *dent;
     50    struct fsw_posix_dirent *dent;
    5151
    52     if (argc != 2) {
    53         printf("Usage: lsroot <file/device>\n");
     52    if (argc != 3) {
     53        printf("Usage: lsroot <file/device> <directory>\n");
    5454        return 1;
    5555    }
     
    6363    }
    6464    //dir = fsw_posix_opendir(vol, "/drivers/net/");
    65     dir = fsw_posix_opendir(vol, "/");
     65    dir = fsw_posix_opendir(vol, argv[2]);
    6666    if (dir == NULL) {
    6767        printf("opendir call failed.\n");
     
    6969    }
    7070    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);
    7272    }
    7373    fsw_posix_closedir(dir);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette