summaryrefslogtreecommitdiff
path: root/src/bootstrap
diff options
context:
space:
mode:
authordzwdz2024-08-17 17:10:04 +0200
committerdzwdz2024-08-17 17:10:04 +0200
commit2ea826b428246eb62be81630f441a4367a675968 (patch)
treef2bb2c528f3e496efed741c5ecdfd4f922547067 /src/bootstrap
parent3609248bab04e0d273bb58d2544034b3ed7c35e0 (diff)
*: getxattr
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/tar.c70
1 files changed, 43 insertions, 27 deletions
diff --git a/src/bootstrap/tar.c b/src/bootstrap/tar.c
index 678f54f..61b5b03 100644
--- a/src/bootstrap/tar.c
+++ b/src/bootstrap/tar.c
@@ -1,12 +1,13 @@
#include "tar.h"
+#include <camellia/compat.h>
#include <camellia/flags.h>
+#include <camellia/fs/dir.h>
#include <camellia/fsutil.h>
#include <camellia/syscalls.h>
+#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
-#include <camellia/compat.h>
-#include <camellia/fs/dir.h>
#define BUF_SIZE 64
@@ -27,29 +28,46 @@ void tar_driver(void *base) {
void *ptr;
while (!c0_fs_wait(buf, BUF_SIZE, &res)) {
switch (res.op) {
- case VFSOP_OPEN:
- ptr = tar_open(buf, res.len, base, ~0);
- c0_fs_respond(ptr, ptr ? 0 : -1, 0);
- break;
-
- case VFSOP_READ:
- tar_read(&res, base, ~0);
- break;
-
- case VFSOP_GETSIZE:
- if (tar_type(res.id) != '5') {
- c0_fs_respond(NULL, tar_size(res.id), 0);
- } else {
- struct dirbuild db;
- dir_start(&db, res.offset, NULL, 0);
- tar_dirbuild(&db, res.id, base, ~0);
- c0_fs_respond(NULL, dir_finish(&db), 0);
- }
- break;
-
- default:
- c0_fs_respond(NULL, -1, 0); // unsupported
- break;
+ case VFSOP_OPEN:
+ ptr = tar_open(buf, res.len, base, ~0);
+ c0_fs_respond(ptr, ptr ? 0 : -1, 0);
+ break;
+
+ case VFSOP_READ:
+ tar_read(&res, base, ~0);
+ break;
+
+ case VFSOP_GETSIZE:
+ if (tar_type(res.id) != '5') {
+ c0_fs_respond(NULL, tar_size(res.id), 0);
+ } else {
+ struct dirbuild db;
+ dir_start(&db, res.offset, NULL, 0);
+ tar_dirbuild(&db, res.id, base, ~0);
+ c0_fs_respond(NULL, dir_finish(&db), 0);
+ }
+ break;
+
+ case VFSOP_GETXATTR:
+ if (strcmp("virt.index", buf) == 0) {
+ char res[] = "virt.mode\0virt.owner\0virt.group";
+ c0_fs_respond(res, sizeof(res), 0);
+ } else if (strcmp("virt.mode", buf) == 0) {
+ c0_fs_respond(res.id + 100, 7, 0);
+ } else if (strcmp("virt.owner", buf) == 0) {
+ ssize_t ret = snprintf(buf, BUF_SIZE, "%d", oct_parse(res.id + 108, 7));
+ c0_fs_respond(buf, ret, 0);
+ } else if (strcmp("virt.group", buf) == 0) {
+ ssize_t ret = snprintf(buf, BUF_SIZE, "%d", oct_parse(res.id + 116, 7));
+ c0_fs_respond(buf, ret, 0);
+ } else {
+ c0_fs_respond(NULL, -ENOENT, 0);
+ }
+ break;
+
+ default:
+ c0_fs_respond(NULL, -ENOSYS, 0); // unsupported
+ break;
}
}
exit(0);
@@ -60,7 +78,6 @@ static char tar_type(void *meta) {
return *(char*)(meta + 156);
}
-#include <stdio.h>
static void *tar_open(const char *path, int len, void *base, size_t base_len) {
void *res;
if (len <= 0) return NULL;
@@ -78,7 +95,6 @@ static void *tar_open(const char *path, int len, void *base, size_t base_len) {
res = tar_find(path, len, base, base_len);
if (res && tar_type(res) == '1') { /* hard link */
- _klogf("hard link to %s", res+157);
res = tar_find(res + 157, strnlen(res + 157, 100), base, base_len);
}
return res;