1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
13 /*---------------------------------------------------------------------------
15 Test program used to test the DMAPI function dm_probe_hole(). The
18 probe_hole [-o offset] [-l length] [-s sid] pathname
20 where pathname is the name of a file, offset is the offset of the start of
21 the proposed punch, and length is the length of the punch. sid is the
22 session ID whose events you you are interested in.
24 ----------------------------------------------------------------------------*/
27 extern char *sys_errlist[];
39 fprintf(stderr, "usage:\t%s [-o offset] [-l length] "
40 "[-s sid] pathname\n", Progname);
50 dm_sessid_t sid = DM_NO_SESSION;
51 char *pathname = NULL;
61 Progname = strrchr(argv[0], '/');
68 /* Crack and validate the command line options. */
70 while ((opt = getopt(argc, argv, "o:l:s:")) != EOF) {
73 offset = atol(optarg);
76 length = atol(optarg);
85 if (optind + 1 != argc)
87 pathname = argv[optind];
89 if (dm_init_service(&name) == -1) {
90 fprintf(stderr, "Can't initialize the DMAPI\n");
93 if (sid == DM_NO_SESSION)
94 find_test_session(&sid);
96 /* Get the file's handle. */
98 if (dm_path_to_handle(pathname, &hanp, &hlen)) {
99 fprintf(stderr, "can't get handle for file %s\n", pathname);
103 if (dm_probe_hole(sid, hanp, hlen, DM_NO_TOKEN, offset, length,
105 fprintf(stderr, "dm_probe_hole failed, %s\n",
109 fprintf(stdout, "roffp is %lld, rlenp is %llu\n",
110 (long long) roffp, (unsigned long long) rlenp);
111 dm_handle_free(hanp, hlen);