On Tue, 28 Nov 2000, Alexander Viro wrote:
> 
> And you don't want even that - as soon as we release files->file_lock
> the value becomes meaningless. So I'm rather suspicious about the
> correctness of intended use.
> 

Hi Alexander,

I am well aware of the need to take the file_lock. So, I am putting a code
like this into set_user():

       /* switch the open fds from old_user to new_user */
        read_lock(&files->file_lock);
        nr_open = close_files(files, 0); /* 0 means don't close them */
        atomic_sub(nr_open, &old_user->files);
        atomic_add(nr_open, &new_user->files);
        read_unlock(&files->file_lock);

(haven't tested yet -- just an idea -- kernel is still compiling as we
speak). This assumes the close_files() semantics I described in the
previous email. I also put the corresponding code into
get/__put_unused_fd() and also into put_files_struct(). Btw, the latter
happens to call close_files() anyway so as a bonus it gets the nr_open_fd
return and atomic_subs the p->user->files accordingly. If all this works
and I didn't miss some descriptor accounting somewhere then we'll have a
valid p->user->files support which is what I wanted.

Regards,
Tigran

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.tux.org/lkml/

Reply via email to