[cs631apue] whiteout files

Sadia Akhter sakhter at stevens.edu
Mon Oct 6 12:42:37 EDT 2014


Thanks for the advice. Now I'm using strmode(3) function, it solved the whiteout file issue.

-Sadia


On Oct 5, 2014, at 9:14 PM, Jan Schaumann <jschauma at stevens.edu> wrote:

> Sadia Akhter <sakhter at stevens.edu> wrote:
> 
>> found that "S_IFWHT" is defined in sys/stat.h of BSD systems and could
>> be used to check whether a file is whiteout file or not. But I did not
>> find this when I looked up the man page of "stat" in the linux lab
>> machines. So it turns out that I cannot use it in my program as it is
>> not defined.
> 
> You could have code that's ifdef'd to handle this case on systems where
> this is supported.
> 
> #ifdef S_ISWHT
> if (S_ISWHT(file.st_mode)) {
> 	/* white-out related code goes here */
> }
> #endif
> 
> On Linux, you will never trigger this code block, but by having a
> pre-processor directive conditionally including the code based on the
> definition, your code would do the right thing on a platform that _does_
> implement it.
> 
> (If you end up using strmode(3), you probably don't need to deal with
> this at all, I think.)
> 
> For what exactly a whiteout file is, refer to the idea of a "union file
> system" as explained in http://is.gd/09BfOy, for example.
> 
> -Jan



More information about the cs631apue mailing list