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

librat: the database files. More...

#include "internal.h"
#include <dirent.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>

Macros

#define RECORD_MAX   (64u * 1024 * 1024)
 the largest files record and base.files

Functions

int rat_read_files_record (const char *path, rat_entry_t **entries_out, int *count_out, rat_error_t *err)
 read the record of the files of a package (installed/<name>/files).
char * rat_files_record_text (const rat_entry_t *entries, int count)
 the text of a files record.
int rat_owners_load (rat_t *rat, rat_owners_t *owners, rat_error_t *err)
 read base.files and the files records of every installed package.
void rat_owners_free (rat_owners_t *owners)
 release the owners
const rat_owned_t * rat_owners_find (const rat_owners_t *owners, const char *path, int *count_out)
 the owners of a path.
bool rat_owned_by_other (const rat_owners_t *owners, const char *path, const char *name)
 true if the base image, or a package other than name, owns path

Detailed Description

librat: the database files.

the record of the files of a package, and the owners of all paths.

a files record has one line for each folder, file and link, sorted by path, with four fields that a tab separates:

d   0755    -   usr/bin
f   0755    <SHA-256 in hex>    usr/bin/lua
l   0777    lua usr/bin/lua5.4

a path and a link target cannot have a tab or a line break (the reader of package files refuses control characters), so the format needs no escapes.

Macro Definition Documentation

◆ RECORD_MAX

#define RECORD_MAX   (64u * 1024 * 1024)

the largest files record and base.files

Function Documentation

◆ rat_read_files_record()

int rat_read_files_record ( const char * path,
rat_entry_t ** entries_out,
int * count_out,
rat_error_t * err )

read the record of the files of a package (installed/<name>/files).

Returns
0, or -1.

◆ rat_files_record_text()

char * rat_files_record_text ( const rat_entry_t * entries,
int count )

the text of a files record.

Returns
a string to free, or NULL (no memory).

◆ rat_owners_load()

int rat_owners_load ( rat_t * rat,
rat_owners_t * owners,
rat_error_t * err )

read base.files and the files records of every installed package.

Returns
0, or -1.

◆ rat_owners_free()

void rat_owners_free ( rat_owners_t * owners)

release the owners

◆ rat_owners_find()

const rat_owned_t * rat_owners_find ( const rat_owners_t * owners,
const char * path,
int * count_out )

the owners of a path.

Parameters
count_outgets how many there are (0 when none).
Returns
the first of them, or NULL.

◆ rat_owned_by_other()

bool rat_owned_by_other ( const rat_owners_t * owners,
const char * path,
const char * name )

true if the base image, or a package other than name, owns path