1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Fix sysmerge(8) and sysupgrade(8) /etc/sortix-release error handling.

This commit is contained in:
Jonas 'Sortie' Termansen 2016-04-08 23:09:38 +02:00
parent 9995df3638
commit a80bc5d011
2 changed files with 13 additions and 0 deletions

View file

@ -20,6 +20,7 @@
#include <sys/types.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stddef.h>
@ -156,14 +157,22 @@ int main(int argc, char* argv[])
const char* old_release_path = "/etc/sortix-release";
struct release old_release;
if ( !os_release_load(&old_release, old_release_path, old_release_path) )
{
if ( errno == ENOENT )
warn("%s", old_release_path);
exit(2);
}
char* new_release_path;
if ( asprintf(&new_release_path, "%s/etc/sortix-release", source) < 0 )
err(2, "asprintf");
struct release new_release;
if ( !os_release_load(&new_release, new_release_path, new_release_path) )
{
if ( errno == ENOENT )
warn("%s", new_release_path);
exit(2);
}
free(new_release_path);
// TODO: Check if /etc/machine matches the current architecture.

View file

@ -480,7 +480,11 @@ int main(void)
struct release new_release;
if ( !os_release_load(&new_release, "/etc/sortix-release",
"/etc/sortix-release") )
{
if ( errno == ENOENT )
warn("/etc/sortix-release");
exit(2);
}
char mnt[] = "/tmp/fs.XXXXXX";
if ( !mkdtemp(mnt) )