[cs631apue] whiteout files

Jan Schaumann jschauma at stevens.edu
Sun Oct 5 21:14:47 EDT 2014


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