Date: 24 Jul 2001 22:17:09 +0200 From: Assar Westerlund <assar@FreeBSD.ORG> To: Warner Losh <imp@harmony.village.org> Cc: Mike Heffner <mheffner@vt.edu>, obrien@FreeBSD.ORG, arch@FreeBSD.ORG, dan@FreeBSD.ORG Subject: Re: Importing lukemftpd Message-ID: <5lbsmaccai.fsf@assaris.sics.se> In-Reply-To: Warner Losh's message of "Mon, 23 Jul 2001 16:21:18 -0600" References: <5lwv50isea.fsf@assaris.sics.se> <XFMail.20010722001142.mheffner@novacoxmail.com> <200107232221.f6NMLIo93090@harmony.village.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-=
Warner Losh <imp@harmony.village.org> writes:
> : I believe the plan is actually to do the rename in glob(3) to be
> : compatible with the other *BSDs. At least nobody objected when I
> : proposed that.
>
> Yes. I thought you'd done that already... :-)
Actually not. I wasn't sure how much backwards compatability we
wanted, if we want to change RELENG_4 too (which I would prefer).
Since we cannot have full backwards compatability, I propose applying
this patch, keeping the old flag name for glob but not preserving the
return code (since I cannot see any code actually using it). Comments?
/assar
--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=freebsd-glob.diff
Index: include/glob.h
===================================================================
RCS file: /home/ncvs/src/include/glob.h,v
retrieving revision 1.4
diff -u -w -r1.4 glob.h
--- include/glob.h 2001/03/19 19:10:06 1.4
+++ include/glob.h 2001/07/24 20:07:13
@@ -77,11 +77,14 @@
#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */
#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */
#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */
-#define GLOB_MAXPATH 0x1000 /* limit number of returned paths */
+#define GLOB_LIMIT 0x1000 /* limit number of returned paths */
+/* backwards compatibility, this is the old name for this option */
+#define GLOB_MAXPATH GLOB_LIMIT
+
#define GLOB_NOSPACE (-1) /* Malloc call failed. */
#define GLOB_ABEND (-2) /* Unignored error. */
-#define GLOB_LIMIT (-3) /* Path limit was hit. */
+#define GLOB_LIMITHIT (-3) /* Path limit was hit. */
__BEGIN_DECLS
int glob __P((const char *, int, int (*)(const char *, int), glob_t *));
Index: lib/libc/gen/glob.3
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/glob.3,v
retrieving revision 1.15
diff -u -w -r1.15 glob.3
--- lib/libc/gen/glob.3 2001/03/19 19:10:06 1.15
+++ lib/libc/gen/glob.3 2001/07/24 20:07:14
@@ -260,13 +260,14 @@
Expand patterns that start with
.Ql ~
to user name home directories.
-.It Dv GLOB_MAXPATH
+.It Dv GLOB_LIMIT
Limit the total number of returned pathnames to the value provided in
-.Fa gl_matchc .
+.Fa gl_matchc
+(default ARG_MAX).
If
.Fn glob
would match more pathnames,
-.Dv GLOB_LIMIT
+.Dv GLOB_LIMITHIT
will be returned.
.El
.Pp
@@ -384,9 +385,9 @@
was set or
.Fa \*(lp*errfunc\*(rp\*(lp\*(rp
returned non-zero.
-.It Dv GLOB_LIMIT
+.It Dv GLOB_LIMITHIT
The flag
-.Dv GLOB_MAXPATH
+.Dv GLOB_LIMIT
was provided, and the specified limit passed to
.Fn glob
in
Index: lib/libc/gen/glob.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/glob.c,v
retrieving revision 1.17
diff -u -w -r1.17 glob.c
--- lib/libc/gen/glob.c 2001/03/28 23:55:51 1.17
+++ lib/libc/gen/glob.c 2001/07/24 20:07:14
@@ -170,9 +170,11 @@
if (!(flags & GLOB_DOOFFS))
pglob->gl_offs = 0;
}
- if (flags & GLOB_MAXPATH)
+ if (flags & GLOB_LIMIT) {
limit = pglob->gl_matchc;
- else
+ if (limit == 0)
+ limit = ARG_MAX;
+ } else
limit = 0;
pglob->gl_flags = flags & ~GLOB_MAGCHAR;
pglob->gl_errfunc = errfunc;
@@ -688,7 +690,7 @@
const Char *p;
if (*limit && pglob->gl_pathc > *limit)
- return (GLOB_LIMIT);
+ return (GLOB_LIMITHIT);
newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
pathv = pglob->gl_pathv ?
Index: libexec/ftpd/ftpd.c
===================================================================
RCS file: /home/ncvs/src/libexec/ftpd/ftpd.c,v
retrieving revision 1.77
diff -u -w -r1.77 ftpd.c
--- libexec/ftpd/ftpd.c 2001/06/13 00:06:42 1.77
+++ libexec/ftpd/ftpd.c 2001/07/24 20:07:17
@@ -2670,7 +2670,7 @@
memset(&gl, 0, sizeof(gl));
gl.gl_matchc = MAXGLOBARGS;
- flags |= GLOB_MAXPATH;
+ flags |= GLOB_LIMIT;
freeglob = 1;
if (glob(whichf, flags, 0, &gl)) {
reply(550, "not found");
Index: libexec/ftpd/popen.c
===================================================================
RCS file: /home/ncvs/src/libexec/ftpd/popen.c,v
retrieving revision 1.20
diff -u -w -r1.20 popen.c
--- libexec/ftpd/popen.c 2001/03/19 19:11:00 1.20
+++ libexec/ftpd/popen.c 2001/07/24 20:07:17
@@ -108,7 +108,7 @@
memset(&gl, 0, sizeof(gl));
gl.gl_matchc = MAXGLOBARGS;
- flags |= GLOB_MAXPATH;
+ flags |= GLOB_LIMIT;
if (glob(argv[argc], flags, NULL, &gl))
gargv[gargc++] = strdup(argv[argc]);
else
--=-=-=--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5lbsmaccai.fsf>
