Re: ntpd: strptime portability problem
Ok bcook@ > On Mar 4, 2016, at 4:32 PM, Christian Weisgerber wrote: > > Matthias Andree noticed that the constraint > offset was always off by 3600 seconds for him (running OpenNTPD on > FreeBSD with CET timezone). > > The way we parse the HTTP date in the ntpd constraint code isn't > portable: > >if (strptime(p, "%a, %d %h %Y %T %Z", >&httpsdate->tls_tm) == NULL) { > ... >/* Return parsed date as local time */ >t = timegm(&httpsdate->tls_tm); > > Neither %Z nor any kind of timezone information in struct tm are > in POSIX. We end up with a time that, depending on the operating > system, is off by the offset between local time and UTC. > > Since we only support the preferred HTTP date format from > https://tools.ietf.org/html/rfc7231#section-7.1.1.1 > for which the timezone is fixed as the literal string "GMT", > I suggest to simply replace %Z with GMT in the strptime() call. > > Comments? OK? > > > Index: constraint.c > === > RCS file: /cvs/src/usr.sbin/ntpd/constraint.c,v > retrieving revision 1.25 > diff -u -p -r1.25 constraint.c > --- constraint.c27 Jan 2016 21:48:34 -1.25 > +++ constraint.c4 Mar 2016 22:12:37 - > @@ -903,7 +903,7 @@ httpsdate_request(struct httpsdate *http > * or ANSI C's asctime() - the latter doesn't include > * the timezone which is required here. > */ > -if (strptime(p, "%a, %d %h %Y %T %Z", > +if (strptime(p, "%a, %d %h %Y %T GMT", >&httpsdate->tls_tm) == NULL) { >log_warnx("unsupported date format"); >free(line); > > -- > Christian "naddy" Weisgerber na...@mips.inka.de >
Re: cp -i might violate POSIX
On Sat, Mar 05, 2016 at 03:03:36AM +0100, Dmitrij D. Czarkoff wrote: > So the goal of the diff is to replace something like > > $ for src in ${files}; do [ -r "$src" ] && cp ${src} dst/; done > > with > > $ yes n | cp -i ${files} dst/ > > ? Or alternatively, to state in the manual that -i will be ignored if stdin is not a tty, ideally with some rationale on why we deviate from POSIX there. > Well, I guess you can save some performance this way, but it is just > too ugly to make sense. I'd argue that > $ yes n | cp -i ${files} dst/ even if ugly, is more straightforward a solution to arrive at from the manual alone than > $ for src in ${files}; do [ -r "$src" ] && cp ${src} dst/; done unless one is already familiar with the (undocumented) twist. > I'd rather add "-n" flag. I agree that -n would be nice (below a FreeBSD-inspired patch), but I think -i should be fixed (or the behavior documented) regardless. 8<- --- bin/cp/cp.1.orig +++ bin/cp/cp.1 @@ -44,7 +44,7 @@ .Fl R .Op Fl H | Fl L | Fl P .Oc -.Op Fl f | i +.Op Fl f | i | n .Op Fl alNpv .Ar source_file target_file .Nm cp @@ -52,7 +52,7 @@ .Fl R .Op Fl H | Fl L | Fl P .Oc -.Op Fl f | i +.Op Fl f | i | n .Op Fl alNpv .Ar source_file ... target_directory .Sh DESCRIPTION @@ -82,11 +82,14 @@ Same as For each existing destination pathname, attempt to overwrite it. If permissions do not allow copy to succeed, remove it and create a new file, without prompting for confirmation. +.br (The -.Fl i -option is ignored if the .Fl f -option is specified.) +option overrides any previous +.Fl i +or +.Fl n +options.) .It Fl H If the .Fl R @@ -100,6 +103,24 @@ that would overwrite an existing file. If the response from the standard input begins with the character .Sq Li y , the file copy is attempted. +.br +(The +.Fl i +option overrides any previous +.Fl f +or +.Fl n +options.) +.It Fl n +Do not overwrite existing files. +.br +(The +.Fl n +option overrides any previous +.Fl i +or +.Fl f +options.) .It Fl L If the .Fl R --- bin/cp/cp.c.orig +++ bin/cp/cp.c @@ -87,7 +87,7 @@ static char empty[] = ""; PATH_T to = { .p_end = to.p_path, .target_end = empty }; uid_t myuid; -int Hflag, Lflag, Rflag, Pflag, fflag, iflag, lflag, pflag, rflag, vflag, Nflag; +int Hflag, Lflag, Rflag, Pflag, fflag, iflag, lflag, nflag, pflag, rflag, vflag, Nflag; mode_t myumask; sig_atomic_t pinfo; @@ -114,7 +114,7 @@ main(int argc, char *argv[]) (void)setlocale(LC_ALL, ""); Hflag = Lflag = Pflag = Rflag = 0; - while ((ch = getopt(argc, argv, "HLNPRfailprv")) != -1) + while ((ch = getopt(argc, argv, "HLNPRfailnprv")) != -1) switch (ch) { case 'H': Hflag = 1; @@ -142,11 +142,15 @@ main(int argc, char *argv[]) break; case 'f': fflag = 1; - iflag = 0; + nflag = iflag = 0; break; case 'i': iflag = isatty(fileno(stdin)); - fflag = 0; + fflag = nflag = 0; + break; + case 'n': + nflag = 1; + fflag = iflag = 0; break; case 'l': lflag = 1; --- bin/cp/extern.h.orig +++ bin/cp/extern.h @@ -42,7 +42,7 @@ typedef struct { extern PATH_T to; extern uid_t myuid; -extern int Rflag, rflag, Hflag, Lflag, Pflag, fflag, iflag, lflag, pflag, Nflag; +extern int Rflag, rflag, Hflag, Lflag, Pflag, fflag, iflag, lflag, nflag, pflag, Nflag; extern mode_t myumask; extern sig_atomic_t pinfo; --- bin/cp/utils.c.orig +++ bin/cp/utils.c @@ -120,7 +120,10 @@ copy_file(FTSENT *entp, int dne) struct stat sb; int sval; - if (iflag) { + if (nflag) { + (void)close(from_fd); + return (0); + } else if (iflag) { (void)fprintf(stderr, "overwrite %s? ", to.p_path); checkch = ch = getchar(); while (ch != '\n' && ch != EOF) @@ -412,8 +415,8 @@ void usage(void) { (void)fprintf(stderr, - "usage: %s [-R [-H | -L | -P]] [-f | -i] [-alNpv] src target\n" - " %s [-R [-H | -L | -P]] [-f | -i] [-alNpv] src1 ... srcN directory\n", + "usage: %s [-R [-H | -L | -P]] [-f | -i | -n] [-alNpv] src target\n" + " %s [-R [-H | -L | -P]] [-f | -i | -n] [-alNpv] src1 ... srcN directory\n", getprogname(), getprogname()); exit(1); /* NOTREACHED */
Re: cp -i might violate POSIX
Timo Buhrmester said: > On Sat, Mar 05, 2016 at 02:39:41AM +0100, Dmitrij D. Czarkoff wrote: > > > This breaks doing something along the lines of ``yes n | cp -i [...]'' > > > > Why would anyone want that? > > To simulate what in FreeBSD's and GNU's implementation of cp is the > -n option, i.e. to only copy files that don't already exist at the > destination. > > I'm not saying it is pretty, it just seems to be the only way to > convince cp to do that, without relying on non-POSIX options. So the goal of the diff is to replace something like $ for src in ${files}; do [ -r "$src" ] && cp ${src} dst/; done with $ yes n | cp -i ${files} dst/ ? Well, I guess you can save some performance this way, but it is just too ugly to make sense. I'd rather add "-n" flag. -- Dmitrij D. Czarkoff
Re: cp -i might violate POSIX
On Sat, Mar 05, 2016 at 02:39:41AM +0100, Dmitrij D. Czarkoff wrote: > > This breaks doing something along the lines of ``yes n | cp -i [...]'' > > Why would anyone want that? To simulate what in FreeBSD's and GNU's implementation of cp is the -n option, i.e. to only copy files that don't already exist at the destination. I'm not saying it is pretty, it just seems to be the only way to convince cp to do that, without relying on non-POSIX options.
Re: [ksh] [patch] Make "$@" and "$*" POSIX-compliant with 'set -u'
Martijn Dekker said: > Martijn Dekker schreef op 04-03-16 om 16:21: > > I've also attached a simple regression test. I didn't know what existing > > .t file that would fit in, so I made a new one. > > Perhaps it should be added to obsd-regress.t -- it seems to have all the > miscellaneous tests added for OpenBSD. OK czarkoff@ with this change. -- Dmitrij D. Czarkoff
Re: cp -i might violate POSIX
Timo Buhrmester said: > From src/bin/cp/cp.c: > > while ((ch = getopt(argc, argv, "HLNPRfailprv")) != -1) > > [...] > > case 'i': > > iflag = isatty(fileno(stdin)); > The -i in cp -i is ignored if standard input isn't a tty. > > This breaks doing something along the lines of ``yes n | cp -i [...]'' Why would anyone want that? FWIW interactive mode does only make sense in cases there is an operator with no other means to influence the process but to use tty. The only scenario where non-tty interactive mode really makes sense is some script/program which tries to parse cp's output; preventing that is actually a feature. -- Dmitrij D. Czarkoff
cp -i might violate POSIX
>From src/bin/cp/cp.c: > while ((ch = getopt(argc, argv, "HLNPRfailprv")) != -1) > [...] > case 'i': > iflag = isatty(fileno(stdin)); The -i in cp -i is ignored if standard input isn't a tty. This breaks doing something along the lines of ``yes n | cp -i [...]'' (obviously overwriting files that weren't supposed to be overwritten, as well was rendering the only way to stop cp from overwriting existing files ineffective in scripts) Our man page also doesn't mention this twist. POSIX says (in the rationale at [1]): > Although the 4.3 BSD version does not prompt if the standard input is > not a terminal, (And in fact the isatty line was not touched since ``initial import of 386bsd-0.1 sources'' in '93) > the standard developers decided that use of -i is a request for > interaction, so when the destination path exists, the utility takes > instructions from whatever responds on standard input. ..which I believe conflicts with what our cp's -i does. At the bottom of this mail is a patch that drops the ``isatty()''. Cheers, Timo Buhrmester [1] http://pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html CC OpenBSD's tech@ because their cp does the same. -8< --- bin/cp/cp.c.orig +++ bin/cp/cp.c @@ -145,7 +145,7 @@ main(int argc, char *argv[]) iflag = 0; break; case 'i': - iflag = isatty(fileno(stdin)); + iflag = 1; fflag = 0; break; case 'l':
Re: [ksh] [patch] Make command -v and command -p[vV] POSIX compliant
Martijn Dekker schreef op 04-03-16 om 22:46: > Martijn Dekker schreef op 04-03-16 om 19:30: >> Some minor updates to the man page are also needed. I'll make a new patch. > Here's take 2. It was correctly pointed out that I made some unrelated edits to sh.1 that would be better submitted and evaluated separately. Here's take 3. - M. Index: bin/ksh/c_ksh.c === RCS file: /cvs/src/bin/ksh/c_ksh.c,v retrieving revision 1.49 diff -u -p -u -r1.49 c_ksh.c --- bin/ksh/c_ksh.c 15 Jan 2016 17:55:45 - 1.49 +++ bin/ksh/c_ksh.c 4 Mar 2016 22:33:45 - @@ -433,23 +433,23 @@ c_whence(char **wp) fcflags = FC_BI | FC_PATH | FC_FUNC; if (!iam_whence) { - /* Note that -p on its own is deal with in comexec() */ + /* Note that -p on its own is dealt with in comexec() */ if (pflag) fcflags |= FC_DEFPATH; - /* Convert command options to whence options - note that - * command -pV uses a different path search than whence -v - * or whence -pv. This should be considered a feature. + /* Convert command options to whence options. Note that + * command -pV and command -pv use a different path search + * than whence -v or whence -pv. This should be considered + * a feature. */ vflag = Vflag; - } - if (pflag) + } else if (pflag) fcflags &= ~(FC_BI | FC_FUNC); while ((vflag || ret == 0) && (id = *wp++) != NULL) { tp = NULL; - if ((iam_whence || vflag) && !pflag) + if (!iam_whence || !pflag) tp = ktsearch(&keywords, id, hash(id)); - if (!tp && !pflag) { + if (!tp && (!iam_whence || !pflag)) { tp = ktsearch(&aliases, id, hash(id)); if (tp && !(tp->flag & ISSET)) tp = NULL; Index: bin/ksh/ksh.1 === RCS file: /cvs/src/bin/ksh/ksh.1,v retrieving revision 1.173 diff -u -p -u -r1.173 ksh.1 --- bin/ksh/ksh.1 29 Dec 2015 01:02:34 - 1.173 +++ bin/ksh/ksh.1 4 Mar 2016 22:33:48 - @@ -2969,7 +2969,7 @@ is executed exactly as if had not been specified, with two exceptions: firstly, .Ar cmd -cannot be a shell function; +cannot be an alias or a shell function; and secondly, special built-in commands lose their specialness (i.e. redirection and utility errors do not cause the shell to exit, and command assignments are not permanent). @@ -2981,6 +2981,8 @@ option is given, a default search path i (the actual value of the default path is system dependent: on POSIX-ish systems, it is the value returned by .Ic getconf CS_PATH ) . +Nevertheless, reserved words, aliases, shell functions, and +builtin commands are still found before external commands. .Pp If the .Fl v @@ -4473,7 +4475,7 @@ is similar to .Ic command Fl v except that .Ic whence -will find reserved words and won't print aliases as alias commands. +won't print aliases as alias commands. With the .Fl v option, Index: bin/ksh/sh.1 === RCS file: /cvs/src/bin/ksh/sh.1,v retrieving revision 1.130 diff -u -p -u -r1.130 sh.1 --- bin/ksh/sh.1 12 Oct 2015 12:34:42 - 1.130 +++ bin/ksh/sh.1 4 Mar 2016 22:33:48 - @@ -329,6 +329,9 @@ but identify how the shell will interpre Do not invoke .Ar command , but identify the pathname the shell will use to run it. +For aliases, a command to define that alias is printed. +For shell reserved words, shell functions, and built-in utilities, +just the name is printed. .El .Pp The exit status is that of @@ -346,8 +349,9 @@ If the options or .Fl v are given, -the exit status is 0 on success, -or >0 if an error occurs. +the exit status is 0 if the +.Ar command +was found, or >0 if it was not found. .It Ic continue Op Ar n Go directly to the next iteration of the innermost .Ic for , while , Index: regress/bin/ksh/obsd-regress.t === RCS file: /cvs/src/regress/bin/ksh/obsd-regress.t,v retrieving revision 1.1 diff -u -p -u -r1.1 obsd-regress.t --- regress/bin/ksh/obsd-regress.t 2 Dec 2013 20:39:44 - 1.1 +++ regress/bin/ksh/obsd-regress.t 4 Mar 2016 22:33:48 - @@ -273,3 +273,75 @@ stdin: set foo bar baz ; for out in ; do echo $out ; done --- +name: command-pvV-posix-priorities +description: + For POSIX compatibility, command -v should find aliases and reserved + words, and command -p[vV] should find aliases, reserved words, and + builtins over external commands. +stdin: + PATH=/bin:/usr/bin + alias foo="bar baz" + bar() { :; } + for word in 'if' 'foo' 'bar' 'set' 'true'; do + command -v "$word" + command -pv "$word" + command -V "$word" + command -pV "$word" + done +expected-stdout: + if + if + if is a reserved word + if is a reserved word + alias foo='bar baz' + alias foo='bar baz' + foo is an alias for 'bar baz' + foo is an alias for 'bar baz' + bar + bar + bar is a function + bar is a function + set + set + set is a special shell builtin + set is a special shell builtin + true + true + true i
Re: ntpd: strptime portability problem
On Fri, Mar 04, 2016 at 11:32:51PM +0100, Christian Weisgerber wrote: > Matthias Andree noticed that the constraint > offset was always off by 3600 seconds for him (running OpenNTPD on > FreeBSD with CET timezone). > > The way we parse the HTTP date in the ntpd constraint code isn't > portable: > > if (strptime(p, "%a, %d %h %Y %T %Z", > &httpsdate->tls_tm) == NULL) { > ... > /* Return parsed date as local time */ > t = timegm(&httpsdate->tls_tm); > > Neither %Z nor any kind of timezone information in struct tm are > in POSIX. We end up with a time that, depending on the operating > system, is off by the offset between local time and UTC. > > Since we only support the preferred HTTP date format from > https://tools.ietf.org/html/rfc7231#section-7.1.1.1 > for which the timezone is fixed as the literal string "GMT", > I suggest to simply replace %Z with GMT in the strptime() call. > > Comments? OK? > make sense, ok. Cheers Giovanni > > Index: constraint.c > === > RCS file: /cvs/src/usr.sbin/ntpd/constraint.c,v > retrieving revision 1.25 > diff -u -p -r1.25 constraint.c > --- constraint.c 27 Jan 2016 21:48:34 - 1.25 > +++ constraint.c 4 Mar 2016 22:12:37 - > @@ -903,7 +903,7 @@ httpsdate_request(struct httpsdate *http >* or ANSI C's asctime() - the latter doesn't include >* the timezone which is required here. >*/ > - if (strptime(p, "%a, %d %h %Y %T %Z", > + if (strptime(p, "%a, %d %h %Y %T GMT", > &httpsdate->tls_tm) == NULL) { > log_warnx("unsupported date format"); > free(line); > > -- > Christian "naddy" Weisgerber na...@mips.inka.de >
Re: landisk: invalidate the entire cache on EMODE CPUs
> SH4 CPUs with EMODE bit set have a cache twice as big. Fix the obvious > copy&paste mistake. There is nothing to fix in these routines. When EMODE is enabled, the cache becomes two way, instead of one way, which is why it becomes twice as big. sh4_emode_icache_sync_all() and sh4_emode_dcache_wbinv_all() wrap cache_sh4_emode_op_8lines_32(), which will operate on both ways.
ntpd: strptime portability problem
Matthias Andree noticed that the constraint offset was always off by 3600 seconds for him (running OpenNTPD on FreeBSD with CET timezone). The way we parse the HTTP date in the ntpd constraint code isn't portable: if (strptime(p, "%a, %d %h %Y %T %Z", &httpsdate->tls_tm) == NULL) { ... /* Return parsed date as local time */ t = timegm(&httpsdate->tls_tm); Neither %Z nor any kind of timezone information in struct tm are in POSIX. We end up with a time that, depending on the operating system, is off by the offset between local time and UTC. Since we only support the preferred HTTP date format from https://tools.ietf.org/html/rfc7231#section-7.1.1.1 for which the timezone is fixed as the literal string "GMT", I suggest to simply replace %Z with GMT in the strptime() call. Comments? OK? Index: constraint.c === RCS file: /cvs/src/usr.sbin/ntpd/constraint.c,v retrieving revision 1.25 diff -u -p -r1.25 constraint.c --- constraint.c27 Jan 2016 21:48:34 - 1.25 +++ constraint.c4 Mar 2016 22:12:37 - @@ -903,7 +903,7 @@ httpsdate_request(struct httpsdate *http * or ANSI C's asctime() - the latter doesn't include * the timezone which is required here. */ - if (strptime(p, "%a, %d %h %Y %T %Z", + if (strptime(p, "%a, %d %h %Y %T GMT", &httpsdate->tls_tm) == NULL) { log_warnx("unsupported date format"); free(line); -- Christian "naddy" Weisgerber na...@mips.inka.de
Re: prefer memset() over bzero() for ber.c in snmpd and ypldap
On 2016/03/04 16:40, Rob Pierce wrote: > A similar change was done to ber.c in ldapd by @mmcc. > > I just copied those changes for snmpd and ypldap. > > No binary change. ok sthen@
Re: [ksh] [patch] Make command -v and command -p[vV] POSIX compliant
Martijn Dekker schreef op 04-03-16 om 19:30: > Todd C. Miller schreef op 04-03-16 om 19:22: >> This also looks fine but we should add a similar regress for whence's >> -p and -v flags. > > Some minor updates to the man page are also needed. I'll make a new patch. Here's take 2. I had missed one thing: aliases were also missed by 'command -pv' and 'command -pV', but should be found for the same reason as reserved words. Now fixed. I've also added two fairly comprehensive regression tests, the first to test that 'command' now behaves like POSIX for reserved words, aliases, functions, special builtins and regular builtins, and the second to ensure that the behaviour of 'whence' is unchanged. The latter test passes both on the original ksh and the patched one. Finally I've edited both ksh.1 and sh.1 to reflect the change and to make the language a little clearer. Thanks, - M. Index: bin/ksh/c_ksh.c === RCS file: /cvs/src/bin/ksh/c_ksh.c,v retrieving revision 1.49 diff -u -p -u -r1.49 c_ksh.c --- bin/ksh/c_ksh.c 15 Jan 2016 17:55:45 - 1.49 +++ bin/ksh/c_ksh.c 4 Mar 2016 21:28:35 - @@ -433,23 +433,23 @@ c_whence(char **wp) fcflags = FC_BI | FC_PATH | FC_FUNC; if (!iam_whence) { - /* Note that -p on its own is deal with in comexec() */ + /* Note that -p on its own is dealt with in comexec() */ if (pflag) fcflags |= FC_DEFPATH; - /* Convert command options to whence options - note that - * command -pV uses a different path search than whence -v - * or whence -pv. This should be considered a feature. + /* Convert command options to whence options. Note that + * command -pV and command -pv use a different path search + * than whence -v or whence -pv. This should be considered + * a feature. */ vflag = Vflag; - } - if (pflag) + } else if (pflag) fcflags &= ~(FC_BI | FC_FUNC); while ((vflag || ret == 0) && (id = *wp++) != NULL) { tp = NULL; - if ((iam_whence || vflag) && !pflag) + if (!iam_whence || !pflag) tp = ktsearch(&keywords, id, hash(id)); - if (!tp && !pflag) { + if (!tp && (!iam_whence || !pflag)) { tp = ktsearch(&aliases, id, hash(id)); if (tp && !(tp->flag & ISSET)) tp = NULL; Index: bin/ksh/ksh.1 === RCS file: /cvs/src/bin/ksh/ksh.1,v retrieving revision 1.173 diff -u -p -u -r1.173 ksh.1 --- bin/ksh/ksh.1 29 Dec 2015 01:02:34 - 1.173 +++ bin/ksh/ksh.1 4 Mar 2016 21:28:37 - @@ -2969,7 +2969,7 @@ is executed exactly as if had not been specified, with two exceptions: firstly, .Ar cmd -cannot be a shell function; +cannot be an alias or a shell function; and secondly, special built-in commands lose their specialness (i.e. redirection and utility errors do not cause the shell to exit, and command assignments are not permanent). @@ -2981,6 +2981,8 @@ option is given, a default search path i (the actual value of the default path is system dependent: on POSIX-ish systems, it is the value returned by .Ic getconf CS_PATH ) . +However, this does not change that reserved words, aliases, shell +functions, and builtin commands are found before external commands. .Pp If the .Fl v @@ -4473,7 +4475,7 @@ is similar to .Ic command Fl v except that .Ic whence -will find reserved words and won't print aliases as alias commands. +won't print aliases as alias commands. With the .Fl v option, Index: bin/ksh/sh.1 === RCS file: /cvs/src/bin/ksh/sh.1,v retrieving revision 1.130 diff -u -p -u -r1.130 sh.1 --- bin/ksh/sh.1 12 Oct 2015 12:34:42 - 1.130 +++ bin/ksh/sh.1 4 Mar 2016 21:28:38 - @@ -305,15 +305,15 @@ Resolve symbolic links before processing components. .El .It Ic command Oo Fl p | V | v Oc Ar command Op Ar arg ... -Invoke +Invoke the specified .Ar command -(and any optional arguments), +(with any arguments given), overriding any functions with the same name, and without any of the properties that special built-ins have. .Pp -The options to +The options to the .Ic command -are as follows: +utility are as follows: .Pp .Bl -tag -width Ds -offset 3n -compact .It Fl p @@ -321,24 +321,27 @@ Use a default value for .Ev PATH to search for the command. .It Fl V -Do not invoke +Do not invoke the specified .Ar command , but identify how the shell will interpret it (such as a function or special built-in). .It Fl v -Do not invoke +Do not invoke the specified .Ar command , but identify the pathname the shell will use to run it. +For aliases, a command to define that alias is printed. +For shell reserved words, shell functions, and built-in utilities, +just the name is printed. .El .Pp -The exit status is that of +The exit status is that of the specified .Ar command , -or 126 if +or 126 if the .Ar command could not be invoked, -or 127 if an error occurred in +or 127 if an error occurred in the .Ic command -it
prefer memset() over bzero() for ber.c in snmpd and ypldap
A similar change was done to ber.c in ldapd by @mmcc. I just copied those changes for snmpd and ypldap. No binary change. Regards, Index: snmpd/ber.c === RCS file: /cvs/src/usr.sbin/snmpd/ber.c,v retrieving revision 1.30 diff -u -p -r1.30 ber.c --- snmpd/ber.c 5 Dec 2015 06:42:18 - 1.30 +++ snmpd/ber.c 4 Mar 2016 21:34:32 - @@ -420,7 +420,7 @@ ber_string2oid(const char *oidstr, struc if (strlcpy(str, oidstr, sizeof(str)) >= sizeof(str)) return (-1); - bzero(o, sizeof(*o)); + memset(o, 0, sizeof(*o)); /* Parse OID strings in the common forms n.n.n, n_n_n_n, or n-n-n */ for (p = sp = str; p != NULL; sp = p) { @@ -505,7 +505,7 @@ ber_get_oid(struct ber_element *elm, str if (!buf[i]) return (-1); - bzero(o, sizeof(*o)); + memset(o, 0, sizeof(*o)); o->bo_id[j++] = buf[i] / 40; o->bo_id[j++] = buf[i++] % 40; for (; i < len && j < BER_MAX_OID_LEN; i++) { @@ -639,7 +639,7 @@ ber_scanf_elements(struct ber_element *b struct ber_oid *o; struct ber_element *parent[_MAX_SEQ], **e; - bzero(parent, sizeof(struct ber_element *) * _MAX_SEQ); + memset(parent, 0, sizeof(struct ber_element *) * _MAX_SEQ); va_start(ap, fmt); while (*fmt) { Index: ypldap/ber.c === RCS file: /cvs/src/usr.sbin/ypldap/ber.c,v retrieving revision 1.10 diff -u -p -r1.10 ber.c --- ypldap/ber.c5 Dec 2015 19:10:19 - 1.10 +++ ypldap/ber.c4 Mar 2016 21:34:33 - @@ -420,7 +420,7 @@ ber_string2oid(const char *oidstr, struc if (strlcpy(str, oidstr, sizeof(str)) >= sizeof(str)) return (-1); - bzero(o, sizeof(*o)); + memset(o, 0, sizeof(*o)); /* Parse OID strings in the common forms n.n.n, n_n_n_n, or n-n-n */ for (p = sp = str; p != NULL; sp = p) { @@ -505,7 +505,7 @@ ber_get_oid(struct ber_element *elm, str if (!buf[i]) return (-1); - bzero(o, sizeof(*o)); + memset(o, 0, sizeof(*o)); o->bo_id[j++] = buf[i] / 40; o->bo_id[j++] = buf[i++] % 40; for (; i < len && j < BER_MAX_OID_LEN; i++) { @@ -638,7 +638,7 @@ ber_scanf_elements(struct ber_element *b struct ber_oid *o; struct ber_element *parent[_MAX_SEQ], **e; - bzero(parent, sizeof(struct ber_element *) * _MAX_SEQ); + memset(parent, 0, sizeof(struct ber_element *) * _MAX_SEQ); va_start(ap, fmt); while (*fmt) {
sdhc: don't always compile the pci attachment driver
Hi, if you attach sdhc, you automatically compile the pci attachment driver, even if there's no "sdhc* at pci?" in the config. This might fail on architectures that don't have pci compiled in. If I'm not completely mistaken, this can be averted by making the file depend on sdhc_pci. Tested to still compile correctly on amd64. Patrick diff --git sys/dev/pci/files.pci sys/dev/pci/files.pci index 0614e56..c5d0494 100644 --- sys/dev/pci/files.pci +++ sys/dev/pci/files.pci @@ -766,7 +766,7 @@ filedev/pci/nviic.c nviic # SD Host Controller attach sdhc at pci with sdhc_pci -file dev/pci/sdhc_pci.c sdhc +file dev/pci/sdhc_pci.c sdhc_pci # AMD NPT Family 0Fh Processors, Function 3 -- Miscellaneous Control device kate
Re: arm/fdt: map fdt and use given memory/bootargs
On Fri, Mar 04, 2016 at 02:35:34PM -0500, Brandon Mercer wrote: > On Fri, Mar 04, 2016 at 08:08:36PM +0100, Patrick Wildt wrote: > > On Fri, Mar 04, 2016 at 09:38:18AM -0500, Brandon Mercer wrote: > > > On Fri, Mar 04, 2016 at 03:15:23PM +0100, Patrick Wildt wrote: > > > > Hi, > > > > > > > > this diff makes armv7 map the FDT, if available, and uses it to read > > > > information about the machine's available memory and bootargs. > > > > > > > > I'd like to get some opinions about the way I have implemented some > > > > stuff. For instance, I need the size of the FDT so I can properly > > > > copy it. Does it make sense to implement fdt_get_size()? Is there > > > > another, preferred way? > > > > > > > > Additionally, reading memory information, like where a node is mapped, > > > > is a bit more complicated than just reading two values. Especially if > > > > there are translation ranges on a node's parent. I also have working > > > > code or that, but I skipped "ranges" to not bloat the diff any further. > > > > > > If memory serves me correctly we need ranges right out of the gate for > > > the exynos boards I have, but those aren't important to anyone except > > > for me so I'm ok with waiting a short while. > > > > Yes, I stumbled upon that on the raspberry pi. The default device tree > > delivered by the raspberry pi foundation makes use of that. > > > > Excerpt: > > > > / { > > #address-cells = <0x1>; > > #size-cells = <0x1>; > > interrupt-parent = <0x1>; > > compatible = "brcm,bcm2710", "brcm,bcm2709"; > > model = "Raspberry Pi 3 Model B"; > > [...] > > soc { > > compatible = "simple-bus"; > > #address-cells = <0x1>; > > #size-cells = <0x1>; > > ranges = <0x7e00 0x3f00 0x100>; > > [...] > > interrupt-controller@7e00b200 { > > compatible = "brcm,bcm2708-armctrl-ic"; > > reg = <0x7e00b200 0x200>; > > interrupt-controller; > > #interrupt-cells = <0x2>; > > linux,phandle = <0x1>; > > phandle = <0x1>; > > }; > > Yes, this is needed as well. However I was commenting on reserved memory > regions. I don't want to see this turn into a bikeshed session so I > suggest we start with the initial diff, and add these additional > features soon after. Agreed. I'd like to give a brief introduction to the big picture that I have in my mind and that I have worked on. I have mailed this to jsg@ and bmercer@ already to get some feedback on it. As you gathered, this is based on the socppc code with some additions. I added functions to extract integer values from a node, to find a fdt node with a specific compatible string, to find a node by its property value, find by a phandle, translate address regions, extract memory addresses and more such stuff. Using those helpers I have implemented an fdtbus (fdt0 at mainbus0) which in essence goes through each device (agtimer* at fdt?), calls its match function and passes every nodes. The device driver can then use the compatible string to see if the node matches. This way every driver has a chance to claim a node. I then have a list of fdt nodes that are already attached, so that I don't attach a node twice. There's a reason that I iterate over the devices and then for each device iterate over all nodes: The drivers were usually written to depend on the order they attached in. Keeping it this way we don't have to re-think them and can more easily integrate fdt. Usually device drivers depend on having their interrupt controller (and clocks) attached. Otherwise intr_establish does not really work. Using the interrupt-controller property I can attach the interrupt tree (like ampintc as root interrupt controller, and a gpio controller as secondary interrupt controller hanging off the ampintc) before I attach any other device. This way I always have the interrupt controller driver attached before I attach a device that needs it. Similarly the clock tree. Before I attach a device, I check the node's clock requirements. I work my way up to the root and make sure to attach all clock controller nodes. As I have a list of already attached nodes, I can easily find out how far I have already gone up. For the clocks I have implemented a framework inspired by some other clock frameworks. It's a bit bare but does an ok job so far. The nice thing is that a driver can basically do clk_enable(clk_fdt_get(aa->aa_node, 0)); and the job is done. Additionally I have implemented a simple API to attach interrupts. Currently there's only arm_intr_establish() and there can only be one interrupt controller. I implemented something called arm_intr_establish_fdt() where you can pass the FDT node instead of an IRQ number, like this: arm_intr_establish_fdt(aa->aa_node, IPL
Re: [file] file -i doesn't detect epub correctly
The only thing I see that we do not support is the indirect on the last line, I suggest just commenting it. On Fri, Mar 04, 2016 at 07:01:57PM +, Stuart Henderson wrote: > On 2016/03/04 19:50, Dmitrij D. Czarkoff wrote: > > Jiri B said: > > > file -i *.epub returns 'application/x-not-regular-file' or > > > 'application/zip' > > > and it should return 'application/epub+zip' (at least this is on Fedora). > > > > Below comes the patch that changes the way zip archives are treated in > > magic file: > > Can you try just pulling across magdir/archive from the other "file"? > Unless there is a special case I think it is better to keep in sync. > > e.g. > > Index: archive > === > RCS file: /cvs/src/usr.bin/file/magdir/archive,v > retrieving revision 1.6 > diff -u -p -r1.6 archive > --- archive 24 Apr 2009 18:54:34 - 1.6 > +++ archive 4 Mar 2016 19:00:39 - > @@ -13,6 +13,11 @@ > 257 string ustar\040\040\0 GNU tar archive > !:mime application/x-tar # encoding: gnu > > +# Incremental snapshot gnu-tar format from: > +# http://www.gnu.org/software/tar/manual/html_node/Snapshot-Files.html > +0string GNU\ tar- GNU tar incremental snapshot data > +>&0 regex [0-9]\.[0-9]+-[0-9]+version %s > + > # cpio archives > # > # Yes, the top two "cpio archive" formats *are* supposed to just be "short". > @@ -32,12 +37,66 @@ > 0string 070701 ASCII cpio archive (SVR4 with no CRC) > 0string 070702 ASCII cpio archive (SVR4 with CRC) > > -# Debian package (needs to go before regular portable archives) > +# > +# Various archive formats used by various versions of the "ar" > +# command. > +# > + > +# > +# Original UNIX archive formats. > +# They were written with binary values in host byte order, and > +# the magic number was a host "int", which might have been 16 bits > +# or 32 bits. We don't say "PDP-11" or "VAX", as there might have > +# been ports to little-endian 16-bit-int or 32-bit-int platforms > +# (x86?) using some of those formats; if none existed, feel free > +# to use "PDP-11" for little-endian 16-bit and "VAX" for little-endian > +# 32-bit. There might have been big-endian ports of that sort as > +# well. > +# > +0leshort 0177555 very old 16-bit-int little-endian > archive > +0beshort 0177555 very old 16-bit-int big-endian archive > +0lelong 0177555 very old 32-bit-int little-endian > archive > +0belong 0177555 very old 32-bit-int big-endian archive > + > +0leshort 0177545 old 16-bit-int little-endian archive > +>2 string __.SYMDEF random library > +0beshort 0177545 old 16-bit-int big-endian archive > +>2 string __.SYMDEF random library > +0lelong 0177545 old 32-bit-int little-endian archive > +>4 string __.SYMDEF random library > +0belong 0177545 old 32-bit-int big-endian archive > +>4 string __.SYMDEF random library > + > +# > +# From "pdp" (but why a 4-byte quantity?) > +# > +0lelong 0x39bed PDP-11 old archive > +0lelong 0x39bee PDP-11 4.0 archive > + > +# > +# XXX - what flavor of APL used this, and was it a variant of > +# some ar archive format? It's similar to, but not the same > +# as, the APL workspace magic numbers in pdp. > +# > +0long0100554 apl workspace > + > +# > +# System V Release 1 portable(?) archive format. > +# > +0string = System V Release 1 ar archive > +!:mime application/x-archive > + > +# > +# Debian package; it's in the portable archive format, and needs to go > +# before the entry for regular portable archives, as it's recognized as > +# a portable archive whose first member has a name beginning with > +# "debian". > # > 0string =!\ndebian > -!:mime application/x-debian-package > >8 string debian-splitpart of multipart Debian package > +!:mime application/vnd.debian.binary-package > >8 string debian-binary Debian binary package > +!:mime application/vnd.debian.binary-package > >8 string !debian > >68 string >\0 (format %s) > # These next two lines do not work, because a bzip2 Debian archive > @@ -49,18 +108,14 @@ > #>84 string gz \b, uses gzip compression > #>136ledate x created: %s > > -# other archives > -0long0177555 very old archive > -0short 0177555 very old PDP-11 archive > -0long0177545 old archive > -0short 0177545 old PDP-11 archive > -0long0100554 apl workspace > -0string = arch
Re: arm/fdt: map fdt and use given memory/bootargs
On Fri, Mar 04, 2016 at 08:08:36PM +0100, Patrick Wildt wrote: > On Fri, Mar 04, 2016 at 09:38:18AM -0500, Brandon Mercer wrote: > > On Fri, Mar 04, 2016 at 03:15:23PM +0100, Patrick Wildt wrote: > > > Hi, > > > > > > this diff makes armv7 map the FDT, if available, and uses it to read > > > information about the machine's available memory and bootargs. > > > > > > I'd like to get some opinions about the way I have implemented some > > > stuff. For instance, I need the size of the FDT so I can properly > > > copy it. Does it make sense to implement fdt_get_size()? Is there > > > another, preferred way? > > > > > > Additionally, reading memory information, like where a node is mapped, > > > is a bit more complicated than just reading two values. Especially if > > > there are translation ranges on a node's parent. I also have working > > > code or that, but I skipped "ranges" to not bloat the diff any further. > > > > If memory serves me correctly we need ranges right out of the gate for > > the exynos boards I have, but those aren't important to anyone except > > for me so I'm ok with waiting a short while. > > Yes, I stumbled upon that on the raspberry pi. The default device tree > delivered by the raspberry pi foundation makes use of that. > > Excerpt: > > / { > #address-cells = <0x1>; > #size-cells = <0x1>; > interrupt-parent = <0x1>; > compatible = "brcm,bcm2710", "brcm,bcm2709"; > model = "Raspberry Pi 3 Model B"; > [...] > soc { > compatible = "simple-bus"; > #address-cells = <0x1>; > #size-cells = <0x1>; > ranges = <0x7e00 0x3f00 0x100>; > [...] > interrupt-controller@7e00b200 { > compatible = "brcm,bcm2708-armctrl-ic"; > reg = <0x7e00b200 0x200>; > interrupt-controller; > #interrupt-cells = <0x2>; > linux,phandle = <0x1>; > phandle = <0x1>; > }; Yes, this is needed as well. However I was commenting on reserved memory regions. I don't want to see this turn into a bikeshed session so I suggest we start with the initial diff, and add these additional features soon after. > diff --git sys/dev/ofw/fdt.c sys/dev/ofw/fdt.c > index 18f6077..0993c92 100644 > --- sys/dev/ofw/fdt.c > +++ sys/dev/ofw/fdt.c > @@ -33,6 +33,7 @@ void*skip_node_name(u_int32_t *); > void *fdt_parent_node_recurse(void *, void *); > int fdt_node_property_int(void *, char *, int *); > int fdt_node_property_ints(void *, char *, int *, int); > +int fdt_translate_memory_address(void *, struct fdt_memory *); > #ifdef DEBUG > void fdt_print_node_recurse(void *, int); > #endif > @@ -361,10 +362,94 @@ fdt_parent_node(void *node) > if (!tree_inited) > return NULL; > > + if (node == pnode) > + return NULL; > + > return fdt_parent_node_recurse(pnode, node); > } > > /* > + * Translate memory address depending on parent's range. > + */ > +int > +fdt_translate_memory_address(void *node, struct fdt_memory *mem) > +{ > + void *parent; > + int pac, psc, ac, sc, ret, rlen, rone, *range; > + uint64_t from, to, size; > + > + if (node == NULL || mem == NULL) > + return 1; > + > + parent = fdt_parent_node(node); > + if (parent == NULL) > + return 0; > + > + /* Empty ranges, 1:1 mapping. No ranges, translation barrier. */ > + rlen = fdt_node_property(node, "ranges", (char **)&range) / sizeof(int); > + if (range == NULL) > + return 0; > + if (rlen <= 0) > + return fdt_translate_memory_address(parent, mem); > + > + /* We only support 32-bit (1), and 64-bit (2) wide addresses here. */ > + ret = fdt_node_property_int(parent, "#address-cells", &pac); > + if (ret != 1 || pac <= 0 || pac > 2) > + return 1; > + > + /* We only support 32-bit (1), and 64-bit (2) wide sizes here. */ > + ret = fdt_node_property_int(parent, "#size-cells", &psc); > + if (ret != 1 || psc <= 0 || psc > 2) > + return 1; > + > + /* We only support 32-bit (1), and 64-bit (2) wide addresses here. */ > + ret = fdt_node_property_int(node, "#address-cells", &ac); > + if (ret <= 0) > + ac = pac; > + else if (ret > 1 || ac <= 0 || ac > 2) > + return 1; > + > + /* We only support 32-bit (1), and 64-bit (2) wide sizes here. */ > + ret = fdt_node_property_int(node, "#size-cells", &sc); > + if (ret <= 0) > + sc = psc; > + else if (ret > 1 || sc <= 0 || sc > 2) > + return 1; > + > + /* Must have at least one range. */ > + rone = pac + ac + sc; > + if (rlen < rone) > + return 1; > + > + /* For each range. */ > + for (; rlen >= rone; rlen -= rone, range += rone) { > +
Re: arm/fdt: map fdt and use given memory/bootargs
On Fri, Mar 04, 2016 at 09:38:18AM -0500, Brandon Mercer wrote: > On Fri, Mar 04, 2016 at 03:15:23PM +0100, Patrick Wildt wrote: > > Hi, > > > > this diff makes armv7 map the FDT, if available, and uses it to read > > information about the machine's available memory and bootargs. > > > > I'd like to get some opinions about the way I have implemented some > > stuff. For instance, I need the size of the FDT so I can properly > > copy it. Does it make sense to implement fdt_get_size()? Is there > > another, preferred way? > > > > Additionally, reading memory information, like where a node is mapped, > > is a bit more complicated than just reading two values. Especially if > > there are translation ranges on a node's parent. I also have working > > code or that, but I skipped "ranges" to not bloat the diff any further. > > If memory serves me correctly we need ranges right out of the gate for > the exynos boards I have, but those aren't important to anyone except > for me so I'm ok with waiting a short while. Yes, I stumbled upon that on the raspberry pi. The default device tree delivered by the raspberry pi foundation makes use of that. Excerpt: / { #address-cells = <0x1>; #size-cells = <0x1>; interrupt-parent = <0x1>; compatible = "brcm,bcm2710", "brcm,bcm2709"; model = "Raspberry Pi 3 Model B"; [...] soc { compatible = "simple-bus"; #address-cells = <0x1>; #size-cells = <0x1>; ranges = <0x7e00 0x3f00 0x100>; [...] interrupt-controller@7e00b200 { compatible = "brcm,bcm2708-armctrl-ic"; reg = <0x7e00b200 0x200>; interrupt-controller; #interrupt-cells = <0x2>; linux,phandle = <0x1>; phandle = <0x1>; }; So basically the interrupt-controller node says it's at 0x7e00b200, but you need to translate that address using the parent's ranges array to find out that the actual address is 0x3f00b200. If that had another parent with a range, it would have to be translated another time. diff --git sys/dev/ofw/fdt.c sys/dev/ofw/fdt.c index 18f6077..0993c92 100644 --- sys/dev/ofw/fdt.c +++ sys/dev/ofw/fdt.c @@ -33,6 +33,7 @@ void *skip_node_name(u_int32_t *); void *fdt_parent_node_recurse(void *, void *); int fdt_node_property_int(void *, char *, int *); int fdt_node_property_ints(void *, char *, int *, int); +int fdt_translate_memory_address(void *, struct fdt_memory *); #ifdef DEBUG voidfdt_print_node_recurse(void *, int); #endif @@ -361,10 +362,94 @@ fdt_parent_node(void *node) if (!tree_inited) return NULL; + if (node == pnode) + return NULL; + return fdt_parent_node_recurse(pnode, node); } /* + * Translate memory address depending on parent's range. + */ +int +fdt_translate_memory_address(void *node, struct fdt_memory *mem) +{ + void *parent; + int pac, psc, ac, sc, ret, rlen, rone, *range; + uint64_t from, to, size; + + if (node == NULL || mem == NULL) + return 1; + + parent = fdt_parent_node(node); + if (parent == NULL) + return 0; + + /* Empty ranges, 1:1 mapping. No ranges, translation barrier. */ + rlen = fdt_node_property(node, "ranges", (char **)&range) / sizeof(int); + if (range == NULL) + return 0; + if (rlen <= 0) + return fdt_translate_memory_address(parent, mem); + + /* We only support 32-bit (1), and 64-bit (2) wide addresses here. */ + ret = fdt_node_property_int(parent, "#address-cells", &pac); + if (ret != 1 || pac <= 0 || pac > 2) + return 1; + + /* We only support 32-bit (1), and 64-bit (2) wide sizes here. */ + ret = fdt_node_property_int(parent, "#size-cells", &psc); + if (ret != 1 || psc <= 0 || psc > 2) + return 1; + + /* We only support 32-bit (1), and 64-bit (2) wide addresses here. */ + ret = fdt_node_property_int(node, "#address-cells", &ac); + if (ret <= 0) + ac = pac; + else if (ret > 1 || ac <= 0 || ac > 2) + return 1; + + /* We only support 32-bit (1), and 64-bit (2) wide sizes here. */ + ret = fdt_node_property_int(node, "#size-cells", &sc); + if (ret <= 0) + sc = psc; + else if (ret > 1 || sc <= 0 || sc > 2) + return 1; + + /* Must have at least one range. */ + rone = pac + ac + sc; + if (rlen < rone) + return 1; + + /* For each range. */ + for (; rlen >= rone; rlen -= rone, range += rone) { + /* Extract from and size, so we can see if we fit. */ + from = betoh32(range[0]); + if (ac == 2) + from = (from << 32) +
Re: [file] file -i doesn't detect epub correctly
On 2016/03/04 19:50, Dmitrij D. Czarkoff wrote: > Jiri B said: > > file -i *.epub returns 'application/x-not-regular-file' or 'application/zip' > > and it should return 'application/epub+zip' (at least this is on Fedora). > > Below comes the patch that changes the way zip archives are treated in > magic file: Can you try just pulling across magdir/archive from the other "file"? Unless there is a special case I think it is better to keep in sync. e.g. Index: archive === RCS file: /cvs/src/usr.bin/file/magdir/archive,v retrieving revision 1.6 diff -u -p -r1.6 archive --- archive 24 Apr 2009 18:54:34 - 1.6 +++ archive 4 Mar 2016 19:00:39 - @@ -13,6 +13,11 @@ 257string ustar\040\040\0 GNU tar archive !:mime application/x-tar # encoding: gnu +# Incremental snapshot gnu-tar format from: +# http://www.gnu.org/software/tar/manual/html_node/Snapshot-Files.html +0 string GNU\ tar- GNU tar incremental snapshot data +>&0regex [0-9]\.[0-9]+-[0-9]+version %s + # cpio archives # # Yes, the top two "cpio archive" formats *are* supposed to just be "short". @@ -32,12 +37,66 @@ 0 string 070701 ASCII cpio archive (SVR4 with no CRC) 0 string 070702 ASCII cpio archive (SVR4 with CRC) -# Debian package (needs to go before regular portable archives) +# +# Various archive formats used by various versions of the "ar" +# command. +# + +# +# Original UNIX archive formats. +# They were written with binary values in host byte order, and +# the magic number was a host "int", which might have been 16 bits +# or 32 bits. We don't say "PDP-11" or "VAX", as there might have +# been ports to little-endian 16-bit-int or 32-bit-int platforms +# (x86?) using some of those formats; if none existed, feel free +# to use "PDP-11" for little-endian 16-bit and "VAX" for little-endian +# 32-bit. There might have been big-endian ports of that sort as +# well. +# +0 leshort 0177555 very old 16-bit-int little-endian archive +0 beshort 0177555 very old 16-bit-int big-endian archive +0 lelong 0177555 very old 32-bit-int little-endian archive +0 belong 0177555 very old 32-bit-int big-endian archive + +0 leshort 0177545 old 16-bit-int little-endian archive +>2 string __.SYMDEF random library +0 beshort 0177545 old 16-bit-int big-endian archive +>2 string __.SYMDEF random library +0 lelong 0177545 old 32-bit-int little-endian archive +>4 string __.SYMDEF random library +0 belong 0177545 old 32-bit-int big-endian archive +>4 string __.SYMDEF random library + +# +# From "pdp" (but why a 4-byte quantity?) +# +0 lelong 0x39bed PDP-11 old archive +0 lelong 0x39bee PDP-11 4.0 archive + +# +# XXX - what flavor of APL used this, and was it a variant of +# some ar archive format? It's similar to, but not the same +# as, the APL workspace magic numbers in pdp. +# +0 long0100554 apl workspace + +# +# System V Release 1 portable(?) archive format. +# +0 string = System V Release 1 ar archive +!:mime application/x-archive + +# +# Debian package; it's in the portable archive format, and needs to go +# before the entry for regular portable archives, as it's recognized as +# a portable archive whose first member has a name beginning with +# "debian". # 0 string =!\ndebian -!:mime application/x-debian-package >8 string debian-splitpart of multipart Debian package +!:mime application/vnd.debian.binary-package >8 string debian-binary Debian binary package +!:mime application/vnd.debian.binary-package >8 string !debian >68string >\0 (format %s) # These next two lines do not work, because a bzip2 Debian archive @@ -49,18 +108,14 @@ #>84 string gz \b, uses gzip compression #>136 ledate x created: %s -# other archives -0 long0177555 very old archive -0 short 0177555 very old PDP-11 archive -0 long0177545 old archive -0 short 0177545 old PDP-11 archive -0 long0100554 apl workspace -0 string = archive -!:mime application/x-archive - -# MIPS archive (needs to go before regular portable archives) +# +# MIPS archive; they're in the portable archive format, and need to go +# before the entry for regular portable archives, as it's recognized as +# a portable archive whose first member has a name beginning with +# "__E". # 0 string =!\n__E MIPS arch
Re: [file] file -i doesn't detect epub correctly
Jiri B said: > file -i *.epub returns 'application/x-not-regular-file' or 'application/zip' > and it should return 'application/epub+zip' (at least this is on Fedora). Below comes the patch that changes the way zip archives are treated in magic file: 1. Immediately write "Zip archive data" for all zip files. 2. If zip file does not contain extra attributes and starts with file "mimetype", whose content begins with the word "application", treat it as container format - add document type name. 3. Otherwise detect zip version required to open the file and note it. #2 breaks backward compatibility in several ways: * previously "mimetype" test only considered zip 2.0 archives, although at least OpenDocument standard permits any. * output for ODT and friends changed from "" to "Zip archive data: ". * if you run file(1) on an archive that you make by decompressing and recompressing ODT file, the type would be "Zip archive data, at least v1.0 to extract" instead of just "data". Comments? OKs? P.S.: While doing this I noticed that under some circumstances file gets tricked into discarding all matches and falling back to 'application/x-not-regular-file', as Jiri B notes above. This looks like a bug. P.P.S.: it looks like magic format could benefit from something like python's "finally". Do we want to maintain compatibility with other magic file parsers? -- Dmitrij D. Czarkoff Index: magdir/archive === RCS file: /cvs/src/usr.bin/file/magdir/archive,v retrieving revision 1.6 diff -u -p -r1.6 archive --- magdir/archive 24 Apr 2009 18:54:34 - 1.6 +++ magdir/archive 4 Mar 2016 18:20:07 - @@ -563,75 +563,78 @@ 0 string UC2\x1a UC2 archive data # ZIP archives (Greg Roelofs, c/o zip-b...@wkuvx1.wku.edu) -0 string PK\003\004 ->4 byte0x00Zip archive data -!:mime application/zip ->4 byte0x09Zip archive data, at least v0.9 to extract -!:mime application/zip ->4 byte0x0aZip archive data, at least v1.0 to extract -!:mime application/zip ->4 byte0x0bZip archive data, at least v1.1 to extract -!:mime application/zip ->0x161 string WINZIP Zip archive data, WinZIP self-extracting -!:mime application/zip ->4 byte0x14 ->>30 ubelong !0x6d696d65 Zip archive data, at least v2.0 to extract +0 string PK\003\004 Zip archive data !:mime application/zip # OpenOffice.org / KOffice / StarOffice documents # From: Abel Cheung # Listed here because they are basically zip files ->>30 string mimetype +>30string mimetypeapplication # KOffice (1.2 or above) formats ->>>50 string vnd.kde.KOffice (>=1.2) -58 string karbon Karbon document -58 string kchart KChart document -58 string kformulaKFormula document -58 string kivio Kivio document -58 string kontour Kontour document -58 string kpresenter KPresenter document -58 string kspread KSpread document -58 string kword KWord document +>>50 string vnd.kde.\b, KOffice (>=1.2) +>>>58 string karbon Karbon document +>>>58 string kchart KChart document +>>>58 string kformulaKFormula document +>>>58 string kivio Kivio document +>>>58 string kontour Kontour document +>>>58 string kpresenter KPresenter document +>>>58 string kspread KSpread document +>>>58 string kword KWord document # OpenOffice formats (for OpenOffice 1.x / StarOffice 6/7) ->>>50 string vnd.sun.xml.OpenOffice.org 1.x -62 string writer Writer ->68byte!0x2e document ->68string .template template ->68string .global global document -62 string calcCalc ->66byte!0x2e spreadsheet ->66string .template template -62 string drawDraw ->66byte!0x2e document ->66string .template template -62 string impress Impress ->69byte!0x2e presentation ->69string .template template -62 string mathMath document +>>50 string vnd.sun.xml.\b, OpenOffice.org 1.x +>>>62 string writer Writer +68 byte!0x2e document +68 string .template template +68 string .global
Re: [ksh] [patch] Make command -v and command -p[vV] POSIX compliant
Todd C. Miller schreef op 04-03-16 om 19:22: > This also looks fine but we should add a similar regress for whence's > -p and -v flags. Some minor updates to the man page are also needed. I'll make a new patch. - M.
Re: [ksh] [patch] Make "$@" and "$*" POSIX-compliant with 'set -u'
Martijn Dekker schreef op 04-03-16 om 16:21: > I've also attached a simple regression test. I didn't know what existing > .t file that would fit in, so I made a new one. Perhaps it should be added to obsd-regress.t -- it seems to have all the miscellaneous tests added for OpenBSD. - M.
Re: [ksh] [patch] Make command -v and command -p[vV] POSIX compliant
On Fri, 04 Mar 2016 18:05:39 +0100, Martijn Dekker wrote: > This simple patch makes the 'command' builtin POSIX-compliant and > consistent with other current shells. It fixes two things: > >a) 'command -v' does not find shell reserved words (a.k.a. keywords). > For instance, 'command -v select' outputs nothing but should output > 'select'. > >b) 'command -pv' always outputs the path of an external command, even > if 'command -p' would execute a builtin. For instance, 'command -p kill' > executes the 'kill' builtin, as expected, but 'command -pv kill' outputs > '/bin/kill'. The '-v' option is supposed to reflect what would actually > be executed, so 'command -pv kill' should output 'kill'. The -p option > sets the PATH to a default system value before doing the search, but > that has no bearing on the fact that builtins take precedence over > external commands. > > The patch fixes both issues for 'command' without affecting the > behaviour of the ksh-specific builtin 'whence', which is handled by the > same C function. This also looks fine but we should add a similar regress for whence's -p and -v flags. - todd
Re: [ksh] [patch] Make "$@" and "$*" POSIX-compliant with 'set -u'
On Fri, 04 Mar 2016 16:21:37 +0100, Martijn Dekker wrote: > Here is another patch related to "$@" and "$*". It makes their behaviour > in combination with 'set -u' (set -o nounset) POSIX-compliant and > consistent with other current shells. > > As of 2009, POSIX mandates that the special parameters "$@" and "$*" be > exempt from 'set -u' checking. The reason is that it should be possible > to pass on an empty set of positional parameters even when expansions of > unset variables are disallowed. ksh currently does not do this, making > 'set -u' less useful. > > I've also attached a simple regression test. I didn't know what existing > .t file that would fit in, so I made a new one. This looks good to me. - todd
sys_process.c: remove relebad
relebad used to have more body: relebad: PRELE(t); return (error); But then PRELE(t); was removed. This diff gets rid of what remains of relebad. Index: sys/kern/sys_process.c === RCS file: /cvs/src/sys/kern/sys_process.c,v retrieving revision 1.68 diff -u -p -r1.68 sys_process.c --- sys/kern/sys_process.c 24 Sep 2015 20:35:18 - 1.68 +++ sys/kern/sys_process.c 4 Mar 2016 17:51:14 - @@ -454,7 +454,7 @@ sys_ptrace(struct proc *p, void *v, regi /* If the address parameter is not (int *)1, set the pc. */ if ((int *)SCARG(uap, addr) != (int *)1) if ((error = process_set_pc(t, SCARG(uap, addr))) != 0) - goto relebad; + return (error); #ifdef PT_STEP /* @@ -462,7 +462,7 @@ sys_ptrace(struct proc *p, void *v, regi */ error = process_sstep(t, req == PT_STEP); if (error) - goto relebad; + return (error); #endif goto sendsig; @@ -492,7 +492,7 @@ sys_ptrace(struct proc *p, void *v, regi */ error = process_sstep(t, 0); if (error) - goto relebad; + return (error); #endif /* give process back to original parent or init */ @@ -522,9 +522,6 @@ sys_ptrace(struct proc *p, void *v, regi } return (0); - - relebad: - return (error); case PT_KILL: if (SCARG(uap, pid) < THREAD_PID_OFFSET && tr->ps_single) -- Michal Mazurek
Re: landisk: match function declaration
On 2016-03-04, Tobias Ulmer wrote: > Match function declaration, use void Yes, please. There is quite a bit of this in the MD parts of the tree. Since you are already in sh... $ grep -R '^[A-Za-z0-9_]*()' . ./dev/scif.c:scif_intr_init() ./sh/cache.c:sh_cache_init() ./sh/cache.c:sh_cache_information() ./sh/cache.c:__cache_flush() ./sh/cache_sh3.c:sh3_cache_config() ./sh/cache_sh3.c:sh3_cache_wbinv_all() ./sh/clock.c:sh_clock_get_cpuclock() ./sh/clock.c:sh_clock_get_pclock() ./sh/clock.c:cpu_initclocks() ./sh/clock.c:resettodr() ./sh/db_interface.c:Debugger() ./sh/devreg.c:sh_devreg_init() ./sh/mmu_sh3.c:sh3_mmu_start() ./sh/mmu_sh3.c:sh3_tlb_invalidate_all() ./sh/mmu_sh4.c:__sh4_itlb_invalidate_all() ./sh/mmu_sh4.c:sh4_mmu_start() ./sh/mmu_sh4.c:sh4_tlb_invalidate_all() ./sh/pmap.c:pmap_bootstrap() ./sh/pmap.c:pmap_init() ./sh/pmap.c:pmap_create() ./sh/pmap.c:__pmap_asid_alloc() ./sh/sh_machdep.c:sh_proc0_init() ./sh/sh_machdep.c:sh_startup() ./sh/sh_machdep.c:dumpsys() ./sh/sh_machdep.c:cpu_reset() -- Christian "naddy" Weisgerber na...@mips.inka.de
[ksh] [patch] Make "$@" and "$*" POSIX-compliant with 'set -u'
Here is another patch related to "$@" and "$*". It makes their behaviour in combination with 'set -u' (set -o nounset) POSIX-compliant and consistent with other current shells. As of 2009, POSIX mandates that the special parameters "$@" and "$*" be exempt from 'set -u' checking. The reason is that it should be possible to pass on an empty set of positional parameters even when expansions of unset variables are disallowed. ksh currently does not do this, making 'set -u' less useful. I've also attached a simple regression test. I didn't know what existing .t file that would fit in, so I made a new one. Thanks, - M. References: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_25_03 "When the shell tries to expand an unset parameter other than the '@' and '*' special parameters, it shall write a message to standard error and shall not execute the command containing the expansion [...]" #tag_18_25_18 "Historically, some shells applied the -u option to all parameters including $@ and $*. The standard developers felt that this was a misfeature since it is normal and common for $@ and $* to be used in shell scripts regardless of whether they were passed any arguments. Treating these uses as an error when no arguments are passed reduces the value of -u for its intended purpose of finding spelling mistakes in variable names and uses of unset positional parameters." Index: bin/ksh/eval.c === RCS file: /cvs/src/bin/ksh/eval.c,v retrieving revision 1.49 diff -u -p -r1.49 eval.c --- bin/ksh/eval.c 30 Dec 2015 09:07:00 - 1.49 +++ bin/ksh/eval.c 4 Mar 2016 04:44:31 - @@ -707,6 +707,7 @@ varsub(Expand *xp, char *sp, char *word, int slen; char *p; struct tbl *vp; + int zero_ok = 0; if (sp[0] == '\0') /* Bad variable name */ return -1; @@ -715,8 +716,6 @@ varsub(Expand *xp, char *sp, char *word, /* ${#var}, string length or array size */ if (sp[0] == '#' && (c = sp[1]) != '\0') { - int zero_ok = 0; - /* Can't have any modifiers for ${#...} */ if (*word != CSUBST) return -1; @@ -789,6 +788,7 @@ varsub(Expand *xp, char *sp, char *word, xp->split = c == '@'; /* $@ */ state = XARG; } + zero_ok = 1; /* exempt "$@" and "$*" from 'set -u' */ } else { if ((p=strchr(sp,'[')) && (p[1]=='*'||p[1]=='@') && p[2]==']') { XPtrV wv; @@ -835,7 +835,7 @@ varsub(Expand *xp, char *sp, char *word, (((stype&0x80) ? *xp->str=='\0' : xp->str==null) ? /* undef? */ c == '=' || c == '-' || c == '?' : c == '+')) state = XBASE; /* expand word instead of variable value */ - if (Flag(FNOUNSET) && xp->str == null && + if (Flag(FNOUNSET) && xp->str == null && !zero_ok && (ctype(c, C_SUBOP2) || (state != XBASE && c != '+'))) errorf("%s: parameter not set", sp); return state; name: shellopt-u-1 description: Check that "$@" and "$*" are exempt from 'set -u' (nounset) stdin: set -u : "$@$*$1" expected-exit: e == 1 expected-stderr-pattern: /: 1: parameter not set$/ ---
typo in magic.5
OK? -- Dmitrij D. Czarkoff Index: magic.5 === RCS file: /cvs/src/usr.bin/file/magic.5,v retrieving revision 1.14 diff -u -p -r1.14 magic.5 --- magic.5 15 Jul 2010 21:54:20 - 1.14 +++ magic.5 4 Mar 2016 15:13:06 - @@ -354,7 +354,7 @@ If a the test on a line at level .Em n succeeds, all following tests at level .Em n+1 -are performed, and the messages printed if the tests succeed, untile a line +are performed, and the messages printed if the tests succeed, until a line with level .Em n (or less) appears.
Re: arm/fdt: map fdt and use given memory/bootargs
On Fri, Mar 04, 2016 at 03:15:23PM +0100, Patrick Wildt wrote: > Hi, > > this diff makes armv7 map the FDT, if available, and uses it to read > information about the machine's available memory and bootargs. > > I'd like to get some opinions about the way I have implemented some > stuff. For instance, I need the size of the FDT so I can properly > copy it. Does it make sense to implement fdt_get_size()? Is there > another, preferred way? > > Additionally, reading memory information, like where a node is mapped, > is a bit more complicated than just reading two values. Especially if > there are translation ranges on a node's parent. I also have working > code or that, but I skipped "ranges" to not bloat the diff any further. If memory serves me correctly we need ranges right out of the gate for the exynos boards I have, but those aren't important to anyone except for me so I'm ok with waiting a short while. > > I would like to extend the fdt_* API and add helpers to the code, so > that it's easier to use the device tree. Is this the correct way? > Should I rather implement some OF_* API? My initial thought is that it makes sense to extend fdt for this. I have not tested this diff, but I like the direction that this is going. Cheers, bmercer > > Patrick > > diff --git sys/arch/armv7/armv7/armv7_machdep.c > sys/arch/armv7/armv7/armv7_machdep.c > index 11bea90..0a067c2 100644 > --- sys/arch/armv7/armv7/armv7_machdep.c > +++ sys/arch/armv7/armv7/armv7_machdep.c > @@ -130,6 +130,7 @@ > #include > > #include > +#include > > #include > > @@ -387,8 +388,10 @@ initarm(void *arg0, void *arg1, void *arg2) > int loop, loop1, i, physsegs; > u_int l1pagetable; > pv_addr_t kernel_l1pt; > + pv_addr_t fdt; > paddr_t memstart; > psize_t memsize; > + void *config; > extern uint32_t esym; /* &_end if no symbols are loaded */ > > /* early bus_space_map support */ > @@ -423,6 +426,49 @@ initarm(void *arg0, void *arg1, void *arg2) > armv7_a4x_bs_tag.bs_map = bootstrap_bs_map; > tmp_bs_tag.bs_map = bootstrap_bs_map; > > + /* > + * Now, map the bootconfig/FDT area. > + * > + * As we don't know the size of a possible FDT, map the size of a > + * typical bootstrap bs map. The FDT might not be aligned, so this > + * might take up to two L1_S_SIZEd mappings. In the unlikely case > + * that the FDT is bigger than L1_S_SIZE (0x0010), we need to > + * remap it. > + * > + * XXX: There's (currently) no way to unmap a bootstrap mapping, so > + * we might lose a bit of the bootstrap address space. > + */ > + bootstrap_bs_map(NULL, (bus_addr_t)arg2, L1_S_SIZE, 0, > + (bus_space_handle_t *)&config); > + if (fdt_init(config) && fdt_get_size(config) != 0) { > + uint32_t size = fdt_get_size(config); > + if (size > L1_S_SIZE) > + bootstrap_bs_map(NULL, (bus_addr_t)arg2, size, 0, > + (bus_space_handle_t *)&config); > + } > + > + if (fdt_init(config) && fdt_get_size(config) != 0) { > + struct fdt_memory mem; > + void *node; > + > + node = fdt_find_node("/memory"); > + if (node == NULL || fdt_get_memory_address(node, 0, &mem)) > + panic("initarm: no memory specificed"); > + > + memstart = mem.addr; > + memsize = mem.size; > + physical_start = mem.addr; > + physical_end = MIN(mem.addr + mem.size, (paddr_t)-PAGE_SIZE); > + > + node = fdt_find_node("/chosen"); > + if (node != NULL) { > + char *bootargs; > + if (fdt_node_property(node, "bootargs", &bootargs)) > + process_kernel_args(bootargs); > + } > + } > + > + /* XXX: Use FDT information. */ > platform_init(); > platform_disable_l2_if_needed(); > > @@ -433,41 +479,36 @@ initarm(void *arg0, void *arg1, void *arg2) > printf("\n%s booting ...\n", platform_boot_name()); > > printf("arg0 %p arg1 %p arg2 %p\n", arg0, arg1, arg2); > - parse_uboot_tags(arg2); > > - /* > - * Examine the boot args string for options we need to know about > - * now. > - */ > - process_kernel_args(bootconfig.bootstring); > + if (fdt_get_size(config) == 0) { > + parse_uboot_tags(config); > + > + /* > + * Examine the boot args string for options we need to know > about > + * now. > + */ > + process_kernel_args(bootconfig.bootstring); > + > + /* normally u-boot will set up bootconfig.dramblocks */ > + bootconfig_dram(&bootconfig, &memstart, &memsize); > + > + /* > + * Set up the variables that define the availablilty of > + * physical memory. > + * > +
Re: arm: support Allwinner A20 Ethernet
> On Fri, Mar 04, 2016 at 11:19:37AM -0300, Daniel Bolgheroni wrote: > > On Sat, Feb 27, 2016 at 11:09:10PM +0100, Patrick Wildt wrote: > > > > > > + /* print interrupt state */ > > > + snprintb(buf, sizeof(buf), "\177\20" > > > + "b\x10""NI\0" ... > > I don't have a quick solution for this too, but it's worth noticing that > > snprintb() is NetBSD-specific. ... > That's correct. So far it's in an ifdef DEBUG. I could've just removed > all that code but thought it was better to keep it in for now. Like every BSD since 4.1, the kernel printf functions support %b, and we never went down the road of adding a different function just to please a compiler that whines.
Re: arm: support Allwinner A20 Ethernet
On Fri, Mar 04, 2016 at 11:19:37AM -0300, Daniel Bolgheroni wrote: > On Sat, Feb 27, 2016 at 11:09:10PM +0100, Patrick Wildt wrote: > > > > + /* print interrupt state */ > > + snprintb(buf, sizeof(buf), "\177\20" > > + "b\x10""NI\0" > > + "b\x0f""AI\0" > > + "b\x0e""ER\0" > > + "b\x0d""FB\0" > > + "b\x0a""ET\0" > > + "b\x09""RW\0" > > + "b\x08""RS\0" > > + "b\x07""RU\0" > > + "b\x06""RI\0" > > + "b\x05""UN\0" > > + "b\x04""OV\0" > > + "b\x03""TJ\0" > > + "b\x02""TU\0" > > + "b\x01""TS\0" > > + "b\x00""TI\0" > > + "\0", dma_status); > > > + /* print filter setup */ > > + snprintb(buf, sizeof(buf), "\177\20" > > + "b\x1f""RA\0" > > + "b\x0a""HPF\0" > > + "b\x09""SAF\0" > > + "b\x08""SAIF\0" > > + "b\x05""DBF\0" > > + "b\x04""PM\0" > > + "b\x03""DAIF\0" > > + "b\x02""HMC\0" > > + "b\x01""HUC\0" > > + "b\x00""PR\0" > > + "\0", ffilt); > > Hi Patrick, > > I don't have a quick solution for this too, but it's worth noticing that > snprintb() is NetBSD-specific. > > Thank you. > > -- > db That's correct. So far it's in an ifdef DEBUG. I could've just removed all that code but thought it was better to keep it in for now.
Re: arm: support Allwinner A20 Ethernet
On Sat, Feb 27, 2016 at 11:09:10PM +0100, Patrick Wildt wrote: > > + /* print interrupt state */ > + snprintb(buf, sizeof(buf), "\177\20" > + "b\x10""NI\0" > + "b\x0f""AI\0" > + "b\x0e""ER\0" > + "b\x0d""FB\0" > + "b\x0a""ET\0" > + "b\x09""RW\0" > + "b\x08""RS\0" > + "b\x07""RU\0" > + "b\x06""RI\0" > + "b\x05""UN\0" > + "b\x04""OV\0" > + "b\x03""TJ\0" > + "b\x02""TU\0" > + "b\x01""TS\0" > + "b\x00""TI\0" > + "\0", dma_status); > + /* print filter setup */ > + snprintb(buf, sizeof(buf), "\177\20" > + "b\x1f""RA\0" > + "b\x0a""HPF\0" > + "b\x09""SAF\0" > + "b\x08""SAIF\0" > + "b\x05""DBF\0" > + "b\x04""PM\0" > + "b\x03""DAIF\0" > + "b\x02""HMC\0" > + "b\x01""HUC\0" > + "b\x00""PR\0" > + "\0", ffilt); Hi Patrick, I don't have a quick solution for this too, but it's worth noticing that snprintb() is NetBSD-specific. Thank you. -- db
arm/fdt: map fdt and use given memory/bootargs
Hi, this diff makes armv7 map the FDT, if available, and uses it to read information about the machine's available memory and bootargs. I'd like to get some opinions about the way I have implemented some stuff. For instance, I need the size of the FDT so I can properly copy it. Does it make sense to implement fdt_get_size()? Is there another, preferred way? Additionally, reading memory information, like where a node is mapped, is a bit more complicated than just reading two values. Especially if there are translation ranges on a node's parent. I also have working code or that, but I skipped "ranges" to not bloat the diff any further. I would like to extend the fdt_* API and add helpers to the code, so that it's easier to use the device tree. Is this the correct way? Should I rather implement some OF_* API? Patrick diff --git sys/arch/armv7/armv7/armv7_machdep.c sys/arch/armv7/armv7/armv7_machdep.c index 11bea90..0a067c2 100644 --- sys/arch/armv7/armv7/armv7_machdep.c +++ sys/arch/armv7/armv7/armv7_machdep.c @@ -130,6 +130,7 @@ #include #include +#include #include @@ -387,8 +388,10 @@ initarm(void *arg0, void *arg1, void *arg2) int loop, loop1, i, physsegs; u_int l1pagetable; pv_addr_t kernel_l1pt; + pv_addr_t fdt; paddr_t memstart; psize_t memsize; + void *config; extern uint32_t esym; /* &_end if no symbols are loaded */ /* early bus_space_map support */ @@ -423,6 +426,49 @@ initarm(void *arg0, void *arg1, void *arg2) armv7_a4x_bs_tag.bs_map = bootstrap_bs_map; tmp_bs_tag.bs_map = bootstrap_bs_map; + /* +* Now, map the bootconfig/FDT area. +* +* As we don't know the size of a possible FDT, map the size of a +* typical bootstrap bs map. The FDT might not be aligned, so this +* might take up to two L1_S_SIZEd mappings. In the unlikely case +* that the FDT is bigger than L1_S_SIZE (0x0010), we need to +* remap it. +* +* XXX: There's (currently) no way to unmap a bootstrap mapping, so +* we might lose a bit of the bootstrap address space. +*/ + bootstrap_bs_map(NULL, (bus_addr_t)arg2, L1_S_SIZE, 0, + (bus_space_handle_t *)&config); + if (fdt_init(config) && fdt_get_size(config) != 0) { + uint32_t size = fdt_get_size(config); + if (size > L1_S_SIZE) + bootstrap_bs_map(NULL, (bus_addr_t)arg2, size, 0, + (bus_space_handle_t *)&config); + } + + if (fdt_init(config) && fdt_get_size(config) != 0) { + struct fdt_memory mem; + void *node; + + node = fdt_find_node("/memory"); + if (node == NULL || fdt_get_memory_address(node, 0, &mem)) + panic("initarm: no memory specificed"); + + memstart = mem.addr; + memsize = mem.size; + physical_start = mem.addr; + physical_end = MIN(mem.addr + mem.size, (paddr_t)-PAGE_SIZE); + + node = fdt_find_node("/chosen"); + if (node != NULL) { + char *bootargs; + if (fdt_node_property(node, "bootargs", &bootargs)) + process_kernel_args(bootargs); + } + } + + /* XXX: Use FDT information. */ platform_init(); platform_disable_l2_if_needed(); @@ -433,41 +479,36 @@ initarm(void *arg0, void *arg1, void *arg2) printf("\n%s booting ...\n", platform_boot_name()); printf("arg0 %p arg1 %p arg2 %p\n", arg0, arg1, arg2); - parse_uboot_tags(arg2); - /* -* Examine the boot args string for options we need to know about -* now. -*/ - process_kernel_args(bootconfig.bootstring); + if (fdt_get_size(config) == 0) { + parse_uboot_tags(config); + + /* +* Examine the boot args string for options we need to know about +* now. +*/ + process_kernel_args(bootconfig.bootstring); + + /* normally u-boot will set up bootconfig.dramblocks */ + bootconfig_dram(&bootconfig, &memstart, &memsize); + + /* +* Set up the variables that define the availablilty of +* physical memory. +* +* XXX pmap_bootstrap() needs an enema. +*/ + physical_start = bootconfig.dram[0].address; + physical_end = MIN((uint64_t)physical_start + + (bootconfig.dram[0].pages * PAGE_SIZE), (paddr_t)-PAGE_SIZE); + } + #ifdef RAMDISK_HOOKS -boothowto |= RB_DFLTROOT; + boothowto |= RB_DFLTROOT; #endif /* RAMDISK_HOOKS */ - /* normally u-boot will set up bootconfig.dramblocks */ - bootconfig_dram(&bootconfig, &
proc.h: fix comment
After looking at dowait4() I believe this is a typo. Change space to a tab while here. Index: sys/sys/proc.h === RCS file: /cvs/src/sys/sys/proc.h,v retrieving revision 1.213 diff -u -p -r1.213 proc.h --- sys/sys/proc.h 6 Dec 2015 17:50:21 - 1.213 +++ sys/sys/proc.h 4 Mar 2016 13:57:54 - @@ -245,7 +245,7 @@ struct process { #definePS_ISPWAIT 0x0080 /* Is parent of PPWAIT child. */ #definePS_PROFIL 0x0100 /* Has started profiling. */ #definePS_TRACED 0x0200 /* Being ptraced. */ -#definePS_WAITED 0x0400 /* Stopped proc has waited for. */ +#definePS_WAITED 0x0400 /* Stopped proc was waited for. */ #definePS_COREDUMP 0x0800 /* Busy coredumping */ #definePS_SINGLEEXIT 0x1000 /* Other threads must die. */ #definePS_SINGLEUNWIND 0x2000 /* Other threads must unwind. */ @@ -255,7 +255,7 @@ struct process { #definePS_EMBRYO 0x0002 /* New process, not yet fledged */ #definePS_ZOMBIE 0x0004 /* Dead and ready to be waited for */ #definePS_NOBROADCASTKILL 0x0008 /* Process excluded from kill -1. */ -#define PS_PLEDGE 0x0010 /* Has called pledge(2) */ +#definePS_PLEDGE 0x0010 /* Has called pledge(2) */ #definePS_BITS \ ("\20" "\01CONTROLT" "\02EXEC" "\03INEXEC" "\04EXITING" "\05SUGID" \ -- Michal Mazurek
Re: KASSERT() @ pf_test() is back
Hello Stuart, thanks for testing it. I'll commit it today. regards sasha On Fri, Mar 04, 2016 at 01:08:42AM +, Stuart Henderson wrote: > On 2016/02/28 13:01, Martin Pieuchot wrote: > > On 08/02/16(Mon) 01:55, Alexandr Nedvedicky wrote: > > > Hello, > > > > > > I don't expect to see O.K. to patch below. > > > > > > The patch is the part of the change, which has been backed out last > > > weekend. > > > Too many things were wrong so I'm trying to untangle the code a bit. > > > > > > Patch below is for brave hearts, who don't mind to see KASSERT() to fire: > > > > Any progress with this diff? Now would be the good time to get it in. > > I'm running it on a pppoe router (v4/v6 plus ipsec), it hasn't exploded > yet. I'm in favour of putting it in to see what happens, it's a good time > in the cycle. >
kern_proc.c: fix comment
The argument was changed from 'proc *p' to 'process *pr' in 2010. Index: sys/kern/kern_proc.c === RCS file: /cvs/src/sys/kern/kern_proc.c,v retrieving revision 1.65 diff -u -p -r1.65 kern_proc.c --- sys/kern/kern_proc.c11 Sep 2015 08:27:39 - 1.65 +++ sys/kern/kern_proc.c4 Mar 2016 12:36:26 - @@ -150,7 +150,7 @@ chgproccnt(uid_t uid, int diff) } /* - * Is p an inferior of parent? + * Is pr an inferior of parent? */ int inferior(struct process *pr, struct process *parent) -- Michal Mazurek
Re: [ksh] [patch] Make "$@" POSIX-compliant with empty IFS
Martijn Dekker said: > So this patch makes quoted "$@" act according to the standard even when > IFS is empty. Quoted "$*" is unchanged. For the unspecified (not > standardised) cases of unquoted $@ and $*, this patch makes ksh act like > AT&T ksh93, bash, zsh and (d)ash, which seems safest from a > compatibility point of view. This makes sense to me, and changes seem reasonable. I've re-generated diff against -current. Anyone willing to OK it? -- Dmitrij D. Czarkoff Index: bin/ksh/eval.c === RCS file: /cvs/src/bin/ksh/eval.c,v retrieving revision 1.49 diff -u -p -r1.49 eval.c --- bin/ksh/eval.c 30 Dec 2015 09:07:00 - 1.49 +++ bin/ksh/eval.c 4 Mar 2016 09:39:07 - @@ -47,6 +47,8 @@ typedef struct Expand { #define IFS_WORD 0 /* word has chars (or quotes) */ #define IFS_WS 1 /* have seen IFS white-space */ #define IFS_NWS2 /* have seen IFS non-white-space */ +#define IFS_IWS3 /* beginning of word, ignore IFS white-space */ +#define IFS_QUOTE 4 /* beg.w/quote, becomes IFS_WORD unless "$@" */ static int varsub(Expand *, char *, char *, int *, int *); static int comsub(Expand *, char *); @@ -215,7 +217,17 @@ expand(char *cp, /* input word */ c = *sp++; break; case OQUOTE: - word = IFS_WORD; + switch (word) { + case IFS_QUOTE: + /* """something */ + word = IFS_WORD; + break; + case IFS_WORD: + break; + default: + word = IFS_QUOTE; + break; + } tilde_ok = 0; quote = 1; continue; @@ -295,6 +307,8 @@ expand(char *cp,/* input word */ if (f&DOBLANK) doblank++; tilde_ok = 0; + if (word == IFS_QUOTE && type != XNULLSUB) + word = IFS_WORD; if (type == XBASE) {/* expand? */ if (!st->next) { SubType *newst; @@ -356,6 +370,11 @@ expand(char *cp, /* input word */ f |= DOTEMP_; /* FALLTHROUGH */ default: + /* '-' '+' '?' */ + if (quote) + word = IFS_WORD; + else if (dp == Xstring(ds, dp)) + word = IFS_IWS; /* Enable tilde expansion */ tilde_ok = 1; f |= DOTILDE; @@ -385,10 +404,17 @@ expand(char *cp, /* input word */ */ x.str = trimsub(str_val(st->var), dp, st->stype); - if (x.str[0] != '\0' || st->quote) + if (x.str[0] != '\0') { + word = IFS_IWS; + type = XSUB; + } else if (quote) { + word = IFS_WORD; type = XSUB; - else + } else { + if (dp == Xstring(ds, dp)) + word = IFS_IWS; type = XNULLSUB; + } if (f&DOBLANK) doblank++; st = st->prev; @@ -420,6 +446,7 @@ expand(char *cp,/* input word */ if (f&DOBLANK) doblank++; st = st->prev; + word = quote || (!*x.str) ? IFS_WORD :
landisk: invalidate the entire cache on EMODE CPUs
SH4 CPUs with EMODE bit set have a cache twice as big. Fix the obvious copy&paste mistake. Didn't fix the problem I was looking at, but may help with general stability (I think all landisks use the EMODE capable SH7751R) My "good" landisk is happy with this. diff --git a/sys/arch/sh/sh/cache_sh4.c b/sys/arch/sh/sh/cache_sh4.c index 8c736a1..ea70312 100644 --- a/sys/arch/sh/sh/cache_sh4.c +++ b/sys/arch/sh/sh/cache_sh4.c @@ -403,7 +403,7 @@ void sh4_emode_icache_sync_all(void) { vaddr_t va = 0; - vaddr_t eva = SH4_ICACHE_SIZE; + vaddr_t eva = SH4_EMODE_ICACHE_SIZE; sh4_emode_dcache_wbinv_all(); @@ -443,7 +443,7 @@ void sh4_emode_dcache_wbinv_all(void) { vaddr_t va = 0; - vaddr_t eva = SH4_DCACHE_SIZE; + vaddr_t eva = SH4_EMODE_DCACHE_SIZE; while (va < eva) { cache_sh4_emode_op_8lines_32(va, SH4_CCDA, CCDA_ENTRY_MASK,
landisk: match function declaration
Match function declaration, use void --- a/sys/arch/sh/sh/mmu_sh3.c +++ b/sys/arch/sh/sh/mmu_sh3.c @@ -38,7 +38,7 @@ #include void -sh3_mmu_start() +sh3_mmu_start(void) { /* Zero clear all TLB entry */ sh3_tlb_invalidate_all(); @@ -89,7 +89,7 @@ sh3_tlb_invalidate_asid(int asid) } void -sh3_tlb_invalidate_all() +sh3_tlb_invalidate_all(void) { uint32_t aw, a; int e, w; diff --git a/sys/arch/sh/sh/mmu_sh4.c b/sys/arch/sh/sh/mmu_sh4.c index 4870d79..63a8cf4 100644 --- a/sys/arch/sh/sh/mmu_sh4.c +++ b/sys/arch/sh/sh/mmu_sh4.c @@ -42,7 +42,7 @@ static inline void __sh4_itlb_invalidate_all(void); static inline void -__sh4_itlb_invalidate_all() +__sh4_itlb_invalidate_all(void) { _reg_write_4(SH4_ITLB_AA, 0); _reg_write_4(SH4_ITLB_AA | (1 << SH4_ITLB_E_SHIFT), 0); @@ -51,7 +51,7 @@ __sh4_itlb_invalidate_all() } void -sh4_mmu_start() +sh4_mmu_start(void) { /* Zero clear all TLB entry */ _reg_write_4(SH4_MMUCR, 0); /* zero wired entry */ @@ -115,7 +115,7 @@ sh4_tlb_invalidate_asid(int asid) } void -sh4_tlb_invalidate_all() +sh4_tlb_invalidate_all(void) { uint32_t a; int e, eend, s;
landisk: bus_dma.c cleanup
Found while debugging cache problems on landisk Remove mapstore and error, remnants of code logic long gone. DMAMAP_RESET is only used on landisk, disrupts readability and the one line saved per use doesn't really justify its existence to me --- a/sys/arch/landisk/landisk/bus_dma.c +++ b/sys/arch/landisk/landisk/bus_dma.c @@ -67,11 +67,6 @@ struct _bus_dma_tag landisk_bus_dma = { ._dmamem_mmap = _bus_dmamem_mmap, }; -#define DMAMAP_RESET(_m) do { \ - (_m)->dm_mapsize = 0; \ - (_m)->dm_nsegs = 0; \ -} while (0) - int_bus_dmamap_load_vaddr(bus_dma_tag_t, bus_dmamap_t, void *, bus_size_t, pmap_t); int_bus_dmamap_load_paddr(bus_dma_tag_t, bus_dmamap_t, @@ -85,9 +80,7 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments, bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp) { bus_dmamap_t map; - void *mapstore; size_t mapsize; - int error; DPRINTF(("bus_dmamap_create: t = %p, size = %ld, nsegments = %d, maxsegsz = %ld, boundary = %ld, flags = %x\n", t, size, nsegments, maxsegsz, boundary, flags)); @@ -103,23 +96,21 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments, * The bus_dmamap_t includes one bus_dma_segment_t, hence * the (nsegments - 1). */ - error = 0; mapsize = sizeof(struct _bus_dmamap) + (sizeof(bus_dma_segment_t) * (nsegments - 1)); - if ((mapstore = malloc(mapsize, M_DEVBUF, (flags & BUS_DMA_NOWAIT) ? + if ((map = malloc(mapsize, M_DEVBUF, (flags & BUS_DMA_NOWAIT) ? (M_NOWAIT | M_ZERO) : (M_WAITOK | M_ZERO))) == NULL) return (ENOMEM); - DPRINTF(("bus_dmamap_create: dmamp = %p\n", mapstore)); + DPRINTF(("bus_dmamap_create: dmamp = %p\n", map)); - map = (bus_dmamap_t)mapstore; map->_dm_size = size; map->_dm_segcnt = nsegments; map->_dm_maxsegsz = maxsegsz; map->_dm_boundary = boundary; map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT); - - DMAMAP_RESET(map); /* no valid mappings */ + map->dm_mapsize = 0;/* no valid mappings */ + map->dm_nsegs = 0; *dmamp = map; @@ -245,7 +236,8 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, DPRINTF(("bus_dmamap_load: t = %p, map = %p, buf = %p, buflen = %ld, p = %p, flags = %x\n", t, map, buf, buflen, p, flags)); - DMAMAP_RESET(map); + map->dm_mapsize = 0; + map->dm_nsegs = 0; if (buflen > map->_dm_size) return (EINVAL); @@ -253,7 +245,8 @@ _bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, error = _bus_dmamap_load_vaddr(t, map, buf, buflen, p == NULL ? pmap_kernel() : p->p_vmspace->vm_map.pmap); if (error != 0) { - DMAMAP_RESET(map); /* no valid mappings */ + map->dm_mapsize = 0; /* no valid mappings */ + map->dm_nsegs = 0; return (error); } @@ -272,7 +265,8 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0, struct mbuf *m; int error; - DMAMAP_RESET(map); + map->dm_mapsize = 0; + map->dm_nsegs = 0; #ifdef DIAGNOSTIC if ((m0->m_flags & M_PKTHDR) == 0) @@ -289,7 +283,8 @@ _bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0, error = _bus_dmamap_load_vaddr(t, map, m->m_data, m->m_len, pmap_kernel()); if (error != 0) { - DMAMAP_RESET(map); + map->dm_mapsize = 0; + map->dm_nsegs = 0; return (error); } }