2 * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
33 * Create a file given path argument and then unlink it but
35 * Then do an attr_list for parentptrs. (supported on IRIX)
43 #include <sys/types.h>
46 #include <sys/attributes.h>
47 #include <sys/fs/xfs_itable.h>
50 #define ATTR_PARENT 0x0040
53 #define EA_LISTBUF_SZ 16384
56 main(int argc, char *argv[])
63 attrlist_cursor_t cursor;
64 attrlist_t *ea_listbuf = (attrlist_t *)malloc(EA_LISTBUF_SZ);
72 fprintf(stderr, "%s: missing pathname argument\n", prog);
78 fprintf(stderr, "%s: too many arguments\n", prog);
82 /* if file already exists then error out */
83 if (access(path, F_OK) == 0) {
84 fprintf(stderr, "%s: file \"%s\" already exists\n", prog, path);
88 fd = open(path, O_RDWR|O_CREAT|O_EXCL);
90 fprintf(stderr, "%s: failed to create \"%s\": %s\n", prog, path, strerror(errno));
95 /* for linux libhandle version - to set libhandle fsfd cache */
100 if (path_to_fshandle(path, &fshandle, &fshlen) != 0) {
101 fprintf(stderr, "%s: failed path_to_fshandle \"%s\": %s\n",
102 prog, path, strerror(errno));
109 * look at parentptr EAs and see if the path exists now that
110 * it has been unlinked.
112 if (fd_to_handle(fd, &handle, &hlen) != 0) {
113 fprintf(stderr, "%s: failed to fd_to_handle \"%s\": %s\n",
114 prog, path, strerror(errno));
118 if (unlink(path) == -1) {
119 fprintf(stderr, "%s: failed to unlink \"%s\": %s\n", prog, path, strerror(errno));
123 memset(&cursor, 0, sizeof(cursor));
125 /* just do one call - don't bother with continue logic */
126 sts = attr_list_by_handle(handle,
133 fprintf(stderr, "%s: failed to list attr for \"%s\": %s\n", prog, path, strerror(errno));
137 printf("ea count = %d\n", ea_listbuf->al_count);
142 for (nameix = 0; nameix < ea_listbuf->al_count; nameix++) {
143 entp = ATTR_ENTRY(ea_listbuf, nameix);
145 sts = sscanf(entp->a_name, "%llx %llx", &parent_ino, &link_cnt);
148 "inode-path for \"%s\" is corrupted\n",
151 /* go onto next EA name */
154 /* just print the info out */
155 printf("[%d] parent_ino = %llu, link_cnt = %llu\n", nameix, parent_ino, link_cnt);
159 free_handle(handle, hlen);
161 if (close(fd) == -1) {
162 fprintf(stderr, "%s: failed to close \"%s\": %s\n", prog, path, strerror(errno));