Summary: | [PATCH] GNU/kFreeBSD support | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Robert Millan <rmh> |
Component: | [OLD] baselayout | Assignee: | Gentoo's Team for Core System packages <base-system> |
Status: | VERIFIED FIXED | ||
Severity: | normal | CC: | absinthe, bsd+disabled |
Priority: | High | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: |
ttyname-based implementation
consoletype.c |
Description
Robert Millan
2005-01-29 20:00:13 UTC
Any news on this? ive committed the start-stop-daemon.c change, but i dont really want to take a step back with consoletype and use bash ... the bsd guys gave me a fix which ifdef's out the linux-specific code so current baselayout-1.11.11* should build fine on kfbsd ... I'm not sure if that'd work. Can I see the patch? If you just don't like bash, I could rewrite it in C using ttyname() without much problem. Ok, now that I've seen it, there are two problems with the patch as committed to current CVS: - major/minor numbers are not portable. In consoletype.c, the Linux-specific ioctl that causes build failure is #ifdef'ed out, but the node number checks won't work since every kernel has its own numbering policy for devices. We could test for each kernel using the numbers or use ttyname() as i mentioned before which is more intuitive. - headers.h defines HAVE_ERROR_H and HAVE_SYS_SYSMACROS_H only for __linux__ but these in fact are not Linux-specific. They're Glibc-specific so the __GLIBC__ macro should be used instead (otherwise it breaks on Glibc systems that don't use Linux). changed the __linux__ to __GLIBC__ as you suggested sorry for the delay, but could you post the ttyname() C fix ? Created attachment 66374 [details]
ttyname-based implementation
Was that ok? Created attachment 78136 [details]
consoletype.c
try this one instead please
You have to use strncmp, otherwise it'll compare the next character after '/' with '\0' and fail (see patch below). OTOH, the check_devnode function is Linux-specific, because it hardcodes major numbers. On non-Linux, it'll always return IS_PTY, which I don't think is the intended. I suggest protecting the whole function with #ifdef __linux__. (Note: it's not an option to hardcode major numbers of kFreeBSD because, on that kernel, they're assigned dynamicaly) --- test.c.old 2006-01-26 08:17:02.000000000 +0100 +++ test.c 2006-01-26 08:19:26.000000000 +0100 @@ -25,7 +25,7 @@ if (tty == NULL) return IS_UNK; - if (strcmp(tty, "/dev/") == 0) + if (strncmp(tty, "/dev/", 5) == 0) tty += 5; if (!strncmp (tty, "ttyS", 4) || !strncmp (tty, "cuaa", 4)) ok, added to baselayout including your last fixes sorry for the delay Looks fine. Thank you! |