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_punch_hole(). The
18 punch_hole [-o offset] [-l length] [-s sid] {pathname|handle}
20 where pathname is the name of a file, offset is the offset of the start of
21 the 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|handle}\n", Progname);
50 dm_sessid_t sid = DM_NO_SESSION;
59 Progname = strrchr(argv[0], '/');
66 /* Crack and validate the command line options. */
68 while ((opt = getopt(argc, argv, "o:l:s:")) != EOF) {
71 offset = atol(optarg);
74 length = atol(optarg);
83 if (optind + 1 != argc)
85 object = argv[optind];
87 if (dm_init_service(&name) == -1) {
88 fprintf(stderr, "Can't initialize the DMAPI\n");
91 if (sid == DM_NO_SESSION)
92 find_test_session(&sid);
94 /* Get the file's handle. */
96 if (opaque_to_handle(object, &hanp, &hlen)) {
97 fprintf(stderr, "can't get handle for %s\n", object);
101 if (dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, offset, length)) {
102 fprintf(stderr, "dm_punch_hole failed, %s\n",
106 dm_handle_free(hanp, hlen);