Re: man page update (fcntl(2) new set/get write hints)

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

 



On 08/28/2017 01:19 PM, Michael Kerrisk (man-pages) wrote:
> Hi Jens,
> 
> On 08/25/2017 10:55 PM, Jens Axboe wrote:
>> On 08/25/2017 02:51 PM, Michael Kerrisk (man-pages) wrote:
>>>>>>> Do you mean here "file descriptor" or "file description (i.e., the
>>>>>>> open file handle)? Maybe you mean the former, but I want to confirm.
>>>>>>
>>>>>> I do mean file descriptor.
>>>>>
>>>>> So, what are the semantics if a file descriptor is duplicated using
>>>>> dup(2) or similar? If I understand correctly, then the write lifetime
>>>>> hint has no effect for the new file descriptor, right?
>>>>
>>>> If it's dup(2)'ed, then the new file descriptor will refer to the same
>>>> hints as the previous. See attached test file.
>>>
>>> But then isn't this exactly the point I asked about: are the hints
>>> private to a file descriptor or are they associated with the open file
>>> description (open file table entry, "struct file")? You said "I do
>>> mean file descriptor", but actually I understand what you just said
>>> now as "hints are associated with the open file description, which may
>>> be referred to by multiple duplicated file descriptors". Can you
>>> clarify?
>>
>> You are right, I misunderstood your original question. They do follow
>> the file description. So the dup'ed one will return the same as the
>> original, even if the hints on the original fd get modified. That is the
>> expected behavior.
> 
> So, I am still confused. I was wondering whether the hints are 
> associated with the open file description (OFD), rather than the 
> file descriptor. You said yes, then say that the dup'ed file 
> descriptor will have the same hints even if the hints on the
> original file descriptor are modified. To me that sounds like:
> the hints are associated with the file descriptor, and not the
> OFD, and during dup(2) the hints are *copied* to the the new
> file descriptor, with the result that after the dup(2) the hints
> can be modified independently for the two file descriptors.
> 
> Can you clarify please?

No, that's not how it behaves. If you dup(2) the file descriptor, then
the dup'ed descriptor will return the same hint as was set on the
original.  If you change/clear the hint on the original, the dup'ed
descriptor will now return the new hint.


-- 
Jens Axboe

--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux