change set_return_on_destroy tool to take a fshandle

This commit is contained in:
Dean Roehrich
2002-01-22 19:05:08 +00:00
parent 35975de1ce
commit 7dec550348
+23 -4
View File
@@ -40,13 +40,15 @@
Test program used to test the DMAPI function dm_set_return_on_destroy(). The Test program used to test the DMAPI function dm_set_return_on_destroy(). The
command line is: command line is:
set_return_on_destroy [-s sid] pathname [attr] set_return_on_destroy [-F] [-s sid] {pathname|fshandle} [attr]
where pathname is the name of a file which resides in the filesystem of where pathname is the name of a file which resides in the filesystem of
interest. attr is the name of the DMAPI attribute; if none is specified, interest. attr is the name of the DMAPI attribute; if none is specified,
then set-return-on-destroy will be disabled for the filesystem. then set-return-on-destroy will be disabled for the filesystem.
sid is the session ID whose attribute you are interested in setting. sid is the session ID whose attribute you are interested in setting.
Use -F if you want the program to find the fshandle based on the pathname.
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
#ifndef linux #ifndef linux
@@ -61,7 +63,7 @@ char *Progname;
static void static void
usage(void) usage(void)
{ {
fprintf(stderr, "usage:\t%s [-s sid] pathname [attr]\n", Progname); fprintf(stderr, "usage:\t%s [-F] [-s sid] {pathname|fshandle} [attr]\n", Progname);
exit(1); exit(1);
} }
@@ -79,6 +81,7 @@ main(
size_t hlen; size_t hlen;
char *name; char *name;
int opt; int opt;
int Fflag = 0;
if (Progname = strrchr(argv[0], '/')) { if (Progname = strrchr(argv[0], '/')) {
Progname++; Progname++;
@@ -88,11 +91,14 @@ main(
/* Crack and validate the command line options. */ /* Crack and validate the command line options. */
while ((opt = getopt(argc, argv, "s:")) != EOF) { while ((opt = getopt(argc, argv, "Fs:")) != EOF) {
switch (opt) { switch (opt) {
case 's': case 's':
sid = atol(optarg); sid = atol(optarg);
break; break;
case 'F':
Fflag++;
break;
case '?': case '?':
usage(); usage();
} }
@@ -112,13 +118,26 @@ main(
if (sid == DM_NO_SESSION) if (sid == DM_NO_SESSION)
find_test_session(&sid); find_test_session(&sid);
if (opaque_to_handle(pathname, &hanp, &hlen)) {
fprintf(stderr, "can't get handle for %s\n", pathname);
exit(1);
}
/* Get the file's handle. */ /* Get the file's handle. */
if (dm_path_to_fshandle(pathname, &hanp, &hlen)) { if (Fflag) {
void *fshanp;
size_t fshlen;
if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
fprintf(stderr, "can't get filesystem handle for file %s, %s\n", fprintf(stderr, "can't get filesystem handle for file %s, %s\n",
pathname, strerror(errno)); pathname, strerror(errno));
exit(1); exit(1);
} }
dm_handle_free(hanp, hlen);
hanp = fshanp;
hlen = fshlen;
}
if (dm_set_return_on_destroy(sid, hanp, hlen, DM_NO_TOKEN, if (dm_set_return_on_destroy(sid, hanp, hlen, DM_NO_TOKEN,
attrnamep, enable)) { attrnamep, enable)) {