Re: [RFC v4][PATCH 9/9] File descriprtors (restore)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2008-09-09 at 21:49 -0400, Oren Laadan wrote:
> 
> Dave Hansen wrote:
> > On Tue, 2008-09-09 at 03:42 -0400, Oren Laadan wrote:
> >> +static int cr_close_all_fds(struct files_struct *files)
> >> +{
> >> +       int *fdtable;
> >> +       int n;
> >> +
> >> +       do {
> >> +               n = cr_scan_fds(files, &fdtable);
> >> +               if (n < 0)
> >> +                       return n;
> >> +               while (n--)
> >> +                       sys_close(fdtable[n]);
> >> +               kfree(fdtable);
> >> +       } while (n != -1);
> >> +
> >> +       return 0;
> >> +}
> > 
> > This needs to use an ERR_PTR().  It will save using the double-pointer.
> 
> I suppose you refer to the call to cr_scan_fds(): either 'fdtable'
> or 'n' will have to pass-by-reference. Is it that you prefer it to be
> 	fdtable = cr_scan_fds(files, &n);
> ?

I was misreading the use of 'n'.  Can you really not use close_files()
for this operation?  You'd need to add some locking around it, but I
think it does what you need here.

-- Dave

_______________________________________________
Containers mailing list
Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/containers

[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux