~ubuntu-branches/debian/jessie/ufsutils/jessie

« back to all changes in this revision

Viewing changes to sbin/dumpfs/dumpfs.c

  • Committer: Bazaar Package Importer
  • Author(s): Guillem Jover, Robert Millan, Guillem Jover, Peter Pentchev
  • Date: 2011-05-31 03:50:05 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110531035005-wyiyk25p99ivd0k0
Tags: 8.2-1
[ Robert Millan ]
* Set ufsutils-udeb to kfreebsd-any.

[ Guillem Jover ]
* New upstream version (based on FreeBSD 8.2)
* Now using Standards-Version 3.9.2 (no changes needed).
* Switch to source format “3.0 (quilt)”.
  - Remove quilt from Build-Depends.
  - Remove patch target in debian/rules.
  - Remove now unneeded README.source.
  - Refresh all patches.
* Reorganize source code:
  - Switch from debian/upstream.sh to debian/rules get-orig-source target.
  - Switch from CVS to Subversion to retrieve the source code.
  - Use the same source layout as upstream (no more relocations),
    i.e. lib/, sbin/, sys/sys, sys/ufs.
  - Move libport/ to port/.
  - Merge libdisklabel/ into port/.
* Remove unneeded linking against libtermcap, thus removing the need for
  ncurses.
* Add an empty debian/watch file explaining that there's no packaged
  upstream releases. Suggested by Peter Pentchev.
* Update CVS to Subversion reference to upstream source code in
  debian/copyright.
* Remove unused lib variable from debian/rules.
* Use dpkg-buildflags to set CPPFLAGS, CFLAGS and LDFLAGS.
  Based on a patch by Peter Pentchev.
* Remove bogus reference to BSD license in /usr/share/common-licenses.
* Always set -I../../sys, even on GNU/kFreeBSD systems.

[ Peter Pentchev ]
* Remove duplicate section “utils” from ufsutils binary package.
* Remove XC- prefix from Package-Type.
* Honour CPPFLAGS and LDFLAGS and do not link with CFLAGS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2009 Robert N. M. Watson
 
3
 * All rights reserved.
 
4
 *
 
5
 * This software was developed at the University of Cambridge Computer
 
6
 * Laboratory with support from a grant from Google, Inc.
 
7
 *
 
8
 * Copyright (c) 2002 Networks Associates Technology, Inc.
 
9
 * All rights reserved.
 
10
 *
 
11
 * This software was developed for the FreeBSD Project by Marshall
 
12
 * Kirk McKusick and Network Associates Laboratories, the Security
 
13
 * Research Division of Network Associates, Inc. under DARPA/SPAWAR
 
14
 * contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA CHATS
 
15
 * research program.
 
16
 *
 
17
 * Copyright (c) 1983, 1992, 1993
 
18
 *      The Regents of the University of California.  All rights reserved.
 
19
 *
 
20
 * Redistribution and use in source and binary forms, with or without
 
21
 * modification, are permitted provided that the following conditions
 
22
 * are met:
 
23
 * 1. Redistributions of source code must retain the above copyright
 
24
 *    notice, this list of conditions and the following disclaimer.
 
25
 * 2. Redistributions in binary form must reproduce the above copyright
 
26
 *    notice, this list of conditions and the following disclaimer in the
 
27
 *    documentation and/or other materials provided with the distribution.
 
28
 * 4. Neither the name of the University nor the names of its contributors
 
29
 *    may be used to endorse or promote products derived from this software
 
30
 *    without specific prior written permission.
 
31
 *
 
32
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 
33
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
34
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
35
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 
36
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
37
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 
38
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 
39
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
40
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
41
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 
42
 * SUCH DAMAGE.
 
43
 */
 
44
 
 
45
#ifndef lint
 
46
static const char copyright[] =
 
47
"@(#) Copyright (c) 1983, 1992, 1993\n\
 
48
        The Regents of the University of California.  All rights reserved.\n";
 
49
#endif /* not lint */
 
50
 
 
51
#ifndef lint
 
52
#if 0
 
53
static char sccsid[] = "@(#)dumpfs.c    8.5 (Berkeley) 4/29/95";
 
54
#endif
 
55
static const char rcsid[] =
 
56
  "$FreeBSD$";
 
57
#endif /* not lint */
 
58
 
 
59
#include <sys/param.h>
 
60
#include <sys/time.h>
 
61
#include <sys/disklabel.h>
 
62
 
 
63
#include <ufs/ufs/dinode.h>
 
64
#include <ufs/ffs/fs.h>
 
65
 
 
66
#include <err.h>
 
67
#include <errno.h>
 
68
#include <fcntl.h>
 
69
#include <fstab.h>
 
70
#include <libufs.h>
 
71
#include <time.h>
 
72
#include <stdint.h>
 
73
#include <stdio.h>
 
74
#include <stdlib.h>
 
75
#include <unistd.h>
 
76
 
 
77
#define afs     disk.d_fs
 
78
#define acg     disk.d_cg
 
79
 
 
80
struct uufsd disk;
 
81
 
 
82
int     dumpfs(const char *);
 
83
int     dumpcg(void);
 
84
int     dumpfreespace(const char *, int);
 
85
void    dumpfreespacecg(int);
 
86
int     marshal(const char *);
 
87
void    pbits(void *, int);
 
88
void    pblklist(void *, int, off_t, int);
 
89
void    ufserr(const char *);
 
90
void    usage(void) __dead2;
 
91
 
 
92
int
 
93
main(int argc, char *argv[])
 
94
{
 
95
        const char *name;
 
96
        int ch, dofreespace, domarshal, eval;
 
97
 
 
98
        dofreespace = domarshal = eval = 0;
 
99
 
 
100
        while ((ch = getopt(argc, argv, "fm")) != -1) {
 
101
                switch (ch) {
 
102
                case 'f':
 
103
                        dofreespace++;
 
104
                        break;
 
105
                case 'm':
 
106
                        domarshal = 1;
 
107
                        break;
 
108
                case '?':
 
109
                default:
 
110
                        usage();
 
111
                }
 
112
        }
 
113
        argc -= optind;
 
114
        argv += optind;
 
115
 
 
116
        if (argc < 1)
 
117
                usage();
 
118
        if (dofreespace && domarshal)
 
119
                usage();
 
120
        if (dofreespace > 2)
 
121
                usage();
 
122
 
 
123
        while ((name = *argv++) != NULL) {
 
124
                if (ufs_disk_fillout(&disk, name) == -1) {
 
125
                        ufserr(name);
 
126
                        eval |= 1;
 
127
                        continue;
 
128
                }
 
129
                if (dofreespace)
 
130
                        eval |= dumpfreespace(name, dofreespace);
 
131
                else if (domarshal)
 
132
                        eval |= marshal(name);
 
133
                else
 
134
                        eval |= dumpfs(name);
 
135
                ufs_disk_close(&disk);
 
136
        }
 
137
        exit(eval);
 
138
}
 
139
 
 
140
int
 
141
dumpfs(const char *name)
 
142
{
 
143
        time_t fstime;
 
144
        int64_t fssize;
 
145
        int32_t fsflags;
 
146
        int i;
 
147
 
 
148
        switch (disk.d_ufs) {
 
149
        case 2:
 
150
                fssize = afs.fs_size;
 
151
                fstime = afs.fs_time;
 
152
                printf("magic\t%x (UFS2)\ttime\t%s",
 
153
                    afs.fs_magic, ctime(&fstime));
 
154
                printf("superblock location\t%jd\tid\t[ %x %x ]\n",
 
155
                    (intmax_t)afs.fs_sblockloc, afs.fs_id[0], afs.fs_id[1]);
 
156
                printf("ncg\t%d\tsize\t%jd\tblocks\t%jd\n",
 
157
                    afs.fs_ncg, (intmax_t)fssize, (intmax_t)afs.fs_dsize);
 
158
                break;
 
159
        case 1:
 
160
                fssize = afs.fs_old_size;
 
161
                fstime = afs.fs_old_time;
 
162
                printf("magic\t%x (UFS1)\ttime\t%s",
 
163
                    afs.fs_magic, ctime(&fstime));
 
164
                printf("id\t[ %08x %08x ]\n", afs.fs_id[0], afs.fs_id[1]);
 
165
                printf("ncg\t%d\tsize\t%jd\tblocks\t%jd\n",
 
166
                    afs.fs_ncg, (intmax_t)fssize, (intmax_t)afs.fs_dsize);
 
167
                break;
 
168
        default:
 
169
                goto err;
 
170
        }
 
171
        printf("bsize\t%d\tshift\t%d\tmask\t0x%08x\n",
 
172
            afs.fs_bsize, afs.fs_bshift, afs.fs_bmask);
 
173
        printf("fsize\t%d\tshift\t%d\tmask\t0x%08x\n",
 
174
            afs.fs_fsize, afs.fs_fshift, afs.fs_fmask);
 
175
        printf("frag\t%d\tshift\t%d\tfsbtodb\t%d\n",
 
176
            afs.fs_frag, afs.fs_fragshift, afs.fs_fsbtodb);
 
177
        printf("minfree\t%d%%\toptim\t%s\tsymlinklen %d\n",
 
178
            afs.fs_minfree, afs.fs_optim == FS_OPTSPACE ? "space" : "time",
 
179
            afs.fs_maxsymlinklen);
 
180
        switch (disk.d_ufs) {
 
181
        case 2:
 
182
                printf("%s %d\tmaxbpg\t%d\tmaxcontig %d\tcontigsumsize %d\n",
 
183
                    "maxbsize", afs.fs_maxbsize, afs.fs_maxbpg,
 
184
                    afs.fs_maxcontig, afs.fs_contigsumsize);
 
185
                printf("nbfree\t%jd\tndir\t%jd\tnifree\t%jd\tnffree\t%jd\n",
 
186
                    (intmax_t)afs.fs_cstotal.cs_nbfree, 
 
187
                    (intmax_t)afs.fs_cstotal.cs_ndir,
 
188
                    (intmax_t)afs.fs_cstotal.cs_nifree, 
 
189
                    (intmax_t)afs.fs_cstotal.cs_nffree);
 
190
                printf("bpg\t%d\tfpg\t%d\tipg\t%d\tunrefs\t%jd\n",
 
191
                    afs.fs_fpg / afs.fs_frag, afs.fs_fpg, afs.fs_ipg,
 
192
                    (intmax_t)afs.fs_unrefs);
 
193
                printf("nindir\t%d\tinopb\t%d\tmaxfilesize\t%ju\n",
 
194
                    afs.fs_nindir, afs.fs_inopb, 
 
195
                    (uintmax_t)afs.fs_maxfilesize);
 
196
                printf("sbsize\t%d\tcgsize\t%d\tcsaddr\t%jd\tcssize\t%d\n",
 
197
                    afs.fs_sbsize, afs.fs_cgsize, (intmax_t)afs.fs_csaddr,
 
198
                    afs.fs_cssize);
 
199
                break;
 
200
        case 1:
 
201
                printf("maxbpg\t%d\tmaxcontig %d\tcontigsumsize %d\n",
 
202
                    afs.fs_maxbpg, afs.fs_maxcontig, afs.fs_contigsumsize);
 
203
                printf("nbfree\t%d\tndir\t%d\tnifree\t%d\tnffree\t%d\n",
 
204
                    afs.fs_old_cstotal.cs_nbfree, afs.fs_old_cstotal.cs_ndir,
 
205
                    afs.fs_old_cstotal.cs_nifree, afs.fs_old_cstotal.cs_nffree);
 
206
                printf("cpg\t%d\tbpg\t%d\tfpg\t%d\tipg\t%d\n",
 
207
                    afs.fs_old_cpg, afs.fs_fpg / afs.fs_frag, afs.fs_fpg,
 
208
                    afs.fs_ipg);
 
209
                printf("nindir\t%d\tinopb\t%d\tnspf\t%d\tmaxfilesize\t%ju\n",
 
210
                    afs.fs_nindir, afs.fs_inopb, afs.fs_old_nspf,
 
211
                    (uintmax_t)afs.fs_maxfilesize);
 
212
                printf("sbsize\t%d\tcgsize\t%d\tcgoffset %d\tcgmask\t0x%08x\n",
 
213
                    afs.fs_sbsize, afs.fs_cgsize, afs.fs_old_cgoffset,
 
214
                    afs.fs_old_cgmask);
 
215
                printf("csaddr\t%d\tcssize\t%d\n",
 
216
                    afs.fs_old_csaddr, afs.fs_cssize);
 
217
                printf("rotdelay %dms\trps\t%d\ttrackskew %d\tinterleave %d\n",
 
218
                    afs.fs_old_rotdelay, afs.fs_old_rps, afs.fs_old_trackskew,
 
219
                    afs.fs_old_interleave);
 
220
                printf("nsect\t%d\tnpsect\t%d\tspc\t%d\n",
 
221
                    afs.fs_old_nsect, afs.fs_old_npsect, afs.fs_old_spc);
 
222
                break;
 
223
        default:
 
224
                goto err;
 
225
        }
 
226
        printf("sblkno\t%d\tcblkno\t%d\tiblkno\t%d\tdblkno\t%d\n",
 
227
            afs.fs_sblkno, afs.fs_cblkno, afs.fs_iblkno, afs.fs_dblkno);
 
228
        printf("cgrotor\t%d\tfmod\t%d\tronly\t%d\tclean\t%d\n",
 
229
            afs.fs_cgrotor, afs.fs_fmod, afs.fs_ronly, afs.fs_clean);
 
230
        printf("avgfpdir %d\tavgfilesize %d\n",
 
231
            afs.fs_avgfpdir, afs.fs_avgfilesize);
 
232
        printf("flags\t");
 
233
        if (afs.fs_old_flags & FS_FLAGS_UPDATED)
 
234
                fsflags = afs.fs_flags;
 
235
        else
 
236
                fsflags = afs.fs_old_flags;
 
237
        if (fsflags == 0)
 
238
                printf("none");
 
239
        if (fsflags & FS_UNCLEAN)
 
240
                printf("unclean ");
 
241
        if (fsflags & FS_DOSOFTDEP)
 
242
                printf("soft-updates ");
 
243
        if (fsflags & FS_NEEDSFSCK)
 
244
                printf("needs fsck run ");
 
245
        if (fsflags & FS_INDEXDIRS)
 
246
                printf("indexed directories ");
 
247
        if (fsflags & FS_ACLS)
 
248
                printf("acls ");
 
249
        if (fsflags & FS_MULTILABEL)
 
250
                printf("multilabel ");
 
251
        if (fsflags & FS_GJOURNAL)
 
252
                printf("gjournal ");
 
253
        if (fsflags & FS_FLAGS_UPDATED)
 
254
                printf("fs_flags expanded ");
 
255
        if (fsflags & FS_NFS4ACLS)
 
256
                printf("nfsv4acls ");
 
257
        fsflags &= ~(FS_UNCLEAN | FS_DOSOFTDEP | FS_NEEDSFSCK | FS_INDEXDIRS |
 
258
                     FS_ACLS | FS_MULTILABEL | FS_GJOURNAL | FS_FLAGS_UPDATED |
 
259
                     FS_NFS4ACLS);
 
260
        if (fsflags != 0)
 
261
                printf("unknown flags (%#x)", fsflags);
 
262
        putchar('\n');
 
263
        printf("fsmnt\t%s\n", afs.fs_fsmnt);
 
264
        printf("volname\t%s\tswuid\t%ju\n",
 
265
                afs.fs_volname, (uintmax_t)afs.fs_swuid);
 
266
        printf("\ncs[].cs_(nbfree,ndir,nifree,nffree):\n\t");
 
267
        afs.fs_csp = calloc(1, afs.fs_cssize);
 
268
        if (bread(&disk, fsbtodb(&afs, afs.fs_csaddr), afs.fs_csp, afs.fs_cssize) == -1)
 
269
                goto err;
 
270
        for (i = 0; i < afs.fs_ncg; i++) {
 
271
                struct csum *cs = &afs.fs_cs(&afs, i);
 
272
                if (i && i % 4 == 0)
 
273
                        printf("\n\t");
 
274
                printf("(%d,%d,%d,%d) ",
 
275
                    cs->cs_nbfree, cs->cs_ndir, cs->cs_nifree, cs->cs_nffree);
 
276
        }
 
277
        printf("\n");
 
278
        if (fssize % afs.fs_fpg) {
 
279
                if (disk.d_ufs == 1)
 
280
                        printf("cylinders in last group %d\n",
 
281
                            howmany(afs.fs_old_size % afs.fs_fpg,
 
282
                            afs.fs_old_spc / afs.fs_old_nspf));
 
283
                printf("blocks in last group %ld\n\n",
 
284
                    (long)((fssize % afs.fs_fpg) / afs.fs_frag));
 
285
        }
 
286
        while ((i = cgread(&disk)) != 0) {
 
287
                if (i == -1 || dumpcg())
 
288
                        goto err;
 
289
        }
 
290
        return (0);
 
291
 
 
292
err:    ufserr(name);
 
293
        return (1);
 
294
}
 
295
 
 
296
int
 
297
dumpcg(void)
 
298
{
 
299
        time_t cgtime;
 
300
        off_t cur;
 
301
        int i, j;
 
302
 
 
303
        printf("\ncg %d:\n", disk.d_lcg);
 
304
        cur = fsbtodb(&afs, cgtod(&afs, disk.d_lcg)) * disk.d_bsize;
 
305
        switch (disk.d_ufs) {
 
306
        case 2:
 
307
                cgtime = acg.cg_time;
 
308
                printf("magic\t%x\ttell\t%jx\ttime\t%s",
 
309
                    acg.cg_magic, (intmax_t)cur, ctime(&cgtime));
 
310
                printf("cgx\t%d\tndblk\t%d\tniblk\t%d\tinitiblk %d\tunrefs %d\n",
 
311
                    acg.cg_cgx, acg.cg_ndblk, acg.cg_niblk, acg.cg_initediblk,
 
312
                    acg.cg_unrefs);
 
313
                break;
 
314
        case 1:
 
315
                cgtime = acg.cg_old_time;
 
316
                printf("magic\t%x\ttell\t%jx\ttime\t%s",
 
317
                    acg.cg_magic, (intmax_t)cur, ctime(&cgtime));
 
318
                printf("cgx\t%d\tncyl\t%d\tniblk\t%d\tndblk\t%d\n",
 
319
                    acg.cg_cgx, acg.cg_old_ncyl, acg.cg_old_niblk,
 
320
                    acg.cg_ndblk);
 
321
                break;
 
322
        default:
 
323
                break;
 
324
        }
 
325
        printf("nbfree\t%d\tndir\t%d\tnifree\t%d\tnffree\t%d\n",
 
326
            acg.cg_cs.cs_nbfree, acg.cg_cs.cs_ndir,
 
327
            acg.cg_cs.cs_nifree, acg.cg_cs.cs_nffree);
 
328
        printf("rotor\t%d\tirotor\t%d\tfrotor\t%d\nfrsum",
 
329
            acg.cg_rotor, acg.cg_irotor, acg.cg_frotor);
 
330
        for (i = 1, j = 0; i < afs.fs_frag; i++) {
 
331
                printf("\t%d", acg.cg_frsum[i]);
 
332
                j += i * acg.cg_frsum[i];
 
333
        }
 
334
        printf("\nsum of frsum: %d", j);
 
335
        if (afs.fs_contigsumsize > 0) {
 
336
                for (i = 1; i < afs.fs_contigsumsize; i++) {
 
337
                        if ((i - 1) % 8 == 0)
 
338
                                printf("\nclusters %d-%d:", i,
 
339
                                    afs.fs_contigsumsize - 1 < i + 7 ?
 
340
                                    afs.fs_contigsumsize - 1 : i + 7);
 
341
                        printf("\t%d", cg_clustersum(&acg)[i]);
 
342
                }
 
343
                printf("\nclusters size %d and over: %d\n",
 
344
                    afs.fs_contigsumsize,
 
345
                    cg_clustersum(&acg)[afs.fs_contigsumsize]);
 
346
                printf("clusters free:\t");
 
347
                pbits(cg_clustersfree(&acg), acg.cg_nclusterblks);
 
348
        } else
 
349
                printf("\n");
 
350
        printf("inodes used:\t");
 
351
        pbits(cg_inosused(&acg), afs.fs_ipg);
 
352
        printf("blks free:\t");
 
353
        pbits(cg_blksfree(&acg), afs.fs_fpg);
 
354
        return (0);
 
355
}
 
356
 
 
357
int
 
358
dumpfreespace(const char *name, int fflag)
 
359
{
 
360
        int i;
 
361
 
 
362
        while ((i = cgread(&disk)) != 0) {
 
363
                if (i == -1)
 
364
                        goto err;
 
365
                dumpfreespacecg(fflag);
 
366
        }
 
367
        return (0);
 
368
err:
 
369
        ufserr(name);
 
370
        return (1);
 
371
}
 
372
 
 
373
void
 
374
dumpfreespacecg(int fflag)
 
375
{
 
376
 
 
377
        pblklist(cg_blksfree(&acg), afs.fs_fpg, disk.d_lcg * afs.fs_fpg,
 
378
            fflag);
 
379
}
 
380
 
 
381
int
 
382
marshal(const char *name)
 
383
{
 
384
        struct fs *fs;
 
385
 
 
386
        fs = &disk.d_fs;
 
387
 
 
388
        printf("# newfs command for %s (%s)\n", name, disk.d_name);
 
389
        printf("newfs ");
 
390
        if (fs->fs_volname[0] != '\0')
 
391
                printf("-L %s ", fs->fs_volname);
 
392
        printf("-O %d ", disk.d_ufs);
 
393
        if (fs->fs_flags & FS_DOSOFTDEP)
 
394
                printf("-U ");
 
395
        printf("-a %d ", fs->fs_maxcontig);
 
396
        printf("-b %d ", fs->fs_bsize);
 
397
        /* -c is dumb */
 
398
        printf("-d %d ", fs->fs_maxbsize);
 
399
        printf("-e %d ", fs->fs_maxbpg);
 
400
        printf("-f %d ", fs->fs_fsize);
 
401
        printf("-g %d ", fs->fs_avgfilesize);
 
402
        printf("-h %d ", fs->fs_avgfpdir);
 
403
        /* -i is dumb */
 
404
        /* -j..l unimplemented */
 
405
        printf("-m %d ", fs->fs_minfree);
 
406
        /* -n unimplemented */
 
407
        printf("-o ");
 
408
        switch (fs->fs_optim) {
 
409
        case FS_OPTSPACE:
 
410
                printf("space ");
 
411
                break;
 
412
        case FS_OPTTIME:
 
413
                printf("time ");
 
414
                break;
 
415
        default:
 
416
                printf("unknown ");
 
417
                break;
 
418
        }
 
419
        /* -p..r unimplemented */
 
420
        printf("-s %jd ", (intmax_t)fsbtodb(fs, fs->fs_size));
 
421
        printf("%s ", disk.d_name);
 
422
        printf("\n");
 
423
 
 
424
        return 0;
 
425
}
 
426
 
 
427
void
 
428
pbits(void *vp, int max)
 
429
{
 
430
        int i;
 
431
        char *p;
 
432
        int count, j;
 
433
 
 
434
        for (count = i = 0, p = vp; i < max; i++)
 
435
                if (isset(p, i)) {
 
436
                        if (count)
 
437
                                printf(",%s", count % 6 ? " " : "\n\t");
 
438
                        count++;
 
439
                        printf("%d", i);
 
440
                        j = i;
 
441
                        while ((i+1)<max && isset(p, i+1))
 
442
                                i++;
 
443
                        if (i != j)
 
444
                                printf("-%d", i);
 
445
                }
 
446
        printf("\n");
 
447
}
 
448
 
 
449
void
 
450
pblklist(void *vp, int max, off_t offset, int fflag)
 
451
{
 
452
        int i, j;
 
453
        char *p;
 
454
 
 
455
        for (i = 0, p = vp; i < max; i++) {
 
456
                if (isset(p, i)) {
 
457
                        printf("%jd", (intmax_t)(i + offset));
 
458
                        if (fflag < 2) {
 
459
                                j = i;
 
460
                                while ((i+1)<max && isset(p, i+1))
 
461
                                        i++;
 
462
                                if (i != j)
 
463
                                        printf("-%jd", (intmax_t)(i + offset));
 
464
                        }
 
465
                        printf("\n");
 
466
                }
 
467
        }
 
468
}
 
469
 
 
470
void
 
471
ufserr(const char *name)
 
472
{
 
473
        if (disk.d_error != NULL)
 
474
                warnx("%s: %s", name, disk.d_error);
 
475
        else if (errno)
 
476
                warn("%s", name);
 
477
}
 
478
 
 
479
void
 
480
usage(void)
 
481
{
 
482
        (void)fprintf(stderr, "usage: dumpfs [-fm] filesys | device\n");
 
483
        exit(1);
 
484
}