mirror of
https://github.com/wiiu-env/wut.git
synced 2025-01-08 13:20:40 +01:00
Allocate FSCmdBlock to stack
This commit is contained in:
parent
bdac0fc52b
commit
163aa51251
176
crt/fs_dev.c
176
crt/fs_dev.c
@ -122,7 +122,7 @@ fsDevInit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
fsClient = memalign(0x20, sizeof(FSClient));
|
fsClient = memalign(0x20, sizeof(FSClient));
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSMountSource mountSource;
|
FSMountSource mountSource;
|
||||||
char mountPath[0x80];
|
char mountPath[0x80];
|
||||||
char workDir[0x83];
|
char workDir[0x83];
|
||||||
@ -132,11 +132,10 @@ fsDevInit()
|
|||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
free(fsClient);
|
free(fsClient);
|
||||||
free(fsCmd);
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
int dev = AddDevice(&fs_devoptab);
|
int dev = AddDevice(&fs_devoptab);
|
||||||
@ -146,13 +145,13 @@ fsDevInit()
|
|||||||
fsInitialised = true;
|
fsInitialised = true;
|
||||||
|
|
||||||
// Mount the SD card
|
// Mount the SD card
|
||||||
rc = FSGetMountSource(fsClient, fsCmd, FS_MOUNT_SOURCE_SD, &mountSource, -1);
|
rc = FSGetMountSource(fsClient, &fsCmd, FS_MOUNT_SOURCE_SD, &mountSource, -1);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = FSMount(fsClient, fsCmd, &mountSource, mountPath, 0x80, -1);
|
rc = FSMount(fsClient, &fsCmd, &mountSource, mountPath, 0x80, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
// chdir to SD root for general use
|
// chdir to SD root for general use
|
||||||
@ -163,13 +162,10 @@ fsDevInit()
|
|||||||
} else {
|
} else {
|
||||||
FSDelClient(fsClient, -1);
|
FSDelClient(fsClient, -1);
|
||||||
free(fsClient);
|
free(fsClient);
|
||||||
free(fsCmd);
|
|
||||||
return dev;
|
return dev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,22 +271,20 @@ fs_open(struct _reent *r,
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
// Open the file
|
// Open the file
|
||||||
rc = FSOpenFile(fsClient, fsCmd, path_fixed, fs_mode, &fd, -1);
|
rc = FSOpenFile(fsClient, &fsCmd, path_fixed, fs_mode, &fd, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
file->fd = fd;
|
file->fd = fd;
|
||||||
file->flags = (flags & (O_ACCMODE|O_APPEND|O_SYNC));
|
file->flags = (flags & (O_ACCMODE|O_APPEND|O_SYNC));
|
||||||
FSGetPosFile(fsClient, fsCmd, fd, &file->offset, -1);
|
FSGetPosFile(fsClient, &fsCmd, fd, &file->offset, -1);
|
||||||
free(path_fixed);
|
free(path_fixed);
|
||||||
free(fsCmd);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(fsCmd);
|
|
||||||
free(path_fixed);
|
free(path_fixed);
|
||||||
r->_errno = fs_translate_error(rc);
|
r->_errno = fs_translate_error(rc);
|
||||||
return -1;
|
return -1;
|
||||||
@ -304,11 +298,10 @@ fs_close(struct _reent *r,
|
|||||||
fs_file_t *file = (fs_file_t*)fd;
|
fs_file_t *file = (fs_file_t*)fd;
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSCloseFile(fsClient, fsCmd, file->fd, -1);
|
rc = FSCloseFile(fsClient, &fsCmd, file->fd, -1);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -348,12 +341,11 @@ fs_write(struct _reent *r,
|
|||||||
memcpy(tmp_buffer, ptr, toWrite);
|
memcpy(tmp_buffer, ptr, toWrite);
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
// Write the data
|
// Write the data
|
||||||
rc = FSWriteFile(fsClient, fsCmd, tmp_buffer, 1, toWrite, file->fd, 0, -1);
|
rc = FSWriteFile(fsClient, &fsCmd, tmp_buffer, 1, toWrite, file->fd, 0, -1);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if(rc < 0) {
|
if(rc < 0) {
|
||||||
free(tmp_buffer);
|
free(tmp_buffer);
|
||||||
@ -409,12 +401,11 @@ fs_write_safe(struct _reent *r,
|
|||||||
memcpy(tmp_buffer, ptr, toWrite);
|
memcpy(tmp_buffer, ptr, toWrite);
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
// Write the data
|
// Write the data
|
||||||
rc = FSWriteFile(fsClient, fsCmd, tmp_buffer, 1, toWrite, file->fd, 0, -1);
|
rc = FSWriteFile(fsClient, &fsCmd, tmp_buffer, 1, toWrite, file->fd, 0, -1);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
free(tmp_buffer);
|
free(tmp_buffer);
|
||||||
@ -457,15 +448,14 @@ fs_read(struct _reent *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
FSStat fsstat;
|
FSStat fsstat;
|
||||||
rc = FSGetStatFile(fsClient, fsCmd, file->fd, &fsstat, -1);
|
rc = FSGetStatFile(fsClient, &fsCmd, file->fd, &fsstat, -1);
|
||||||
|
|
||||||
if(rc < 0) {
|
if(rc < 0) {
|
||||||
r->_errno = fs_translate_error(rc);
|
r->_errno = fs_translate_error(rc);
|
||||||
free(fsCmd);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,12 +470,11 @@ fs_read(struct _reent *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the data
|
// Write the data
|
||||||
rc = FSReadFile(fsClient, fsCmd, tmp_buffer, 1, toRead, file->fd, 0, -1);
|
rc = FSReadFile(fsClient, &fsCmd, tmp_buffer, 1, toRead, file->fd, 0, -1);
|
||||||
|
|
||||||
if(rc <= 0)
|
if(rc <= 0)
|
||||||
{
|
{
|
||||||
free(tmp_buffer);
|
free(tmp_buffer);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
// Return partial transfer
|
// Return partial transfer
|
||||||
if (bytesRead > 0) {
|
if (bytesRead > 0) {
|
||||||
@ -507,7 +496,6 @@ fs_read(struct _reent *r,
|
|||||||
len -= bytes;
|
len -= bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(fsCmd);
|
|
||||||
free(tmp_buffer);
|
free(tmp_buffer);
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
}
|
}
|
||||||
@ -523,15 +511,14 @@ fs_seek(struct _reent *r,
|
|||||||
fs_file_t *file = (fs_file_t*)fd;
|
fs_file_t *file = (fs_file_t*)fd;
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
FSStat fsstat;
|
FSStat fsstat;
|
||||||
rc = FSGetStatFile(fsClient, fsCmd, file->fd, &fsstat, -1);
|
rc = FSGetStatFile(fsClient, &fsCmd, file->fd, &fsstat, -1);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
r->_errno = fs_translate_error(rc);
|
r->_errno = fs_translate_error(rc);
|
||||||
free(fsCmd);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,7 +542,6 @@ fs_seek(struct _reent *r,
|
|||||||
// An invalid option was provided
|
// An invalid option was provided
|
||||||
default:
|
default:
|
||||||
r->_errno = EINVAL;
|
r->_errno = EINVAL;
|
||||||
free(fsCmd);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,14 +549,12 @@ fs_seek(struct _reent *r,
|
|||||||
if(pos < 0 && offset < -pos) {
|
if(pos < 0 && offset < -pos) {
|
||||||
// Don't allow seek to before the beginning of the file
|
// Don't allow seek to before the beginning of the file
|
||||||
r->_errno = EINVAL;
|
r->_errno = EINVAL;
|
||||||
free(fsCmd);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the current offset
|
// Update the current offset
|
||||||
file->offset = offset + pos;
|
file->offset = offset + pos;
|
||||||
FSStatus result = FSSetPosFile(fsClient, fsCmd, file->fd, file->offset, -1);
|
FSStatus result = FSSetPosFile(fsClient, &fsCmd, file->fd, file->offset, -1);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
return result;
|
return result;
|
||||||
@ -589,11 +573,10 @@ fs_fstat(struct _reent *r,
|
|||||||
fs_file_t *file = (fs_file_t*)fd;
|
fs_file_t *file = (fs_file_t*)fd;
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSGetStatFile(fsClient, fsCmd, file->fd, &fsstat, -1);
|
rc = FSGetStatFile(fsClient, &fsCmd, file->fd, &fsstat, -1);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
memset(st, 0, sizeof(struct stat));
|
memset(st, 0, sizeof(struct stat));
|
||||||
@ -622,34 +605,30 @@ fs_stat(struct _reent *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
// First try open as file
|
// First try open as file
|
||||||
rc = FSOpenFile(fsClient, fsCmd, file, "r", (FSFileHandle*)&fd, -1);
|
rc = FSOpenFile(fsClient, &fsCmd, file, "r", (FSFileHandle*)&fd, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
fs_file_t tmpfd = { .fd = fd };
|
fs_file_t tmpfd = { .fd = fd };
|
||||||
rc = fs_fstat(r, (int)&tmpfd, st);
|
rc = fs_fstat(r, (int)&tmpfd, st);
|
||||||
FSCloseFile(fsClient, fsCmd, fd, -1);
|
FSCloseFile(fsClient, &fsCmd, fd, -1);
|
||||||
free(fsCmd);
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// File failed, so lets try open as directory
|
// File failed, so lets try open as directory
|
||||||
rc = FSOpenDir(fsClient, fsCmd, file, (FSDirectoryHandle*)&fd, -1);
|
rc = FSOpenDir(fsClient, &fsCmd, file, (FSDirectoryHandle*)&fd, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
memset(st, 0, sizeof(struct stat));
|
memset(st, 0, sizeof(struct stat));
|
||||||
st->st_nlink = 1;
|
st->st_nlink = 1;
|
||||||
st->st_mode = S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO;
|
st->st_mode = S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO;
|
||||||
FSCloseDir(fsClient, fsCmd, fd, -1);
|
FSCloseDir(fsClient, &fsCmd, fd, -1);
|
||||||
free(fsCmd);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
r->_errno = fs_translate_error(rc);
|
r->_errno = fs_translate_error(rc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -681,12 +660,11 @@ fs_unlink(struct _reent *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSRemove(fsClient, fsCmd, path_fix, -1);
|
rc = FSRemove(fsClient, &fsCmd, path_fix, -1);
|
||||||
free(path_fix);
|
free(path_fix);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -714,12 +692,11 @@ fs_chdir(struct _reent *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSChangeDir(fsClient, fsCmd, path, -1);
|
rc = FSChangeDir(fsClient, &fsCmd, path, -1);
|
||||||
free(path);
|
free(path);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -759,13 +736,12 @@ fs_rename(struct _reent *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSRename(fsClient, fsCmd, path_old, path_new, -1);
|
rc = FSRename(fsClient, &fsCmd, path_old, path_new, -1);
|
||||||
free(path_old);
|
free(path_old);
|
||||||
free(path_new);
|
free(path_new);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -794,13 +770,12 @@ fs_mkdir(struct _reent *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
// TODO: Use mode to set directory attributes.
|
// TODO: Use mode to set directory attributes.
|
||||||
rc = FSMakeDir(fsClient, fsCmd, path_fix, -1);
|
rc = FSMakeDir(fsClient, &fsCmd, path_fix, -1);
|
||||||
free(path_fix);
|
free(path_fix);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc == FS_ERROR_ALREADY_EXISTS) {
|
if (rc == FS_ERROR_ALREADY_EXISTS) {
|
||||||
r->_errno = EEXIST;
|
r->_errno = EEXIST;
|
||||||
@ -833,12 +808,11 @@ fs_diropen(struct _reent *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
fs_dir_t *dir = (fs_dir_t*)(dirState->dirStruct);
|
fs_dir_t *dir = (fs_dir_t*)(dirState->dirStruct);
|
||||||
rc = FSOpenDir(fsClient, fsCmd, path_fixed, &fd, -1);
|
rc = FSOpenDir(fsClient, &fsCmd, path_fixed, &fd, -1);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
dir->magic = FS_DIRITER_MAGIC;
|
dir->magic = FS_DIRITER_MAGIC;
|
||||||
@ -860,12 +834,11 @@ fs_dirreset(struct _reent *r,
|
|||||||
FSStatus rc;
|
FSStatus rc;
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
fs_dir_t *dir = (fs_dir_t*)(dirState->dirStruct);
|
fs_dir_t *dir = (fs_dir_t*)(dirState->dirStruct);
|
||||||
rc = FSRewindDir(fsClient, fsCmd, dir->fd, -1);
|
rc = FSRewindDir(fsClient, &fsCmd, dir->fd, -1);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -885,13 +858,12 @@ fs_dirnext(struct _reent *r,
|
|||||||
fs_dir_t *dir = (fs_dir_t*)(dirState->dirStruct);
|
fs_dir_t *dir = (fs_dir_t*)(dirState->dirStruct);
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
// Fetch the next dir
|
// Fetch the next dir
|
||||||
memset(&dir->entry_data, 0, sizeof(dir->entry_data));
|
memset(&dir->entry_data, 0, sizeof(dir->entry_data));
|
||||||
rc = FSReadDir(fsClient, fsCmd, dir->fd, &dir->entry_data, -1);
|
rc = FSReadDir(fsClient, &fsCmd, dir->fd, &dir->entry_data, -1);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
// There are no more entries; ENOENT signals end-of-directory
|
// There are no more entries; ENOENT signals end-of-directory
|
||||||
@ -931,12 +903,11 @@ fs_dirclose(struct _reent *r,
|
|||||||
FSStatus rc;
|
FSStatus rc;
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
fs_dir_t *dir = (fs_dir_t*)(dirState->dirStruct);
|
fs_dir_t *dir = (fs_dir_t*)(dirState->dirStruct);
|
||||||
rc = FSCloseDir(fsClient, fsCmd, dir->fd, -1);
|
rc = FSCloseDir(fsClient, &fsCmd, dir->fd, -1);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -982,19 +953,17 @@ fs_ftruncate(struct _reent *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
// Set the new file size
|
// Set the new file size
|
||||||
rc = FSSetPosFile(fsClient, fsCmd, file->fd, len, -1);
|
rc = FSSetPosFile(fsClient, &fsCmd, file->fd, len, -1);
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
free(fsCmd);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = FSTruncateFile(fsClient, fsCmd, file->fd, -1);
|
rc = FSTruncateFile(fsClient, &fsCmd, file->fd, -1);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -1012,11 +981,10 @@ fs_fsync(struct _reent *r,
|
|||||||
fs_file_t *file = (fs_file_t*)fd;
|
fs_file_t *file = (fs_file_t*)fd;
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSFlushFile(fsClient, fsCmd, file->fd, -1);
|
rc = FSFlushFile(fsClient, &fsCmd, file->fd, -1);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -1040,12 +1008,11 @@ fs_chmod(struct _reent *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSChangeMode(fsClient, fsCmd, path_fix, (FSMode)mode, -1);
|
rc = FSChangeMode(fsClient, &fsCmd, path_fix, (FSMode)mode, -1);
|
||||||
free(path_fix);
|
free(path_fix);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -1084,12 +1051,11 @@ fs_rmdir(struct _reent *r,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up command block
|
// Set up command block
|
||||||
FSCmdBlock* fsCmd = memalign(0x20, sizeof(FSCmdBlock));
|
FSCmdBlock fsCmd;
|
||||||
FSInitCmdBlock(fsCmd);
|
FSInitCmdBlock(&fsCmd);
|
||||||
|
|
||||||
rc = FSRemove(fsClient, fsCmd, path_fix, -1);
|
rc = FSRemove(fsClient, &fsCmd, path_fix, -1);
|
||||||
free(path_fix);
|
free(path_fix);
|
||||||
free(fsCmd);
|
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user