mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-31 14:38:21 +00:00
file: FDTABLE_LIMIT
This commit is contained in:
@@ -57,6 +57,9 @@ static int getfree(int start) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int growtable(int newcount) {
|
static int growtable(int newcount) {
|
||||||
|
if (newcount > FDTABLE_LIMIT)
|
||||||
|
return EMFILE;
|
||||||
|
|
||||||
proc_t *proc = _cpu()->thread->proc;
|
proc_t *proc = _cpu()->thread->proc;
|
||||||
__assert(newcount > proc->fdcount);
|
__assert(newcount > proc->fdcount);
|
||||||
void *newtable = realloc(proc->fd, sizeof(fd_t) * newcount);
|
void *newtable = realloc(proc->fd, sizeof(fd_t) * newcount);
|
||||||
@@ -184,6 +187,11 @@ int fd_dup(int oldfd, int newfd, bool exact, int fdflags, int *retfd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (exact) {
|
if (exact) {
|
||||||
|
if (newfd >= FDTABLE_LIMIT) {
|
||||||
|
err = EBADF;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
if (newfd >= proc->fdcount) {
|
if (newfd >= proc->fdcount) {
|
||||||
err = growtable(newfd + 1);
|
err = growtable(newfd + 1);
|
||||||
if (err)
|
if (err)
|
||||||
|
|||||||
@@ -63,4 +63,6 @@ static inline int fileflagstovnodeflags(int flags) {
|
|||||||
#define O_RSYNC 04010000
|
#define O_RSYNC 04010000
|
||||||
#define O_TMPFILE 020000000
|
#define O_TMPFILE 020000000
|
||||||
|
|
||||||
|
#define FDTABLE_LIMIT 256
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user