1997-05-06 04:46:58 +08:00
|
|
|
#ifndef H_CPIO
|
|
|
|
#define H_CPIO
|
|
|
|
|
|
|
|
#include <zlib.h>
|
1997-10-17 12:34:34 +08:00
|
|
|
#include <sys/types.h>
|
1997-05-06 04:46:58 +08:00
|
|
|
|
1998-11-19 05:41:05 +08:00
|
|
|
#include "rpmio.h"
|
|
|
|
|
1998-02-09 01:30:39 +08:00
|
|
|
/* Note the CPIO_CHECK_ERRNO bit is set only if errno is valid. These have to
|
|
|
|
be positive numbers or this setting the high bit stuff is a bad idea. */
|
1998-12-06 07:22:41 +08:00
|
|
|
#define CPIOERR_CHECK_ERRNO 0x80000000
|
|
|
|
|
|
|
|
#define CPIOERR_BAD_MAGIC (2 )
|
|
|
|
#define CPIOERR_BAD_HEADER (3 )
|
|
|
|
#define CPIOERR_OPEN_FAILED (4 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_CHMOD_FAILED (5 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_CHOWN_FAILED (6 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_WRITE_FAILED (7 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_UTIME_FAILED (8 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_UNLINK_FAILED (9 | CPIOERR_CHECK_ERRNO)
|
|
|
|
|
|
|
|
#define CPIOERR_SYMLINK_FAILED (11 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_STAT_FAILED (12 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_MKDIR_FAILED (13 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_MKNOD_FAILED (14 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_MKFIFO_FAILED (15 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_LINK_FAILED (16 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_READLINK_FAILED (17 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_READ_FAILED (18 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_COPY_FAILED (19 | CPIOERR_CHECK_ERRNO)
|
|
|
|
#define CPIOERR_INTERNAL (20 )
|
|
|
|
#define CPIOERR_HDR_SIZE (21 )
|
|
|
|
#define CPIOERR_UNKNOWN_FILETYPE (22 )
|
|
|
|
|
1997-05-06 04:46:58 +08:00
|
|
|
|
|
|
|
/* Don't think this behaves just like standard cpio. It's pretty close, but
|
|
|
|
it has some behaviors which are more to RPM's liking. I tried to document
|
1999-01-07 05:05:03 +08:00
|
|
|
them in cpio.c, but I may have missed some. */
|
1997-05-06 04:46:58 +08:00
|
|
|
|
1997-07-31 22:04:56 +08:00
|
|
|
#define CPIO_MAP_PATH (1 << 0)
|
|
|
|
#define CPIO_MAP_MODE (1 << 1)
|
|
|
|
#define CPIO_MAP_UID (1 << 2)
|
|
|
|
#define CPIO_MAP_GID (1 << 3)
|
|
|
|
#define CPIO_FOLLOW_SYMLINKS (1 << 4) /* only for building */
|
1997-05-06 04:46:58 +08:00
|
|
|
|
|
|
|
struct cpioFileMapping {
|
|
|
|
char * archivePath;
|
1997-07-24 02:07:46 +08:00
|
|
|
char * fsPath;
|
1997-05-06 04:46:58 +08:00
|
|
|
mode_t finalMode;
|
|
|
|
uid_t finalUid;
|
|
|
|
gid_t finalGid;
|
|
|
|
int mapFlags;
|
|
|
|
};
|
|
|
|
|
1997-07-24 02:07:46 +08:00
|
|
|
/* on cpio building, only "file" is filled in */
|
1997-05-06 23:27:46 +08:00
|
|
|
struct cpioCallbackInfo {
|
|
|
|
char * file;
|
|
|
|
long fileSize; /* total file size */
|
|
|
|
long fileComplete; /* amount of file unpacked */
|
|
|
|
long bytesProcessed; /* bytes in archive read */
|
|
|
|
};
|
|
|
|
|
1998-07-25 23:33:15 +08:00
|
|
|
typedef struct CFD {
|
|
|
|
union {
|
1998-11-19 05:41:05 +08:00
|
|
|
FD_t _cfdu_fd;
|
1998-07-25 23:33:15 +08:00
|
|
|
#define cpioFd _cfdu._cfdu_fd
|
|
|
|
FILE * _cfdu_fp;
|
|
|
|
#define cpioFp _cfdu._cfdu_fp
|
1998-11-23 03:48:48 +08:00
|
|
|
FD_t _cfdu_gzfd;
|
1998-07-25 23:33:15 +08:00
|
|
|
#define cpioGzFd _cfdu._cfdu_gzfd
|
|
|
|
} _cfdu;
|
|
|
|
int cpioPos;
|
|
|
|
enum cpioIoType {
|
|
|
|
cpioIoTypeDebug,
|
|
|
|
cpioIoTypeFd,
|
|
|
|
cpioIoTypeFp,
|
1999-04-09 04:53:45 +08:00
|
|
|
cpioIoTypeGzFd
|
1998-07-25 23:33:15 +08:00
|
|
|
} cpioIoType;
|
|
|
|
} CFD_t;
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
1997-05-06 23:27:46 +08:00
|
|
|
typedef void (*cpioCallback)(struct cpioCallbackInfo * filespec, void * data);
|
1997-05-06 04:46:58 +08:00
|
|
|
|
|
|
|
/* If no mappings are passed, this installs everything! If one is passed
|
|
|
|
it should be sorted according to cpioFileMapCmp() and only files included
|
|
|
|
in the map are installed. Files are installed relative to the current
|
1998-07-25 23:33:15 +08:00
|
|
|
directory unless a mapping is given which specifies an absolute
|
1997-05-06 04:46:58 +08:00
|
|
|
directory. The mode mapping is only used for the permission bits, not
|
|
|
|
for the file type. The owner/group mappings are ignored for the nonroot
|
|
|
|
user. If *failedFile is non-NULL on return, it should be free()d. */
|
1998-07-25 23:33:15 +08:00
|
|
|
int cpioInstallArchive(CFD_t *cfd, struct cpioFileMapping * mappings,
|
1997-05-06 23:27:46 +08:00
|
|
|
int numMappings, cpioCallback cb, void * cbData,
|
|
|
|
char ** failedFile);
|
1998-07-25 23:33:15 +08:00
|
|
|
int cpioBuildArchive(CFD_t *cfd, struct cpioFileMapping * mappings,
|
1997-07-24 02:07:46 +08:00
|
|
|
int numMappings, cpioCallback cb, void * cbData,
|
1998-11-21 04:18:22 +08:00
|
|
|
unsigned int * archiveSize, /*@out@*/char ** failedFile);
|
1997-05-06 04:46:58 +08:00
|
|
|
|
|
|
|
/* This is designed to be qsort/bsearch compatible */
|
|
|
|
int cpioFileMapCmp(const void * a, const void * b);
|
|
|
|
|
1998-12-06 07:22:41 +08:00
|
|
|
const char *cpioStrerror(int rc);
|
|
|
|
|
1998-07-25 23:33:15 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
1997-05-06 04:46:58 +08:00
|
|
|
#endif
|
1998-07-25 23:33:15 +08:00
|
|
|
|
|
|
|
#endif /* H_CPIO */
|