Re: [PATCH] fs: add FD_CLOFORK and O_CLOFORK

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

 



On Sat, May 7, 2011 at 2:06 PM, Eric Dumazet <eric.dumazet@xxxxxxxxx> wrote:
> Le samedi 07 mai 2011 à 12:49 +0800, Changli Gao a écrit :
>
>>
>>       for (i = open_files; i != 0; i--) {
>>               struct file *f = *old_fds++;
>>               if (f) {
>> -                     get_file(f);
>> +                     if (FD_ISSET(open_files - i, new_fdt->close_on_fork)) {
>> +                             FD_CLR(open_files - i, new_fdt->open_fds);
>> +                             f = NULL;
>> +                     } else {
>> +                             get_file(f);
>> +                     }
>>               } else {
>>                       /*
>
> You should change the main loop to
>
> for (i = 0; i < open_files; i++) {
>        struct file *f = *old_fds++;
>
>        if (f && FD_ISSET(i, new_fdt->close_on_fork))
>                f = NULL;
>        if (f)
>                get_file(f);
>        else
>                FD_CLR(i, new_fdt->open_fds)
>        rcu_assign_pointer(*new_fds++, f);
> }

It seems more clear. Thanks.

BTW: I will work on F_CLOSFD after this patch accepted. It is useful
to close all the opened file descriptors when programing a daemon.

-- 
Regards,
Changli Gao(xiaosuo@xxxxxxxxx)
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux