feat: adapt semios filesystem layout

Signed-off-by: sisungo <[email protected]>
This commit is contained in:
2026-07-18 21:20:39 +08:00
parent 4360d2fd2e
commit d65988fcf0
7 changed files with 14 additions and 13 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ typedef struct __res_state {
#define __RES 19960801 #define __RES 19960801
#ifndef _PATH_RESCONF #ifndef _PATH_RESCONF
#define _PATH_RESCONF "/etc/resolv.conf" #define _PATH_RESCONF "/var/config/network/resolv.conf"
#endif #endif
struct res_sym { struct res_sym {
+1 -1
View File
@@ -69,7 +69,7 @@
#define ICONV_ERR_ILLEGAL_OPCODE -4 #define ICONV_ERR_ILLEGAL_OPCODE -4
#define ICONV_ERR_MEMORY_OVERFLOW -5 #define ICONV_ERR_MEMORY_OVERFLOW -5
#define ICONV_CHARSET_PATH_PREFIX "/etc/iconv/" #define ICONV_CHARSET_PATH_PREFIX "/share/iconv/"
static const uint8_t vm_binary_magic[4] = { 'S', 'I', 'C', 'V' }; static const uint8_t vm_binary_magic[4] = { 'S', 'I', 'C', 'V' };
+3 -3
View File
@@ -47,7 +47,7 @@ static void reverse_hosts(char *buf, const unsigned char *a, unsigned scopeid, i
char line[512], *p, *z; char line[512], *p, *z;
unsigned char _buf[1032], atmp[16]; unsigned char _buf[1032], atmp[16];
struct address iplit; struct address iplit;
FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf); FILE _f, *f = __fopen_rb_ca("/var/config/network/hosts", &_f, _buf, sizeof _buf);
if (!f) return; if (!f) return;
if (family == AF_INET) { if (family == AF_INET) {
memcpy(atmp+12, a, 4); memcpy(atmp+12, a, 4);
@@ -71,7 +71,7 @@ static void reverse_hosts(char *buf, const unsigned char *a, unsigned scopeid, i
if (memcmp(a, iplit.addr, 16) || iplit.scopeid != scopeid) if (memcmp(a, iplit.addr, 16) || iplit.scopeid != scopeid)
continue; continue;
for (; *p && isspace(*p); p++); for (; *p && isspace(*p); p++);
for (z=p; *z && !isspace(*z); z++); for (z=p; *z && !isspace(*z); z++);
*z = 0; *z = 0;
@@ -116,7 +116,7 @@ static int dns_parse_callback(void *c, int rr, const void *data, int len, const
data, c, 256) <= 0) data, c, 256) <= 0)
*(char *)c = 0; *(char *)c = 0;
return 0; return 0;
} }
int getnameinfo(const struct sockaddr *restrict sa, socklen_t sl, int getnameinfo(const struct sockaddr *restrict sa, socklen_t sl,
+1 -1
View File
@@ -52,7 +52,7 @@ static int name_from_hosts(struct address buf[static MAXADDRS], char canon[stati
size_t l = strlen(name); size_t l = strlen(name);
int cnt = 0, badfam = 0, have_canon = 0; int cnt = 0, badfam = 0, have_canon = 0;
unsigned char _buf[1032]; unsigned char _buf[1032];
FILE _f, *f = __fopen_rb_ca("/etc/hosts", &_f, _buf, sizeof _buf); FILE _f, *f = __fopen_rb_ca("/var/config/network/hosts", &_f, _buf, sizeof _buf);
if (!f) switch (errno) { if (!f) switch (errno) {
case ENOENT: case ENOENT:
case ENOTDIR: case ENOTDIR:
+1 -1
View File
@@ -18,7 +18,7 @@ int __get_resolv_conf(struct resolvconf *conf, char *search, size_t search_sz)
conf->attempts = 2; conf->attempts = 2;
if (search) *search = 0; if (search) *search = 0;
f = __fopen_rb_ca("/etc/resolv.conf", &_f, _buf, sizeof _buf); f = __fopen_rb_ca("/var/config/network/resolv.conf", &_f, _buf, sizeof _buf);
if (!f) switch (errno) { if (!f) switch (errno) {
case ENOENT: case ENOENT:
case ENOTDIR: case ENOTDIR:
+3 -3
View File
@@ -132,7 +132,7 @@ static void do_tzset()
"/usr/share/zoneinfo/\0/share/zoneinfo/\0/etc/zoneinfo/\0"; "/usr/share/zoneinfo/\0/share/zoneinfo/\0/etc/zoneinfo/\0";
s = getenv("TZ"); s = getenv("TZ");
if (!s) s = "/etc/localtime"; if (!s) s = "/var/config/localtime";
if (!*s) s = __utc; if (!*s) s = __utc;
if (old_tz && !strcmp(s, old_tz)) return; if (old_tz && !strcmp(s, old_tz)) return;
@@ -163,7 +163,7 @@ static void do_tzset()
|| !strcmp(dummy_name, "UTC") || !strcmp(dummy_name, "UTC")
|| !strcmp(dummy_name, "GMT"))) || !strcmp(dummy_name, "GMT")))
posix_form = 1; posix_form = 1;
} }
/* Non-suid can use an absolute tzfile pathname or a relative /* Non-suid can use an absolute tzfile pathname or a relative
* pathame beginning with "."; in secure mode, only the * pathame beginning with "."; in secure mode, only the
@@ -171,7 +171,7 @@ static void do_tzset()
if (!posix_form) { if (!posix_form) {
if (*s == ':') s++; if (*s == ':') s++;
if (*s == '/' || *s == '.') { if (*s == '/' || *s == '.') {
if (!libc.secure || !strcmp(s, "/etc/localtime")) if (!libc.secure || !strcmp(s, "/var/config/localtime"))
map = __map_file(s, &map_size); map = __map_file(s, &map_size);
} else { } else {
size_t l = strlen(s); size_t l = strlen(s);
+4 -3
View File
@@ -11,8 +11,7 @@ fn main() {
let dst = args.next().expect("please specify output file"); let dst = args.next().expect("please specify output file");
let mut octos = Vec::new(); let mut octos = Vec::new();
let src_content = std::fs::read_to_string(&src) let src_content = std::fs::read_to_string(&src).expect("cannot read source file");
.expect("cannot read source file");
let mut current_tag = None; let mut current_tag = None;
for (nline, line) in src_content.lines().enumerate() { for (nline, line) in src_content.lines().enumerate() {
let line = line.trim(); let line = line.trim();
@@ -129,7 +128,9 @@ fn do_arg(s: &str, content: &mut [u8; 8], cursor: &mut usize) -> Option<(usize,
_ => panic!("unknown radix"), _ => panic!("unknown radix"),
}; };
*cursor = 8; *cursor = 8;
*content = u64::from_str_radix(&digit[1..], radix).unwrap().to_be_bytes(); *content = u64::from_str_radix(&digit[1..], radix)
.unwrap()
.to_be_bytes();
None None
} else if let Some(reg_id) = s.strip_prefix("&r") { } else if let Some(reg_id) = s.strip_prefix("&r") {
content[*cursor] = reg_id.parse::<u8>().unwrap(); content[*cursor] = reg_id.parse::<u8>().unwrap();