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

librat: open a root folder, the lock, and the root image check. More...

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

Functions

rat_t * rat_open (const char *root, bool write, rat_error_t *err)
 open a root folder.
void rat_close (rat_t *rat)
 close the handle and release the lock.
const char * rat_recovered (const rat_t *rat)
 what rat_open did with an interrupted change.
bool rat_pending (const rat_t *rat)
 true if a handle opened for queries saw an interrupted change, which the next rat_open for writing finishes.
bool rat_root_in_ram (const rat_t *rat)
 true if the root folder is the root image in RAM (from /proc/mounts): a change is then lost at the next boot.

Detailed Description

librat: open a root folder, the lock, and the root image check.

Function Documentation

◆ rat_open()

rat_t * rat_open ( const char * root,
bool write,
rat_error_t * err )

open a root folder.

Parameters
rootthe root folder; "/" on a running system.
writetrue to change packages: takes the lock (one writer at a time), and finishes or removes an interrupted change. false for queries: no lock.
Returns
the handle, or NULL (err has the reason).

◆ rat_close()

void rat_close ( rat_t * rat)

close the handle and release the lock.

◆ rat_recovered()

const char * rat_recovered ( const rat_t * rat)

what rat_open did with an interrupted change.

Returns
a message, or NULL if there was none.

◆ rat_pending()

bool rat_pending ( const rat_t * rat)

true if a handle opened for queries saw an interrupted change, which the next rat_open for writing finishes.

the queries can then show a state between the old one and the new one.

◆ rat_root_in_ram()

bool rat_root_in_ram ( const rat_t * rat)

true if the root folder is the root image in RAM (from /proc/mounts): a change is then lost at the next boot.

always false for a root other than "/".