Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 651 lines (620 sloc) 15.851 kb
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
1 /*
2 * Copyright (c) 2007 The DragonFly Project. All rights reserved.
84e57c2 hammer(8): whitespace cleanup: delete blank at end of line
Thomas Nikolajsen authored
3 *
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
84e57c2 hammer(8): whitespace cleanup: delete blank at end of line
Thomas Nikolajsen authored
6 *
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
84e57c2 hammer(8): whitespace cleanup: delete blank at end of line
Thomas Nikolajsen authored
10 *
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
84e57c2 hammer(8): whitespace cleanup: delete blank at end of line
Thomas Nikolajsen authored
20 *
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
84e57c2 hammer(8): whitespace cleanup: delete blank at end of line
Thomas Nikolajsen authored
33 *
de1c0b3 HAMMER utilities:
Matthew Dillon authored
34 * $DragonFly: src/sbin/hammer/hammer.c,v 1.44 2008/11/13 02:04:27 dillon Exp $
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
35 */
36
61aeeb3 HAMMER 15/many - user utility infrastructure, refactor alists, misc
Matthew Dillon authored
37 #include "hammer.h"
0006ada HAMMER Utilities: enhanced show, timeout option
Matthew Dillon authored
38 #include <signal.h>
d71afe7 HAMMER utilities: automatic sync/sleep
Matthew Dillon authored
39 #include <math.h>
9c9ac2f DEVTAB - Add support in umount, fsck, and hammer, and add sample /etc…
Matthew Dillon authored
40 #include <fstab.h>
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
41
d38ab09 HAMMER utilities:
Matthew Dillon authored
42 static void hammer_parsedevs(const char *blkdevs);
0006ada HAMMER Utilities: enhanced show, timeout option
Matthew Dillon authored
43 static void sigalrm(int signo);
445faa6 HAMMER utility - Add ^C support, improve verbosity.
Matthew Dillon authored
44 static void sigintr(int signo);
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
45 static void usage(int exit_code);
46
d38ab09 HAMMER utilities:
Matthew Dillon authored
47 int RecurseOpt;
563b484 HAMMER utilities: Add a verbose (-v) option.
Matthew Dillon authored
48 int VerboseOpt;
e95314d HAMMER Utilities: Adjust 'show' defaults.
Matthew Dillon authored
49 int QuietOpt;
d71afe7 HAMMER utilities: automatic sync/sleep
Matthew Dillon authored
50 int NoSyncOpt;
243ca32 HAMMER Utilities: Sync with 60E
Matthew Dillon authored
51 int TwoWayPipeOpt;
52 int TimeoutOpt;
48eadef HAMMER Utilities: Streaming mirroring!
Matthew Dillon authored
53 int DelayOpt = 5;
6c45ca3 HAMMER Utility - Add -p <ssh-port> option
Matthew Dillon authored
54 char *SshPort;
0748527 @mneumann Implement -y "force yes" option for hammer utility.
mneumann authored
55 int ForceYesOpt = 0;
3a99820 HAMMER Utility - Add ssh compression option
Matthew Dillon authored
56 int CompressOpt;
e7f926a HAMMER Util - Add new features, fix history retention bug in prune
Matthew Dillon authored
57 int ForceOpt;
445faa6 HAMMER utility - Add ^C support, improve verbosity.
Matthew Dillon authored
58 int RunningIoctl;
59 int DidInterrupt;
0bd7a37 HAMMER Util - Bulk transfer, SIGPIPE, more features.
Matthew Dillon authored
60 int BulkOpt;
48eadef HAMMER Utilities: Streaming mirroring!
Matthew Dillon authored
61 u_int64_t BandwidthOpt;
527a7bd HAMMER Utility - Change default split size from 100MB to 4G
Matthew Dillon authored
62 u_int64_t SplitupOpt = 4ULL * 1024ULL * 1024ULL * 1024ULL;
fbe1c66 hammer - Add memory use limit option for dedup runs
Matthew Dillon authored
63 u_int64_t MemoryLimit = 1024LLU * 1024 * 1024;
b6ced25 hammer - Pass -S option to remote mirror-read
Matthew Dillon authored
64 const char *SplitupOptStr;
d7ae405 HAMMER Utilities: Features
Matthew Dillon authored
65 const char *CyclePath;
da804f1 HAMMER utilities: feature add.
Matthew Dillon authored
66 const char *LinkPath;
d38ab09 HAMMER utilities:
Matthew Dillon authored
67
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
68 int
69 main(int ac, char **av)
70 {
d38ab09 HAMMER utilities:
Matthew Dillon authored
71 char *blkdevs = NULL;
48eadef HAMMER Utilities: Streaming mirroring!
Matthew Dillon authored
72 char *ptr;
73 u_int32_t status;
74 int ch;
0faa08a HAMMER UTIL - Add -C cachesize option to improve the 'show' command.
Matthew Dillon authored
75 int cacheSize = 0;
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
76
fbe1c66 hammer - Add memory use limit option for dedup runs
Matthew Dillon authored
77 while ((ch = getopt(ac, av, "b:c:dhf:i:m:p:qrs:t:v2yBC:FS:X")) != -1) {
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
78 switch(ch) {
243ca32 HAMMER Utilities: Sync with 60E
Matthew Dillon authored
79 case '2':
80 TwoWayPipeOpt = 1;
81 break;
0748527 @mneumann Implement -y "force yes" option for hammer utility.
mneumann authored
82 case 'y':
83 ForceYesOpt = 1;
84 break;
48eadef HAMMER Utilities: Streaming mirroring!
Matthew Dillon authored
85 case 'b':
86 BandwidthOpt = strtoull(optarg, &ptr, 0);
87 switch(*ptr) {
88 case 'g':
89 case 'G':
90 BandwidthOpt *= 1024;
91 /* fall through */
92 case 'm':
93 case 'M':
94 BandwidthOpt *= 1024;
95 /* fall through */
96 case 'k':
97 case 'K':
98 BandwidthOpt *= 1024;
99 break;
224ac2f HAMMER Utility: Allow -b to specify bytes per second if no suffix is …
Matthew Dillon authored
100 case '\0':
101 /* bytes per second if no suffix */
102 break;
48eadef HAMMER Utilities: Streaming mirroring!
Matthew Dillon authored
103 default:
104 usage(1);
105 }
106 break;
3d7b239 HAMMER Utility - Refactor the histogram code for mirror-stream.
Matthew Dillon authored
107 case 'S':
b6ced25 hammer - Pass -S option to remote mirror-read
Matthew Dillon authored
108 SplitupOptStr = strdup(optarg);
3d7b239 HAMMER Utility - Refactor the histogram code for mirror-stream.
Matthew Dillon authored
109 SplitupOpt = strtoull(optarg, &ptr, 0);
110 switch(*ptr) {
111 case 'g':
112 case 'G':
113 SplitupOpt *= 1024;
114 /* fall through */
115 case 'm':
116 case 'M':
117 SplitupOpt *= 1024;
118 /* fall through */
119 case 'k':
120 case 'K':
121 SplitupOpt *= 1024;
122 break;
123 case '\0':
124 /* bytes per second if no suffix */
125 break;
126 default:
127 usage(1);
128 }
129 break;
d7ae405 HAMMER Utilities: Features
Matthew Dillon authored
130 case 'c':
131 CyclePath = optarg;
132 break;
ba7b52c HAMMER Utilities: Cleanup.
Matthew Dillon authored
133 case 'd':
134 ++DebugOpt;
135 break;
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
136 case 'h':
137 usage(0);
138 /* not reached */
48eadef HAMMER Utilities: Streaming mirroring!
Matthew Dillon authored
139 case 'i':
140 DelayOpt = strtol(optarg, NULL, 0);
141 break;
fbe1c66 hammer - Add memory use limit option for dedup runs
Matthew Dillon authored
142 case 'm':
143 MemoryLimit = strtouq(optarg, &ptr, 0);
144 switch(*ptr) {
145 case 't':
146 case 'T':
147 MemoryLimit *= 1024;
148 /* fall through */
149 case 'g':
150 case 'G':
151 MemoryLimit *= 1024;
152 /* fall through */
153 case 'm':
154 case 'M':
155 MemoryLimit *= 1024;
156 /* fall through */
157 case 'k':
158 case 'K':
159 MemoryLimit *= 1024;
160 /* fall through */
161 default:
162 break;
163 }
164
165 /* minimum limit */
166 if (MemoryLimit < 1024 * 1024)
167 MemoryLimit = 1024 * 1024;
168 break;
6c45ca3 HAMMER Utility - Add -p <ssh-port> option
Matthew Dillon authored
169 case 'p':
170 SshPort = optarg;
171 break;
d38ab09 HAMMER utilities:
Matthew Dillon authored
172 case 'r':
173 RecurseOpt = 1;
174 break;
175 case 'f':
176 blkdevs = optarg;
177 break;
da804f1 HAMMER utilities: feature add.
Matthew Dillon authored
178 case 's':
179 LinkPath = optarg;
180 break;
0006ada HAMMER Utilities: enhanced show, timeout option
Matthew Dillon authored
181 case 't':
243ca32 HAMMER Utilities: Sync with 60E
Matthew Dillon authored
182 TimeoutOpt = strtol(optarg, NULL, 0);
0006ada HAMMER Utilities: enhanced show, timeout option
Matthew Dillon authored
183 break;
563b484 HAMMER utilities: Add a verbose (-v) option.
Matthew Dillon authored
184 case 'v':
e95314d HAMMER Utilities: Adjust 'show' defaults.
Matthew Dillon authored
185 if (QuietOpt > 0)
186 --QuietOpt;
187 else
188 ++VerboseOpt;
189 break;
190 case 'q':
191 if (VerboseOpt > 0)
192 --VerboseOpt;
193 else
194 ++QuietOpt;
563b484 HAMMER utilities: Add a verbose (-v) option.
Matthew Dillon authored
195 break;
0bd7a37 HAMMER Util - Bulk transfer, SIGPIPE, more features.
Matthew Dillon authored
196 case 'B':
197 BulkOpt = 1;
198 break;
0faa08a HAMMER UTIL - Add -C cachesize option to improve the 'show' command.
Matthew Dillon authored
199 case 'C':
200 cacheSize = strtol(optarg, &ptr, 0);
201 switch(*ptr) {
202 case 'm':
203 case 'M':
204 cacheSize *= 1024;
205 /* fall through */
206 case 'k':
207 case 'K':
208 cacheSize *= 1024;
b46b99b HAMMER UTILITY - reorg cache, add -C, document blockmap and show comm…
Matthew Dillon authored
209 ++ptr;
0faa08a HAMMER UTIL - Add -C cachesize option to improve the 'show' command.
Matthew Dillon authored
210 break;
211 case '\0':
b46b99b HAMMER UTILITY - reorg cache, add -C, document blockmap and show comm…
Matthew Dillon authored
212 case ':':
0faa08a HAMMER UTIL - Add -C cachesize option to improve the 'show' command.
Matthew Dillon authored
213 /* bytes if no suffix */
214 break;
215 default:
216 usage(1);
217 }
b46b99b HAMMER UTILITY - reorg cache, add -C, document blockmap and show comm…
Matthew Dillon authored
218 if (*ptr == ':') {
219 UseReadAhead = strtol(ptr + 1, NULL, 0);
220 UseReadBehind = -UseReadAhead;
221 }
0faa08a HAMMER UTIL - Add -C cachesize option to improve the 'show' command.
Matthew Dillon authored
222 if (cacheSize < 1024 * 1024)
223 cacheSize = 1024 * 1024;
b46b99b HAMMER UTILITY - reorg cache, add -C, document blockmap and show comm…
Matthew Dillon authored
224 if (UseReadAhead < 0)
225 usage(1);
226 if (UseReadAhead * HAMMER_BUFSIZE / cacheSize / 16) {
227 UseReadAhead = cacheSize / 16 / HAMMER_BUFSIZE;
228 UseReadBehind = -UseReadAhead;
229 }
0faa08a HAMMER UTIL - Add -C cachesize option to improve the 'show' command.
Matthew Dillon authored
230 hammer_cache_set(cacheSize);
231 break;
e7f926a HAMMER Util - Add new features, fix history retention bug in prune
Matthew Dillon authored
232 case 'F':
233 ForceOpt = 1;
234 break;
3a99820 HAMMER Utility - Add ssh compression option
Matthew Dillon authored
235 case 'X':
236 CompressOpt = 1;
237 break;
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
238 default:
239 usage(1);
240 /* not reached */
241 }
242 }
243 ac -= optind;
244 av += optind;
245 if (ac < 1) {
246 usage(1);
247 /* not reached */
248 }
249
243ca32 HAMMER Utilities: Sync with 60E
Matthew Dillon authored
250 signal(SIGALRM, sigalrm);
445faa6 HAMMER utility - Add ^C support, improve verbosity.
Matthew Dillon authored
251 signal(SIGINT, sigintr);
0006ada HAMMER Utilities: enhanced show, timeout option
Matthew Dillon authored
252
367431c HAMMER Utilities: Feature add
Matthew Dillon authored
253 if (strcmp(av[0], "synctid") == 0) {
254 hammer_cmd_synctid(av + 1, ac - 1);
255 exit(0);
256 }
5e435c9 HAMMER Filesystem changes:
Matthew Dillon authored
257 if (strcmp(av[0], "namekey2") == 0) {
258 int64_t key;
259 int32_t crcx;
260 int len;
261 const char *aname = av[1];
262
263 if (aname == NULL)
264 usage(1);
265 len = strlen(aname);
266 key = (u_int32_t)crc32(aname, len) & 0xFFFFFFFEU;
267
268 switch(len) {
269 default:
270 crcx = crc32(aname + 3, len - 5);
271 crcx = crcx ^ (crcx >> 6) ^ (crcx >> 12);
272 key |= (int64_t)(crcx & 0x3F) << 42;
273 /* fall through */
274 case 5:
275 case 4:
276 /* fall through */
277 case 3:
278 key |= ((int64_t)(aname[2] & 0x1F) << 48);
279 /* fall through */
280 case 2:
281 key |= ((int64_t)(aname[1] & 0x1F) << 53) |
282 ((int64_t)(aname[len-2] & 0x1F) << 37);
283 /* fall through */
284 case 1:
285 key |= ((int64_t)(aname[0] & 0x1F) << 58) |
286 ((int64_t)(aname[len-1] & 0x1F) << 32);
287 /* fall through */
288 case 0:
289 break;
290 }
291 if (key == 0)
292 key |= 0x100000000LL;
a276dc6 AMD64 - AUDIT RUN - Fix format strings, size_t, and other issues
Matthew Dillon authored
293 printf("0x%016jx\n", (uintmax_t)key);
5e435c9 HAMMER Filesystem changes:
Matthew Dillon authored
294 exit(0);
295 }
296 if (strcmp(av[0], "namekey1") == 0) {
cbd800c HAMMER utilities: Features and sync with VFS.
Matthew Dillon authored
297 int64_t key;
298
299 if (av[1] == NULL)
300 usage(1);
301 key = (int64_t)(crc32(av[1], strlen(av[1])) & 0x7FFFFFFF) << 32;
302 if (key == 0)
303 key |= 0x100000000LL;
a276dc6 AMD64 - AUDIT RUN - Fix format strings, size_t, and other issues
Matthew Dillon authored
304 printf("0x%016jx\n", (uintmax_t)key);
cbd800c HAMMER utilities: Features and sync with VFS.
Matthew Dillon authored
305 exit(0);
306 }
307 if (strcmp(av[0], "namekey32") == 0) {
308 int32_t key;
309
310 if (av[1] == NULL)
311 usage(1);
312 key = crc32(av[1], strlen(av[1])) & 0x7FFFFFFF;
313 if (key == 0)
314 ++key;
315 printf("0x%08x\n", key);
316 exit(0);
317 }
34ebae7 HAMMER Utilities: Mirroring and pseudo-fs directives
Matthew Dillon authored
318 if (strcmp(av[0], "pfs-status") == 0) {
319 hammer_cmd_pseudofs_status(av + 1, ac - 1);
320 exit(0);
321 }
d4e5b69 HAMMER Utilities: Sync with 60I
Matthew Dillon authored
322 if (strcmp(av[0], "pfs-master") == 0) {
323 hammer_cmd_pseudofs_create(av + 1, ac - 1, 0);
324 exit(0);
325 }
326 if (strcmp(av[0], "pfs-slave") == 0) {
327 hammer_cmd_pseudofs_create(av + 1, ac - 1, 1);
34ebae7 HAMMER Utilities: Mirroring and pseudo-fs directives
Matthew Dillon authored
328 exit(0);
329 }
330 if (strcmp(av[0], "pfs-update") == 0) {
d4e5b69 HAMMER Utilities: Sync with 60I
Matthew Dillon authored
331 hammer_cmd_pseudofs_update(av + 1, ac - 1);
66db805 HAMMER Utilities: Add the 'pseudofs' directive for commit 57
Matthew Dillon authored
332 exit(0);
333 }
9c67b4d HAMMER Utillities: Sync with 61D
Matthew Dillon authored
334 if (strcmp(av[0], "pfs-upgrade") == 0) {
335 hammer_cmd_pseudofs_upgrade(av + 1, ac - 1);
336 exit(0);
337 }
338 if (strcmp(av[0], "pfs-downgrade") == 0) {
339 hammer_cmd_pseudofs_downgrade(av + 1, ac - 1);
340 exit(0);
341 }
243ca32 HAMMER Utilities: Sync with 60E
Matthew Dillon authored
342 if (strcmp(av[0], "pfs-destroy") == 0) {
343 hammer_cmd_pseudofs_destroy(av + 1, ac - 1);
344 exit(0);
345 }
a7fbbf9 HAMMER Utilities: Sync with 59A
Matthew Dillon authored
346 if (strcmp(av[0], "status") == 0) {
347 hammer_cmd_status(av + 1, ac - 1);
348 exit(0);
349 }
13ce745 HAMMER utilities: Add the 'prune' and 'history' commands.
Matthew Dillon authored
350 if (strcmp(av[0], "prune") == 0) {
b5aaba7 HAMMER Utilities: Sync with 58A
Matthew Dillon authored
351 hammer_cmd_softprune(av + 1, ac - 1, 0);
13ce745 HAMMER utilities: Add the 'prune' and 'history' commands.
Matthew Dillon authored
352 exit(0);
353 }
83f2a3a HAMMER - Add version 3 meta-data features
Matthew Dillon authored
354 if (strcmp(av[0], "config") == 0) {
355 hammer_cmd_config(av + 1, ac - 1);
356 exit(0);
357 }
358 if (strcmp(av[0], "viconfig") == 0) {
359 hammer_cmd_viconfig(av + 1, ac - 1);
360 exit(0);
361 }
6a6e350 Add the 'hammer cleanup' command. This is a meta-command which will
Matthew Dillon authored
362 if (strcmp(av[0], "cleanup") == 0) {
363 hammer_cmd_cleanup(av + 1, ac - 1);
364 exit(0);
365 }
b66b942 @tuxillo Add 'hammer info' command that shows extended information about mount…
tuxillo authored
366 if (strcmp(av[0], "info") == 0) {
eac446c HAMMER Util - Refactor mount list scan and other fixes
Matthew Dillon authored
367 hammer_cmd_info();
b66b942 @tuxillo Add 'hammer info' command that shows extended information about mount…
tuxillo authored
368 exit(0);
369 }
b5aaba7 HAMMER Utilities: Sync with 58A
Matthew Dillon authored
370 if (strcmp(av[0], "prune-everything") == 0) {
371 hammer_cmd_softprune(av + 1, ac - 1, 1);
e8969ef HAMMER Utilities: Add the 'hammer softprune' command.
Matthew Dillon authored
372 exit(0);
373 }
83f2a3a HAMMER - Add version 3 meta-data features
Matthew Dillon authored
374 if (strcmp(av[0], "snap") == 0) {
375 hammer_cmd_snap(av + 1, ac - 1, 0, 1);
376 exit(0);
377 }
378 if (strcmp(av[0], "snaplo") == 0) {
379 hammer_cmd_snap(av + 1, ac - 1, 0, 0);
380 exit(0);
381 }
382 if (strcmp(av[0], "snapq") == 0) {
383 hammer_cmd_snap(av + 1, ac - 1, 1, 0);
384 exit(0);
385 }
386 if (strcmp(av[0], "snapls") == 0) {
387 hammer_cmd_snapls(av + 1, ac - 1);
388 exit(0);
389 }
390 if (strcmp(av[0], "snaprm") == 0) {
391 hammer_cmd_snaprm(av + 1, ac - 1);
392 exit(0);
393 }
6b669ab Implement: hammer snapshot <softlink-dir> [<filesystem>]
Michael Neumann authored
394 if (strcmp(av[0], "snapshot") == 0) {
395 hammer_cmd_snapshot(av + 1, ac - 1);
396 exit(0);
397 }
68e079b HAMMER Utilities: sync with 56A
Matthew Dillon authored
398 if (strcmp(av[0], "bstats") == 0) {
399 hammer_cmd_bstats(av + 1, ac - 1);
400 exit(0);
401 }
402 if (strcmp(av[0], "iostats") == 0) {
403 hammer_cmd_iostats(av + 1, ac - 1);
404 exit(0);
405 }
13ce745 HAMMER utilities: Add the 'prune' and 'history' commands.
Matthew Dillon authored
406
407 if (strncmp(av[0], "history", 7) == 0) {
408 hammer_cmd_history(av[0] + 7, av + 1, ac - 1);
409 exit(0);
410 }
797a0b6 HAMMER Utility: Change B-Tree, inodes, and dir reblocking params, add…
Matthew Dillon authored
411 if (strcmp(av[0], "rebalance") == 0) {
412 signal(SIGINT, sigalrm);
413 hammer_cmd_rebalance(av + 1, ac - 1);
414 exit(0);
415 }
ba7b52c HAMMER Utilities: Cleanup.
Matthew Dillon authored
416 if (strncmp(av[0], "reblock", 7) == 0) {
6a6e350 Add the 'hammer cleanup' command. This is a meta-command which will
Matthew Dillon authored
417 signal(SIGINT, sigalrm);
ba7b52c HAMMER Utilities: Cleanup.
Matthew Dillon authored
418 if (strcmp(av[0], "reblock") == 0)
419 hammer_cmd_reblock(av + 1, ac - 1, -1);
420 else if (strcmp(av[0], "reblock-btree") == 0)
421 hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_BTREE);
58c1789 HAMMER Utilities: Update for HAMMER changes.
Matthew Dillon authored
422 else if (strcmp(av[0], "reblock-inodes") == 0)
423 hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_INODES);
9e29c87 HAMMER Utilities: Sync with commit 55 - MEDIA STRUCTURES CHANGED!
Matthew Dillon authored
424 else if (strcmp(av[0], "reblock-dirs") == 0)
425 hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_DIRS);
ba7b52c HAMMER Utilities: Cleanup.
Matthew Dillon authored
426 else if (strcmp(av[0], "reblock-data") == 0)
427 hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_DATA);
428 else
429 usage(1);
3f673d5 HAMMER utilities: Add the reblock command, adjust newfs_hammer.
Matthew Dillon authored
430 exit(0);
431 }
a7fbbf9 HAMMER Utilities: Sync with 59A
Matthew Dillon authored
432 if (strncmp(av[0], "mirror", 6) == 0) {
433 if (strcmp(av[0], "mirror-read") == 0)
48eadef HAMMER Utilities: Streaming mirroring!
Matthew Dillon authored
434 hammer_cmd_mirror_read(av + 1, ac - 1, 0);
7a27dae HAMMER Utilities: Cleanup
Matthew Dillon authored
435 else if (strcmp(av[0], "mirror-read-stream") == 0)
48eadef HAMMER Utilities: Streaming mirroring!
Matthew Dillon authored
436 hammer_cmd_mirror_read(av + 1, ac - 1, 1);
a7fbbf9 HAMMER Utilities: Sync with 59A
Matthew Dillon authored
437 else if (strcmp(av[0], "mirror-write") == 0)
438 hammer_cmd_mirror_write(av + 1, ac - 1);
439 else if (strcmp(av[0], "mirror-copy") == 0)
48eadef HAMMER Utilities: Streaming mirroring!
Matthew Dillon authored
440 hammer_cmd_mirror_copy(av + 1, ac - 1, 0);
441 else if (strcmp(av[0], "mirror-stream") == 0)
442 hammer_cmd_mirror_copy(av + 1, ac - 1, 1);
243ca32 HAMMER Utilities: Sync with 60E
Matthew Dillon authored
443 else if (strcmp(av[0], "mirror-dump") == 0)
444 hammer_cmd_mirror_dump();
a7fbbf9 HAMMER Utilities: Sync with 59A
Matthew Dillon authored
445 else
446 usage(1);
447 exit(0);
448 }
bb29b5d HAMMER - Add hammer dedup directive and support
Matthew Dillon authored
449 if (strcmp(av[0], "dedup-simulate") == 0) {
450 hammer_cmd_dedup_simulate(av + 1, ac - 1);
451 exit(0);
452 }
453 if (strcmp(av[0], "dedup") == 0) {
454 hammer_cmd_dedup(av + 1, ac - 1);
455 exit(0);
456 }
de1c0b3 HAMMER utilities:
Matthew Dillon authored
457 if (strcmp(av[0], "version") == 0) {
458 hammer_cmd_get_version(av + 1, ac - 1);
459 exit(0);
460 }
461 if (strcmp(av[0], "version-upgrade") == 0) {
462 hammer_cmd_set_version(av + 1, ac - 1);
463 exit(0);
464 }
d121f61 @mneumann Rename "hammer expand" to "hammer volume-add"
mneumann authored
465 if (strcmp(av[0], "volume-add") == 0) {
466 hammer_cmd_volume_add(av + 1, ac - 1);
e27700c @mneumann Expand HAMMER filesystem stubs
mneumann authored
467 exit(0);
468 }
865c960 @mneumann HAMMER - Implement experimental volume removal
mneumann authored
469 if (strcmp(av[0], "volume-del") == 0) {
470 hammer_cmd_volume_del(av + 1, ac - 1);
471 exit(0);
472 }
e914c91 HAMMER - Implement volume-list command
Stathis Kamperis authored
473 if (strcmp(av[0], "volume-list") == 0) {
474 hammer_cmd_volume_list(av + 1, ac - 1);
475 exit(0);
476 }
61aeeb3 HAMMER 15/many - user utility infrastructure, refactor alists, misc
Matthew Dillon authored
477
478 uuid_name_lookup(&Hammer_FSType, "DragonFly HAMMER", &status);
479 if (status != uuid_s_ok) {
480 errx(1, "uuids file does not have the DragonFly "
481 "HAMMER filesystem type");
482 }
483
d38ab09 HAMMER utilities:
Matthew Dillon authored
484 if (strcmp(av[0], "show") == 0) {
e7f926a HAMMER Util - Add new features, fix history retention bug in prune
Matthew Dillon authored
485 u_int32_t lo = 0;
a276dc6 AMD64 - AUDIT RUN - Fix format strings, size_t, and other issues
Matthew Dillon authored
486 intmax_t obj_id = (int64_t)HAMMER_MIN_OBJID;
61aeeb3 HAMMER 15/many - user utility infrastructure, refactor alists, misc
Matthew Dillon authored
487
d38ab09 HAMMER utilities:
Matthew Dillon authored
488 hammer_parsedevs(blkdevs);
489 if (ac > 1)
a276dc6 AMD64 - AUDIT RUN - Fix format strings, size_t, and other issues
Matthew Dillon authored
490 sscanf(av[1], "%08x:%jx", &lo, &obj_id);
491 hammer_cmd_show(-1, lo, (int64_t)obj_id, 0, NULL, NULL);
d38ab09 HAMMER utilities:
Matthew Dillon authored
492 exit(0);
493 }
6aec797 HAMMER UTIL - Version 4 part 2/many - UNDO FIFO layout work.
Matthew Dillon authored
494 if (strcmp(av[0], "show-undo") == 0) {
495 hammer_parsedevs(blkdevs);
496 hammer_cmd_show_undo();
497 exit(0);
498 }
b9107f5 HAMMER Utility - Add catastrophic recovery feature
Matthew Dillon authored
499 if (strcmp(av[0], "recover") == 0) {
500 hammer_parsedevs(blkdevs);
501 if (ac <= 1)
502 errx(1, "hammer recover required target directory");
503 hammer_cmd_recover(av[1]);
504 exit(0);
505 }
eb3f8f1 HAMMER 30A/many: blockmap cleanup
Matthew Dillon authored
506 if (strcmp(av[0], "blockmap") == 0) {
507 hammer_parsedevs(blkdevs);
508 hammer_cmd_blockmap();
509 exit(0);
510 }
6ed4c88 HAMMER Util - Add 'checkmap', adjust hammer show
Matthew Dillon authored
511 if (strcmp(av[0], "checkmap") == 0) {
512 hammer_parsedevs(blkdevs);
513 hammer_cmd_checkmap();
514 exit(0);
515 }
61aeeb3 HAMMER 15/many - user utility infrastructure, refactor alists, misc
Matthew Dillon authored
516 usage(1);
517 /* not reached */
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
518 return(0);
519 }
520
9c9ac2f DEVTAB - Add support in umount, fsck, and hammer, and add sample /etc…
Matthew Dillon authored
521 /*
522 * Parse the device specification.
523 *
524 * Multi-volume hammer devices are colon-separated. Each element
525 * may be further expanded via /etc/devtab. One may also specify
526 * a single element which is expanded into multiple elements via
527 * /etc/devtab.
528 */
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
529 static
530 void
d38ab09 HAMMER utilities:
Matthew Dillon authored
531 hammer_parsedevs(const char *blkdevs)
532 {
533 char *copy;
534 char *volname;
535
536 if (blkdevs == NULL) {
f6532f0 hammer: minor doc update
Thomas Nikolajsen authored
537 errx(1, "A -f blkdevs specification is required "
d38ab09 HAMMER utilities:
Matthew Dillon authored
538 "for this command");
539 }
540
541 copy = strdup(blkdevs);
542 while ((volname = copy) != NULL) {
543 if ((copy = strchr(copy, ':')) != NULL)
544 *copy++ = 0;
9c9ac2f DEVTAB - Add support in umount, fsck, and hammer, and add sample /etc…
Matthew Dillon authored
545 volname = getdevpath(volname, 0);
546 if (strchr(volname, ':'))
547 hammer_parsedevs(volname);
548 else
549 setup_volume(-1, volname, 0, O_RDONLY);
d38ab09 HAMMER utilities:
Matthew Dillon authored
550 }
551 }
552
553 static
554 void
0006ada HAMMER Utilities: enhanced show, timeout option
Matthew Dillon authored
555 sigalrm(int signo __unused)
556 {
557 /* do nothing (interrupts HAMMER ioctl) */
558 }
559
560 static
561 void
445faa6 HAMMER utility - Add ^C support, improve verbosity.
Matthew Dillon authored
562 sigintr(int signo __unused)
563 {
564 if (RunningIoctl == 0)
565 _exit(1);
566 DidInterrupt = 1;
567 /* do nothing (interrupts HAMMER ioctl) */
568 }
569
570 static
571 void
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
572 usage(int exit_code)
573 {
84e57c2 hammer(8): whitespace cleanup: delete blank at end of line
Thomas Nikolajsen authored
574 fprintf(stderr,
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
575 "hammer -h\n"
8ceaba3 hammer(8): Add -X to usage().
Sascha Wildner authored
576 "hammer [-2BqrvXy] [-b bandwidth] [-C cachesize[:readahead]] [-c cyclefile]\n"
3d7b239 HAMMER Utility - Refactor the histogram code for mirror-stream.
Matthew Dillon authored
577 " [-f blkdevs] [-i delay] [-t seconds] [-S splitup]\n"
578 " command [argument ...]\n"
8408292 Update hammer doc:
Thomas Nikolajsen authored
579 "hammer synctid <filesystem> [quick]\n"
bb8e52c - sync usage() to manual
Thomas Nikolajsen authored
580 "hammer bstats [interval]\n"
581 "hammer iostats [interval]\n"
582 "hammer history[@offset[,len]] <file> ...\n"
5e435c9 HAMMER Filesystem changes:
Matthew Dillon authored
583 "hammer namekey1 <path>\n"
584 "hammer namekey2 <path>\n"
4567021 hammer(8): Update man page & sync usage()
Thomas Nikolajsen authored
585 "hammer namekey32 <path>\n"
bb8e52c - sync usage() to manual
Thomas Nikolajsen authored
586 "hammer cleanup [<filesystem> ...]\n"
b66b942 @tuxillo Add 'hammer info' command that shows extended information about mount…
tuxillo authored
587 "hammer info\n"
bb8e52c - sync usage() to manual
Thomas Nikolajsen authored
588 "hammer snapshot [<filesystem>] <snapshot-dir>\n"
1626579 hammer(8): version 3 doc update
Thomas Nikolajsen authored
589 "hammer snapshot <filesystem> <snapshot-dir> [<note>]\n"
8408292 Update hammer doc:
Thomas Nikolajsen authored
590 "hammer prune <softlink-dir>\n"
b5aaba7 HAMMER Utilities: Sync with 58A
Matthew Dillon authored
591 "hammer prune-everything <filesystem>\n"
797a0b6 HAMMER Utility: Change B-Tree, inodes, and dir reblocking params, add…
Matthew Dillon authored
592 "hammer rebalance <filesystem> [saturation_percentage]\n"
4567021 hammer(8): Update man page & sync usage()
Thomas Nikolajsen authored
593 "hammer reblock[-btree|-inodes|-dirs|-data] "
8408292 Update hammer doc:
Thomas Nikolajsen authored
594 "<filesystem> [fill_percentage]\n"
34bb69d Update hammer:
Thomas Nikolajsen authored
595 "hammer pfs-status <dirpath> ...\n"
d4e5b69 HAMMER Utilities: Sync with 60I
Matthew Dillon authored
596 "hammer pfs-master <dirpath> [options]\n"
597 "hammer pfs-slave <dirpath> [options]\n"
34ebae7 HAMMER Utilities: Mirroring and pseudo-fs directives
Matthew Dillon authored
598 "hammer pfs-update <dirpath> [options]\n"
9c67b4d HAMMER Utillities: Sync with 61D
Matthew Dillon authored
599 "hammer pfs-upgrade <dirpath>\n"
600 "hammer pfs-downgrade <dirpath>\n"
601 "hammer pfs-destroy <dirpath>\n"
bb8e52c - sync usage() to manual
Thomas Nikolajsen authored
602 "hammer mirror-read <filesystem> [begin-tid]\n"
603 "hammer mirror-read-stream <filesystem> [begin-tid]\n"
604 "hammer mirror-write <filesystem>\n"
605 "hammer mirror-dump\n"
606 "hammer mirror-copy [[user@]host:]<filesystem>"
607 " [[user@]host:]<filesystem>\n"
608 "hammer mirror-stream [[user@]host:]<filesystem>"
609 " [[user@]host:]<filesystem>\n"
5e435c9 HAMMER Filesystem changes:
Matthew Dillon authored
610 "hammer version <filesystem>\n"
4567021 hammer(8): Update man page & sync usage()
Thomas Nikolajsen authored
611 "hammer version-upgrade <filesystem> <version> [force]\n"
d121f61 @mneumann Rename "hammer expand" to "hammer volume-add"
mneumann authored
612 "hammer volume-add <device> <filesystem>\n"
865c960 @mneumann HAMMER - Implement experimental volume removal
mneumann authored
613 "hammer volume-del <device> <filesystem>\n"
e914c91 HAMMER - Implement volume-list command
Stathis Kamperis authored
614 "hammer volume-list <filesystem>\n"
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
615 );
83f2a3a HAMMER - Add version 3 meta-data features
Matthew Dillon authored
616
f6532f0 hammer: minor doc update
Thomas Nikolajsen authored
617 fprintf(stderr, "\nHAMMER utility version 3+ commands:\n");
83f2a3a HAMMER - Add version 3 meta-data features
Matthew Dillon authored
618
619 fprintf(stderr,
620 "hammer config [<filesystem> [<configfile>]]\n"
621 "hammer viconfig [<filesystem>]\n"
f6532f0 hammer: minor doc update
Thomas Nikolajsen authored
622 "hammer snap <path> [<note>]\n"
623 "hammer snaplo <path> [<note>]\n"
624 "hammer snapq <dir> [<note>]\n"
aaf9306 hammer(8): adjust markup & improve wording
Thomas Nikolajsen authored
625 "hammer snaprm <path> ...\n"
626 "hammer snaprm <transid> ...\n"
627 "hammer snaprm <filesystem> <transid> ...\n"
f6532f0 hammer: minor doc update
Thomas Nikolajsen authored
628 "hammer snapls [<path> ...]\n"
629 );
630
631 fprintf(stderr, "\nHAMMER utility version 4+ commands:\n");
632
633 fprintf(stderr,
c71cab3 HAMMER Utility - Adjust documentation
Matthew Dillon authored
634 "hammer -f blkdevs blockmap\n"
635 "hammer -f blkdevs checkmap\n"
636 "hammer -f blkdevs [-qqq] show [lo:objid]\n"
f6532f0 hammer: minor doc update
Thomas Nikolajsen authored
637 "hammer -f blkdevs show-undo\n"
b9107f5 HAMMER Utility - Add catastrophic recovery feature
Matthew Dillon authored
638 "hammer -f blkdevs recover <target_dir>\n"
83f2a3a HAMMER - Add version 3 meta-data features
Matthew Dillon authored
639 );
640
bb29b5d HAMMER - Add hammer dedup directive and support
Matthew Dillon authored
641 fprintf(stderr, "\nHAMMER utility version 5+ commands:\n");
642
643 fprintf(stderr,
644 "hammer dedup-simulate <filesystem>\n"
645 "hammer dedup <filesystem>\n"
646 );
647
0dfeb6c Add the 'hammer' utility. This is going to be a catch-all for various
Matthew Dillon authored
648 exit(exit_code);
649 }
d38ab09 HAMMER utilities:
Matthew Dillon authored
650
Something went wrong with that request. Please try again.