1
/*********************************************************
2
* Copyright (C) 2008 VMware, Inc. All rights reserved.
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License as published
6
* by the Free Software Foundation version 2.1 and no later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
11
* License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17
*********************************************************/
22
* A small test program for manually manipulating vmblock.
33
#include "vmblock_user.h"
37
*-----------------------------------------------------------------------------
41
* Takes the target file to block as a command line arg. Sits in a loop
42
* waiting for commands.
45
* Returns 0 on success and nonzero on failure.
50
*-----------------------------------------------------------------------------
61
strcmp(argv[1], "-h") == 0 ||
62
strcmp(argv[1], "--help") == 0) {
63
printf("Usage: %s <path>\n", argv[0]);
64
puts("a to Add a block, d to Delete a block, or l to List blocks (to"
65
" vmblock's log).\n");
69
int fd = open(VMBLOCK_DEVICE, VMBLOCK_DEVICE_MODE);
74
printf("Opened " VMBLOCK_DEVICE " as fd %d.\n", fd);
79
status = VMBLOCK_CONTROL(fd, VMBLOCK_ADD_FILEBLOCK, argv[1]);
83
printf("%s blocked.\n", argv[1]);
85
} else if (op == 'd') {
86
status = VMBLOCK_CONTROL(fd, VMBLOCK_DEL_FILEBLOCK, argv[1]);
90
printf("%s unblocked.\n", argv[1]);
92
} else if (op == 'l') {
93
status = VMBLOCK_CONTROL(fd, VMBLOCK_LIST_FILEBLOCKS, argv[1]);
97
printf("Check vmblock's log for list of blocks.\n");