diff --git a/ee/libc/src/ps2sdkapi.c b/ee/libc/src/ps2sdkapi.c index 9ffee9fdbbc..4ce1802cae1 100644 --- a/ee/libc/src/ps2sdkapi.c +++ b/ee/libc/src/ps2sdkapi.c @@ -77,6 +77,23 @@ static mode_t io_to_posix_mode(unsigned int ps2mode) return posixmode; } +static void fill_stat(struct stat *stat, const io_stat_t *fiostat) +{ + stat->st_dev = 0; + stat->st_ino = 0; + stat->st_mode = io_to_posix_mode(fiostat->mode); + stat->st_nlink = 0; + stat->st_uid = 0; + stat->st_gid = 0; + stat->st_rdev = 0; + stat->st_size = ((off_t)fiostat->hisize << 32) | (off_t)fiostat->size; + stat->st_atime = io_to_posix_time(fiostat->atime); + stat->st_mtime = io_to_posix_time(fiostat->mtime); + stat->st_ctime = io_to_posix_time(fiostat->ctime); + stat->st_blksize = 16*1024; + stat->st_blocks = stat->st_size / 512; +} + static int fioGetstatHelper(const char *path, struct stat *buf) { io_stat_t fiostat; @@ -85,19 +102,7 @@ static int fioGetstatHelper(const char *path, struct stat *buf) { return -1; } - buf->st_dev = 0; - buf->st_ino = 0; - buf->st_mode = io_to_posix_mode(fiostat.mode); - buf->st_nlink = 0; - buf->st_uid = 0; - buf->st_gid = 0; - buf->st_rdev = 0; - buf->st_size = ((off_t)fiostat.hisize << 32) | (off_t)fiostat.size; - buf->st_atime = io_to_posix_time(fiostat.atime); - buf->st_mtime = io_to_posix_time(fiostat.mtime); - buf->st_ctime = io_to_posix_time(fiostat.ctime); - buf->st_blksize = 16*1024; - buf->st_blocks = buf->st_size / 512; + fill_stat(buf, &fiostat); return 0; } @@ -115,11 +120,7 @@ static DIR *fioOpendirHelper(const char *path) dir = malloc(sizeof(DIR)); dir->dd_fd = dd; - dir->dd_loc = 0; - dir->dd_size = 0; - dir->dd_buf = malloc(sizeof(struct dirent) + 255); - dir->dd_len = 0; - dir->dd_seek = 0; + dir->dd_buf = malloc(sizeof(struct dirent)); return dir; } @@ -141,9 +142,7 @@ static struct dirent *fioReaddirHelper(DIR *dir) return NULL; } - de->d_ino = 0; - de->d_off = 0; - de->d_reclen = 0; + fill_stat(&de->d_stat, &fiode.stat); strncpy(de->d_name, fiode.name, 255); de->d_name[255] = 0; diff --git a/ee/rpc/filexio/src/fileXio_rpc.c b/ee/rpc/filexio/src/fileXio_rpc.c index fb5d982d437..ee1549c2e62 100644 --- a/ee/rpc/filexio/src/fileXio_rpc.c +++ b/ee/rpc/filexio/src/fileXio_rpc.c @@ -81,6 +81,23 @@ static mode_t iox_to_posix_mode(unsigned int ps2mode) return posixmode; } +static void fill_stat(struct stat *stat, const iox_stat_t *fiostat) +{ + stat->st_dev = 0; + stat->st_ino = 0; + stat->st_mode = iox_to_posix_mode(fiostat->mode); + stat->st_nlink = 0; + stat->st_uid = 0; + stat->st_gid = 0; + stat->st_rdev = 0; + stat->st_size = ((off_t)fiostat->hisize << 32) | (off_t)fiostat->size; + stat->st_atime = io_to_posix_time(fiostat->atime); + stat->st_mtime = io_to_posix_time(fiostat->mtime); + stat->st_ctime = io_to_posix_time(fiostat->ctime); + stat->st_blksize = 16*1024; + stat->st_blocks = stat->st_size / 512; +} + static int fileXioGetstatHelper(const char *path, struct stat *buf) { iox_stat_t fiostat; @@ -89,19 +106,7 @@ static int fileXioGetstatHelper(const char *path, struct stat *buf) { return -1; } - buf->st_dev = 0; - buf->st_ino = 0; - buf->st_mode = iox_to_posix_mode(fiostat.mode); - buf->st_nlink = 0; - buf->st_uid = 0; - buf->st_gid = 0; - buf->st_rdev = 0; - buf->st_size = ((off_t)fiostat.hisize << 32) | (off_t)fiostat.size; - buf->st_atime = io_to_posix_time(fiostat.atime); - buf->st_mtime = io_to_posix_time(fiostat.mtime); - buf->st_ctime = io_to_posix_time(fiostat.ctime); - buf->st_blksize = 16*1024; - buf->st_blocks = buf->st_size / 512; + fill_stat(buf, &fiostat); return 0; } @@ -120,11 +125,7 @@ static DIR *fileXioOpendirHelper(const char *path) dir = malloc(sizeof(DIR)); dir->dd_fd = dd; - dir->dd_loc = 0; - dir->dd_size = 0; - dir->dd_buf = malloc(sizeof(struct dirent) + 255); - dir->dd_len = 0; - dir->dd_seek = 0; + dir->dd_buf = malloc(sizeof(struct dirent)); return dir; } @@ -147,9 +148,7 @@ static struct dirent *fileXioReaddirHelper(DIR *dir) return NULL; } - de->d_ino = 0; - de->d_off = 0; - de->d_reclen = 0; + fill_stat(&de->d_stat, &fiode.stat); strncpy(de->d_name, fiode.name, 255); de->d_name[255] = 0;