Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Jun 2020 18:44:30 +0000 (UTC)
From:      Matthias Andree <mandree@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r540401 - in head: misc/e2fsprogs-libblkid sysutils/e2fsprogs sysutils/e2fsprogs/files
Message-ID:  <202006251844.05PIiUId046384@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mandree
Date: Thu Jun 25 18:44:30 2020
New Revision: 540401
URL: https://svnweb.freebsd.org/changeset/ports/540401

Log:
  sysutils/e2fsprogs: fix "blkid" probe-all feature
  
  e2fsprogs's misc/blkid utility would expect a /proc/partitions file
  in a Linux-specific format.  Add code to read the kern.geom.conftxt
  sysctl(3) value instead, and adjust parser.
  
  While here, patch /etc/blkid.tab location to ${ETCDIR}.
  
  Reported by:	Adam Dobrawy (private mail)
  Tip to:		bapt@ (for the pointer to kern.geom.conftxt)

Added:
  head/sysutils/e2fsprogs/files/patch-lib_blkid_devname.c   (contents, props changed)
  head/sysutils/e2fsprogs/files/patch-misc_blkid.8.in   (contents, props changed)
Modified:
  head/misc/e2fsprogs-libblkid/Makefile
  head/sysutils/e2fsprogs/Makefile

Modified: head/misc/e2fsprogs-libblkid/Makefile
==============================================================================
--- head/misc/e2fsprogs-libblkid/Makefile	Thu Jun 25 16:04:49 2020	(r540400)
+++ head/misc/e2fsprogs-libblkid/Makefile	Thu Jun 25 18:44:30 2020	(r540401)
@@ -1,7 +1,7 @@
 # Created by: Matthias Andree <matthias.andree@gmx.de>
 # $FreeBSD$
 
-PORTREVISION=	0
+PORTREVISION=	1
 CATEGORIES=	misc devel
 PKGNAMESUFFIX=	-libblkid
 

Modified: head/sysutils/e2fsprogs/Makefile
==============================================================================
--- head/sysutils/e2fsprogs/Makefile	Thu Jun 25 16:04:49 2020	(r540400)
+++ head/sysutils/e2fsprogs/Makefile	Thu Jun 25 18:44:30 2020	(r540401)
@@ -3,7 +3,7 @@
 
 PORTNAME=	e2fsprogs
 PORTVERSION=	1.45.6
-PORTREVISION?=	2
+PORTREVISION?=	3
 CATEGORIES?=	sysutils
 MASTER_SITES=	KERNEL_ORG/linux/kernel/people/tytso/${PORTNAME}/v${PORTVERSION}
 
@@ -142,6 +142,7 @@ post-patch::
 	    -e "s/ == 0/ = 0/" -e "s/tar x$$/tar xf -/" -e "s/\<dd\>/gdd/" \
 	    ${WRKSRC}/tests/[a-z]_*/script
 	@${REINPLACE_CMD} -e 's/<malloc\.h>/<stdlib.h>/' ${WRKSRC}/*/*.c
+	@${REINPLACE_CMD} -e 's,/etc/blkid.tab,${ETCDIR}/blkid.tab,' ${WRKSRC}/misc/blkid* ${WRKSRC}/lib/blkid/blkidP.h
 	@${REINPLACE_CMD} -E -e 's/__GNUC_PREREQ\>/__GNUC_PREREQ__/' ${WRKSRC}/*/*/*.[ch] ${WRKSRC}/*/*.c
 .if empty(PORT_OPTIONS:MALLTESTS)
 . for i in \

Added: head/sysutils/e2fsprogs/files/patch-lib_blkid_devname.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/e2fsprogs/files/patch-lib_blkid_devname.c	Thu Jun 25 18:44:30 2020	(r540401)
@@ -0,0 +1,110 @@
+--- lib/blkid/devname.c.orig	2020-03-21 04:24:04 UTC
++++ lib/blkid/devname.c
+@@ -40,6 +40,9 @@
+ #include <sys/sysmacros.h>
+ #endif
+ #include <time.h>
++#ifdef __FreeBSD__
++#include <sys/sysctl.h>
++#endif
+ 
+ #include "blkidP.h"
+ 
+@@ -397,11 +400,15 @@ evms_probe_all(blkid_cache cache, int only_if_new)
+ static int probe_all(blkid_cache cache, int only_if_new)
+ {
+ 	FILE *proc;
++#ifndef __FreeBSD__
+ 	char line[1024];
++	int ma, mi;
++#else
++	char *line;
++#endif /* __FreeBSD__ */
+ 	char ptname0[129], ptname1[129], *ptname = 0;
+ 	char *ptnames[2];
+ 	dev_t devs[2];
+-	int ma, mi;
+ 	unsigned long long sz;
+ 	int lens[2] = { 0, 0 };
+ 	int which = 0, last = 0;
+@@ -423,20 +430,68 @@ static int probe_all(blkid_cache cache, int only_if_ne
+ 	lvm_probe_all(cache, only_if_new);
+ #endif
+ 
++#ifndef __FreeBSD__
+ 	proc = fopen(PROC_PARTITIONS, "r");
+ 	if (!proc)
+ 		return -BLKID_ERR_PROC;
+ 
+ 	while (fgets(line, sizeof(line), proc)) {
++#else
++	size_t len, bufsiz = 4096;
++	char *buf = NULL;
++
++	for(;;) {
++		buf = realloc(buf, bufsiz);
++		if (!buf) return -BLKID_ERR_MEM;
++		len = bufsiz - 1;
++		if (sysctlbyname("kern.geom.conftxt", buf, &len, NULL, 0)) {
++			if (ENOMEM != errno) {
++				free(buf);
++				return -BLKID_ERR_IO;
++			}
++			bufsiz <<= 1;
++		} else {
++			if (len < bufsiz) buf[len] = '\0';
++			else              buf[bufsiz - 1] = '\0';
++			break;
++		}
++	}
++	char *str = buf;
++	while (line = strsep(&str, "\n")) {
++#endif /* __FreeBSD__ */
+ 		last = which;
+ 		which ^= 1;
+ 		ptname = ptnames[which];
+ 
++#ifndef __FreeBSD__
+ 		if (sscanf(line, " %d %d %llu %128[^\n ]",
+ 			   &ma, &mi, &sz, ptname) != 4)
+ 			continue;
+ 		devs[which] = makedev(ma, mi);
++#else
++		char type[5];
++		int dummy;
+ 
++		if (sscanf(line, "%*d %5s %128[^ ] %lld %d",
++			   type, ptname, &sz, &dummy) != 4)
++			continue;
++		sz /= 1024;
++
++		if (strcmp("PART", type) && strcmp("DISK", type))
++			continue;
++		{
++			struct stat st;
++			char dn[128];
++			if (snprintf(dn, sizeof dn, "/dev/%s", ptname) >= sizeof dn)
++				continue;
++
++			if (stat(dn, &st))
++				continue;
++
++			devs[which] = st.st_rdev;
++		}
++#endif /* __FreeBSD__ */
++
+ 		DBG(DEBUG_DEVNAME, printf("read partition name %s\n", ptname));
+ 
+ 		/* Skip whole disk devs unless they have no partitions.
+@@ -507,7 +562,11 @@ static int probe_all(blkid_cache cache, int only_if_ne
+ 	if (lens[which])
+ 		probe_one(cache, ptname, devs[which], 0, only_if_new);
+ 
++#ifndef __FreeBSD__
+ 	fclose(proc);
++#else
++	free(buf);
++#endif /* __FreeBSD__ */
+ 	blkid_flush_cache(cache);
+ 	return 0;
+ }

Added: head/sysutils/e2fsprogs/files/patch-misc_blkid.8.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/e2fsprogs/files/patch-misc_blkid.8.in	Thu Jun 25 18:44:30 2020	(r540401)
@@ -0,0 +1,17 @@
+--- misc/blkid.8.in.orig	2020-03-21 04:24:04 UTC
++++ misc/blkid.8.in
+@@ -144,10 +144,10 @@ option.
+ Display tokens from only the specified device.  It is possible to
+ give multiple
+ .I device
+-options on the command line.  If none is given, all devices which
+-appear in
+-.I /proc/partitions
+-are shown, if they are recognized.
++options on the command line.  If none is given, all DISK and PART devices which
++appear in the
++.I kern.geom.conftxt
++sysctl variable are shown, if they are recognized.
+ .SH "RETURN CODE"
+ If the specified token was found, or if any tags were shown from (specified)
+ devices, 0 is returned.  If the specified token was not found, or no



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006251844.05PIiUId046384>