Subject: Moving getmaxpartitions to libc
To: None <tech-userlevel@netbsd.org>
From: Leo Weppelman <leo@wau.mis.ah.nl>
List: tech-userlevel
Date: 08/19/1999 10:43:50
--2SCkAp4GZ/dPZZf/
Content-Type: text/plain; charset=us-ascii

Since I am still hoping for a shared m68k distribution, I want to fix the
getdiskbyname() function. Currently it uses the MAXPARTITIONS define while
it should use the getmaxpartitions() function.
After talking to a few people, I have come to the conclusion that usage
of the getmaxpartitions() by getdiskbyname() means moving getmaxpartitions()
from libutil to libc.

So what I would like to do is:
    - move getmaxpartitions.[c3] to libc through cvscopy
    - apply the attached diff which does:
        - fix getdiskbyname()
        - extend the d_partitions field of the disklabel to MAXMAXPARTITIONS
          entries.
        - bump the shlib version of libutil to 6.0
        - move the getmaxpartitions() prototype from util.h to disktab.h

Besides an opinion on the above, there are a few other related things that
I have not yet decided upon:

   - Since the above changes affect sizeof(struct disklabel), the following
     ioctls will stop working: DIOCGDINFO,DIOCSDINFO,DIOCWDINFO,DIOCGDEFLABEL.
     Do we want to provide backward compatibility (through COMPAT_14) and
     provide ODIOCGDINFO etc? The problem is that the handling of these are
     scattered all over the kernel. Is there a better method than fixing all
     these locations?

   - An addition to the previous item: should the kernel version be bumped?

Thoughts?

Leo.

         
        


--2SCkAp4GZ/dPZZf/
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diffy

diff -ru src.org/distrib/sets/lists/base/shl.mi src/distrib/sets/lists/base/shl.mi
--- src.org/distrib/sets/lists/base/shl.mi	Thu Aug 19 09:40:52 1999
+++ src/distrib/sets/lists/base/shl.mi	Thu Aug 19 09:42:21 1999
@@ -23,6 +23,6 @@
 ./usr/lib/libtermcap.so.0.1
 ./usr/lib/libtermlib.so.0.0
 ./usr/lib/libusb.so.0.0
-./usr/lib/libutil.so.5.1
+./usr/lib/libutil.so.6.0
 ./usr/lib/libwrap.so.0.0
 ./usr/lib/libz.so.0.1
diff -ru src.org/include/disktab.h src/include/disktab.h
--- src.org/include/disktab.h	Thu Aug 19 09:19:20 1999
+++ src/include/disktab.h	Thu Aug 19 09:24:28 1999
@@ -48,6 +48,7 @@
 __BEGIN_DECLS
 int setdisktab __P((char *));
 struct disklabel *getdiskbyname __P((const char *));
+int getmaxpartitions __P((void));
 __END_DECLS
 
 #endif /* !_DISKTAB_H_ */
diff -ru src.org/include/util.h src/include/util.h
--- src.org/include/util.h	Thu Aug 19 09:22:00 1999
+++ src/include/util.h	Thu Aug 19 09:23:22 1999
@@ -71,7 +71,6 @@
 		     struct winsize *));
 char   *fparseln __P((FILE *, size_t *, size_t *, const char[3], int));
 pid_t	forkpty __P((int *, char *, struct termios *, struct winsize *));
-int	getmaxpartitions __P((void));
 int	getrawpartition __P((void));
 int	opendisk __P((const char *, int, char *, size_t, int));
 int	pidlock __P((const char *, int, pid_t *, const char *));
diff -ru src.org/lib/libc/gen/Makefile.inc src/lib/libc/gen/Makefile.inc
--- src.org/lib/libc/gen/Makefile.inc	Sun May  2 00:45:57 1999
+++ src/lib/libc/gen/Makefile.inc	Thu Aug 19 09:33:06 1999
@@ -10,7 +10,7 @@
 	execle.c execlp.c execv.c execvp.c fnmatch.c fstab.c \
 	ftok.c __fts13.c fts.c getbsize.c getcap.c getcwd.c \
 	getdomainname.c getgrent.c getgrouplist.c gethostname.c \
-	getloadavg.c getlogin.c getmntinfo.c getnetgrent.c \
+	getloadavg.c getlogin.c getmaxpartitions.c getmntinfo.c getnetgrent.c \
 	getpagesize.c getpass.c getpwent.c getsubopt.c getttyent.c \
 	getusershell.c __glob13.c glob.c initgroups.c isatty.c \
 	isctype.c lockf.c nice.c nlist.c nlist_aout.c \
@@ -41,8 +41,8 @@
 	fnmatch.3 fpgetmask.3 frexp.3 ftok.3 fts.3 getbsize.3 getcap.3 \
 	getcwd.3 getdomainname.3 getdiskbyname.3 getfsent.3 \
 	getgrent.3 getgrouplist.3 gethostname.3 getloadavg.3 \
-	getmntinfo.3 getnetgrent.3 getpagesize.3 getpass.3 \
-	getpwent.3 getttyent.3 getusershell.3 glob.3 \
+	getmaxpartitions.3 getmntinfo.3 getnetgrent.3 getpagesize.3 \
+	getpass.3 getpwent.3 getttyent.3 getusershell.3 glob.3 \
 	initgroups.3 isalnum.3 isalpha.3 isascii.3 isblank.3 \
 	iscntrl.3 isdigit.3 isgraph.3 isinf.3 islower.3 isprint.3 \
 	ispunct.3 isspace.3 isupper.3 isxdigit.3 ldexp.3 lockf.3 \
diff -ru src.org/lib/libc/gen/disklabel.c src/lib/libc/gen/disklabel.c
--- src.org/lib/libc/gen/disklabel.c	Tue Jan 19 07:24:08 1999
+++ src/lib/libc/gen/disklabel.c	Thu Aug 19 09:28:23 1999
@@ -94,6 +94,7 @@
 	char	*cp, *cq;	/* can't be */
 	char	p, max, psize[3], pbsize[3],
 		pfsize[3], poffset[3], ptype[3];
+	int	max_part;
 	u_int32_t *dx;
 	long f;
 
@@ -153,8 +154,9 @@
 	strcpy(poffset, "ox");	/* XXX: strcpy is safe */
 	strcpy(ptype, "tx");	/* XXX: strcpy is safe */
 	max = 'a' - 1;
+	max_part = getmaxpartitions();
 	pp = &dp->d_partitions[0];
-	for (p = 'a'; p < 'a' + MAXPARTITIONS; p++, pp++) {
+	for (p = 'a'; p < 'a' + max_part; p++, pp++) {
 		long ff;
 
 		psize[1] = pbsize[1] = pfsize[1] = poffset[1] = ptype[1] = p;
Only in src/lib/libc/gen: getmaxpartitions.3
Only in src/lib/libc/gen: getmaxpartitions.c
diff -ru src.org/lib/libutil/Makefile src/lib/libutil/Makefile
--- src.org/lib/libutil/Makefile	Fri Jul  2 17:49:12 1999
+++ src/lib/libutil/Makefile	Thu Aug 19 09:35:17 1999
@@ -3,11 +3,11 @@
 
 LIB=	util
 CPPFLAGS+=-DLIBC_SCCS
-SRCS=	fparseln.c getmaxpartitions.c getrawpartition.c login.c login_tty.c \
+SRCS=	fparseln.c getrawpartition.c login.c login_tty.c \
 	logout.c logwtmp.c opendisk.c passwd.c pw_scan.c pidfile.c pidlock.c \
 	pty.c ttyaction.c ttymsg.c
 
-MAN=	fparseln.3 getmaxpartitions.3 getrawpartition.3 login.3 opendisk.3 \
+MAN=	fparseln.3 getrawpartition.3 login.3 opendisk.3 \
 	openpty.3 pidfile.3 pidlock.3 pw_init.3 pw_lock.3 ttyaction.3 ttymsg.3
 
 .PATH:	${.CURDIR}/../libc/gen
diff -ru src.org/lib/libutil/shlib_version src/lib/libutil/shlib_version
--- src.org/lib/libutil/shlib_version	Sun Jun  6 03:50:01 1999
+++ src/lib/libutil/shlib_version	Thu Aug 19 09:38:51 1999
@@ -1,5 +1,5 @@
 #	$NetBSD: shlib_version,v 1.19 1999/06/06 01:50:01 thorpej Exp $
 #	Remember to update distrib/sets/lists/base/shl.* when changing
 #
-major=5
-minor=1
+major=6
+minor=0
diff -ru src.org/sys/sys/disklabel.h src/sys/sys/disklabel.h
--- src.org/sys/sys/disklabel.h	Thu Aug 19 09:12:51 1999
+++ src/sys/sys/disklabel.h	Thu Aug 19 09:13:24 1999
@@ -162,7 +162,7 @@
 		} __partition_u1;
 #define	p_cpg	__partition_u1.cpg
 #define	p_sgs	__partition_u1.sgs
-	} d_partitions[MAXPARTITIONS];	/* actually may be more */
+	} d_partitions[MAXMAXPARTITIONS];	/* actually may be more */
 };
 #else /* _LOCORE */
 	/*

--2SCkAp4GZ/dPZZf/--