Giter Site home page Giter Site logo

Eudev: Coldplug and settle about finit HOT 15 CLOSED

xhebox avatar xhebox commented on May 12, 2024
Eudev: Coldplug and settle

from finit.

Comments (15)

xhebox avatar xhebox commented on May 12, 2024 1

Tested, nice work!

from finit.

troglobit avatar troglobit commented on May 12, 2024 1

Thank you for your patience! 😌

from finit.

troglobit avatar troglobit commented on May 12, 2024

This could be a good place to gather information and links to experiences with both udev and eudev. I think it's great that you're using Finit and trying it out with udev and eudev! 😃

Unfortunately, my primary use-case for Finit is embedded, with BusyBox and thus mdev. At least for the moment, so I wont be able to test and help out as much as I'd like. There are some thoughts about moving to Alpine Linux "soonish", which could be beneficial to this issue, but not in the near future.

However, as usual I'm more than happy to discuss fixes and pull requests with fixes and/or extensions to support other systems.

from finit.

xhebox avatar xhebox commented on May 12, 2024

@troglobit is there a function in finit that run commands sync(not async or fork)? I think i get the point, udevd is running while mounting, so....

gentoo's openrc is sync, right?

from finit.

troglobit avatar troglobit commented on May 12, 2024

Yup, there's run ... it's like task but runs in sequence in the given runlevel. So try something like this:

service [S] /path/to/daemon1 ... 
run [S] /path/to/cmd --some-args -- Some description of what cmd does
# Service will not be started until cmd has completed.
service [S12345] /path/to/daemon2 -- Description

At boot, runlevel [S], this example starts daemon1 in the background and then waits for cmd to complete before proceeding to fork off daemon2. Hopefully this does what you want.

Both systemd and OpenRC can also be made to execute tasks synchronously.

from finit.

xhebox avatar xhebox commented on May 12, 2024

@troglobit Oh...my god...you should not move bootclean to bootmisc, since it will clean udev!

--- finit.c 2016-11-20 13:33:11.277907155 +0000
+++ b/finit.c   2016-11-20 13:33:11.277907155 +0000
@@ -329,8 +331,9 @@

    run_interactive(devfsd, "Populating device tree");
    if (fexist("/sbin/udevadm")) {
        run("/sbin/udevadm trigger --action=add --type=subsystems");
        run("/sbin/udevadm trigger --action=add --type=devices");
+       run("/sbin/udevadm settle --timeout=120");
    }

    /*
--- .src/finit-master/plugins/bootmisc.c    2016-11-20 15:15:38.257645296 +0000
+++ finit-master/plugins/bootmisc.c 2016-11-20 15:15:38.257645296 +0000
@@ -39,6 +39,9 @@

 static int do_clean(const char *fpath, const struct stat *UNUSED(sb), int UNUSED(tflag), struct FTW *ftwbuf)
 {
+   // skip udev files
+   if((strstr(fpath, "/var/run/udev") - fpath) == 0)
+       return 0;
    if (ftwbuf->level == 0)
        return 1;

EDIT: /var/run is a link to /run on my system, also a number of others...

from finit.

troglobit avatar troglobit commented on May 12, 2024

Actually, /var/run (or /run) should be clean on boot. But what you're saying is that there is a dependency on udev/eudev to run after bootclean?

I'm thinking maybe it's time to move that part of the boot to a plugin and properly delare that plugin to depend on bootmisc.so. That way the udev files would not be removed.

Good catch!

from finit.

troglobit avatar troglobit commented on May 12, 2024

OK, I've now looked at how SysV init in Debian does this.

  1. In mountall, which runs very early, they mark tmpfs file systems like /run with a flag, /run/.tmpfs
  2. In bootclean, which runs before bootmisc, they check for $DIR/.tmpfs before cleaning out files

How do you set up /var/run or /run? In Finit I have added builtin support for creating /run as a tmpfs if its not already mounted, with /var/run symlink created in bootmisc. Maybe you are using something else?

My idea right now is to skip all mount points listed in bootclean() which we can identify as tmpfs using /proc/mounts.

from finit.

troglobit avatar troglobit commented on May 12, 2024

@xhebox I hope these two fixes resolve your issue. If not, feel free to reopen it or file a new issue.

from finit.

xhebox avatar xhebox commented on May 12, 2024

@troglobit I cant reopen the issue you closed...

And this is not working. You need to find which file the symbolic refers to, this check the link file /var/run but miss the real dir /run.

from finit.

troglobit avatar troglobit commented on May 12, 2024

Ah, thanks. Didn't know I was the only one allowed to reopen issues.

OK, you're obviously correct, sorry! I'll improve the check.

from finit.

troglobit avatar troglobit commented on May 12, 2024

Hopefully current master, as of 47060c9, works better ...

from finit.

xhebox avatar xhebox commented on May 12, 2024

@troglobit Not working, you need to use lstat, since stat will resolve the symbolic automatically. And strip the '/' from the end of path. Check the man. But forget it, i think this way better:

--- bootmisc.c	2016-11-21 13:29:55.725183408 +0000
+++ b/plugins/bootmisc.c	2016-11-21 13:29:55.725183408 +0000
@@ -32,33 +32,15 @@
 #include "../plugin.h"
 #include "../utmp-api.h"
 
-/* Resolve symbolic links */
-static char *desym(char *dir)
-{
-	static char path[80];	/* Should be enough for our use-case */
-	struct stat st;
-
-	if (stat(dir, &st))
-		return NULL;
-
-	if (S_ISLNK(st.st_mode)) {
-		if (-1 == readlink(dir, path, sizeof(path)))
-			return NULL;
-
-		return desym(path);
-	}
-
-	return dir;
-}
-
-static int is_tmpfs(char *dir)
+static int is_tmpfs(char *path)
 {
 	int tmpfs = 0;
 	FILE *fp;
 	struct mntent *mnt;
+	static char dir[80];	/* Should be enough for our use-case */
 
 	/* If /var/run is a symlink, check what it resolves to */
-	dir = desym(dir);
+	realpath(path, dir);
 	if (!dir)
 		return 0;	/* Outlook not so good */
 

More there.

from finit.

troglobit avatar troglobit commented on May 12, 2024

Ah, lstat() of course. Your version looks much cleaner, didn't even know about realpath(), thanks!

from finit.

troglobit avatar troglobit commented on May 12, 2024

Slight variation of your proposal, without hardcoded array, in b9ae4d0.

from finit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.