The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
archive.c File Reference

librat: read and check a package file (gzip, then ustar), and unpack its files and links into a stage folder. More...

#include "internal.h"
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <zlib.h>
#include "sha2.h"

Macros

#define BLOCK   512

Functions

int rat_package_unpack (const char *path, const char *arch, const char *stage, rat_package_t *package, rat_error_t *err)
 read and check a package file, as rat_package_read.
int rat_package_read (const char *path, const char *arch, rat_package_t *package, rat_error_t *err)
 read and check a package file.
void rat_package_free (rat_package_t *package)
 release the memory of a package (not the struct itself).
void rat_stage_name (const char *path, char out[RAT_STAGE_NAME_MAX])
 the name of a path in the stage folder: 'f' and the SHA-256 of the path

Detailed Description

librat: read and check a package file (gzip, then ustar), and unpack its files and links into a stage folder.

the reader takes only what mkpkg makes: POSIX ustar headers (magic "ustar", version "00"), with regular files, folders and symbolic links. it refuses GNU and pax extensions, hard links, devices and named pipes.

Macro Definition Documentation

◆ BLOCK

#define BLOCK   512

Function Documentation

◆ rat_package_unpack()

int rat_package_unpack ( const char * path,
const char * arch,
const char * stage,
rat_package_t * package,
rat_error_t * err )

read and check a package file, as rat_package_read.

with a stage folder, also write each file and link there, under the name that rat_stage_name gives for its path.

Parameters
stagethe stage folder (it must exist), or NULL.

◆ rat_package_read()

int rat_package_read ( const char * path,
const char * arch,
rat_package_t * package,
rat_error_t * err )

read and check a package file.

nothing is written.

Parameters
archthe architecture the package must have ("any" also matches), or NULL for every architecture.
Returns
0, or -1 if the file is not a correct package.

◆ rat_package_free()

void rat_package_free ( rat_package_t * package)

release the memory of a package (not the struct itself).

◆ rat_stage_name()

void rat_stage_name ( const char * path,
char out[RAT_STAGE_NAME_MAX] )

the name of a path in the stage folder: 'f' and the SHA-256 of the path