|
ginnOS
The reference: libc, the libraries and the kernel
|
the parts of librat that its source files share. More...
Go to the source code of this file.
Data Structures | |
| struct | rat |
| struct | rat_txn_t |
| a list of operations that is being made More... | |
| struct | rat_owned_t |
| the owners of all paths: the base image and the installed packages More... | |
| struct | rat_owners_t |
Macros | |
| #define | RAT_MACHINE_ARCH "i686" |
| the architecture of this machine, as packages name it | |
| #define | RAT_ENTRIES_MAX 65536 |
| the most members in a package | |
| #define | RAT_TEXT_MAX 512 |
| the longest description and licence | |
| #define | RAT_KEYS_DIR "etc/rat/keys" |
| the folder of the public keys that sign the index, relative to the root | |
| #define | RAT_RATINFO_MAX 65536 |
| the largest .RATINFO | |
| #define | RAT_STAGE_NAME_MAX 66 |
| the size of a name in the stage folder: 'f', 64 hex digits, '\0' | |
| #define | RAT_NEW_SUFFIX ".ratnew" |
| the end of the name that a new settings file gets when the person changed the old one | |
Enumerations | |
| enum | rat_disk_t { RAT_DISK_GONE , RAT_DISK_SAME , RAT_DISK_CHANGED , RAT_DISK_FOLDER } |
| what is on the disk at the path of a file or link of an installed package More... | |
Functions | |
| int | rat_fail (rat_error_t *err, const char *format,...) __attribute__((format(printf |
| set the message of err (printf format). | |
| int void | rat_say (rat_note_t note, void *context, const char *format,...) __attribute__((format(printf |
| give a note to the caller (printf format); nothing when note is NULL | |
| int void char * | rat_path (const rat_t *rat, const char *rel) |
| a path on the root: <root>/<rel>. | |
| const char * | rat_check_path (const char *path, char out[RAT_PATH_MAX+1]) |
| check a path of a package and make it the normal form: a "./" at the start and a '/' at the end are removed. | |
| const char * | rat_check_link (const char *path, const char *target) |
| check the target of a symbolic link at path: relative, and inside the package root when it is resolved from the folder of the link. | |
| void | rat_hex (const uint8_t sha[32], char out[65]) |
| the SHA-256 as 64 hexadecimal digits and a '\0' | |
| int | rat_unhex (const char *text, uint8_t sha[32]) |
| read 64 hexadecimal digits. | |
| int | rat_sha256_file (const char *path, uint8_t sha[32], uint64_t *size_out) |
| the SHA-256 and size of a file. | |
| char * | rat_read_file (const char *path, size_t max, size_t *size_out) |
| read a whole file into memory, with a '\0' after it. | |
| int | rat_write_file (const char *path, const void *data, size_t size, uint32_t mode) |
| write a file so that a crash leaves the old file or the new one: to <path>.new, fsync, then rename. | |
| int | rat_mkdirs (const char *path, uint32_t mode) |
| make a folder and the folders above it that are not there. | |
| int | rat_remove_tree (const char *path) |
| remove a file, a link, or a folder with everything in it. | |
| char * | rat_strdup (const char *s) |
| a copy of a string, or NULL when there is no memory | |
| void | rat_entry_clear (rat_entry_t *entry) |
| release the members of an entry | |
| int | rat_parse_info (const char *text, rat_info_t *info, rat_error_t *err) |
| fill info from the text of .RATINFO and check its fields. | |
| int | rat_info_from_conf (const conf_t *conf, const char *section, const char *where, rat_info_t *info, rat_error_t *err) |
| fill info from one section of a parsed file and check its fields. | |
| bool | rat_version_ok (const char *version) |
| a version: 1 to RAT_VERSION_MAX characters of 0-9 a-z A-Z . | |
| bool | rat_text_ok (const char *text) |
| a text field: at most RAT_TEXT_MAX bytes, and no control characters | |
| int | rat_parse_number (const char *text, uint64_t max, uint64_t *out) |
| a whole number of decimal digits only, at most max. | |
| void | rat_sort_entries (rat_entry_t *entries, int count) |
| sort entries by path | |
| int | rat_compare_entries (const void *a, const void *b) |
| compare two entries by path, for qsort and bsearch | |
| 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. | |
| 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 | |
| void | rat_txn_init (rat_txn_t *txn) |
| void | rat_txn_free (rat_txn_t *txn) |
| int | rat_txn_add (rat_txn_t *txn, const char *format,...) __attribute__((format(printf |
| add one operation (printf format, without the ' '). | |
| int int | rat_txn_commit (rat_t *rat, rat_txn_t *txn, const char *note, rat_error_t *err) |
| write the list and do it, then remove the list and the stage folder. | |
| bool | rat_txn_pending (const rat_t *rat) |
| true if the list of an interrupted change is there | |
| 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_recover (rat_t *rat, rat_error_t *err) |
| finish the transaction of an earlier rat that stopped, or remove its stage folder. | |
| 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_is_settings (const rat_entry_t *entry) |
| true if a path of a package is a settings file: a file under etc/. | |
| 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 | |
| rat_disk_t | rat_disk_state (const rat_t *rat, const rat_entry_t *entry) |
| compare a file or link of a record with the disk | |
| int | rat_signature_check (const rat_t *rat, const void *data, size_t size, const void *signature, size_t signature_size, rat_error_t *err) |
| check a detached signature: ECDSA P-256 over the SHA-256 of the data, in DER. | |
| int | rat_index_parse (const char *text, const char *arch, rat_index_t *index, rat_error_t *err) |
| read the text of index.conf and check every field. | |
| void | rat_remote_clear (rat_remote_t *remote) |
| release the strings of one package of an index | |
| int | rat_download (const char *url, const char *path, uint64_t max_size, rat_progress_t progress, void *context, rat_error_t *err) |
| download a URL into a file. | |
Variables | |
| int | rat_test_stop_after |
| for the host tests only: when 0 or more, a transaction stops after this number of operations, as if the power went off. | |
the parts of librat that its source files share.
| #define RAT_MACHINE_ARCH "i686" |
the architecture of this machine, as packages name it
| #define RAT_ENTRIES_MAX 65536 |
the most members in a package
| #define RAT_TEXT_MAX 512 |
the longest description and licence
| #define RAT_KEYS_DIR "etc/rat/keys" |
the folder of the public keys that sign the index, relative to the root
| #define RAT_RATINFO_MAX 65536 |
the largest .RATINFO
| #define RAT_STAGE_NAME_MAX 66 |
the size of a name in the stage folder: 'f', 64 hex digits, '\0'
| #define RAT_NEW_SUFFIX ".ratnew" |
the end of the name that a new settings file gets when the person changed the old one
| enum rat_disk_t |
| int rat_fail | ( | rat_error_t * | err, |
| const char * | format, | ||
| ... ) |
set the message of err (printf format).
| int void rat_say | ( | rat_note_t | note, |
| void * | context, | ||
| const char * | format, | ||
| ... ) |
give a note to the caller (printf format); nothing when note is NULL
| int void char * rat_path | ( | const rat_t * | rat, |
| const char * | rel ) |
a path on the root: <root>/<rel>.
| const char * rat_check_path | ( | const char * | path, |
| char | out[RAT_PATH_MAX+1] ) |
check a path of a package and make it the normal form: a "./" at the start and a '/' at the end are removed.
| out | gets the normal form (RAT_PATH_MAX + 1 bytes). |
| const char * rat_check_link | ( | const char * | path, |
| const char * | target ) |
check the target of a symbolic link at path: relative, and inside the package root when it is resolved from the folder of the link.
| void rat_hex | ( | const uint8_t | sha[32], |
| char | out[65] ) |
the SHA-256 as 64 hexadecimal digits and a '\0'
| int rat_unhex | ( | const char * | text, |
| uint8_t | sha[32] ) |
read 64 hexadecimal digits.
the SHA-256 and size of a file.
read a whole file into memory, with a '\0' after it.
| max | the largest size that is read. |
write a file so that a crash leaves the old file or the new one: to <path>.new, fsync, then rename.
| int rat_mkdirs | ( | const char * | path, |
| uint32_t | mode ) |
make a folder and the folders above it that are not there.
| int rat_remove_tree | ( | const char * | path | ) |
remove a file, a link, or a folder with everything in it.
it never follows a symbolic link. a path that is not there is not an error.
| char * rat_strdup | ( | const char * | s | ) |
a copy of a string, or NULL when there is no memory
| void rat_entry_clear | ( | rat_entry_t * | entry | ) |
release the members of an entry
| int rat_parse_info | ( | const char * | text, |
| rat_info_t * | info, | ||
| rat_error_t * | err ) |
fill info from the text of .RATINFO and check its fields.
| int rat_info_from_conf | ( | const conf_t * | conf, |
| const char * | section, | ||
| const char * | where, | ||
| rat_info_t * | info, | ||
| rat_error_t * | err ) |
fill info from one section of a parsed file and check its fields.
| where | the place for messages: ".RATINFO" or "index.conf [lua]". |
| bool rat_version_ok | ( | const char * | version | ) |
a version: 1 to RAT_VERSION_MAX characters of 0-9 a-z A-Z .
| bool rat_text_ok | ( | const char * | text | ) |
a text field: at most RAT_TEXT_MAX bytes, and no control characters
a whole number of decimal digits only, at most max.
| void rat_sort_entries | ( | rat_entry_t * | entries, |
| int | count ) |
sort entries by path
| int rat_compare_entries | ( | const void * | a, |
| const void * | b ) |
compare two entries by path, for qsort and bsearch
| 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.
| stage | the stage folder (it must exist), or NULL. |
| 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
| void rat_txn_init | ( | rat_txn_t * | txn | ) |
| void rat_txn_free | ( | rat_txn_t * | txn | ) |
| int rat_txn_add | ( | rat_txn_t * | txn, |
| const char * | format, | ||
| ... ) |
add one operation (printf format, without the '
').
| int int rat_txn_commit | ( | rat_t * | rat, |
| rat_txn_t * | txn, | ||
| const char * | note, | ||
| rat_error_t * | err ) |
write the list and do it, then remove the list and the stage folder.
| note | a line that tells what the change is ("install lua 5.4.9-1"). |
| 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_recover | ( | rat_t * | rat, |
| rat_error_t * | err ) |
finish the transaction of an earlier rat that stopped, or remove its stage folder.
rat->recovered gets a message when there was one.
| 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.
| count_out | gets how many there are (0 when none). |
| bool rat_is_settings | ( | const rat_entry_t * | entry | ) |
true if a path of a package is a settings file: a file under etc/.
a settings file that the person changed stays at an upgrade or a remove.
| 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
| rat_disk_t rat_disk_state | ( | const rat_t * | rat, |
| const rat_entry_t * | entry ) |
compare a file or link of a record with the disk
| int rat_signature_check | ( | const rat_t * | rat, |
| const void * | data, | ||
| size_t | size, | ||
| const void * | signature, | ||
| size_t | signature_size, | ||
| rat_error_t * | err ) |
check a detached signature: ECDSA P-256 over the SHA-256 of the data, in DER.
one of the keys in <root>/etc/rat/keys must verify it.
| int rat_index_parse | ( | const char * | text, |
| const char * | arch, | ||
| rat_index_t * | index, | ||
| rat_error_t * | err ) |
read the text of index.conf and check every field.
the signature must be checked before.
| arch | the architecture that the index must be for. |
| void rat_remote_clear | ( | rat_remote_t * | remote | ) |
release the strings of one package of an index
| int rat_download | ( | const char * | url, |
| const char * | path, | ||
| uint64_t | max_size, | ||
| rat_progress_t | progress, | ||
| void * | context, | ||
| rat_error_t * | err ) |
download a URL into a file.
only https and file URLs are used, and a redirect must go to https. on a failure the file is removed.
| max_size | the largest file that is accepted. |
| progress | gets the progress (may be NULL). |
|
extern |
for the host tests only: when 0 or more, a transaction stops after this number of operations, as if the power went off.
-1 normally.