Discussion:
[Toybox] [PATCH] macOS: move getmountlist.c functions into portability.c.
Reverend Homer
2018-12-04 21:28:20 UTC
Permalink
<...>
+
+// Get a linked list of mount points, with stat information.
+#ifdef __APPLE__
+
+// Not implemented for macOS.
+// See <sys/mount.h>'s getmntinfo(3) for the BSD API.
+
Shouldn't there be some warning?


R.H.
+#else
+
+#include <mntent.h>
+
+static void octal_deslash(char *s)
+{
+ char *o = s;
+
+ while (*s) {
+ if (*s == '\\') {
+ int i, oct = 0;
+
+ for (i = 1; i < 4; i++) {
+ if (!isdigit(s[i])) break;
+ oct = (oct<<3)+s[i]-'0';
+ }
+ if (i == 4) {
+ *o++ = oct;
+ s += i;
+ continue;
+ }
+ }
+ *o++ = *s++;
+ }
+
+ *o = 0;
+}
+
+// Check if this type matches list.
+// Odd syntax: typelist all yes = if any, typelist all no = if none.
+
+int mountlist_istype(struct mtab_list *ml, char *typelist)
+{
+ int len, skip;
+ char *t;
+
+ if (!typelist) return 1;
+
+ skip = strncmp(typelist, "no", 2);
+
+ for (;;) {
+ if (!(t = comma_iterate(&typelist, &len))) break;
+ if (!skip) {
+ // If one -t starts with "no", the rest must too
+ if (strncmp(t, "no", 2)) error_exit("bad typelist");
+ if (!strncmp(t+2, ml->type, len-2)) {
+ skip = 1;
+ break;
+ }
+ } else if (!strncmp(t, ml->type, len) && !ml->type[len]) {
+ skip = 0;
+ break;
+ }
+ }
+
+ return !skip;
+}
+
+// Get list of mounted filesystems, including stat and statvfs info.
+// Returns a reversed list, which is good for finding overmounts and such.
+
+struct mtab_list *xgetmountlist(char *path)
+{
+ struct mtab_list *mtlist = 0, *mt;
+ struct mntent *me;
+ FILE *fp;
+ char *p = path ? path : "/proc/mounts";
+
+ if (!(fp = setmntent(p, "r"))) perror_exit("bad %s", p);
+
+ // The "test" part of the loop is done before the first time through and
+ // again after each "increment", so putting the actual load there avoids
+ // duplicating it. If the load was NULL, the loop stops.
+
+ while ((me = getmntent(fp))) {
+ mt = xzalloc(sizeof(struct mtab_list) + strlen(me->mnt_fsname) +
+ strlen(me->mnt_dir) + strlen(me->mnt_type) + strlen(me->mnt_opts) + 4);
+ dlist_add_nomalloc((void *)&mtlist, (void *)mt);
+
+ // Collect details about mounted filesystem
+ // Don't report errors, just leave data zeroed
+ if (!path) {
+ stat(me->mnt_dir, &(mt->stat));
+ statvfs(me->mnt_dir, &(mt->statvfs));
+ }
+
+ // Remember information from /proc/mounts
+ mt->dir = stpcpy(mt->type, me->mnt_type)+1;
+ mt->device = stpcpy(mt->dir, me->mnt_dir)+1;
+ mt->opts = stpcpy(mt->device, me->mnt_fsname)+1;
+ strcpy(mt->opts, me->mnt_opts);
+
+ octal_deslash(mt->dir);
+ octal_deslash(mt->device);
+ }
+ endmntent(fp);
+
+ return mtlist;
+}
+
+#endif
_______________________________________________
Toybox mailing list
http://lists.landley.net/listinfo.cgi/toybox-landley.net
Rob Landley
2018-12-04 22:15:31 UTC
Permalink
it'll fail to build if you actually try to build a toy that needs these :-)
Oddy enough for that one I got your reply, but not Revend Homer's, and going
through the spam filter (about 35 things from the buildroot list and such had
wound up in there since I last checked)... still didn't find it.

I suspect gmail did the "refuse delivery" thing, except I didn't get unsubcribed
from the list again? (Does it have a third "accept delivery but discard and not
even put it in the spam folder" option?)

Wheee,

Rob
Reverend Homer
2018-12-05 08:47:39 UTC
Permalink
There's something strange about gmail and this mailing list.  I still can read
your messages only from Elliot Hughes' replies (And of course I saw that
message since you Cc'ed me). I can't even find your messages in the "Spam"
folder in Thunderbird!


Confused,

R.H.
Post by Rob Landley
it'll fail to build if you actually try to build a toy that needs these :-)
Oddy enough for that one I got your reply, but not Revend Homer's, and going
through the spam filter (about 35 things from the buildroot list and such had
wound up in there since I last checked)... still didn't find it.
I suspect gmail did the "refuse delivery" thing, except I didn't get unsubcribed
from the list again? (Does it have a third "accept delivery but discard and not
even put it in the spam folder" option?)
Wheee,
Rob
Rob Landley
2018-12-05 17:44:30 UTC
Permalink
There's something strange about gmail and this mailing list. I still can read
your messages only from Elliot Hughes' replies (And of course I saw that
message since you Cc'ed me). I can't even find your messages in the "Spam"
folder in Thunderbird!
I got this one, but probably via the cc. :)

Storify went down in may, tumblr is imploding, google's already had plus and
wave and orkut and so on... if gmail's spam filter goes completely unmanageable,
that's why pretty much every ISP hosts its own mail servers.

Me, I still haven't set up my own git server for toybox yet, and am still
distributing it through github even after microsoft bought it. (I'm fine keeping
a mirror there because china can see it through the Great Firewall, but it
shouldn't be the only outlet. It's on the todo list...)

This is why I care so much about the web archive. I should re-enage with the
dreamhost guys and try to get the holes in the history filled in from my copies,
I just have to collate three different mboxes to produce said copies, because of
a completely different gmail bug that's been around for 10 years now (the
unavoidable dupe-killing you can't ever opt out of).

It's on the todo list somewhere after getting my blog edited and posted up to
the present. :)

Rob
Confused,
R.H.
Post by Rob Landley
it'll fail to build if you actually try to build a toy that needs these :-)
Oddy enough for that one I got your reply, but not Revend Homer's, and going
through the spam filter (about 35 things from the buildroot list and such had
wound up in there since I last checked)... still didn't find it.
I suspect gmail did the "refuse delivery" thing, except I didn't get unsubcribed
from the list again? (Does it have a third "accept delivery but discard and not
even put it in the spam folder" option?)
Wheee,
Rob
Rob Landley
2018-12-05 17:56:03 UTC
Permalink
Post by Reverend Homer
There's something strange about gmail and this mailing list.  I still
can read your messages only from Elliot Hughes' replies (And of
course I saw that message since you Cc'ed me). I can't even find your
messages in the "Spam" folder in Thunderbird!
Switching to no longer using gmail seems to have worked for me.
Though now I'm getting annoyed at mailman sending plain ASCII text as
base64 encoding. My email proggy can't handle quoting that. It didn't
used to.
I wonder if that's related to me enabling the "header rewrite" option to avoid
triggering gmail's spam filtering when a mail server has that funky sender
verification thing that breaks mailing lists?

Apparently it's gotten so bad some open source projects are abandoning mailing
lists:

https://lwn.net/Articles/768483/

Given that everything else is subject to cloud rot, I'm pretty sure the ones
that _don't_ abandon mailing lists will outlive the ones that do. But it'll be
some years before that shakes out. (When microsoft finally kills github it's
gonna suck for the digital archaeologists.)

Rob

Loading...