]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - logprint/log_copy.c
2 * Copyright (c) 2004-2005 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
24 * Extract a log and write it out to a file
35 char buf
[XLOG_HEADER_SIZE
];
37 if ((ofd
= open(filename
, O_CREAT
|O_EXCL
|O_RDWR
|O_TRUNC
, 0666)) == -1) {
42 xlog_print_lseek(log
, fd
, 0, SEEK_SET
);
43 for (blkno
= 0; blkno
< log
->l_logBBsize
; blkno
++) {
44 r
= read(fd
, buf
, sizeof(buf
));
46 fprintf(stderr
, _("%s: read error (%lld): %s\n"),
47 __FUNCTION__
, (long long)blkno
,
51 printf(_("%s: physical end of log at %lld\n"),
52 __FUNCTION__
, (long long)blkno
);
54 } else if (r
!= sizeof(buf
)) {
55 fprintf(stderr
, _("%s: short read? (%lld)\n"),
56 __FUNCTION__
, (long long)blkno
);
60 r
= write(ofd
, buf
, sizeof(buf
));
62 fprintf(stderr
, _("%s: write error (%lld): %s\n"),
63 __FUNCTION__
, (long long)blkno
,
66 } else if (r
!= sizeof(buf
)) {
67 fprintf(stderr
, _("%s: short write? (%lld)\n"),
68 __FUNCTION__
, (long long)blkno
);