TarStream: Support mode
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-01-11 18:42:50 +01:00
parent 82b555cf5c
commit d150c55143
Signed by: apio
GPG Key ID: B8A7D06E42258954
6 changed files with 34 additions and 4 deletions

View File

@ -59,8 +59,8 @@ Result<void> init()
{
if (entry.type == TarStream::EntryType::RegularFile)
{
kinfoln("Found file %s in initial ramdisk, of size %s", entry.name,
to_dynamic_unit(entry.size).release_value().chars());
kinfoln("Found file %s in initial ramdisk, of size %s and mode %#ho", entry.name,
to_dynamic_unit(entry.size).release_value().chars(), entry.mode);
if (!strcmp(entry.name, "bin/app")) { TRY(Scheduler::new_userspace_thread(entry, g_initrd)); }
}

View File

@ -0,0 +1,23 @@
/* bits/fixed-size-types.h: Fixed size types for internal use. Do not use in applications, include <stdint.h>. */
#ifndef _BITS_FIXED_SIZE_TYPES_H
#define _BITS_FIXED_SIZE_TYPES_H
#ifndef _SYS_TYPES_H
#error "Never include bits/fixed-size-types.h, use the standard <stdint.h> header instead."
#endif
#if defined(__GNUC__)
typedef __INT8_TYPE__ __i8_t;
typedef __UINT8_TYPE__ __u8_t;
typedef __INT16_TYPE__ __i16_t;
typedef __UINT16_TYPE__ __u16_t;
typedef __INT32_TYPE__ __i32_t;
typedef __UINT32_TYPE__ __u32_t;
typedef __INT64_TYPE__ __i64_t;
typedef __UINT64_TYPE__ __u64_t;
#else
#error "Unsupported compiler"
#endif
#endif

View File

@ -6,8 +6,10 @@
#define __need_size_t
#include <stddef.h>
typedef int pid_t;
#include <bits/fixed-size-types.h>
typedef long time_t;
typedef int pid_t;
typedef __i64_t time_t;
typedef __u16_t mode_t;
#endif

View File

@ -15,6 +15,7 @@ extern "C"
char* strdup(const char* str);
// Copies len bytes from src into dest and adds a null terminator.
// FIXME: Replace this invented function with strlcpy().
void nullcpy(char* dest, const char* src, usize len);
[[deprecated]] char* strcpy(char* dst, const char* src);

View File

@ -2,6 +2,7 @@
#include <luna/OwnedStringView.h>
#include <luna/Result.h>
#include <luna/Types.h>
#include <sys/types.h>
class TarStream
{
@ -16,6 +17,7 @@ class TarStream
{
char name[257];
usize size;
mode_t mode;
EntryType type;
private:

View File

@ -43,6 +43,8 @@ Result<TarStream::Entry> TarStream::parse_header(const TarStream::TarHeader* hdr
nullcpy(size, hdr->size, 12);
entry.size = parse_unsigned_integer(size, nullptr, 8);
entry.mode = (mode_t)parse_unsigned_integer(hdr->mode, nullptr, 8);
entry.pos = m_offset;
switch (hdr->typeflag)