- update to 2.4.0 (mostly integrating FreeBSD support upstream)

Feature safe:	yes
This commit is contained in:
Baptiste Daroussin 2012-04-01 21:39:17 +00:00
parent 3102ecba81
commit aa80085d96
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=294096
4 changed files with 6 additions and 173 deletions

View file

@ -6,15 +6,17 @@
#
PORTNAME= dfc
PORTVERSION= 2.3.0
PORTVERSION= 2.4.0
CATEGORIES= sysutils
MASTER_SITES= http://projects.gw-computing.net/attachments/download/30/
MASTER_SITES= http://projects.gw-computing.net/attachments/download/39/
MAINTAINER= bapt@FreeBSD.org
COMMENT= Display file system space usage using graph and colors
LICENSE= BSD
USE_GMAKE= yes
PLIST_FILES= bin/dfc
MAN1= dfc.1

View file

@ -1,2 +1,2 @@
SHA256 (dfc-2.3.0.tar.gz) = 153ee2e023be207d165db33183d7235d0dcb4f9ed4e435900984c2f55b310576
SIZE (dfc-2.3.0.tar.gz) = 9732
SHA256 (dfc-2.4.0.tar.gz) = ae47383c6d95efb76f8a35da6fc33e1593d0be8b8401378f8dfb52b69f3788df
SIZE (dfc-2.4.0.tar.gz) = 10765

View file

@ -1,22 +0,0 @@
--- ./Makefile.orig 2012-03-31 16:22:26.000000000 +0200
+++ ./Makefile 2012-04-01 10:18:51.224657259 +0200
@@ -1,5 +1,5 @@
CC ?= gcc
-CFLAGS = -O2 -std=c89
+CFLAGS ?= -O2 -std=c89
LDFLAGS +=
CFDEBUG = -g3 -pedantic -Wall -Wunused-parameter -Wlong-long\
-Wsign-conversion -Wconversion -Wimplicit-function-declaration
@@ -18,10 +18,10 @@
${CC} ${LDFLAGS} -o ${EXEC} ${OBJS}
install-main: dfc
- install -Dm755 dfc ${DESTDIR}${BINDIR}/dfc
+ install -m755 dfc ${DESTDIR}${BINDIR}/dfc
install-data: dfc.1
- install -Dm644 dfc.1 ${DESTDIR}${MANDIR}/man1/dfc.1
+ install -m644 dfc.1 ${DESTDIR}${MANDIR}/man1/dfc.1
install: all install-main install-data

View file

@ -1,147 +0,0 @@
--- ./dfc.c.orig 2012-03-31 16:22:26.000000000 +0200
+++ ./dfc.c 2012-04-01 10:18:26.366658586 +0200
@@ -6,8 +6,10 @@
* Displays free disk space in an elegant manner.
*/
#define _BSD_SOURCE
+#ifndef __FreeBSD__
#define _POSIX_C_SOURCE 2
#define _XOPEN_SOURCE 500
+#endif
#define STRMAXLEN 24
@@ -15,14 +17,23 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
+#include <err.h>
+#ifndef __FreeBSD__
#include <mntent.h>
+#endif
#include <string.h>
+#include <sys/types.h>
#include <sys/param.h>
#include <sys/statvfs.h>
#include <sys/ioctl.h>
+#ifdef __FreeBSD__
+#include <sys/ucred.h>
+#include <sys/mount.h>
+#endif
+
#include "dfc.h"
/* set flags for options */
@@ -384,9 +395,15 @@
fetch_info(struct list *lst)
{
FILE *mtab;
+ struct fsmntinfo *fmi;
+#ifdef __FreeBSD__
+ int nummnt;
+ struct statfs *entbuf;
+ struct statfs vfsbuf, **fs;
+#else
struct mntent *entbuf;
struct statvfs vfsbuf;
- struct fsmntinfo *fmi;
+#endif
/* init fsmntinfo */
if ((fmi = malloc(sizeof(struct fsmntinfo))) == NULL) {
@@ -396,6 +413,14 @@
}
*fmi = fmi_init();
+#ifdef __FreeBSD__
+ if ((nummnt = getmntinfo(&entbuf, MNT_WAIT)) <= 0)
+ err(EXIT_FAILURE, "Error while getting the list of mountpoints");
+
+ for (fs = &entbuf; nummnt--; (*fs)++) {
+ vfsbuf = **fs;
+
+#else
/* open mtab file */
if ((mtab = fopen("/etc/mtab", "r")) == NULL) {
perror("Error while opening mtab file ");
@@ -421,7 +446,27 @@
/* NOTREACHED */
}
} else {
+#endif
/* infos from getmntent */
+#ifdef __FreeBSD__
+ if ((fmi->fsname = strdup(shortenstr(
+ trk(entbuf->f_mntfromname),
+ STRMAXLEN))) == NULL) {
+ fmi->fsname = "unknown";
+ }
+ if ((fmi->dir = strdup(shortenstr(
+ trk(entbuf->f_mntonname),
+ STRMAXLEN))) == NULL) {
+ fmi->dir = "unknown";
+ }
+ if ((fmi->type = strdup(shortenstr(
+ trk(entbuf->f_fstypename),
+ 9))) == NULL) {
+ fmi->type = "unknown";
+ }
+ /* TODO add the options */
+ fmi->opts = "non";
+#else
if ((fmi->fsname = strdup(shortenstr(
trk(entbuf->mnt_fsname),
STRMAXLEN))) == NULL) {
@@ -438,16 +483,17 @@
if ((fmi->opts = strdup(trk(entbuf->mnt_opts))) == NULL) {
fmi->opts = "none";
}
+#endif
/* infos from statvfs */
fmi->bsize = vfsbuf.f_bsize;
- fmi->frsize = vfsbuf.f_frsize;
+ fmi->frsize = 0; /*vfsbuf.f_frsize;*/
fmi->blocks = vfsbuf.f_blocks;
fmi->bfree = vfsbuf.f_bfree;
fmi->bavail = vfsbuf.f_bavail;
fmi->files = vfsbuf.f_files;
fmi->ffree = vfsbuf.f_ffree;
- fmi->favail = vfsbuf.f_favail;
+ fmi->favail = 0; /*vfsbuf.f_favail;*/
/* pointer to the next element */
fmi->next = NULL;
@@ -465,11 +511,13 @@
lst->typemaxlen);
}
}
+#ifndef __FreeBSD__
}
/* we need to close the mtab file now */
if (fclose(mtab) == EOF)
perror("Could not close mtab file ");
+#endif
}
/*
@@ -563,9 +611,15 @@
(void)printf(" ");
}
+#ifdef __FreeBSD__
+ size = p->bsize * p->blocks;
+ avail = p->bsize * p->bavail;
+ used = p->bsize * (p->blocks - p->bfree);
+#else
size = (double)p->blocks *(double)p->frsize;
avail = (double)p->bavail * (double)p->frsize;
used = size - avail;
+#endif
/* calculate the % used */
if ((int)size == 0)