tags 366487 fixed-upstream
thanks

Paul,

> The man page for ftruncate(2) says:
> 
>      If the file previously was shorter, it is extended,
> 
> However this is not always true.  The glibc documentation says:
>      
>      The POSIX standard leaves it implementation defined what happens
>      if the specified new LENGTH of the file is bigger than the
>      original size.  The `ftruncate' function might simply leave the
>      file alone and do nothing

Yes.  But did you see the NOTES section in the man page:

   NOTES
       The above description is  for  XSI-compliant  systems.
       For  non-XSI-compliant  systems,  the  POSIX  standard
       allows two  behaviours  for  ftruncate()  when  length
       exceeds  the  file length (note that truncate() is not
       specified at  all  in  such  an  environment):  either
       returning  an  error,  or  extending  the file.  (Most
       Unices follow the XSI requirement.)

I've now reworded this a little in the light of the specific
example you mention:

   NOTES
       The above description is  for  XSI-compliant  systems.
       For  non-XSI-compliant  systems,  the  POSIX  standard
       allows two  behaviours  for  ftruncate()  when  length
       exceeds  the  file length (note that truncate() is not
       specified at  all  in  such  an  environment):  either
       returning  an error, or extending the file.  Like most
       Unix implementations, Linux follows the  XSI  require‐
       ment  when dealing with native file systems.  However,
       some non-native file systems do not permit  truncate()
       and ftruncate() to be used to extend a file beyond its
       current length: a notable example on Linux is VFAT.

By the way, the way, I'm puzzled that this limitation exists,
since VFAT does let us do things like lseek() way past EOF
and then writing, which is analogous to using [f]truncate()
to extend a file.

> Empirical evidence shows that Linux returns EPERM and leaves the file
> unchanged when trying to extend files on a vfat filesystem.

Yep, I've replicated this on SUSE 10 (kernel 2.6.13).

I added the following error text for EPERM:

       EPERM  The  underlying  file  system  does not support
              extending a file beyond its current size.

The new text will be in man-pages-2.32.

Thanks for your report.

Cheers,

Michael

-- 
Michael Kerrisk
maintainer of Linux man pages Sections 2, 3, 4, 5, and 7 

Want to help with man page maintenance?  
Grab the latest tarball at
ftp://ftp.win.tue.nl/pub/linux-local/manpages/, 
read the HOWTOHELP file and grep the source 
files for 'FIXME'.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to