Compare commits
5 Commits
3619b03290
...
36409cc472
Author | SHA1 | Date |
---|---|---|
Izaya | 36409cc472 | |
Izaya | 7ad9f21182 | |
Izaya | 2d386f1276 | |
Izaya | 2867038094 | |
Izaya | 7544fdc578 |
6
Makefile
6
Makefile
|
@ -1,7 +1,7 @@
|
||||||
# LuPI2 Makefile
|
# LuPI2 Makefile
|
||||||
|
|
||||||
# Default compiler settings.
|
# Default compiler settings.
|
||||||
PREFIX?=x86_64-linux-musl
|
PREFIX?=powerpc-linux-musl
|
||||||
|
|
||||||
CC = $(PREFIX)-gcc
|
CC = $(PREFIX)-gcc
|
||||||
CFLAGS?=-O2 -std=c99 -fdata-sections -ffunction-sections -pthread
|
CFLAGS?=-O2 -std=c99 -fdata-sections -ffunction-sections -pthread
|
||||||
|
@ -67,10 +67,10 @@ web: iso bin/web
|
||||||
|
|
||||||
|
|
||||||
####
|
####
|
||||||
ISOKERNEL=linux-4.5.2
|
ISOKERNEL=linux-5.12.1
|
||||||
|
|
||||||
dependencies/$(ISOKERNEL).tar.xz:
|
dependencies/$(ISOKERNEL).tar.xz:
|
||||||
cd dependencies && wget https://cdn.kernel.org/pub/linux/kernel/v4.x/$(ISOKERNEL).tar.xz
|
cd dependencies && wget https://cdn.kernel.org/pub/linux/kernel/v5.x/$(ISOKERNEL).tar.xz
|
||||||
|
|
||||||
dependencies/$(ISOKERNEL)/arch/x86/boot/bzImage: $(BUILD)lupi.cpio dependencies/$(ISOKERNEL).tar.xz
|
dependencies/$(ISOKERNEL)/arch/x86/boot/bzImage: $(BUILD)lupi.cpio dependencies/$(ISOKERNEL).tar.xz
|
||||||
rm -rf dependencies/$(ISOKERNEL)/
|
rm -rf dependencies/$(ISOKERNEL)/
|
||||||
|
|
|
@ -38,6 +38,10 @@ case "$1" in
|
||||||
TOOL=i686-w64-mingw32
|
TOOL=i686-w64-mingw32
|
||||||
OUT=$TOOL
|
OUT=$TOOL
|
||||||
;;
|
;;
|
||||||
|
powerpc )
|
||||||
|
TOOL=powerpc-linux-musl
|
||||||
|
OUT=$TOOL
|
||||||
|
;;
|
||||||
*) echo "Invalid target!" ; exit 1
|
*) echo "Invalid target!" ; exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -11,6 +11,7 @@ void lupi_init() {
|
||||||
if(getpid() == 1) {
|
if(getpid() == 1) {
|
||||||
mount(NULL, "/sys", "sysfs", 0, NULL);
|
mount(NULL, "/sys", "sysfs", 0, NULL);
|
||||||
mount(NULL, "/proc", "procfs", 0, NULL);
|
mount(NULL, "/proc", "procfs", 0, NULL);
|
||||||
|
mount(NULL, "/tmp", "tmpfs", 0, NULL);
|
||||||
}
|
}
|
||||||
struct statvfs fsstat;
|
struct statvfs fsstat;
|
||||||
|
|
||||||
|
@ -21,4 +22,4 @@ void lupi_init() {
|
||||||
void lupi_init() {
|
void lupi_init() {
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <linux/reboot.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -151,7 +152,7 @@ static int l_fs_spaceUsed (lua_State *L) {
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
struct statvfs s;
|
struct statvfs s;
|
||||||
if( statvfs(fname, &s) != -1 ) {
|
if( statvfs(fname, &s) != -1 ) {
|
||||||
lua_pushnumber(L, s.f_bsize * s.f_bfree);
|
lua_pushnumber(L, s.f_bsize * (s.f_blocks - s.f_bfree));
|
||||||
} else {
|
} else {
|
||||||
lua_pushnumber(L, -1);
|
lua_pushnumber(L, -1);
|
||||||
}
|
}
|
||||||
|
@ -377,6 +378,18 @@ static int l_uptime (lua_State *L) { /* Return ms */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int l_shutdown(lua_State *L) {
|
||||||
|
int shutdownmode = lua_toboolean(L, 1);
|
||||||
|
sync();
|
||||||
|
printf("%i", shutdownmode);
|
||||||
|
int rebootcmd = LINUX_REBOOT_CMD_POWER_OFF;
|
||||||
|
if (shutdownmode == 1) {
|
||||||
|
rebootcmd = LINUX_REBOOT_CMD_RESTART;
|
||||||
|
}
|
||||||
|
reboot(rebootcmd);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
static int l_totalMemory (lua_State *L) {
|
static int l_totalMemory (lua_State *L) {
|
||||||
#if defined(_WIN32) && (defined(__CYGWIN__) || defined(__CYGWIN32__))
|
#if defined(_WIN32) && (defined(__CYGWIN__) || defined(__CYGWIN32__))
|
||||||
MEMORYSTATUS status;
|
MEMORYSTATUS status;
|
||||||
|
@ -492,6 +505,7 @@ void luanative_start(lua_State *L) {
|
||||||
{"towupper", l_towupper},
|
{"towupper", l_towupper},
|
||||||
{"beep", l_beep},
|
{"beep", l_beep},
|
||||||
{"uptime", l_uptime},
|
{"uptime", l_uptime},
|
||||||
|
{"shutdown", l_shutdown},
|
||||||
{"totalMemory", l_totalMemory},
|
{"totalMemory", l_totalMemory},
|
||||||
{"freeMemory", l_freeMemory},
|
{"freeMemory", l_freeMemory},
|
||||||
{"pull", l_pull},
|
{"pull", l_pull},
|
||||||
|
|
|
@ -166,7 +166,7 @@ function api.totalMemory()
|
||||||
return native.totalMemory()
|
return native.totalMemory()
|
||||||
end
|
end
|
||||||
|
|
||||||
function api.shutdown()
|
function api.shutdown(reboot)
|
||||||
--TODO: Longjmp to init somehow?
|
--TODO: Longjmp to init somehow?
|
||||||
print("Running shutdown hooks")
|
print("Running shutdown hooks")
|
||||||
for k, hook in ipairs(deadhooks) do
|
for k, hook in ipairs(deadhooks) do
|
||||||
|
@ -178,7 +178,8 @@ function api.shutdown()
|
||||||
end
|
end
|
||||||
print("Hooks executed: " .. #deadhooks)
|
print("Hooks executed: " .. #deadhooks)
|
||||||
|
|
||||||
|
native.shutdown(reboot)
|
||||||
os.exit(0)
|
os.exit(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
return computer
|
return computer
|
||||||
|
|
|
@ -123,7 +123,7 @@ function filesystem.register(basePath, uuid)
|
||||||
end
|
end
|
||||||
function fs.list(path)
|
function fs.list(path)
|
||||||
checkArg(1, path, "string")
|
checkArg(1, path, "string")
|
||||||
return native.fs_list(realpath(path)) --TODO: Test, check if dirs get / at end
|
return native.fs_list(realpath(path)) or {} --TODO: Test, check if dirs get / at end
|
||||||
end
|
end
|
||||||
function fs.lastModified(path)
|
function fs.lastModified(path)
|
||||||
checkArg(1, path, "string")
|
checkArg(1, path, "string")
|
||||||
|
@ -159,4 +159,4 @@ function filesystem.register(basePath, uuid)
|
||||||
return modules.component.api.register(uuid, "filesystem", fs)
|
return modules.component.api.register(uuid, "filesystem", fs)
|
||||||
end
|
end
|
||||||
|
|
||||||
return filesystem
|
return filesystem
|
||||||
|
|
Loading…
Reference in New Issue