Skip to content

Commit 6d0c867

Browse files
committed
feat(skipcpio): move cpio on-disk format into separate header
Preparation for reusing cpio archive definitions. skipcpio's PROGRAM_VERSION_STRING is currently unused so drop it. Signed-off-by: David Disseldorp <ddiss@suse.de>
1 parent cabe94c commit 6d0c867

File tree

2 files changed

+43
-27
lines changed

2 files changed

+43
-27
lines changed

skipcpio/skipcpio.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,14 @@
1717
along with this program; If not, see <http://www.gnu.org/licenses/>.
1818
*/
1919

20-
#define PROGRAM_VERSION_STRING "1"
21-
2220
#ifndef _GNU_SOURCE
2321
#define _GNU_SOURCE
2422
#endif
2523

2624
#include <stdio.h>
2725
#include <stdlib.h>
2826
#include <string.h>
29-
30-
#define CPIO_MAGIC "070701"
31-
#define CPIO_END "TRAILER!!!"
32-
#define CPIO_ENDLEN (sizeof(CPIO_END) - 1)
33-
34-
#define CPIO_ALIGNMENT 4
35-
36-
struct cpio_header {
37-
char c_magic[6];
38-
char c_ino[8];
39-
char c_mode[8];
40-
char c_uid[8];
41-
char c_gid[8];
42-
char c_nlink[8];
43-
char c_mtime[8];
44-
char c_filesize[8];
45-
char c_dev_maj[8];
46-
char c_dev_min[8];
47-
char c_rdev_maj[8];
48-
char c_rdev_min[8];
49-
char c_namesize[8];
50-
char c_chksum[8];
51-
} __attribute__((packed));
27+
#include "skipcpio.h"
5228

5329
struct buf_struct {
5430
struct cpio_header h;
@@ -62,8 +38,6 @@ union buf_union {
6238

6339
static union buf_union buf;
6440

65-
#define ALIGN_UP(n, a) (((n) + (a) - 1) & (~((a) - 1)))
66-
6741
int main(int argc, char **argv)
6842
{
6943
FILE *f;

skipcpio/skipcpio.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
Copyright (C) 2021 Harald Hoyer
3+
Copyright (C) 2021 Red Hat, Inc. All rights reserved.
4+
5+
This program is free software: you can redistribute it and/or modify
6+
under the terms of the GNU Lesser General Public License as published by
7+
the Free Software Foundation; either version 2.1 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful, but
11+
WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public License
16+
along with this program; If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
#define CPIO_MAGIC "070701"
20+
#define CPIO_END "TRAILER!!!"
21+
#define CPIO_ENDLEN (sizeof(CPIO_END) - 1)
22+
23+
#define CPIO_ALIGNMENT 4
24+
25+
struct cpio_header {
26+
char c_magic[6];
27+
char c_ino[8];
28+
char c_mode[8];
29+
char c_uid[8];
30+
char c_gid[8];
31+
char c_nlink[8];
32+
char c_mtime[8];
33+
char c_filesize[8];
34+
char c_dev_maj[8];
35+
char c_dev_min[8];
36+
char c_rdev_maj[8];
37+
char c_rdev_min[8];
38+
char c_namesize[8];
39+
char c_chksum[8];
40+
} __attribute__((packed));
41+
42+
#define ALIGN_UP(n, a) (((n) + (a) - 1) & (~((a) - 1)))

0 commit comments

Comments
 (0)