Beispiel #1
0
main(int ac, char **av)
{
    char *part;
    int volid;
    int p1, p2, p3, p4;
    IHandle_t lh, *lhp;
    Inode ino;

    if (ac != 7)
	Usage();

    part = av[1];
    volid = atoi(av[2]);
    p1 = atoi(av[3]);
    p2 = atoi(av[4]);
    p3 = atoi(av[5]);
    p4 = atoi(av[6]);

    if (p2 == -1 && p3 == VI_LINKTABLE)
	lhp = NULL;
    else {
	lhp = GetLinkHandle(part, volid);
	if (!lhp) {
	    perror("Getting link handle.\n");
	    exit(1);
	}
    }

    ino = namei_icreate(lhp, part, p1, p2, p3, p4);
    if (!VALID_INO(ino)) {
	perror("namei_icreate");
    } else {
	printf("Returned inode %s\n", PrintInode(NULL, ino));
    }
}
Beispiel #2
0
main(int ac, char **av)
{
    char *part;
    int volid;
    Inode ino;
    Inode vno;
    Inode tag;
    Inode uniq;
    int code;
    IHandle_t *lh;
    int do_inc = -1;
    char *incdecarg;
    int i;


    if (ac < 5)
	Usage();

    part = av[1];
    volid = atoi(av[2]);

    i = 4;
    if (!strcmp(av[3], "-i")) {
	code = sscanf(av[i++], "%Lu", &ino);
	if (code != 1) {
	    printf("Failed to get inode from %s\n", av[4]);
	    exit(1);
	}
    } else if (!strcmp(av[3], "-v")) {
	vno = (int64_t) atoi(av[i++]);
	vno &= 0x3ffffff;
	tag = (int64_t) atoi(av[i++]);
	uniq = (int64_t) atoi(av[i++]);
	ino = uniq;
	ino |= tag << 32;
	ino |= vno << 35;
	printf("ino=%Lu\n", ino);
    } else {
	printf("Expected \"-i\" or \"-v\" for inode value\n");
	Usage();
    }

    incdecarg = av[i++];
    if (!strcmp(incdecarg, "dec"))
	do_inc = 0;
    else if (!strcmp(incdecarg, "inc"))
	do_inc = 1;
    else {
	printf("%s: Expected \"inc\" or \"dec\"\n", incdecarg);
	Usage();
    }


    lh = GetLinkHandle(part, volid);
    if (!lh) {
	printf("Failed to get link handle, exiting\n");
	exit(1);
    }

    if (do_inc)
	code = namei_inc(lh, ino, volid);
    else
	code = namei_dec(lh, ino, volid);

    printf("namei_%s returned %d\n", do_inc ? "inc" : "dec", code);

    exit(0);

}