2 * Copyright (C) 2015 The ChromiumOS Authors. All rights reserved.
3 * written by Daisuke Nojiri <dnojiri@chromium.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will 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.
21 * Archive file layout:
23 * +----------------------------------+
25 * +----------------------------------+
27 * +----------------------------------+
29 * +----------------------------------+
31 * +----------------------------------+
32 * | file_header[count-1] |
33 * +----------------------------------+
35 * +----------------------------------+
37 * +----------------------------------+
39 * +----------------------------------+
40 * | file(count-1) content |
41 * +----------------------------------+
45 #define CBAR_MAGIC "CBAR"
46 #define NAME_LENGTH 32
51 uint32_t version
; /* version of the header. little endian */
52 uint32_t size
; /* total size of archive. little endian */
53 uint32_t count
; /* number of files. little endian */
58 /* file name. null-terminated if shorter than NAME_LENGTH */
59 char name
[NAME_LENGTH
];
60 /* file offset from the root header. little endian */
62 /* file size. little endian */
66 static inline struct dentry
*get_first_dentry(const struct directory
*dir
)
68 return (struct dentry
*)(dir
+ 1);
71 static inline uint32_t get_first_offset(const struct directory
*dir
)
73 return sizeof(struct directory
) + sizeof(struct dentry
) * dir
->count
;