2 * Copyright (c) 2005 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would 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 the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <sys/types.h>
26 #include <sys/attributes.h>
27 #include <sys/fs/xfs_itable.h>
30 #define ATTR_PARENT 0x0040
33 #define EA_LISTBUF_SZ 16384
36 main(int argc, char *argv[])
43 attrlist_cursor_t cursor;
44 attrlist_t *ea_listbuf = (attrlist_t *)malloc(EA_LISTBUF_SZ);
52 fprintf(stderr, "%s: missing pathname argument\n", prog);
58 fprintf(stderr, "%s: too many arguments\n", prog);
62 /* if file already exists then error out */
63 if (access(path, F_OK) == 0) {
64 fprintf(stderr, "%s: file \"%s\" already exists\n", prog, path);
68 fd = open(path, O_RDWR|O_CREAT|O_EXCL);
70 fprintf(stderr, "%s: failed to create \"%s\": %s\n", prog, path, strerror(errno));
75 /* for linux libhandle version - to set libhandle fsfd cache */
80 if (path_to_fshandle(path, &fshandle, &fshlen) != 0) {
81 fprintf(stderr, "%s: failed path_to_fshandle \"%s\": %s\n",
82 prog, path, strerror(errno));
89 * look at parentptr EAs and see if the path exists now that
90 * it has been unlinked.
92 if (fd_to_handle(fd, &handle, &hlen) != 0) {
93 fprintf(stderr, "%s: failed to fd_to_handle \"%s\": %s\n",
94 prog, path, strerror(errno));
98 if (unlink(path) == -1) {
99 fprintf(stderr, "%s: failed to unlink \"%s\": %s\n", prog, path, strerror(errno));
103 memset(&cursor, 0, sizeof(cursor));
105 /* just do one call - don't bother with continue logic */
106 sts = attr_list_by_handle(handle,
113 fprintf(stderr, "%s: failed to list attr for \"%s\": %s\n", prog, path, strerror(errno));
117 printf("ea count = %d\n", ea_listbuf->al_count);
122 for (nameix = 0; nameix < ea_listbuf->al_count; nameix++) {
123 entp = ATTR_ENTRY(ea_listbuf, nameix);
125 sts = sscanf(entp->a_name, "%llx %llx", &parent_ino, &link_cnt);
128 "inode-path for \"%s\" is corrupted\n",
131 /* go onto next EA name */
134 /* just print the info out */
135 printf("[%d] parent_ino = %llu, link_cnt = %llu\n", nameix, parent_ino, link_cnt);
139 free_handle(handle, hlen);
141 if (close(fd) == -1) {
142 fprintf(stderr, "%s: failed to close \"%s\": %s\n", prog, path, strerror(errno));