Skip to contentSkip to conversation

Redundant syscalls?

DISCUSSION Lorenzo Allegrucci 3 participants 3 messages Feb 15, 2002

lore
Share & tools
lore
#0 lore raw

I was wondering why do we need fsetxattr(2), fgetxattr(2) etc when we already have setxattr(2), getxattr(2) etc working on file names instead of file descriptors.
truncate(2)/ftruncate(2) is another more traditional example.

Thanks

#1 lore raw
Quoted 4 lines · Lorenzo Allegrucci

I was wondering why do we need fsetxattr(2), fgetxattr(2) etc when we already have setxattr(2), getxattr(2) etc working on file names instead of file descriptors.
truncate(2)/ftruncate(2) is another more traditional example.

Because you can't reliably derive a file name from an open file descriptor, so it's useful to have a way to act on the file directly through the descriptor.

-Doug

Signature · 2 lines
Let us cross over the river, and rest under the shade of the trees.
   --T. J. Jackson, 1863
#2 lore raw
In reply to Lorenzo Allegrucci

--------- Received message begins Here ---------

Quoted 6 lines

I was wondering why do we need fsetxattr(2), fgetxattr(2) etc when we already have setxattr(2), getxattr(2) etc working on file names instead of file descriptors.
truncate(2)/ftruncate(2) is another more traditional example.

Atomic actions.

Consider the case of a file that doesn't exist yet. first you open it, then perform the fsetxattr. If you use the name, then it becomes possible to rename the file and substitute a different one before the setxattr. Now, the open file will be missing the attribute(s).
-------------------------------------------------------------------------
Jesse I Pollard, II
Email: [email protected]

Any opinions expressed are solely my own.