On Fri, Jan 24, 2014 at 05:03:08PM +0000, sin wrote:
> Hi all,
> 
> The current implementation of mknod(1) uses makedev(3) which apparently
> is not POSIX and does not exist on some systems, such as Haiku.
> 
> I am considering moving this into ubase.  Any objections?
> 
> cheers,
> sin

I moved mknod(1) to ubase.  I attached a trivial patch to handle
makedev.  I realize #ifdef's are bad (this is the first ifdef in
sbase!) but it should work most of the time.  It will silently
ignore character and block devices if makedev is not implemented
as a macro though.

>From 7e5719a7536ee7655c27a218d022a5894e6f0fe8 Mon Sep 17 00:00:00 2001
From: sin <s...@2f30.org>
Date: Tue, 28 Jan 2014 16:54:41 +0000
Subject: [PATCH] Use preprocessor conditionals to check if makedev() is
 present

makedev() is not portable and is typically implemented as a
macro.  If it exists use it, otherwise silently ignore character
and block devices.
---
 tar.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tar.c b/tar.c
index 4585d95..a478e5f 100644
--- a/tar.c
+++ b/tar.c
@@ -245,12 +245,14 @@ unarchive(char *fname, int l, char b[Blksiz])
                break;
        case CHARDEV:
        case BLOCKDEV:
+#ifdef makedev
                mode = strtoul(h->mode, 0, 8);
                major = strtoul(h->major, 0, 8);
                minor = strtoul(h->mode, 0, 8);
                type = (h->type == CHARDEV) ? S_IFCHR : S_IFBLK;
                if(mknod(fname, type | mode, makedev(major, minor)))
                        perror(fname);
+#endif
                break;
        case FIFO:
                mode = strtoul(h->mode, 0, 8);
-- 
1.8.5.3

Reply via email to