mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
change set_return_on_destroy tool to take a fshandle
This commit is contained in:
@@ -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,12 +118,25 @@ 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) {
|
||||||
fprintf(stderr, "can't get filesystem handle for file %s, %s\n",
|
void *fshanp;
|
||||||
pathname, strerror(errno));
|
size_t fshlen;
|
||||||
exit(1);
|
|
||||||
|
if (dm_handle_to_fshandle(hanp, hlen, &fshanp, &fshlen)) {
|
||||||
|
fprintf(stderr, "can't get filesystem handle for file %s, %s\n",
|
||||||
|
pathname, strerror(errno));
|
||||||
|
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,
|
||||||
|
|||||||
Reference in New Issue
Block a user