Hi!
On Tue, 2014-01-07 at 13:51:17 +0300, Hleb Valoshka wrote:
> Package: dpkg
> Version: 1.17.5
> Severity: wishlist
> Tags: patch
>
> I've have ported dpkg to DragonFly BSD, the patch is attached.
Nice! Thanks, some comments below.
> diff -uNr dpkg-1.17.5~/ostable dpkg-1.17.5/ostable
> --- dpkg-1.17.5~/ostable 2013-12-04 02:48:11.000000000 +0000
> +++ dpkg-1.17.5/ostable 2014-01-04 10:53:37.000000000 +0000
> @@ -36,3 +36,4 @@
> uclibceabi-uclinux uclinux-uclibceabi uclinux[^-]*-uclibceabi
> uclibc-uclinux uclinux-uclibc uclinux[^-]*(-uclibc.*)?
> tos-mint mint mint[^-]*
> +bsd-dragonflybsd dragonflybsd dragonfly[^-]*
> diff -uNr dpkg-1.17.5~/triplettable dpkg-1.17.5/triplettable
> --- dpkg-1.17.5~/triplettable 2013-12-04 02:48:11.000000000 +0000
> +++ dpkg-1.17.5/triplettable 2014-01-04 10:53:37.000000000 +0000
> @@ -29,3 +29,4 @@
> uclibceabi-uclinux-arm uclinux-armel
> uclibc-uclinux-<cpu> uclinux-<cpu>
> tos-mint-m68k mint-m68k
> +bsd-dragonflybsd-<cpu> dragonflybsd-<cpu>
Could you place these close to their bsd siblings?
> diff -uNr dpkg-1.17.5~/utils/start-stop-daemon.c
> dpkg-1.17.5/utils/start-stop-daemon.c
> --- dpkg-1.17.5~/utils/start-stop-daemon.c 2013-12-10 06:14:22.000000000
> +0000
> +++ dpkg-1.17.5/utils/start-stop-daemon.c 2014-01-04 10:56:17.000000000
> +0000
> @@ -39,6 +39,8 @@
> # define OSFreeBSD
> #elif defined(__NetBSD__)
> # define OSNetBSD
> +#elif defined(__DragonFly__)
> +# define OSDragonflyBSD
> #else
> # error Unknown architecture - cannot build start-stop-daemon
> #endif
> @@ -59,6 +61,13 @@
> #include <err.h>
> #endif
>
> +#if defined(OSDragonflyBSD)
> +#include <sys/param.h>
> +#include <sys/user.h>
> +
> +#include <err.h>
> +#endif
> +
I think adding OSDragonflyBSD to previous preprocessor block for the
other BSD should be enough, the next one catching HAVE_KVM_H should
include the remaning header files.
> #ifdef HAVE_KVM_H
> #include <sys/sysctl.h>
> #include <sys/user.h>
> @@ -122,6 +131,8 @@
> #define PROCESS_NAME_SIZE 16
> #elif defined(OSFreeBSD)
> #define PROCESS_NAME_SIZE 19
> +#elif defined (OSDragonflyBSD)
> +#define PROCESS_NAME_SIZE MAXCOMLEN
> #endif
Just to know what's the portably safe minimum for callers to use, to
what does MAXCOMLEN expand?
> #define MIN_POLL_INTERVAL 20000 /* µs */
> @@ -1231,11 +1242,15 @@
> kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &nentries);
> if (kp == NULL)
> errx(1, "%s", kvm_geterr(kd));
> +# if defined (OSDragonflyBSD)
> + kvm_read(kd, (u_long)&(kp->kp_ruid), &proc_uid, sizeof(uid_t));
> +# else
> if (kp->kp_proc.p_cred)
> kvm_read(kd, (u_long)&(kp->kp_proc.p_cred->p_ruid),
> &proc_uid, sizeof(uid_t));
> else
> return false;
> +# endif
I've got a patch to switch the FreeBSD code to use the KVM method,
unfortunately it seems to use ki_ namespaced struct members.
Also the KVM method seems to be missing a proper do_procinit(), which
could be something like the following untested code, I had lying
around:
,---
static enum status_code
do_procinit(void)
{
- /* Nothing to do. */
- return status_unknown;
+ kvm_t *kd;
+ int nentries, i;
+ struct kinfo_proc *kp;
+ char errbuf[_POSIX2_LINE_MAX];
+ enum status_code prog_status = status_dead;
+
+ kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
+ if (kd == NULL)
+ errx(1, "%s", errbuf);
+ kp = kvm_getprocs(kd, KERN_PROC_PROC, 0, &nentries);
+ if (kp == NULL)
+ errx(1, "%s", kvm_geterr(kd));
+
+ for (i = 0; i < nentries; i++) {
+ enum status_code pid_status;
+
+ pid_status = pid_check(kp[i].ki_pid);
+ if (pid_status < prog_status)
+ prog_status = pid_status;
+ }
+
+ kvm_close(kd);
+
+ return prog_status;
}
`---
For DragonFly BSD, you'll need to change ki_pid to kp_pid I guess. If
this works on DragonFly BSD, I'll commit that before applying your patch.
Thanks,
Guillem
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]