Reputation: 57
Having a little problem with the stat()
system call on Solaris 10. I'm doing FTP and at the same time, calling stat
(to check on file size) on files that are being written to concurrently through FTP.
Let's assume that files are being written to a directory while a stat()
command/call is being called (in parallel). Then would the result of st_size
in the struct
be 0?
Or would the stat
call reflect the current size of the file while FTP is happening?
Is FTP as transactional as I think it is?
Upvotes: 1
Views: 452
Reputation: 18410
The stat()
-call would show you the same as ls
, since ls
uses stat()
(or a similar function from this family) to show the file size and attributes.
So, for all common filesystems, stat()
would return the current filesize, which will usually constantly grow during the ftp put transaction.
However, an FTP-Server (or even an FTP-client) might choose to create an empty file of the requested target name, write the actual data to a temporary file and rename this file to the real file name after the transfer completed. In this case, stat()
would return size 0. But this is not the usual way it happens.
Upvotes: 1