2 * Copyright (c) 2000-2001 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 /*---------------------------------------------------------------------------
27 Test program used to test the DMAPI function dm_punch_hole(). The
30 punch_hole [-o offset] [-l length] [-s sid] {pathname|handle}
32 where pathname is the name of a file, offset is the offset of the start of
33 the punch, and length is the length of the punch. sid is the
34 session ID whose events you you are interested in.
36 ----------------------------------------------------------------------------*/
39 extern char *sys_errlist[];
51 fprintf(stderr, "usage:\t%s [-o offset] [-l length] "
52 "[-s sid] {pathname|handle}\n", Progname);
62 dm_sessid_t sid = DM_NO_SESSION;
71 if (Progname = strrchr(argv[0], '/')) {
77 /* Crack and validate the command line options. */
79 while ((opt = getopt(argc, argv, "o:l:s:")) != EOF) {
82 offset = atol(optarg);
85 length = atol(optarg);
94 if (optind + 1 != argc)
96 object = argv[optind];
98 if (dm_init_service(&name) == -1) {
99 fprintf(stderr, "Can't initialize the DMAPI\n");
102 if (sid == DM_NO_SESSION)
103 find_test_session(&sid);
105 /* Get the file's handle. */
107 if (opaque_to_handle(object, &hanp, &hlen)) {
108 fprintf(stderr, "can't get handle for %s\n", object);
112 if (dm_punch_hole(sid, hanp, hlen, DM_NO_TOKEN, offset, length)) {
113 fprintf(stderr, "dm_punch_hole failed, %s\n",
117 dm_handle_free(hanp, hlen);