home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / kernel-s / ifs-5.1 / ifsprogs / unwo.c < prev   
C/C++ Source or Header  |  1995-10-10  |  671b  |  42 lines

  1. /* unwo.c  -  unwhiteout files on a mounted IFS file system */
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <unistd.h>
  6. #include <fcntl.h>
  7. #include <sys/ioctl.h>
  8. #include <linux/ifs_fs.h>
  9.  
  10.  
  11. static void unwhiteout(char *path)
  12. {
  13.     char *here,*dir,*file;
  14.     int fd;
  15.  
  16.     if (here = strrchr(path,'/')) {
  17.     *here = 0;
  18.     dir = path;
  19.     file = here+1;
  20.     }
  21.     else {
  22.     dir = ".";
  23.     file = path;
  24.     }
  25.     if ((fd = open(dir,O_RDONLY)) < 0) {
  26.     perror(dir);
  27.     return;
  28.     }
  29.     if (ioctl(fd,IFS_UNWHITEOUT,file) < 0) {
  30.     if (here) *here = '/';
  31.     perror(path);
  32.     }
  33.     (void) close(fd);
  34. }
  35.  
  36.  
  37. int main(int argc,char **argv)
  38. {
  39.     while (--argc) unwhiteout(*++argv);
  40.     return 0;
  41. }
  42.