Compare commits

..

35 Commits

Author SHA1 Message Date
1bd6cf048b
libos: Remove some shared pointers and change them to owned/live on the stack
All checks were successful
continuous-integration/drone/pr Build is passing
2023-08-08 12:51:06 +02:00
2c42b088e0
wind: Spawn a new client process after startup
Also, create the socket after dropping privileges.
2023-08-08 12:51:06 +02:00
d0b5eb11ef
apps: Add gclient 2023-08-08 12:51:05 +02:00
5f7b055c36
libos: Add os::LocalClient 2023-08-08 12:51:05 +02:00
9306b98d17
libui: Change 'into' to 'onto' 2023-08-08 12:51:05 +02:00
fe65be8a89
libui: Document ui::Font 2023-08-08 12:51:05 +02:00
41b54610b0
libui+wind: Move some static variables inside functions 2023-08-08 12:51:05 +02:00
a77d698544
wind: Generate random windows on keypresses 2023-08-08 12:51:05 +02:00
2ad53db448
wind: Make sure windows have a minimum size to fit the titlebar 2023-08-08 12:51:05 +02:00
871b5c6a35
libui: Properly cut off the last drawn character if necessary 2023-08-08 12:51:04 +02:00
a38dbce9bd
libui: Add Rect::contains(Rect) 2023-08-08 12:51:04 +02:00
93d74a29b5
libui: Render font characters properly with no spacing, matching the width calculations 2023-08-08 12:51:04 +02:00
3d3d1aeed5
wind: Render an actual TGA mouse cursor 2023-08-08 12:51:04 +02:00
60385c4614
wind: Add a close button to windows using a TGA icon 2023-08-08 12:51:04 +02:00
38c00a8384
libui: Add support for TGA image loading 2023-08-08 12:51:04 +02:00
ae5dd3f340
libui: Add an interface to fill a Canvas with an array of pixels 2023-08-08 12:51:03 +02:00
a843ef943e
wind: Add window titlebars using ui::Font 2023-08-08 12:51:03 +02:00
4cb2c5ea83
libui: Add PSF font loading and rendering 2023-08-08 12:51:03 +02:00
0bc7af62df
libui: Add Color::GRAY 2023-08-08 12:51:03 +02:00
98a0049e54
libui: Rename Rect::absolute to normalized and add a new absolute function 2023-08-08 12:51:03 +02:00
9c78ec605c
libluna: Add assignment operators to Buffer 2023-08-08 12:51:03 +02:00
d8ba20b23d
wind: Reorder drag sequence 2023-08-08 12:51:02 +02:00
0927dd71cc
libui: Add Rect::relative 2023-08-08 12:51:02 +02:00
3d559cb8c8
libui: Remove redundant statement 2023-08-08 12:51:02 +02:00
42dca14d09
libui: Add getters for separate color values 2023-08-08 12:51:02 +02:00
69b36b0b09
libui: Remove unnecessary stuff 2023-08-08 12:51:02 +02:00
ee0bdd59d3
base: Remove startup items not necessary for GUI startup 2023-08-08 12:51:01 +02:00
d8150113c5
libui+wind: (Draggable) windows 2023-08-08 12:51:01 +02:00
b48daad58a
wind: Create a local server object 2023-08-08 12:51:01 +02:00
a1f47cacd4
libos: Add a new LocalServer class for local domain sockets 2023-08-08 12:51:01 +02:00
78a4c4f111
kernel: Support listening sockets in poll() 2023-08-08 12:51:01 +02:00
cab45a414c
base: Start wind on startup instead of the shell 2023-08-08 12:51:01 +02:00
646ccb2854
wind: Add a simple display server skeleton using libui
No client functionality yet, but it's a start.
2023-08-08 12:51:01 +02:00
1984a4de08
libui: Add a GUI and graphics library 2023-08-08 12:51:00 +02:00
5c09fdfbc6
kernel: Fix negative movement in the PS/2 mouse driver 2023-08-08 12:50:56 +02:00
27 changed files with 19 additions and 589 deletions

View File

@ -1,5 +1,5 @@
# Luna
A simple POSIX-based operating system for personal computers, written in C++. [![Build Status](https://drone.cloudapio.eu/api/badges/apio/Luna/status.svg)](https://drone.cloudapio.eu/apio/Luna)
A very basic POSIX-based operating system for personal computers, written in C++. [![Build Status](https://drone.cloudapio.eu/api/badges/apio/Luna/status.svg)](https://drone.cloudapio.eu/apio/Luna)
## Another UNIX clone?
[Yes, another UNIX clone](https://wiki.osdev.org/User:Sortie/Yes_Another_Unix_Clone).
@ -8,18 +8,16 @@ A simple POSIX-based operating system for personal computers, written in C++. [!
- x86_64-compatible lightweight [kernel](kernel/).
- Preemptive multitasking, with a round-robin [scheduler](kernel/src/thread/).
- [Virtual file system](kernel/src/fs/) with a simple [tmpfs](kernel/src/fs/tmpfs/) and read-only [ext2](kernel/src/fs/ext2/) support.
- Can [load ELF programs](kernel/src/binfmt/ELF.cpp), [shebang scripts](kernel/src/binfmt/Script.cpp) or [arbitrary binary formats](kernel/src/binfmt/BinaryFormat.h) (registered through kernel modules, which are not supported yet =D).
- Can [load ELF programs](kernel/src/thread/ELF.cpp) from the file system as userspace tasks.
- Boots from an [ext2](apps/preinit.cpp) root filesystem (a bit slow for now).
- [System call](kernel/src/sys/) interface and [C Library](libc/), aiming to be almost POSIX-compatible.
- Support for [several third-party programs](ports/), including the [GNU binutils](ports/binutils/PACKAGE) suite of utilities.
- [System call](kernel/src/sys/) interface and [C Library](libc/), aiming to be mostly POSIX-compatible.
- POSIX [signal](libc/src/signal.cpp) support.
- Designed to be [portable](kernel/src/arch), no need to be restricted to x86_64.
- Everything is [UTF-8](libluna/include/luna/Utf8.h).
- Designed around [UTF-8](libluna/include/luna/Utf8.h).
- [UNIX local domain sockets](kernel/src/net/UnixSocket.cpp), allowing for local IPC.
- [POSIX shared memory](libc/include/sys/mman.h) support.
- Environment-agnostic [utility library](libluna/), which can be used in both kernel and userspace.
- Return-oriented [error propagation](libluna/include/luna/Result.h), inspired by Rust and SerenityOS. No exceptions here :).
- An extensive set of [standard Unix utilities](apps/), from [ls](apps/ls.cpp) to [uname](apps/uname.cpp) to [base64](apps/base64.cpp). Written in modern C++ and very small amounts of code, using Luna's practical [OS library](libos/).
- Return-oriented [error propagation](libluna/include/luna/Result.h), inspired by Rust and SerenityOS.
- Build system uses [CMake](CMakeLists.txt).
## Setup

View File

@ -46,5 +46,4 @@ luna_app(socket-test.cpp socket-test)
luna_app(socket-client.cpp socket-client)
luna_app(input.cpp input)
luna_app(shmem-test.cpp shmem-test)
luna_app(touch.cpp touch)
luna_app(gclient.cpp gclient)

View File

@ -2,7 +2,7 @@
#include <os/FileSystem.h>
#include <os/Mode.h>
#include <stdio.h>
#include <time.h>
#include <sys/stat.h>
static const char* file_type(mode_t mode)
{
@ -36,20 +36,10 @@ Result<int> luna_main(int argc, char** argv)
char buf[11];
os::format_mode(st.st_mode, buf);
char atime[256];
strftime(atime, sizeof(atime), "%Y-%m-%d %H:%M:%S", gmtime(&st.st_atim.tv_sec));
char mtime[256];
strftime(mtime, sizeof(mtime), "%Y-%m-%d %H:%M:%S", gmtime(&st.st_mtim.tv_sec));
char ctime[256];
strftime(ctime, sizeof(ctime), "%Y-%m-%d %H:%M:%S", gmtime(&st.st_ctim.tv_sec));
printf(" File: %s\n", path.chars());
printf(" Size: %zu (%s)\n", st.st_size, file_type(st.st_mode));
printf(" Inode: %lu Links: %lu\n", st.st_ino, st.st_nlink);
printf(" Mode: (%#o/%s) UID: %u GID: %u\n", st.st_mode & ~S_IFMT, buf, st.st_uid, st.st_gid);
printf("Access: %s.%.9ld\n", atime, st.st_atim.tv_nsec);
printf("Modify: %s.%.9ld\n", mtime, st.st_mtim.tv_nsec);
printf("Change: %s.%.9ld\n", ctime, st.st_ctim.tv_nsec);
printf(" File: %s\n", path.chars());
printf(" Size: %zu (%s)\n", st.st_size, file_type(st.st_mode));
printf("Inode: %lu Links: %lu\n", st.st_ino, st.st_nlink);
printf(" Mode: (%#o/%s) UID: %u GID: %u\n", st.st_mode & ~S_IFMT, buf, st.st_uid, st.st_gid);
return 0;
}

View File

@ -1,47 +0,0 @@
#include <errno.h>
#include <os/ArgumentParser.h>
#include <os/File.h>
#include <sys/stat.h>
Result<int> luna_main(int argc, char** argv)
{
Vector<StringView> files;
bool only_atime { false };
bool only_mtime { false };
bool no_create { false };
bool no_dereference { false };
os::ArgumentParser parser;
parser.add_description("Update the access and modification times of files."_sv);
parser.add_system_program_info("touch"_sv);
parser.set_vector_argument(files, "files", true);
parser.add_switch_argument(only_atime, 'a', ""_sv, "change only the access time"_sv);
parser.add_switch_argument(no_create, 'c', "no-create"_sv, "do not create new files"_sv);
parser.add_switch_argument(no_dereference, 'h', "no-dereference"_sv, "do not follow symbolic links"_sv);
parser.add_switch_argument(only_mtime, 'm', ""_sv, "change only the modification time"_sv);
TRY(parser.parse(argc, argv));
if (only_atime && only_mtime)
{
os::eprintln("%s: only one of -a and -m can be specified.", argv[0]);
parser.short_usage(argv[0]);
}
struct timespec times[2] = {
{ .tv_sec = 0, .tv_nsec = only_mtime ? UTIME_OMIT : UTIME_NOW },
{ .tv_sec = 0, .tv_nsec = only_atime ? UTIME_OMIT : UTIME_NOW },
};
for (auto& filename : files)
{
SharedPtr<os::File> file;
if (no_create) file = TRY(os::File::open(filename, os::File::ReadOnly));
else
file = TRY(os::File::open_or_create(filename, os::File::ReadOnly));
if (futimens(file->fd(), times, no_dereference ? AT_SYMLINK_NOFOLLOW : 0) < 0) return err(errno);
}
return 0;
}

View File

@ -57,9 +57,6 @@ namespace Ext2
inode->m_metadata.nlinks = inode->m_raw_inode.nlinks;
inode->m_metadata.uid = inode->m_raw_inode.uid;
inode->m_metadata.gid = inode->m_raw_inode.gid;
inode->m_metadata.atime = { .tv_sec = inode->m_raw_inode.atime, .tv_nsec = 0 };
inode->m_metadata.mtime = { .tv_sec = inode->m_raw_inode.mtime, .tv_nsec = 0 };
inode->m_metadata.ctime = { .tv_sec = inode->m_raw_inode.create_time, .tv_nsec = 0 };
#ifdef EXT2_DEBUG
kdbgln("ext2: Read inode %lu with mode %#x (%#x + %#o), size %lu", inum, inode->m_raw_inode.mode,

View File

@ -1,5 +1,4 @@
#include "fs/tmpfs/FileSystem.h"
#include "arch/Timer.h"
#include "fs/devices/DeviceRegistry.h"
#include "fs/tmpfs/Inode.h"
#include <luna/Alloc.h>
@ -27,7 +26,6 @@ namespace TmpFS
inode->set_fs(*this, {});
inode->set_inode_number(m_next_inode_number++, {});
inode->m_metadata.mode = mode;
inode->m_metadata.atime = inode->m_metadata.ctime = inode->m_metadata.mtime = *Timer::realtime_clock();
return (SharedPtr<VFS::Inode>)inode;
}
@ -37,7 +35,6 @@ namespace TmpFS
inode->set_fs(*this, {});
TRY(inode->set_link(link, {}));
inode->set_inode_number(m_next_inode_number++, {});
inode->m_metadata.atime = inode->m_metadata.ctime = inode->m_metadata.mtime = *Timer::realtime_clock();
return (SharedPtr<VFS::Inode>)inode;
}
@ -52,7 +49,6 @@ namespace TmpFS
inode->set_fs(*this, {});
inode->set_inode_number(m_next_inode_number++, {});
inode->m_metadata.mode = mode;
inode->m_metadata.atime = inode->m_metadata.ctime = inode->m_metadata.mtime = *Timer::realtime_clock();
return (SharedPtr<VFS::Inode>)inode;
}
@ -69,8 +65,6 @@ namespace TmpFS
// device ID atm.
inode->set_device_id(luna_dev_makedev(major, minor), {});
inode->m_metadata.mode = mode;
inode->m_metadata.atime = inode->m_metadata.ctime = inode->m_metadata.mtime = *Timer::realtime_clock();
inode->m_metadata.size = device->size();
return (SharedPtr<VFS::Inode>)inode;
}

View File

@ -45,8 +45,6 @@ namespace TmpFS
inode->did_link();
m_metadata.mtime = *Timer::realtime_clock();
return {};
}
@ -63,8 +61,6 @@ namespace TmpFS
inode->did_unlink();
m_metadata.mtime = *Timer::realtime_clock();
return {};
}
@ -118,8 +114,6 @@ namespace TmpFS
m_metadata.size = m_data_buffer.size();
m_metadata.mtime = *Timer::realtime_clock();
return length;
}
@ -133,8 +127,6 @@ namespace TmpFS
m_metadata.size = m_data_buffer.size();
m_metadata.mtime = *Timer::realtime_clock();
return {};
}

View File

@ -4,11 +4,9 @@
#include "memory/MemoryManager.h"
#include "sys/Syscall.h"
#include "thread/Scheduler.h"
#include <bits/atfile.h>
#include <bits/fcntl.h>
#include <bits/open-flags.h>
#include <bits/seek.h>
#include <bits/utime.h>
#include <luna/SafeArithmetic.h>
#include <sys/types.h>
@ -264,58 +262,3 @@ Result<u64> sys_ftruncate(Registers*, SyscallArgs args)
return 0;
}
Result<u64> sys_utimensat(Registers*, SyscallArgs args)
{
int dirfd = (int)args[0];
auto path = TRY(MemoryManager::strdup_from_user(args[1]));
const auto* times = (const struct timespec*)args[2];
int flags = (int)args[3];
auto* current = Scheduler::current();
auto inode = TRY(current->resolve_atfile(dirfd, path, flags & AT_EMPTY_PATH, !(flags & AT_SYMLINK_NOFOLLOW)));
struct timespec ktimes[2];
ktimes[0].tv_sec = ktimes[1].tv_sec = 0;
ktimes[0].tv_nsec = ktimes[1].tv_nsec = UTIME_NOW;
if (times && !MemoryManager::copy_from_user(times, ktimes, sizeof(ktimes))) return err(EFAULT);
// No permission checks are performed, since no actual modification is done, but the above checks are still
// performed.
if (ktimes[0].tv_nsec == UTIME_OMIT && ktimes[1].tv_nsec == UTIME_OMIT) return 0;
bool allow_write_access = ktimes[0].tv_nsec == UTIME_NOW && ktimes[1].tv_nsec == UTIME_NOW;
if (allow_write_access)
{
if (!VFS::can_write(inode, current->auth) && current->auth.euid != inode->metadata().uid &&
current->auth.euid != 0)
return err(EACCES);
}
else if (current->auth.euid != inode->metadata().uid && current->auth.euid != 0)
return err(EPERM);
auto metadata = inode->metadata();
if (ktimes[0].tv_nsec != UTIME_OMIT)
{
if (ktimes[0].tv_nsec == UTIME_NOW) metadata.atime = *Timer::realtime_clock();
else
{
if (ktimes[0].tv_nsec < 0 || ktimes[0].tv_nsec > 999'999'999) return err(EINVAL);
metadata.atime = ktimes[0];
}
}
if (ktimes[1].tv_nsec != UTIME_OMIT)
{
if (ktimes[1].tv_nsec == UTIME_NOW) metadata.mtime = *Timer::realtime_clock();
else
{
if (ktimes[1].tv_nsec < 0 || ktimes[1].tv_nsec > 999'999'999) return err(EINVAL);
metadata.mtime = ktimes[1];
}
}
TRY(inode->set_metadata(metadata));
return 0;
}

View File

@ -48,9 +48,6 @@ Result<u64> sys_fstatat(Registers*, SyscallArgs args)
kstat.st_size = metadata.size;
kstat.st_dev = inode->fs() ? inode->fs()->host_device_id() : 0;
kstat.st_rdev = metadata.devid;
kstat.st_atim = metadata.atime;
kstat.st_mtim = metadata.mtime;
kstat.st_ctim = metadata.ctime;
if (!MemoryManager::copy_to_user_typed(st, &kstat)) return err(EFAULT);

View File

@ -23,8 +23,6 @@ set(SOURCES
src/scanf.cpp
src/signal.cpp
src/termios.cpp
src/utime.cpp
src/strtod.cpp
src/sys/stat.cpp
src/sys/mman.cpp
src/sys/wait.cpp

View File

@ -3,7 +3,6 @@
#ifndef _BITS_STRUCT_STAT_H
#define _BITS_STRUCT_STAT_H
#include <bits/timespec.h>
#include <sys/types.h>
struct stat
@ -16,13 +15,10 @@ struct stat
gid_t st_gid;
off_t st_size;
dev_t st_rdev;
struct timespec st_atim;
struct timespec st_mtim;
struct timespec st_ctim;
#define st_atime st_atim.tv_sec
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec
// FIXME: Actually fill these fields in.
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
#endif

View File

@ -1,9 +0,0 @@
/* bits/utime.h: Definitions for UTIME_NOW and UTIME_OMIT. */
#ifndef _BITS_UTIME_H
#define _BITS_UTIME_H
#define UTIME_NOW -1
#define UTIME_OMIT -2
#endif

View File

@ -84,11 +84,9 @@ extern "C"
/* Parse a decimal integer from a string. */
long long atoll(const char* s);
/* Parse a floating-point number from a string. */
double atof(const char* str);
double atof(const char*);
/* Parse a floating-point number from a string. */
double strtod(const char* str, char** endptr);
double strtod(const char*, char**);
/* Parse an integer of the specified base from a string, storing the first non-number character in endptr if
* nonnull. */

View File

@ -95,9 +95,6 @@ extern "C"
/* Compare two fixed-size null-terminated strings, ignoring case. */
int strncasecmp(const char* a, const char* b, size_t max);
/* Compare two null-terminated strings according to the current locale. */
int strcoll(const char* a, const char* b);
#ifdef __cplusplus
}
#endif

View File

@ -5,8 +5,6 @@
#include <bits/modes.h>
#include <bits/struct_stat.h>
#include <bits/timespec.h>
#include <bits/utime.h>
#include <sys/types.h>
#ifdef __cplusplus
@ -43,12 +41,6 @@ extern "C"
/* Change the process's file creation mask. */
mode_t umask(mode_t mask);
/* Change a file's access and modification timestamps, with nanosecond precision. */
int utimensat(int dirfd, const char* path, const struct timespec times[2], int flags);
/* Change a file's access and modification timestamps, with nanosecond precision. */
int futimens(int fd, const struct timespec times[2], int flags);
#ifdef __cplusplus
}
#endif

View File

@ -16,15 +16,6 @@ extern "C"
/* Get the current time of day. */
__deprecated int gettimeofday(struct timeval* tp, void* timezone);
/* Change a file's access and modification timestamps, with microsecond precision. */
int utimes(const char* path, const struct timeval buf[2]);
/* Change a file descriptor's access and modification timestamps, with microsecond precision. */
int futimes(int fd, const struct timeval buf[2]);
/* Change a symlink's access and modification timestamps, with microsecond precision. */
int lutimes(const char* path, const struct timeval buf[2]);
#ifdef __cplusplus
}
#endif

View File

@ -1,26 +0,0 @@
/* utime.h: The utime function. */
#ifndef _UTIME_H
#define _UTIME_H
#include <sys/types.h>
struct utimbuf
{
time_t actime;
time_t modtime;
};
#ifdef __cplusplus
extern "C"
{
#endif
/* Change a file's access and modification timestamps. */
int utime(const char* path, const struct utimbuf* buf);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -297,9 +297,4 @@ extern "C"
if (errno != EEXIST) return -1;
}
}
double atof(const char* str)
{
return strtod(str, nullptr);
}
}

View File

@ -9,12 +9,6 @@ extern "C"
extern "C++" const char* error_string(int);
int strcoll(const char* a, const char* b)
{
// In the POSIX or C locales strcoll() is equivalent to strcmp().
return strcmp(a, b);
}
char* strerror(int errnum)
{
return const_cast<char*>(error_string(errnum));

View File

@ -1,141 +0,0 @@
/* vi:set ts=8 sts=4 sw=4: */
/*
* strtod implementation.
* author: Yasuhiro Matsumoto
* license: public domain
*
* source from https://gist.github.com/mattn/1890186
*/
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static const char* skipwhite(const char* q)
{
const char* p = q;
while (isspace(*p)) ++p;
return p;
}
extern "C"
{
double strtod(const char* str, char** end)
{
double d = 0.0;
int sign;
int n = 0;
const char *p, *a;
a = p = str;
p = skipwhite(p);
/* decimal part */
sign = 1;
if (*p == '-')
{
sign = -1;
++p;
}
else if (*p == '+')
++p;
if (isdigit(*p))
{
d = (double)(*p++ - '0');
while (*p && isdigit(*p))
{
d = d * 10.0 + (double)(*p - '0');
++p;
++n;
}
a = p;
}
else if (*p != '.')
goto done;
d *= sign;
/* fraction part */
if (*p == '.')
{
double f = 0.0;
double base = 0.1;
++p;
if (isdigit(*p))
{
while (*p && isdigit(*p))
{
f += base * (*p - '0');
base /= 10.0;
++p;
++n;
}
}
d += f * sign;
a = p;
}
/* exponential part */
if ((*p == 'E') || (*p == 'e'))
{
int e = 0;
++p;
sign = 1;
if (*p == '-')
{
sign = -1;
++p;
}
else if (*p == '+')
++p;
if (isdigit(*p))
{
while (*p == '0') ++p;
if (*p == '\0') --p;
e = (int)(*p++ - '0');
while (*p && isdigit(*p))
{
e = e * 10 + (int)(*p - '0');
++p;
}
e *= sign;
}
else if (!isdigit(*(a - 1)))
{
a = str;
goto done;
}
else if (*p == 0)
goto done;
if (d == 2.2250738585072011 && e == -308)
{
d = 0.0;
a = p;
errno = ERANGE;
goto done;
}
if (d == 2.2250738585072012 && e <= -308)
{
d *= 1.0e-308;
a = p;
goto done;
}
d *= __builtin_powi(10.0, e);
a = p;
}
else if (p > str && !isdigit(*(p - 1)))
{
a = str;
goto done;
}
done:
if (end) *end = const_cast<char*>(a);
return d;
}
}

View File

@ -52,15 +52,4 @@ extern "C"
{
return (mode_t)syscall(SYS_umask, mask);
}
int utimensat(int dirfd, const char* path, const struct timespec* times, int flags)
{
long rc = syscall(SYS_utimensat, dirfd, path, times, flags);
__errno_return(rc, int);
}
int futimens(int fd, const struct timespec* times, int flags)
{
return utimensat(fd, "", times, flags | AT_EMPTY_PATH);
}
}

View File

@ -1,55 +0,0 @@
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <utime.h>
extern "C"
{
int utime(const char* path, const struct utimbuf* buf)
{
if (!buf) return utimensat(AT_FDCWD, path, nullptr, 0);
struct timespec times[2] = {
{ .tv_sec = buf->actime, .tv_nsec = 0 },
{ .tv_sec = buf->modtime, .tv_nsec = 0 },
};
return utimensat(AT_FDCWD, path, times, 0);
}
int utimes(const char* path, const struct timeval* buf)
{
if (!buf) return utimensat(AT_FDCWD, path, nullptr, 0);
struct timespec times[2] = {
{ .tv_sec = buf[0].tv_sec, .tv_nsec = buf[0].tv_usec * 1000 },
{ .tv_sec = buf[1].tv_sec, .tv_nsec = buf[1].tv_usec * 1000 },
};
return utimensat(AT_FDCWD, path, times, 0);
}
int futimes(int fd, const struct timeval* buf)
{
if (!buf) return utimensat(fd, "", nullptr, AT_EMPTY_PATH);
struct timespec times[2] = {
{ .tv_sec = buf[0].tv_sec, .tv_nsec = buf[0].tv_usec * 1000 },
{ .tv_sec = buf[1].tv_sec, .tv_nsec = buf[1].tv_usec * 1000 },
};
return utimensat(fd, "", times, AT_EMPTY_PATH);
}
int lutimes(const char* path, const struct timeval* buf)
{
if (!buf) return utimensat(AT_FDCWD, path, nullptr, AT_SYMLINK_NOFOLLOW);
struct timespec times[2] = {
{ .tv_sec = buf[0].tv_sec, .tv_nsec = buf[0].tv_usec * 1000 },
{ .tv_sec = buf[1].tv_sec, .tv_nsec = buf[1].tv_usec * 1000 },
};
return utimensat(AT_FDCWD, path, times, AT_SYMLINK_NOFOLLOW);
}
}

View File

@ -8,7 +8,7 @@
_e(umount) _e(pstat) _e(getrusage) _e(symlinkat) _e(readlinkat) _e(umask) _e(linkat) _e(faccessat) \
_e(pivot_root) _e(sigreturn) _e(sigaction) _e(kill) _e(sigprocmask) _e(setpgid) _e(isatty) \
_e(getpgid) _e(socket) _e(bind) _e(connect) _e(listen) _e(accept) _e(poll) _e(msync) \
_e(truncate) _e(ftruncate) _e(utimensat)
_e(truncate) _e(ftruncate)
enum Syscalls
{

View File

@ -12,7 +12,6 @@ Try to keep this list in alphabetical order.
Name | Version | Description | URL
---|---|--- | ---
bc | 6.6.0 | An implementation of the POSIX bc calculator | https://github.com/gavinhoward/bc
binutils | 2.39 | The GNU suite of binary utilities | https://www.gnu.org/software/binutils
minitar | 1.7.5 | Tiny and easy-to-use C library to read/write tar archives | https://git.cloudapio.eu/apio/minitar
nasm | 2.16.01 | An assembler for the x86 CPU architecture | https://nasm.us

View File

@ -1,30 +0,0 @@
# Basic information
name="binutils"
version="2.39"
# Download options
format="tar"
url="https://ftp.gnu.org/gnu/binutils/binutils-$version.tar.gz"
output="binutils-$version.tar.gz"
sha256sum="d12ea6f239f1ffe3533ea11ad6e224ffcb89eb5d01bbea589e9158780fa11f10"
# Build instructions
default_build_make=true
do_patch()
{
patch -ui $portdir/binutils.patch -p 1 -d $srcdir/..
}
do_configure()
{
$srcdir/configure --host=$LUNA_ARCH-luna --disable-nls --disable-werror --enable-warn-rwx-segments=no --prefix=/usr --enable-gold=no --enable-ld=yes --enable-gprofng=no
}
do_install()
{
make install
cd $installdir/usr/bin
$LUNA_ARCH-luna-strip size objdump ar strings ranlib objcopy addr2line readelf elfedit nm strip c++filt as gprof ld.bfd ld
}

View File

@ -1,117 +0,0 @@
diff --color -rN -u binutils-2.39/bfd/config.bfd build/binutils-2.39/bfd/config.bfd
--- a/binutils-2.39/bfd/config.bfd 2022-01-22 13:14:07.000000000 +0100
+++ b/binutils-2.39/bfd/config.bfd 2022-10-01 22:12:16.914033792 +0200
@@ -651,6 +651,11 @@
targ_selvecs="iamcu_elf32_vec i386_pei_vec"
targ64_selvecs="x86_64_elf64_vec x86_64_elf32_vec x86_64_pe_vec x86_64_pei_vec l1om_elf64_vec k1om_elf64_vec"
;;
+ i[3-7]86-*-luna*)
+ targ_defvec=i386_elf32_vec
+ targ_selvecs=
+ targ64_selvecs=x86_64_elf64_vec
+ ;;
i[3-7]86-*-redox*)
targ_defvec=i386_elf32_vec
targ_selvecs=
@@ -706,6 +711,11 @@
targ_selvecs="i386_elf32_vec iamcu_elf32_vec x86_64_elf32_vec i386_pei_vec x86_64_pe_vec x86_64_pei_vec l1om_elf64_vec k1om_elf64_vec"
want64=true
;;
+ x86_64-*-luna*)
+ targ_defvec=x86_64_elf64_vec
+ targ_selvecs=i386_elf32_vec
+ want64=true
+ ;;
x86_64-*-mingw* | x86_64-*-pe | x86_64-*-pep | x86_64-*-cygwin)
targ_defvec=x86_64_pe_vec
targ_selvecs="x86_64_pe_vec x86_64_pei_vec x86_64_pe_big_vec x86_64_elf64_vec l1om_elf64_vec k1om_elf64_vec i386_pe_vec i386_pei_vec i386_elf32_vec iamcu_elf32_vec"
diff --color -rN -u binutils-2.39/gas/configure.tgt build/binutils-2.39/gas/configure.tgt
--- a/binutils-2.39/gas/configure.tgt 2022-01-22 13:14:08.000000000 +0100
+++ b/binutils-2.39/gas/configure.tgt 2022-10-01 22:12.39.115093972 +0200
@@ -238,6 +238,7 @@
x86_64*-linux-gnux32) arch=x86_64:32 ;;
esac ;;
i386-*-lynxos*) fmt=elf em=lynx ;;
+ i386-*-luna*) fmt=elf em=gnu ;;
i386-*-redox*) fmt=elf ;;
i386-*-solaris*) fmt=elf em=solaris ;;
i386-*-freebsd* \
diff --color -rN -u binutils-2.39/ld/configure.tgt build/binutils-2.39/ld/configure.tgt
--- a/binutils-2.39/ld/configure.tgt 2022-01-22 15:19:36.000000000 +0100
+++ b/binutils-2.39/ld/configure.tgt 2022-10-01 22:15:04.853571062 +0200
@@ -329,6 +329,11 @@
targ64_extra_emuls="elf_x86_64 elf32_x86_64 elf_l1om elf_k1om"
targ64_extra_libpath="elf_x86_64 elf32_x86_64"
;;
+i[3-7]86-*-luna*)
+ targ_emul=elf_i386_luna
+ targ_extra_emuls=elf_i386
+ targ64_extra_emuls="elf_x86_64_luna elf_x86_64"
+ ;;
i[3-7]86-*-redox*) targ_emul=elf_i386
targ_extra_emuls=elf_x86_64
;;
@@ -967,6 +972,10 @@
targ_extra_libpath="elf_i386 elf32_x86_64 elf_l1om elf_k1om"
tdir_elf_i386=`echo ${targ_alias} | sed -e 's/x86_64/i386/'`
;;
+x86_64-*-luna*)
+ targ_emul=elf_x86_64_luna
+ targ_extra_emuls="elf_i386_luna elf_x86_64 elf_i386"
+ ;;
x86_64-*-redox*) targ_emul=elf_x86_64
targ_extra_emuls=elf_i386
;;
diff --color -rN -u binutils-2.39/ld/emulparams/elf_i386_luna.sh build/binutils-2.39/ld/emulparams/elf_i386_luna.sh
--- a/dev/null 1970-01-01 01:00:00.000000000 +0100
+++ b/binutils-2.39/ld/emulparams/elf_i386_luna.sh 2022-10-01 21:52:12.394068335 +0200
@@ -0,0 +1,3 @@
+source_sh ${srcdir}/emulparams/elf_i386.sh
+TEXT_START_ADDR=0x08000000
+MAXPAGESIZE=0x1000
\ No newline at end of file
diff --color -rN -u binutils-2.39/ld/emulparams/elf_x86_64_luna.sh build/binutils-2.39/ld/emulparams/elf_x86_64_luna.sh
--- a/dev/null 1970-01-01 01:00:00.000000000 +0100
+++ b/binutils-2.39/ld/emulparams/elf_x86_64_luna.sh 2022-10-01 21:53:00.411200592 +0200
@@ -0,0 +1,2 @@
+source_sh ${srcdir}/emulparams/elf_x86_64.sh
+MAXPAGESIZE=0x1000
\ No newline at end of file
diff --color -rN -u binutils-2.39/ld/Makefile.am build/binutils-2.39/ld/Makefile.am
--- a/binutils-2.39/ld/Makefile.am 2022-01-22 13:14:09.000000000 +0100
+++ b/binutils-2.39/ld/Makefile.am 2022-10-01 22:18:02.660263017 +0200
@@ -278,6 +278,7 @@
eelf32xtensa.c \
eelf32z80.c \
eelf_i386.c \
+ eelf_i386_luna.c \
eelf_i386_be.c \
eelf_i386_fbsd.c \
eelf_i386_haiku.c \
@@ -464,6 +465,7 @@
eelf_x86_64_fbsd.c \
eelf_x86_64_haiku.c \
eelf_x86_64_sol2.c \
+ eelf_x86_64_luna.c \
ehppa64linux.c \
ei386pep.c \
emmo.c
diff --color -rN -u binutils-2.39/ld/Makefile.in build/binutils-2.39/ld/Makefile.in
--- a/binutils-2.39/ld/Makefile.in 2022-02-09 12:49:03.000000000 +0100
+++ b/binutils-2.39/ld/Makefile.in 2022-10-01 22:17:46.740196925 +0200
@@ -769,6 +769,7 @@
eelf32xtensa.c \
eelf32z80.c \
eelf_i386.c \
+ eelf_i386_luna.c \
eelf_i386_be.c \
eelf_i386_fbsd.c \
eelf_i386_haiku.c \
@@ -954,6 +955,7 @@
eelf_x86_64_fbsd.c \
eelf_x86_64_haiku.c \
eelf_x86_64_sol2.c \
+ eelf_x86_64_luna.c \
ehppa64linux.c \
ei386pep.c \
emmo.c

View File

@ -7,10 +7,6 @@ cd $LUNA_ROOT
fakeroot -u -s $LUNA_ROOT/.fakeroot -- tools/install.sh
disk_space=$(du -s base | awk '{ print $1 }')
min_blocks=$(($disk_space / 4)) # This is just the blocks needed for all the files in the file system: this excludes space for the inode table, block group descriptors, etc.
blocks=$(($min_blocks + 1024)) # This is the actual number of blocks we're using.
fakeroot -u -i $LUNA_ROOT/.fakeroot -- genext2fs -d base -B 4096 -b $blocks -L luna-rootfs -N 1024 build/ext2fs.bin
fakeroot -u -i $LUNA_ROOT/.fakeroot -- genext2fs -d base -B 4096 -b 8192 -L luna-rootfs -N 2048 build/ext2fs.bin
mkbootimg luna.json Luna.iso