Compare commits
9 Commits
032d0f8aca
...
dbd1264352
Author | SHA1 | Date |
---|---|---|
Daniel Barlow | dbd1264352 | |
Daniel Barlow | 834858d5bc | |
Daniel Barlow | 18335b95e3 | |
Daniel Barlow | 6bee2f67ac | |
Daniel Barlow | b4ba3eea21 | |
Daniel Barlow | 16af3984c9 | |
Daniel Barlow | ce7e395295 | |
Daniel Barlow | 7e13e017eb | |
Daniel Barlow | bbf2f53c0e |
14
THOUGHTS.txt
14
THOUGHTS.txt
|
@ -4722,11 +4722,15 @@ I think we could make the event loop abstraction leak less?
|
||||||
It's not actually a _loop_, all the actual GOTO 10 happens
|
It's not actually a _loop_, all the actual GOTO 10 happens
|
||||||
outside of it
|
outside of it
|
||||||
|
|
||||||
1) see if we can do netlink in lualinux
|
[X] 1) see if we can do netlink in lualinux
|
||||||
2) if so, convert it to lualinux
|
[X] 2) if so, convert it to lualinux
|
||||||
3) add netlink socket to event loop
|
[X] 3) add netlink socket to event loop
|
||||||
4) make it send messages to subscribers
|
[X] 4) make it send messages to subscribers
|
||||||
5) package it
|
5) package it
|
||||||
6) make inout test use it instead of uevent-watcher
|
6) make uevent-watcher use it instead of netlink directly
|
||||||
7) write an inout test variant that has the stick inserted
|
7) write an inout test variant that has the stick inserted
|
||||||
at boot time already
|
at boot time already
|
||||||
|
|
||||||
|
I'm also thinking we could wrap the raw fds from lualinux into small
|
||||||
|
objects with read and close methods? It would make testing easier if
|
||||||
|
nothing else - also use of with-open. Maybe do that in anoia.
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
fennel
|
fennel
|
||||||
, stdenv
|
, stdenv
|
||||||
, lua
|
, lua
|
||||||
|
, lualinux
|
||||||
}:
|
}:
|
||||||
let pname = "anoia";
|
let pname = "anoia";
|
||||||
in stdenv.mkDerivation {
|
in stdenv.mkDerivation {
|
||||||
|
@ -9,7 +10,7 @@ in stdenv.mkDerivation {
|
||||||
version = "0.1";
|
version = "0.1";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
nativeBuildInputs = [ fennel ];
|
nativeBuildInputs = [ fennel ];
|
||||||
buildInputs = with lua.pkgs; [ luafilesystem ];
|
buildInputs = with lua.pkgs; [ luafilesystem lualinux ];
|
||||||
outputs = [ "out" "dev" ];
|
outputs = [ "out" "dev" ];
|
||||||
|
|
||||||
doCheck = true;
|
doCheck = true;
|
||||||
|
|
|
@ -1,7 +1,19 @@
|
||||||
(local lfs (require :lfs))
|
(local ll (require :lualinux))
|
||||||
|
|
||||||
|
(local S_IFMT 0xf000)
|
||||||
|
(local S_IFSOCK 0xc000)
|
||||||
|
(local S_IFLNK 0xa000)
|
||||||
|
(local S_IFREG 0x8000)
|
||||||
|
(local S_IFBLK 0x6000)
|
||||||
|
(local S_IFDIR 0x4000)
|
||||||
|
(local S_IFCHR 0x2000)
|
||||||
|
(local S_IFIFO 0x1000)
|
||||||
|
|
||||||
|
(fn ifmt-bits [mode] (and mode (band mode 0xf000)))
|
||||||
|
|
||||||
(fn directory? [pathname]
|
(fn directory? [pathname]
|
||||||
(= (lfs.symlinkattributes pathname :mode) "directory"))
|
(let [(mode size mtime) (ll.lstat3 pathname)]
|
||||||
|
(= (ifmt-bits mode) S_IFDIR)))
|
||||||
|
|
||||||
(fn mktree [pathname]
|
(fn mktree [pathname]
|
||||||
(if (or (= pathname "") (= pathname "/"))
|
(if (or (= pathname "") (= pathname "/"))
|
||||||
|
@ -10,28 +22,28 @@
|
||||||
(or (directory? pathname)
|
(or (directory? pathname)
|
||||||
(let [parent (string.gsub pathname "/[^/]+/?$" "")]
|
(let [parent (string.gsub pathname "/[^/]+/?$" "")]
|
||||||
(or (directory? parent) (mktree parent))
|
(or (directory? parent) (mktree parent))
|
||||||
(assert (lfs.mkdir pathname)))))
|
(assert (ll.mkdir pathname)))))
|
||||||
|
|
||||||
(fn rmtree [pathname]
|
(fn rmtree [pathname]
|
||||||
(case (lfs.symlinkattributes pathname)
|
(case (ifmt-bits (ll.lstat3 pathname))
|
||||||
nil true
|
nil true
|
||||||
{:mode "directory"}
|
S_IFDIR
|
||||||
(do
|
(do
|
||||||
(each [f (lfs.dir pathname)]
|
(each [f (lfs.dir pathname)]
|
||||||
(when (not (or (= f ".") (= f "..")))
|
(when (not (or (= f ".") (= f "..")))
|
||||||
(rmtree ( .. pathname "/" f)))
|
(rmtree ( .. pathname "/" f)))
|
||||||
(lfs.rmdir pathname)))
|
(lfs.rmdir pathname)))
|
||||||
{:mode "file"}
|
S_IFREG
|
||||||
(os.remove pathname)
|
(os.remove pathname)
|
||||||
{:mode "link"}
|
S_IFLNK
|
||||||
(os.remove pathname)
|
(os.remove pathname)
|
||||||
unknown
|
unknown
|
||||||
(error (.. "can't remove " pathname " of kind \"" unknown.mode "\""))))
|
(error (.. "can't remove " pathname " of mode \"" unknown "\""))))
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
: mktree
|
: mktree
|
||||||
: rmtree
|
: rmtree
|
||||||
: directory?
|
: directory?
|
||||||
:symlink (fn [from to] (lfs.link from to true))
|
:symlink (fn [from to] (ll.symlink from to))
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,11 +82,11 @@
|
||||||
(collect [_ v (ipairs pollfds)]
|
(collect [_ v (ipairs pollfds)]
|
||||||
(let [fd (band (rshift v 32) 0xffffffff)
|
(let [fd (band (rshift v 32) 0xffffffff)
|
||||||
revent (band v 0xffff)]
|
revent (band v 0xffff)]
|
||||||
(values fd revent))))
|
(values fd (if (> revent 0) revent nil)))))
|
||||||
|
|
||||||
(fn parse-terms [str]
|
(fn parse-terms [str]
|
||||||
(print :terms str)
|
(print :terms str)
|
||||||
(collect [n (string.gmatch str "([^ ]+)")]
|
(collect [n (string.gmatch (str:gsub "\n+$" "") "([^ ]+)")]
|
||||||
(string.match n "(.-)=(.+)")))
|
(string.match n "(.-)=(.+)")))
|
||||||
|
|
||||||
(fn handle-client [db client]
|
(fn handle-client [db client]
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
true)))
|
true)))
|
||||||
(loop:register
|
(loop:register
|
||||||
nl
|
nl
|
||||||
#(do (print :netlink (ll.read nl)) true))
|
#(do (db:add (ll.read nl)) true))
|
||||||
(while true
|
(while true
|
||||||
(let [pollfds (pollfds-for (loop:fds))]
|
(let [pollfds (pollfds-for (loop:fds))]
|
||||||
(ll.poll pollfds 5000)
|
(ll.poll pollfds 5000)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(local { : database : event-loop } (require :devout))
|
(local { : database : event-loop } (require :devout))
|
||||||
(local { : view } (require :fennel))
|
(local { : view } (require :fennel))
|
||||||
(local sock (require :minisock))
|
(local ll (require :lualinux))
|
||||||
(import-macros { : expect : expect= } :anoia.assert)
|
(import-macros { : expect : expect= } :anoia.assert)
|
||||||
|
|
||||||
(var failed false)
|
(var failed false)
|
||||||
|
@ -166,9 +166,7 @@ MINOR=17")
|
||||||
))
|
))
|
||||||
|
|
||||||
(fn new-fd []
|
(fn new-fd []
|
||||||
(let [fd (sock.bind (.. "\1\0" "/tmp/test-socket" "\0\0\0\0\0"))]
|
(ll.open "/dev/zero" 0 0x1ff))
|
||||||
(os.remove "/tmp/test-socket")
|
|
||||||
fd))
|
|
||||||
|
|
||||||
(example
|
(example
|
||||||
"when the callback returns false it is unregistered and the fd is closed"
|
"when the callback returns false it is unregistered and the fd is closed"
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
, lib
|
, lib
|
||||||
, luaPackages
|
, luaPackages
|
||||||
, lua
|
, lua
|
||||||
|
, lualinux
|
||||||
, writeScriptBin
|
, writeScriptBin
|
||||||
, linotify
|
, linotify
|
||||||
, anoia
|
, anoia
|
||||||
|
@ -15,7 +16,9 @@ let packages = [
|
||||||
linotify
|
linotify
|
||||||
anoia
|
anoia
|
||||||
fennel
|
fennel
|
||||||
|
lualinux
|
||||||
netlink-lua
|
netlink-lua
|
||||||
|
lua.pkgs.readline
|
||||||
lua.pkgs.luafilesystem
|
lua.pkgs.luafilesystem
|
||||||
];
|
];
|
||||||
join = ps: builtins.concatStringsSep ";" ps;
|
join = ps: builtins.concatStringsSep ";" ps;
|
||||||
|
|
|
@ -12,7 +12,10 @@ in lua.pkgs.buildLuaPackage {
|
||||||
version = "0.1"; # :shrug:
|
version = "0.1"; # :shrug:
|
||||||
|
|
||||||
inherit src;
|
inherit src;
|
||||||
makeFlags = [ "LUADIR=." "lualinux.so" ];
|
postPatch = ''
|
||||||
|
sed -i -e '/strip/d' Makefile
|
||||||
|
'';
|
||||||
|
makeFlags = [ "LUADIR=." "CC:=$(CC)" "STRIP=true" "lualinux.so" ];
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p "$out/lib/lua/${lua.luaversion}"
|
mkdir -p "$out/lib/lua/${lua.luaversion}"
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
writeFennelScript
|
writeFennelScript
|
||||||
, anoia
|
, anoia
|
||||||
, lua
|
, lua
|
||||||
|
, lualinux
|
||||||
}:
|
}:
|
||||||
writeFennelScript "odhcpc-script" [anoia lua.pkgs.luafilesystem] ./odhcp6-script.fnl
|
writeFennelScript "odhcpc-script" [anoia lualinux] ./odhcp6-script.fnl
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
lua
|
lua
|
||||||
, nellie
|
, nellie
|
||||||
|
, lualinux
|
||||||
, writeFennel
|
, writeFennel
|
||||||
, runCommand
|
, runCommand
|
||||||
, anoia
|
, anoia
|
||||||
|
@ -15,7 +16,7 @@ stdenv.mkDerivation {
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp -p ${writeFennel "uevent-watch" {
|
cp -p ${writeFennel "uevent-watch" {
|
||||||
packages = [fennel anoia nellie lua.pkgs.luafilesystem];
|
packages = [fennel anoia nellie lualinux];
|
||||||
mainFunction = "run";
|
mainFunction = "run";
|
||||||
} ./watch.fnl} $out/bin/uevent-watch
|
} ./watch.fnl} $out/bin/uevent-watch
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Reference in New Issue