* Enable findmnt on kfreebsd
@ 2013-03-14 0:39 Jeff Epler
2013-03-14 1:06 ` Samuel Thibault
2013-03-14 10:22 ` Karel Zak
0 siblings, 2 replies; 5+ messages in thread
From: Jeff Epler @ 2013-03-14 0:39 UTC (permalink / raw)
To: LaMont Jones; +Cc: Roger Leigh, util-linux
In a recent discussion on #debian-kbsd, rleigh brought up the fact that
findmnt isn't available on kfreebsd; he feels it would be useful in
initscripts.
I had a look at what it would take to enable findmnt, which needs
libmount. It turns out that not much is required: mostly, make a few
bits of code return (-)ENOSYS. There were also a few more bits that
needed tweaking before kfreebsd was happy (LIST_HEAD is also in some
bsd-origin header, and of course <linux/posix_types.h> was not
available).
I'm not sure I correctly intuited where it was proper to return +ENOSYS
and where it was proper to return -ENOSYS, so this merits further study.
There's also a bit of debian bookkeeping which is not of interest to
util-linux@
Once this is done, findmnt (the only libmount-relying part I tested)
seems to work properly, including listing zfs filesystems.
Please copy me on any replies as I am not subscribed to util-linux.
Jeff
diff -u util-linux-2.20.1/configure.ac util-linux-2.20.1/configure.ac
--- util-linux-2.20.1/configure.ac
+++ util-linux-2.20.1/configure.ac
@@ -446,12 +446,7 @@
[], enable_libmount=check
)
build_libmount=yes
-if test "x$enable_libmount" = xcheck; then
- if test "x$linux_os" = xno; then
- AC_MSG_WARN([non-linux system; do not build libmount])
- build_libmount=no
- fi
-elif test "x$enable_libmount" = xno; then
+if test "x$enable_libmount" = xno; then
build_libmount=no
fi
diff -u util-linux-2.20.1/debian/changelog util-linux-2.20.1/debian/changelog
--- util-linux-2.20.1/debian/changelog
+++ util-linux-2.20.1/debian/changelog
@@ -1,3 +1,10 @@
+util-linux (2.20.1-5.4) UNRELEASED; urgency=low
+
+ * Non-maintainer upload.
+ * Hack libmount into building (enables findmnt)
+
+ -- Jeff Epler <jepler@localhost> Wed, 13 Mar 2013 19:04:59 -0500
+
util-linux (2.20.1-5.3) unstable; urgency=low
* Non-maintainer upload.
diff -u util-linux-2.20.1/debian/control util-linux-2.20.1/debian/control
--- util-linux-2.20.1/debian/control
+++ util-linux-2.20.1/debian/control
@@ -130,7 +130,7 @@
Priority: required
Depends: ${shlibs:Depends}, ${misc:Depends}
Pre-Depends: multiarch-support
-Architecture: linux-any
+Architecture: linux-any kfreebsd-any
Description: block device id library
The device mounting library, used by mount and mount helpers.
only in patch2:
unchanged:
--- util-linux-2.20.1.orig/include/list.h
+++ util-linux-2.20.1/include/list.h
@@ -31,6 +31,10 @@
#define LIST_HEAD_INIT(name) { &(name), &(name) }
+#ifdef LIST_HEAD
+#undef LIST_HEAD
+#endif
+
#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
only in patch2:
unchanged:
--- util-linux-2.20.1.orig/libmount/src/context_umount.c
+++ util-linux-2.20.1/libmount/src/context_umount.c
@@ -439,6 +439,9 @@
/* Check whether the kernel supports UMOUNT_NOFOLLOW flag */
static int umount_nofollow_support(void)
{
+#ifdef __FreeBSD_kernel__
+ return 0;
+#else
int res = umount2("", UMOUNT_UNUSED);
if (res != -1 || errno != EINVAL)
return 0;
@@ -448,10 +451,14 @@
return 0;
return 1;
+#endif
}
static int do_umount(struct libmnt_context *cxt)
{
+#ifdef __FreeBSD_kernel__
+ return -ENOSYS;
+#else
int rc = 0, flags = 0;
const char *src, *target;
char *tgtbuf = NULL;
@@ -541,6 +548,7 @@
cxt->syscall_status = 0;
DBG(CXT, mnt_debug_h(cxt, "umount(2) success"));
return 0;
+#endif
}
/**
only in patch2:
unchanged:
--- util-linux-2.20.1.orig/libmount/src/context_mount.c
+++ util-linux-2.20.1/libmount/src/context_mount.c
@@ -385,6 +385,9 @@
*/
static int do_mount(struct libmnt_context *cxt, const char *try_type)
{
+#ifdef __FreeBSD_kernel__
+ return ENOSYS;
+#else
int rc = 0;
const char *src, *target, *type;
unsigned long flags;
@@ -444,6 +447,7 @@
*/
return rc;
+#endif
}
static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern)
only in patch2:
unchanged:
--- util-linux-2.20.1.orig/lib/loopdev.c
+++ util-linux-2.20.1/lib/loopdev.c
@@ -29,7 +29,9 @@
#include <sys/sysmacros.h>
#include <inttypes.h>
#include <dirent.h>
+#ifdef __LINUX__
#include <linux/posix_types.h>
+#endif
#include "linux_version.h"
#include "c.h"
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Enable findmnt on kfreebsd
2013-03-14 0:39 Enable findmnt on kfreebsd Jeff Epler
@ 2013-03-14 1:06 ` Samuel Thibault
2013-03-14 2:02 ` Jeff Epler
2013-03-14 10:22 ` Karel Zak
1 sibling, 1 reply; 5+ messages in thread
From: Samuel Thibault @ 2013-03-14 1:06 UTC (permalink / raw)
To: Jeff Epler; +Cc: LaMont Jones, Roger Leigh, util-linux
Jeff Epler, le Wed 13 Mar 2013 19:39:47 -0500, a écrit :
> --- util-linux-2.20.1.orig/libmount/src/context_umount.c
> +++ util-linux-2.20.1/libmount/src/context_umount.c
> @@ -439,6 +439,9 @@
> /* Check whether the kernel supports UMOUNT_NOFOLLOW flag */
> static int umount_nofollow_support(void)
> {
> +#ifdef __FreeBSD_kernel__
> + return 0;
> +#else
> int res = umount2("", UMOUNT_UNUSED);
> if (res != -1 || errno != EINVAL)
> return 0;
> @@ -448,10 +451,14 @@
> return 0;
>
> return 1;
> +#endif
Perhaps rather turn all these into
#ifdef __linux__
linux stuff
#else
return 0;
#endif
?
Samuel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Enable findmnt on kfreebsd
2013-03-14 1:06 ` Samuel Thibault
@ 2013-03-14 2:02 ` Jeff Epler
2013-03-14 2:39 ` Samuel Thibault
0 siblings, 1 reply; 5+ messages in thread
From: Jeff Epler @ 2013-03-14 2:02 UTC (permalink / raw)
To: Samuel Thibault, LaMont Jones, Roger Leigh, util-linux
On Thu, Mar 14, 2013 at 02:06:20AM +0100, Samuel Thibault wrote:
> Jeff Epler, le Wed 13 Mar 2013 19:39:47 -0500, a écrit :
> > +#ifdef __FreeBSD_kernel__
>
> Perhaps rather turn all these into
> #ifdef __linux__
Fine by me, and might make e.g., hurd work too (or at least get closer).
Jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Enable findmnt on kfreebsd
2013-03-14 2:02 ` Jeff Epler
@ 2013-03-14 2:39 ` Samuel Thibault
0 siblings, 0 replies; 5+ messages in thread
From: Samuel Thibault @ 2013-03-14 2:39 UTC (permalink / raw)
To: Jeff Epler; +Cc: LaMont Jones, Roger Leigh, util-linux
Jeff Epler, le Wed 13 Mar 2013 21:02:41 -0500, a écrit :
> On Thu, Mar 14, 2013 at 02:06:20AM +0100, Samuel Thibault wrote:
> > Jeff Epler, le Wed 13 Mar 2013 19:39:47 -0500, a écrit :
> > > +#ifdef __FreeBSD_kernel__
> >
> > Perhaps rather turn all these into
> > #ifdef __linux__
>
> Fine by me, and might make e.g., hurd work too (or at least get closer).
That was the point, yes :)
Samuel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Enable findmnt on kfreebsd
2013-03-14 0:39 Enable findmnt on kfreebsd Jeff Epler
2013-03-14 1:06 ` Samuel Thibault
@ 2013-03-14 10:22 ` Karel Zak
1 sibling, 0 replies; 5+ messages in thread
From: Karel Zak @ 2013-03-14 10:22 UTC (permalink / raw)
To: Jeff Epler; +Cc: LaMont Jones, Roger Leigh, util-linux
On Wed, Mar 13, 2013 at 07:39:47PM -0500, Jeff Epler wrote:
> In a recent discussion on #debian-kbsd, rleigh brought up the fact that
> findmnt isn't available on kfreebsd; he feels it would be useful in
> initscripts.
Do you mean for fstab/mtab parsing? ... because I cannot imagine
anything else without Linux kernel.
> I had a look at what it would take to enable findmnt, which needs
> libmount. It turns out that not much is required: mostly, make a few
> bits of code return (-)ENOSYS. There were also a few more bits that
> needed tweaking before kfreebsd was happy (LIST_HEAD is also in some
> bsd-origin header, and of course <linux/posix_types.h> was not
> available).
>
> I'm not sure I correctly intuited where it was proper to return +ENOSYS
> and where it was proper to return -ENOSYS, so this merits further study.
Maybe you can #ifdef whole context{.c,_umount.c,mount.c} API. All you
need is probably fs.c tab*.c files. Maybe you can modify libmount/src/Makemodule.am
rather than code to create a minimalistic kernel independent libmount :-)
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-03-14 10:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-14 0:39 Enable findmnt on kfreebsd Jeff Epler
2013-03-14 1:06 ` Samuel Thibault
2013-03-14 2:02 ` Jeff Epler
2013-03-14 2:39 ` Samuel Thibault
2013-03-14 10:22 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox