Contents of /trunk/mkinitrd-magellan/busybox/archival/libunarchive/check_header_gzip.c
Parent Directory | Revision Log
Revision 532 -
(show annotations)
(download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 1391 byte(s)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 1391 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd
1 | /* vi: set sw=4 ts=4: */ |
2 | /* |
3 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
4 | */ |
5 | #include <stdlib.h> |
6 | #include <unistd.h> |
7 | #include "libbb.h" |
8 | #include "unarchive.h" /* for external decl of check_header_gzip */ |
9 | |
10 | void check_header_gzip(int src_fd) |
11 | { |
12 | union { |
13 | unsigned char raw[8]; |
14 | struct { |
15 | unsigned char method; |
16 | unsigned char flags; |
17 | unsigned int mtime; |
18 | unsigned char xtra_flags; |
19 | unsigned char os_flags; |
20 | } formatted; |
21 | } header; |
22 | |
23 | xread(src_fd, header.raw, 8); |
24 | |
25 | /* Check the compression method */ |
26 | if (header.formatted.method != 8) { |
27 | bb_error_msg_and_die("unknown compression method %d", |
28 | header.formatted.method); |
29 | } |
30 | |
31 | if (header.formatted.flags & 0x04) { |
32 | /* bit 2 set: extra field present */ |
33 | unsigned char extra_short; |
34 | |
35 | extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8); |
36 | while (extra_short > 0) { |
37 | /* Ignore extra field */ |
38 | xread_char(src_fd); |
39 | extra_short--; |
40 | } |
41 | } |
42 | |
43 | /* Discard original name if any */ |
44 | if (header.formatted.flags & 0x08) { |
45 | /* bit 3 set: original file name present */ |
46 | while (xread_char(src_fd) != 0); |
47 | } |
48 | |
49 | /* Discard file comment if any */ |
50 | if (header.formatted.flags & 0x10) { |
51 | /* bit 4 set: file comment present */ |
52 | while (xread_char(src_fd) != 0); |
53 | } |
54 | |
55 | /* Read the header checksum */ |
56 | if (header.formatted.flags & 0x02) { |
57 | xread_char(src_fd); |
58 | xread_char(src_fd); |
59 | } |
60 | |
61 | return; |
62 | } |