Skip to content

Commit 1419449

Browse files
committed
devoptab: stubs that only return ENOSYS are redundant, remove them
See https://github.com/devkitPro/buildscripts/blob/devkitARM_r66/dkarm-eabi/patches/newlib-4.5.0.20241231.patch for details
1 parent 7cef9c7 commit 1419449

File tree

2 files changed

+6
-148
lines changed

2 files changed

+6
-148
lines changed

libctru/source/archive_dev.c

Lines changed: 5 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,15 @@ static ssize_t archive_read(struct _reent *r, void *fd, char *ptr, size_t len)
3232
static off_t archive_seek(struct _reent *r, void *fd, off_t pos, int dir);
3333
static int archive_fstat(struct _reent *r, void *fd, struct stat *st);
3434
static int archive_stat(struct _reent *r, const char *file, struct stat *st);
35-
static int archive_link(struct _reent *r, const char *existing, const char *newLink);
3635
static int archive_unlink(struct _reent *r, const char *name);
3736
static int archive_chdir(struct _reent *r, const char *name);
3837
static int archive_rename(struct _reent *r, const char *oldName, const char *newName);
3938
static int archive_mkdir(struct _reent *r, const char *path, int mode);
4039
static DIR_ITER* archive_diropen(struct _reent *r, DIR_ITER *dirState, const char *path);
41-
static int archive_dirreset(struct _reent *r, DIR_ITER *dirState);
4240
static int archive_dirnext(struct _reent *r, DIR_ITER *dirState, char *filename, struct stat *filestat);
4341
static int archive_dirclose(struct _reent *r, DIR_ITER *dirState);
44-
static int archive_statvfs(struct _reent *r, const char *path, struct statvfs *buf);
4542
static int archive_ftruncate(struct _reent *r, void *fd, off_t len);
4643
static int archive_fsync(struct _reent *r, void *fd);
47-
static int archive_chmod(struct _reent *r, const char *path, mode_t mode);
48-
static int archive_fchmod(struct _reent *r, void *fd, mode_t mode);
4944
static int archive_rmdir(struct _reent *r, const char *name);
5045

5146
/// Used for only the SD archive, about which information can actually be found
@@ -75,22 +70,22 @@ archive_devoptab =
7570
.fstat_r = archive_fstat,
7671
.stat_r = archive_stat,
7772
.lstat_r = archive_stat,
78-
.link_r = archive_link,
73+
.link_r = NULL,
7974
.unlink_r = archive_unlink,
8075
.chdir_r = archive_chdir,
8176
.rename_r = archive_rename,
8277
.mkdir_r = archive_mkdir,
8378
.dirStateSize = sizeof(archive_dir_t),
8479
.diropen_r = archive_diropen,
85-
.dirreset_r = archive_dirreset,
80+
.dirreset_r = NULL,
8681
.dirnext_r = archive_dirnext,
8782
.dirclose_r = archive_dirclose,
88-
.statvfs_r = archive_statvfs,
83+
.statvfs_r = NULL,
8984
.ftruncate_r = archive_ftruncate,
9085
.fsync_r = archive_fsync,
9186
.deviceData = 0,
92-
.chmod_r = archive_chmod,
93-
.fchmod_r = archive_fchmod,
87+
.chmod_r = NULL,
88+
.fchmod_r = NULL,
9489
.rmdir_r = archive_rmdir,
9590
};
9691

@@ -856,24 +851,6 @@ archive_stat(struct _reent *r,
856851
return -1;
857852
}
858853

859-
/*! Hard link a file
860-
*
861-
* @param[in,out] r newlib reentrancy struct
862-
* @param[in] existing Path of file to link
863-
* @param[in] newLink Path of new link
864-
*
865-
* @returns 0 for success
866-
* @returns -1 for error
867-
*/
868-
static int
869-
archive_link(struct _reent *r,
870-
const char *existing,
871-
const char *newLink)
872-
{
873-
r->_errno = ENOSYS;
874-
return -1;
875-
}
876-
877854
/*! Unlink a file
878855
*
879856
* @param[in,out] r newlib reentrancy struct
@@ -1097,22 +1074,6 @@ archive_diropen(struct _reent *r,
10971074
return NULL;
10981075
}
10991076

1100-
/*! Reset an open directory to its intial state
1101-
*
1102-
* @param[in,out] r newlib reentrancy struct
1103-
* @param[in] dirState Pointer to open directory state
1104-
*
1105-
* @returns 0 for success
1106-
* @returns -1 for error
1107-
*/
1108-
static int
1109-
archive_dirreset(struct _reent *r,
1110-
DIR_ITER *dirState)
1111-
{
1112-
r->_errno = ENOSYS;
1113-
return -1;
1114-
}
1115-
11161077
/*! Fetch the next entry of an open directory
11171078
*
11181079
* @param[in,out] r newlib reentrancy struct
@@ -1226,61 +1187,6 @@ archive_dirclose(struct _reent *r,
12261187
return -1;
12271188
}
12281189

1229-
/*! Get filesystem statistics for an archive
1230-
*
1231-
* @param[in,out] r newlib reentrancy struct
1232-
* @param[in] path Path to filesystem to get statistics of
1233-
* @param[out] buf Buffer to fill
1234-
*
1235-
* @returns 0 for success
1236-
* @returns -1 for error
1237-
*/
1238-
static int
1239-
archive_statvfs(struct _reent *r,
1240-
const char *path,
1241-
struct statvfs *buf)
1242-
{
1243-
// Result rc;
1244-
// u32 totalSize, directories, files;
1245-
// bool duplicateData;
1246-
1247-
// rc = FSUSER_GetFormatInfo(&totalSize, &directories, &files, &duplicateData, )
1248-
1249-
r->_errno = ENOSYS;
1250-
1251-
return -1;
1252-
1253-
// Result rc;
1254-
// FS_ArchiveResource resource;
1255-
// bool writable = false;
1256-
1257-
// rc = FSUSER_GetArchiveResource(&resource);
1258-
1259-
// if(R_SUCCEEDED(rc))
1260-
// {
1261-
// buf->f_bsize = resource.clusterSize;
1262-
// buf->f_frsize = resource.clusterSize;
1263-
// buf->f_blocks = resource.totalClusters;
1264-
// buf->f_bfree = resource.freeClusters;
1265-
// buf->f_bavail = resource.freeClusters;
1266-
// buf->f_files = 0; //??? how to get
1267-
// buf->f_ffree = resource.freeClusters;
1268-
// buf->f_favail = resource.freeClusters;
1269-
// buf->f_fsid = 0; //??? how to get
1270-
// buf->f_flag = ST_NOSUID;
1271-
// buf->f_namemax = 0; //??? how to get
1272-
1273-
// rc = FSUSER_IsarchiveWritable(&writable);
1274-
// if(R_FAILED(rc) || !writable)
1275-
// buf->f_flag |= ST_RDONLY;
1276-
1277-
// return 0;
1278-
// }
1279-
1280-
// r->_errno = archive_translate_error(rc);
1281-
// return -1;
1282-
}
1283-
12841190
/*! Get filesystem statistics for the SD card
12851191
*
12861192
* @param[in,out] r newlib reentrancy struct
@@ -1386,42 +1292,6 @@ archive_fsync(struct _reent *r,
13861292
return -1;
13871293
}
13881294

1389-
/*! Change a file's mode
1390-
*
1391-
* @param[in,out] r newlib reentrancy struct
1392-
* @param[in] path Path to file to update
1393-
* @param[in] mode New mode to set
1394-
*
1395-
* @returns 0 for success
1396-
* @returns -1 for error
1397-
*/
1398-
static int
1399-
archive_chmod(struct _reent *r,
1400-
const char *path,
1401-
mode_t mode)
1402-
{
1403-
r->_errno = ENOSYS;
1404-
return -1;
1405-
}
1406-
1407-
/*! Change an open file's mode
1408-
*
1409-
* @param[in,out] r newlib reentrancy struct
1410-
* @param[in] fd Pointer to archive_file_t
1411-
* @param[in] mode New mode to set
1412-
*
1413-
* @returns 0 for success
1414-
* @returns -1 for failure
1415-
*/
1416-
static int
1417-
archive_fchmod(struct _reent *r,
1418-
void *fd,
1419-
mode_t mode)
1420-
{
1421-
r->_errno = ENOSYS;
1422-
return -1;
1423-
}
1424-
14251295
/*! Remove a directory
14261296
*
14271297
* @param[in,out] r newlib reentrancy struct

libctru/source/services/soc/soc_init.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <sys/socket.h>
44
#include <3ds/ipc.h>
55

6-
static int soc_open(struct _reent *r, void *fileStruct, const char *path, int flags, int mode);
76
static int soc_close(struct _reent *r, void *fd);
87
static ssize_t soc_write(struct _reent *r, void *fd, const char *ptr, size_t len);
98
static ssize_t soc_read(struct _reent *r, void *fd, char *ptr, size_t len);
@@ -13,7 +12,7 @@ soc_devoptab =
1312
{
1413
.name = "soc",
1514
.structSize = sizeof(Handle),
16-
.open_r = soc_open,
15+
.open_r = NULL,
1716
.close_r = soc_close,
1817
.write_r = soc_write,
1918
.read_r = soc_read,
@@ -138,17 +137,6 @@ Result socExit(void)
138137
return ret;
139138
}
140139

141-
static int
142-
soc_open(struct _reent *r,
143-
void *fileStruct,
144-
const char *path,
145-
int flags,
146-
int mode)
147-
{
148-
r->_errno = ENOSYS;
149-
return -1;
150-
}
151-
152140
static int
153141
soc_close(struct _reent *r,
154142
void *fd)

0 commit comments

Comments
 (0)