Donny9 commented on code in PR #16499: URL: https://github.com/apache/nuttx/pull/16499#discussion_r2135887625
########## fs/inode/fs_files.c: ########## @@ -177,38 +148,97 @@ static int files_extend(FAR struct filelist *list, size_t row) for (j = orig_rows; j < i; j++) { - fs_heap_free(files[j]); + fs_heap_free(fds[j]); } - fs_heap_free(files); + fs_heap_free(fds); return OK; } - if (list->fl_files != NULL) + if (list->fl_fds != NULL) { - memcpy(files, list->fl_files, - list->fl_rows * sizeof(FAR struct file *)); + memcpy(fds, list->fl_fds, list->fl_rows * sizeof(FAR struct fd *)); } - tmp = list->fl_files; - list->fl_files = files; + tmp = list->fl_fds; + list->fl_fds = fds; list->fl_rows = row; spin_unlock_irqrestore_notrace(&list->fl_lock, flags); - if (tmp != NULL && tmp != &list->fl_prefile) + if (tmp != NULL && tmp != &list->fl_prefd) { fs_heap_free(tmp); } return OK; } +/**************************************************************************** + * Name: fdlist_uninstall + ****************************************************************************/ + +static void fdlist_uninstall(FAR struct fdlist *list, FAR struct fd *fdp) +{ + FAR struct file *filep = NULL; + irqstate_t flags; + + flags = spin_lock_irqsave_notrace(&list->fl_lock); + + /* There is a race condition here: someone might have freed and installed Review Comment: Done~ ########## fs/vfs/fs_fcntl.c: ########## @@ -347,23 +282,95 @@ int fcntl(int fd, int cmd, ...) va_start(ap, cmd); - /* Get the file structure corresponding to the file descriptor. */ - - ret = file_get(fd, &filep); - if (ret >= 0) + switch (cmd) { - /* Let file_vfcntl() do the real work. The errno is not set on - * failures. - */ + case F_DUPFD: + /* Return a new file descriptor which shall be the lowest numbered + * available (that is, not already open) file descriptor greater than + * or equal to the third argument, arg, taken as an integer of type + * int. The new file descriptor shall refer to the same open file + * description as the original file descriptor, and shall share any + * locks. The FD_CLOEXEC flag associated with the new file + * descriptor shall be cleared to keep the file open across calls to + * one of the exec functions. + */ - ret = file_vfcntl(filep, cmd, ap); - file_put(filep); - } + { + ret = dup3(fd, va_arg(ap, int), 0); Review Comment: Done ~ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org