From 2042305c3e98934359b14a1900427e185ddaec7e Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Mon, 22 Jul 2019 20:18:04 +0200
Subject: Hack in some Haiku support.


diff --git a/ls/ls.c b/ls/ls.c
index 5f1a450..9228646 100644
--- a/ls/ls.c
+++ b/ls/ls.c
@@ -490,28 +490,22 @@ display(FTSENT *p, FTSENT *list)
 				maxsize = sp->st_size;
 			if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode)) {
 				bcfile = 1;
+#if 0
 				if (major(sp->st_rdev) > maxmajor)
 					maxmajor = major(sp->st_rdev);
 				if (minor(sp->st_rdev) > maxminor)
 					maxminor = minor(sp->st_rdev);
+#endif
 			}
 
 			btotal += sp->st_blocks;
 			if (f_longform) {
-				if (f_numericonly ||
-				    (user = user_from_uid(sp->st_uid, 0)) ==
-				    NULL) {
 					(void)snprintf(nuser, sizeof(nuser),
 					    "%u", sp->st_uid);
 					user = nuser;
-				}
-				if (f_numericonly ||
-				    (group = group_from_gid(sp->st_gid, 0)) ==
-				    NULL) {
 					(void)snprintf(ngroup, sizeof(ngroup),
 					    "%u", sp->st_gid);
 					group = ngroup;
-				}
 				if ((ulen = strlen(user)) > maxuser)
 					maxuser = ulen;
 				if ((glen = strlen(group)) > maxgroup)
diff --git a/ls/print.c b/ls/print.c
index f8d4188..6cb33b5 100644
--- a/ls/print.c
+++ b/ls/print.c
@@ -113,7 +113,7 @@ printlong(DISPLAY *dp)
 		if (f_size)
 			(void)printf(ULLFP("*") " ", dp->s_block,
 			    (ULLT)howmany(sp->st_blocks, blocksize));
-		(void)strmode(sp->st_mode, buf);
+		sprintf(buf, "%4o", sp->st_mode);
 		np = p->fts_pointer;
 		(void)printf("%s %*lu %-*s  %-*s  ", buf, dp->s_nlink,
 		    (unsigned long)sp->st_nlink, dp->s_user, np->user,
@@ -121,9 +121,7 @@ printlong(DISPLAY *dp)
 		if (f_flags)
 			(void)printf("%-*s ", dp->s_flags, np->flags);
 		if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode))
-			(void)printf("%*u, %*u ",
-			    dp->s_major, major(sp->st_rdev), dp->s_minor,
-			    minor(sp->st_rdev));
+			;
 		else
 			(void)printf(ULLFP("*") " ", dp->s_size,
 			    (ULLT)sp->st_size);
diff --git a/src/cmds.c b/src/cmds.c
index 1fdac7d..b580d96 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -768,10 +768,8 @@ fact_type(const char *fact, FILE *fd, factelem *fe)
 		break;
 	case S_IFBLK:
 	case S_IFCHR:
-		cprintf(fd, "OS.unix=%s-" ULLF "/" ULLF,
-		    S_ISBLK(fe->stat->st_mode) ? "blk" : "chr",
-		    (ULLT)major(fe->stat->st_rdev),
-		    (ULLT)minor(fe->stat->st_rdev));
+		cprintf(fd, "OS.unix=%s",
+		    S_ISBLK(fe->stat->st_mode) ? "blk" : "chr");
 		break;
 	default:
 		cprintf(fd, "OS.unix=UNKNOWN(0%o)", fe->stat->st_mode & S_IFMT);
diff --git a/src/ftpcmd.c b/src/ftpcmd.c
index 5717450..5bbeb12 100644
--- a/src/ftpcmd.c
+++ b/src/ftpcmd.c
@@ -71,6 +71,7 @@
 #line 69 "ftpcmd.y"
 
 
+#define NBBY 8
 #if defined(HAVE_TNFTPD_H)
 #include "tnftpd.h"
 #else /* !defined(HAVE_TNFTPD_H) */
diff --git a/src/ftpcmd.y b/src/ftpcmd.y
index 13a1123..e6b9c6d 100644
--- a/src/ftpcmd.y
+++ b/src/ftpcmd.y
@@ -68,6 +68,8 @@
 
 %{
 
+#define NBBY 8
+
 #if defined(HAVE_TNFTPD_H)
 #include "tnftpd.h"
 #else /* !defined(HAVE_TNFTPD_H) */
@@ -111,6 +113,7 @@ __RCSID(" NetBSD: ftpcmd.y,v 1.94 2015/08/10 07:45:50 shm Exp  ");
 #include "extern.h"
 #include "version.h"
 
+
 static	int cmd_type;
 static	int cmd_form;
 static	int cmd_bytesz;
diff --git a/src/ftpd.c b/src/ftpd.c
index cbe10ef..1334e56 100644
--- a/src/ftpd.c
+++ b/src/ftpd.c
@@ -88,6 +88,8 @@
  * SUCH DAMAGE.
  */
 
+#define NBBY 8
+
 #if defined(HAVE_TNFTPD_H)
 
 #define	FTP_NAMES
@@ -3819,6 +3821,7 @@ logrusage(const struct rusage *rusage_before,
 	if (logging <= 1)
 		return;
 
+#if 0
 	timersub(&rusage_after->ru_utime, &rusage_before->ru_utime, &usrtime);
 	timersub(&rusage_after->ru_stime, &rusage_before->ru_stime, &systime);
 	syslog(LOG_INFO, LLF ".%.03ldu " LLF ".%.03lds %ld+%ldio %ldpf+%ldw",
@@ -3828,6 +3831,7 @@ logrusage(const struct rusage *rusage_before,
 	    rusage_after->ru_oublock - rusage_before->ru_oublock,
 	    rusage_after->ru_majflt - rusage_before->ru_majflt,
 	    rusage_after->ru_nswap - rusage_before->ru_nswap);
+#endif
 }
 
 /*
diff --git a/tnftpd.h b/tnftpd.h
index 57805b6..38b639d 100644
--- a/tnftpd.h
+++ b/tnftpd.h
@@ -254,6 +254,7 @@ char	*sl_find(StringList *, char *);
 #endif
 
 #if defined(HAVE_LIBUTIL_H)
+#define _BSD_SOURCE
 # include <libutil.h>
 #endif
 
-- 
2.21.0

