Subject: pkgtools/mtree and file flags
To: None <tech-pkg@NetBSD.org>
From: Klaus Heinz <k.heinz.apr.vier@onlinehome.de>
List: tech-pkg
Date: 04/11/2004 04:20:31
--DBIVS5p969aUjpLe
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

mtree has a test for member st_flags of struct stat in order to
recognize the availability/absence of file flags in the operating
system.  I propose to also check for UF_SETTABLE and SF_SETTABLE. SCO
Unixware has st_flags in struct stat and does not support file flags.

I have omitted the patches for 'configure' and 'config.h.in' because
those files will be generated from 'configure,ac'


ciao
     Klaus

--DBIVS5p969aUjpLe
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="configure.ac.diff"

--- configure.ac.orig	Fri Sep  5 20:38:58 2003
+++ configure.ac	Tue Mar 30 00:16:06 2004
@@ -25,6 +25,15 @@
 AC_TYPE_SIZE_T
 AC_CHECK_MEMBERS([struct stat.st_rdev])
 AC_CHECK_MEMBERS([struct stat.st_flags])
+AC_CHECK_DECLS([UF_SETTABLE, SF_SETTABLE])
+AH_BOTTOM([/* define HAVE_FILE_FLAGS if the user- and root-changeable masks
+were detected */
+#if defined(HAVE_STRUCT_STAT_ST_FLAGS) && (HAVE_DECL_UF_SETTABLE == 1) && (HAVE_DECL_SF_SETTABLE == 1)
+#define HAVE_FILE_FLAGS 1
+#else
+#define HAVE_FILE_FLAGS 0
+#endif
+])
 AC_HEADER_TIME
 
 # Checks for library functions.

--DBIVS5p969aUjpLe
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="compare.diff"

--- compare.c.orig	Fri Sep  5 06:38:46 2003
+++ compare.c	Tue Mar 30 00:15:42 2004
@@ -99,7 +99,7 @@
 } while (0)
 #define	LABEL if (!label++) MARK
 
-#if HAVE_STRUCT_STAT_ST_FLAGS
+#if HAVE_FILE_FLAGS
 
 
 #define CHANGEFLAGS							\
@@ -137,7 +137,7 @@
 	flags = (~(s->st_flags & (mask)) & CH_MASK) & (pflags);		\
 	CHANGEFLAGS;							\
 } while (0)
-#endif	/* HAVE_STRUCT_STAT_ST_FLAGS */
+#endif	/* HAVE_FILE_FLAGS */
 
 int
 compare(NODE *s, FTSENT *p)
@@ -187,7 +187,7 @@
 	}
 	if (Wflag)
 		goto afterpermwhack;
-#if HAVE_STRUCT_STAT_ST_FLAGS
+#if HAVE_FILE_FLAGS
 	if (iflag && !uflag) {
 		if (s->flags & F_FLAGS)
 		    SETFLAGS(p->fts_statp->st_flags, SP_FLGS);
@@ -343,7 +343,7 @@
 			tab = "\t";
 		}
 	}
-#if HAVE_STRUCT_STAT_ST_FLAGS
+#if HAVE_FILE_FLAGS
 	/*
 	 * XXX
 	 * since lchflags(2) will reset file times, the utimes() above
@@ -370,7 +370,7 @@
 			printf(")\n");
 		tab = "\t";
 	}
-#endif	/* HAVE_STRUCT_STAT_ST_FLAGS */
+#endif	/* HAVE_FILE_FLAGS */
 
 	/*
 	 * from this point, no more permission checking or whacking

--DBIVS5p969aUjpLe
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="create.diff"

--- create.c.orig	Fri Sep  5 06:38:47 2003
+++ create.c	Tue Mar 30 01:08:36 2004
@@ -258,7 +258,7 @@
 	if (keys & F_SLINK &&
 	    (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE))
 		output(&indent, "link=%s", rlink(p->fts_accpath));
-#if HAVE_STRUCT_STAT_ST_FLAGS
+#if HAVE_FILE_FLAGS
 	if (keys & F_FLAGS && p->fts_statp->st_flags != flags)
 		output(&indent, "flags=%s",
 		    flags_to_string(p->fts_statp->st_flags, "none"));
@@ -275,7 +275,7 @@
 #define	MTREE_MAXGID	5000
 #define	MTREE_MAXUID	5000
 #define	MTREE_MAXMODE	(MBITS + 1)
-#if HAVE_STRUCT_STAT_ST_FLAGS
+#if HAVE_FILE_FLAGS
 #define	MTREE_MAXFLAGS  (FLAGS2INDEX(CH_MASK) + 1)   /* 1808 */
 #else
 #define MTREE_MAXFLAGS	1
@@ -334,7 +334,7 @@
 			maxuid = u[suid];
 		}
 
-#if HAVE_STRUCT_STAT_ST_FLAGS
+#if HAVE_FILE_FLAGS
 		sflags = FLAGS2INDEX(p->fts_statp->st_flags);
 		if (sflags < MTREE_MAXFLAGS && ++f[sflags] > maxflags) {
 			saveflags = p->fts_statp->st_flags;
@@ -412,3 +412,4 @@
 	}
 	*offset += printf(" %s", buf) + 1;
 }
+

--DBIVS5p969aUjpLe
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="stat_flags.diff"

--- stat_flags.c.orig	Fri Sep  5 20:39:00 2003
+++ stat_flags.c	Tue Mar 30 00:16:18 2004
@@ -47,7 +47,7 @@
 #if HAVE_CONFIG_H
 #include "config.h"
 #else
-#define HAVE_STRUCT_STAT_ST_FLAGS 1
+#define HAVE_FILE_FLAGS 1
 #endif
 
 #if HAVE_SYS_TYPES_H
@@ -88,7 +88,7 @@
 
 	string[0] = '\0';
 	prefix = NULL;
-#if HAVE_STRUCT_STAT_ST_FLAGS
+#if HAVE_FILE_FLAGS
 	if (flags & UF_APPEND)
 		SAPPEND("uappnd");
 	if (flags & UF_IMMUTABLE)
@@ -143,7 +143,7 @@
 	if (clrp)
 		*clrp = 0;
 
-#if HAVE_STRUCT_STAT_ST_FLAGS
+#if HAVE_FILE_FLAGS
 	string = *stringp;
 	while ((p = strsep(&string, "\t ,")) != NULL) {
 		clear = 0;

--DBIVS5p969aUjpLe
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="verify.diff"

--- verify.c.orig	Fri Sep  5 06:38:48 2003
+++ verify.c	Tue Mar 30 00:16:22 2004
@@ -294,7 +294,7 @@
 				printf("%s: permissions not set: %s\n",
 				    path, strerror(errno));
 		}
-#if HAVE_STRUCT_STAT_ST_FLAGS
+#if HAVE_FILE_FLAGS
 		if ((p->flags & F_FLAGS) && p->st_flags) {
 			if (iflag)
 				flags = p->st_flags;
@@ -304,6 +304,6 @@
 				printf("%s: file flags not set: %s\n",
 				    path, strerror(errno));
 		}
-#endif	/* HAVE_STRUCT_STAT_ST_FLAGS */
+#endif	/* HAVE_FILE_FLAGS */
 	}
 }

--DBIVS5p969aUjpLe--