auplink.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (C) 2005-2009 Junjiro Okajima
  3. *
  4. * This program, aufs is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <unistd.h>
  22. #include "au_util.h"
  23. static void usage(char *me)
  24. {
  25. fprintf(stderr,
  26. "usage: %s aufs_mount_point list|cpup|flush\n"
  27. "'list' shows the pseudo-linked inode numbers and filenames.\n"
  28. "'cpup' copies-up all pseudo-link to the writeble branch.\n"
  29. "'flush' calls 'cpup', and then 'mount -o remount,clean_plink=inum'\n"
  30. "and remove the whiteouted plink.\n", me);
  31. exit(EINVAL);
  32. }
  33. int main(int argc, char *argv[])
  34. {
  35. int err, cmd;
  36. char *cwd;
  37. if (argc != 3)
  38. usage(argv[0]);
  39. if (!strcmp(argv[2], "flush"))
  40. cmd = AuPlink_FLUSH;
  41. else if (!strcmp(argv[2], "list"))
  42. cmd = AuPlink_LIST;
  43. else if (!strcmp(argv[2], "cpup"))
  44. cmd = AuPlink_CPUP;
  45. else {
  46. errno = EINVAL;
  47. AuFin("%s", argv[2]);
  48. cmd = 0; /* never reach here */
  49. }
  50. err = chdir(argv[1]);
  51. if (err)
  52. AuFin("chdir");
  53. cwd = getcwd(NULL, 0); /* glibc */
  54. if (!cwd)
  55. AuFin("getcwd");
  56. return au_plink(cwd, cmd, 1, 0);
  57. }