On Mon, Apr 24, 2023 at 01:35:03PM -0700, Linus Torvalds wrote: > On Mon, Apr 24, 2023 at 1:24 PM Linus Torvalds > <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote: > > > > But I really think a potentially much nicer model would have been to > > extend our "get_unused_fd_flags()" model. > > > > IOW, we could have instead marked the 'struct file *' in the file > > descriptor table as being "not ready yet". > > Maybe that isn't worth it just for pdfd, but I have this feeling that > it might make some other code simpler too. > > That pidfd case isn't the only one that has to carry both a file > pointer and a fd around. > > Looking around, I get the feeling that quite a lot of users of > "fd_install()" might actually have been happier if they could just > install it early, and then just have a "fd_expose(fd)" for the success > case, and for the error cases have "put_unused_fd(fd)" also do the > fput on the file descriptor even if the low bit was set. One less > thing to worry about. > > I dunno. Maybe not worth it. That "two return values" just made me go "Eww". I'm not fond of "two return values" - in C at least - as well I think open-coding get_unused_fd() is pretty nasty as well... Let me see...