new package aufs2-util
[openadk.git] / package / aufs2-util / src / auplink.c
blob1b48bea516c4e3364f013b0f4f3f4af4611d508a
1 /*
2 * Copyright (C) 2005-2009 Junjiro Okajima
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.
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.
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
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <unistd.h>
24 #include "au_util.h"
26 static void usage(char *me)
28 fprintf(stderr,
29 "usage: %s aufs_mount_point list|cpup|flush\n"
30 "'list' shows the pseudo-linked inode numbers and filenames.\n"
31 "'cpup' copies-up all pseudo-link to the writeble branch.\n"
32 "'flush' calls 'cpup', and then 'mount -o remount,clean_plink=inum'\n"
33 "and remove the whiteouted plink.\n", me);
34 exit(EINVAL);
37 int main(int argc, char *argv[])
39 int err, cmd;
40 char *cwd;
42 if (argc != 3)
43 usage(argv[0]);
45 if (!strcmp(argv[2], "flush"))
46 cmd = AuPlink_FLUSH;
47 else if (!strcmp(argv[2], "list"))
48 cmd = AuPlink_LIST;
49 else if (!strcmp(argv[2], "cpup"))
50 cmd = AuPlink_CPUP;
51 else {
52 errno = EINVAL;
53 AuFin("%s", argv[2]);
54 cmd = 0; /* never reach here */
57 err = chdir(argv[1]);
58 if (err)
59 AuFin("chdir");
60 cwd = getcwd(NULL, 0); /* glibc */
61 if (!cwd)
62 AuFin("getcwd");
63 return au_plink(cwd, cmd, 1, 0);