1997-05-06 04:46:58 +08:00
|
|
|
#ifndef H_CPIO
|
|
|
|
#define H_CPIO
|
|
|
|
|
2000-08-28 03:18:25 +08:00
|
|
|
/** \ingroup payload
|
|
|
|
* \file lib/cpio.h
|
2000-01-20 06:51:39 +08:00
|
|
|
* Structures used to handle cpio payloads within rpm packages.
|
|
|
|
*
|
2000-08-28 09:08:57 +08:00
|
|
|
* @warning Rpm's cpio implementation may be different than standard cpio.
|
2000-01-20 06:51:39 +08:00
|
|
|
* The implementation is pretty close, but it has some behaviors which are
|
|
|
|
* more to RPM's liking. I tried to document the differing behavior in cpio.c,
|
2000-03-23 23:49:50 +08:00
|
|
|
* but I may have missed some (ewt).
|
2000-01-20 06:51:39 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2000-08-28 03:18:25 +08:00
|
|
|
/** \ingroup payload
|
2001-01-21 23:43:32 +08:00
|
|
|
* @note CPIO_CHECK_ERRNO bit is set only if errno is valid.
|
2000-01-25 06:13:45 +08:00
|
|
|
*/
|
1999-04-14 19:28:31 +08:00
|
|
|
#define CPIOERR_CHECK_ERRNO 0x00008000
|
1998-12-06 07:22:41 +08:00
|
|
|
|
2000-08-28 09:50:45 +08:00
|
|
|
/** \ingroup payload
|
|
|
|
*/
|
|
|
|
enum cpioErrorReturns {
|
|
|
|
CPIOERR_BAD_MAGIC = (2 ),
|
|
|
|
CPIOERR_BAD_HEADER = (3 ),
|
|
|
|
CPIOERR_OPEN_FAILED = (4 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_CHMOD_FAILED = (5 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_CHOWN_FAILED = (6 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_WRITE_FAILED = (7 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_UTIME_FAILED = (8 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_UNLINK_FAILED = (9 | CPIOERR_CHECK_ERRNO),
|
|
|
|
|
2001-01-28 10:13:48 +08:00
|
|
|
CPIOERR_RENAME_FAILED = (10 | CPIOERR_CHECK_ERRNO),
|
2000-08-28 09:50:45 +08:00
|
|
|
CPIOERR_SYMLINK_FAILED = (11 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_STAT_FAILED = (12 | CPIOERR_CHECK_ERRNO),
|
2001-01-28 10:13:48 +08:00
|
|
|
CPIOERR_LSTAT_FAILED = (13 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_MKDIR_FAILED = (14 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_RMDIR_FAILED = (15 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_MKNOD_FAILED = (16 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_MKFIFO_FAILED = (17 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_LINK_FAILED = (18 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_READLINK_FAILED = (19 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_READ_FAILED = (20 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_COPY_FAILED = (21 | CPIOERR_CHECK_ERRNO),
|
2003-12-26 07:00:44 +08:00
|
|
|
CPIOERR_LSETFCON_FAILED = (22 | CPIOERR_CHECK_ERRNO),
|
|
|
|
CPIOERR_HDR_SIZE = (23 ),
|
|
|
|
CPIOERR_HDR_TRAILER = (24 ),
|
|
|
|
CPIOERR_UNKNOWN_FILETYPE= (25 ),
|
|
|
|
CPIOERR_MISSING_HARDLINK= (26 ),
|
|
|
|
CPIOERR_MD5SUM_MISMATCH = (27 ),
|
|
|
|
CPIOERR_INTERNAL = (28 ),
|
|
|
|
CPIOERR_UNMAPPED_FILE = (29 ),
|
|
|
|
CPIOERR_ENOENT = (30 ),
|
|
|
|
CPIOERR_ENOTEMPTY = (31 )
|
2000-08-28 09:50:45 +08:00
|
|
|
};
|
1998-12-06 07:22:41 +08:00
|
|
|
|
2000-10-21 06:04:27 +08:00
|
|
|
/** \ingroup payload
|
|
|
|
*/
|
2001-01-21 23:43:32 +08:00
|
|
|
typedef enum cpioMapFlags_e {
|
2001-02-12 06:02:29 +08:00
|
|
|
CPIO_MAP_PATH = (1 << 0),
|
|
|
|
CPIO_MAP_MODE = (1 << 1),
|
|
|
|
CPIO_MAP_UID = (1 << 2),
|
|
|
|
CPIO_MAP_GID = (1 << 3),
|
2001-07-16 22:48:07 +08:00
|
|
|
CPIO_FOLLOW_SYMLINKS= (1 << 4), /*!< only for building. */
|
2001-02-12 06:02:29 +08:00
|
|
|
CPIO_MAP_ABSOLUTE = (1 << 5),
|
|
|
|
CPIO_MAP_ADDDOT = (1 << 6),
|
2001-06-26 04:01:42 +08:00
|
|
|
CPIO_ALL_HARDLINKS = (1 << 7), /*!< fail if hardlinks are missing. */
|
2007-04-16 20:26:12 +08:00
|
|
|
CPIO_MAP_TYPE = (1 << 8), /*!< only for building. */
|
|
|
|
CPIO_SBIT_CHECK = (1 << 9)
|
2001-01-21 23:43:32 +08:00
|
|
|
} cpioMapFlags;
|
1997-05-06 04:46:58 +08:00
|
|
|
|
2001-02-10 04:58:37 +08:00
|
|
|
#define CPIO_NEWC_MAGIC "070701"
|
|
|
|
#define CPIO_CRC_MAGIC "070702"
|
|
|
|
#define CPIO_TRAILER "TRAILER!!!"
|
|
|
|
|
2001-02-09 07:05:05 +08:00
|
|
|
/** \ingroup payload
|
|
|
|
* Cpio archive header information.
|
|
|
|
*/
|
|
|
|
struct cpioCrcPhysicalHeader {
|
|
|
|
char magic[6];
|
|
|
|
char inode[8];
|
|
|
|
char mode[8];
|
|
|
|
char uid[8];
|
|
|
|
char gid[8];
|
|
|
|
char nlink[8];
|
|
|
|
char mtime[8];
|
|
|
|
char filesize[8];
|
|
|
|
char devMajor[8];
|
|
|
|
char devMinor[8];
|
|
|
|
char rdevMajor[8];
|
|
|
|
char rdevMinor[8];
|
|
|
|
char namesize[8];
|
|
|
|
char checksum[8]; /* ignored !! */
|
|
|
|
};
|
|
|
|
|
2004-10-20 18:19:34 +08:00
|
|
|
#define PHYS_HDR_SIZE 110 /* Don't depend on sizeof(struct) */
|
2001-02-09 07:05:05 +08:00
|
|
|
|
1998-07-25 23:33:15 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2001-02-09 07:05:05 +08:00
|
|
|
/**
|
|
|
|
* Write cpio trailer.
|
|
|
|
* @retval fsm file path and stat info
|
2000-08-23 20:39:49 +08:00
|
|
|
* @return 0 on success
|
2000-01-25 06:13:45 +08:00
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
int cpioTrailerWrite(FSM_t fsm)
|
2003-05-09 04:39:29 +08:00
|
|
|
/*@globals h_errno, fileSystem, internalState @*/
|
2002-07-08 22:21:26 +08:00
|
|
|
/*@modifies fsm, fileSystem, internalState @*/;
|
2000-08-23 20:39:49 +08:00
|
|
|
|
2001-02-09 07:05:05 +08:00
|
|
|
/**
|
|
|
|
* Write cpio header.
|
|
|
|
* @retval fsm file path and stat info
|
2002-04-09 02:56:01 +08:00
|
|
|
* @param st
|
2000-08-23 20:39:49 +08:00
|
|
|
* @return 0 on success
|
2000-01-25 06:13:45 +08:00
|
|
|
*/
|
2001-06-04 21:55:58 +08:00
|
|
|
int cpioHeaderWrite(FSM_t fsm, struct stat * st)
|
2003-05-09 04:39:29 +08:00
|
|
|
/*@globals h_errno, fileSystem, internalState @*/
|
2002-07-08 22:21:26 +08:00
|
|
|
/*@modifies fsm, fileSystem, internalState @*/;
|
2001-02-09 07:05:05 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Read cpio header.
|
|
|
|
* @retval fsm file path and stat info
|
2002-04-09 02:56:01 +08:00
|
|
|
* @retval st
|
2001-02-09 07:05:05 +08:00
|
|
|
* @return 0 on success
|
|
|
|
*/
|
|
|
|
int cpioHeaderRead(FSM_t fsm, struct stat * st)
|
2003-05-09 04:39:29 +08:00
|
|
|
/*@globals h_errno, fileSystem, internalState @*/
|
2002-07-08 22:21:26 +08:00
|
|
|
/*@modifies fsm, *st, fileSystem, internalState @*/;
|
1997-05-06 04:46:58 +08:00
|
|
|
|
2000-08-28 03:18:25 +08:00
|
|
|
/** \ingroup payload
|
2001-01-03 01:19:34 +08:00
|
|
|
* Return formatted error message on payload handling failure.
|
2002-04-09 02:56:01 +08:00
|
|
|
* @param rc error code
|
2000-10-21 06:04:27 +08:00
|
|
|
* @return formatted error string
|
2000-03-23 23:49:50 +08:00
|
|
|
*/
|
2007-07-10 17:15:43 +08:00
|
|
|
/*@observer@*/ const char * cpioStrerror(int rc)
|
2002-07-08 22:21:26 +08:00
|
|
|
/*@*/;
|
1998-12-06 07:22:41 +08:00
|
|
|
|
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 */
|