I am having troubles with elementary file handle functions in libhandle. A basic open_by_handle is giving "Bad file descriptor". But I am suspicious of a side effect; using path_to_fshandle earlier in the program changes these errors to "Operation not permitted". Is there a basic mistake in my use of these calls, or a bug/unmaintained code? I am on an XFS filesystem (otherwise the first call fails with 'inappropriate ioctl'). The only documentation I can find is the man page; no mention about initialising the library, and I wasn't able to find any examples. I'm on Scientific Linux 6.6 (like RedHat 6, kernel 2.6.32-504.1.3), and also tried updating to the latest xfsprogs from Git, with the same results. Many thanks -- Mark $ ./test-xfs ~/scratch/tmp/xfs/file.c; echo $? Handle 24 bytes: bd2c94ba959858e0000000870000000 readlink_by_handle: Bad file descriptor open_by_handle: Bad file descriptor 0 $ ./test-xfs ~/scratch/tmp/xfs/file.c; echo $? Handle 8 bytes: bd2c94ba959858 Handle 24 bytes: bd2c94ba959858e0000000870000000 readlink_by_handle: Operation not permitted open_by_handle: Operation not permitted 0 /* * xfs file handle test * * compile with: gcc -o test-xfs test-xfs.c -lhandle -Wall */ #include <fcntl.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <xfs/handle.h> static void dump(FILE *f, void *m, size_t len) { fprintf(f, "Handle %zu bytes: ", len); while (len--) { fprintf(f, "%hhx", *(unsigned char*)m); m++; } putchar('\n'); } int main(int argc, char *argv[]) { int fd; char *pathname; void *hanp = NULL; size_t hlen; char buf[PATH_MAX]; pathname = argv[1]; #if 0 /* * Switching this section on changes changes the * errors from the later calls */ if (path_to_fshandle(pathname, &hanp, &hlen) == -1) { perror("path_to_fshandle"); return -1; } dump(stderr, hanp, hlen); free_handle(hanp, hlen); #endif if (path_to_handle(pathname, &hanp, &hlen) == -1) { perror("path_to_handle"); return -1; } dump(stderr, hanp, hlen); /* * The above calls were successful, but the next part always * fails */ if (readlink_by_handle(hanp, hlen, buf, sizeof buf) == -1) perror("readlink_by_handle"); else printf("Link: %s\n", buf); fd = open_by_handle(hanp, hlen, O_RDONLY); if (fd == -1) { perror("open_by_handle"); } else { if (close(fd) == -1) abort(); } free_handle(hanp, hlen); return 0; } _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs