svn commit: r194587 - stable/7/bin/cp
Author: jilles Date: Sun Jun 21 15:36:10 2009 New Revision: 194587 URL: http://svn.freebsd.org/changeset/base/194587 Log: MFC r193086: Preserve file flags on symlinks in cp -Rp. This reported ENOSYS before. PR: bin/111226 (part of) Submitted by: Martin Kammerhofer Approved by: ed (mentor) (implicit) Modified: stable/7/bin/cp/ (props changed) stable/7/bin/cp/utils.c Modified: stable/7/bin/cp/utils.c == --- stable/7/bin/cp/utils.c Sun Jun 21 13:41:32 2009(r194586) +++ stable/7/bin/cp/utils.c Sun Jun 21 15:36:10 2009(r194587) @@ -339,7 +339,7 @@ setfile(struct stat *fs, int fd) if (!gotstat || fs-st_flags != ts.st_flags) if (fdval ? fchflags(fd, fs-st_flags) : - (islink ? (errno = ENOSYS) : + (islink ? lchflags(to.p_path, fs-st_flags) : chflags(to.p_path, fs-st_flags))) { warn(chflags: %s, to.p_path); rval = 1; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r194765 - head/bin/sh
Author: jilles Date: Tue Jun 23 20:45:12 2009 New Revision: 194765 URL: http://svn.freebsd.org/changeset/base/194765 Log: sh: Improve handling of setjmp/longjmp volatile: - remove ineffective and unnecessary (void) var; [1] - remove some unnecessary volatile keywords - add a necessary volatile keyword - save the old handler before doing something that could use the saved value Submitted by: Christoph Mallon [1] Approved by: ed (mentor) Modified: head/bin/sh/eval.c head/bin/sh/histedit.c head/bin/sh/parser.c head/bin/sh/var.c Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Tue Jun 23 20:38:35 2009(r194764) +++ head/bin/sh/eval.c Tue Jun 23 20:45:12 2009(r194765) @@ -589,22 +589,14 @@ evalcommand(union node *cmd, int flags, struct cmdentry cmdentry; struct job *jp; struct jmploc jmploc; - struct jmploc *volatile savehandler; - char *volatile savecmdname; - volatile struct shparam saveparam; - struct localvar *volatile savelocalvars; + struct jmploc *savehandler; + char *savecmdname; + struct shparam saveparam; + struct localvar *savelocalvars; volatile int e; char *lastarg; int realstatus; int do_clearcmdentry; -#ifdef __GNUC__ - /* Avoid longjmp clobbering */ - (void) argv; - (void) argc; - (void) lastarg; - (void) flags; - (void) do_clearcmdentry; -#endif /* First expand the arguments. */ TRACE((evalcommand(%p, %d) called\n, (void *)cmd, flags)); @@ -779,9 +771,10 @@ evalcommand(union node *cmd, int flags, savelocalvars = localvars; localvars = NULL; INTON; + savehandler = handler; if (setjmp(jmploc.loc)) { if (exception == EXSHELLPROC) - freeparam((struct shparam *)saveparam); + freeparam(saveparam); else { freeparam(shellparam); shellparam = saveparam; @@ -791,7 +784,6 @@ evalcommand(union node *cmd, int flags, handler = savehandler; longjmp(handler-loc, 1); } - savehandler = handler; handler = jmploc; for (sp = varlist.list ; sp ; sp = sp-next) mklocal(sp-text); @@ -830,12 +822,12 @@ evalcommand(union node *cmd, int flags, savecmdname = commandname; cmdenviron = varlist.list; e = -1; + savehandler = handler; if (setjmp(jmploc.loc)) { e = exception; exitstatus = (e == EXINT)? SIGINT+128 : 2; goto cmddone; } - savehandler = handler; handler = jmploc; redirect(cmd-ncmd.redirect, mode); if (cmdentry.special) Modified: head/bin/sh/histedit.c == --- head/bin/sh/histedit.c Tue Jun 23 20:38:35 2009(r194764) +++ head/bin/sh/histedit.c Tue Jun 23 20:45:12 2009(r194765) @@ -173,25 +173,11 @@ histcmd(int argc, char **argv) char *pat = NULL, *repl; static int active = 0; struct jmploc jmploc; - struct jmploc *volatile savehandler; - char editfile[PATH_MAX]; + struct jmploc *savehandler; + char editfilestr[PATH_MAX]; + char *volatile editfile; FILE *efp; int oldhistnum; -#ifdef __GNUC__ - /* Avoid longjmp clobbering */ - (void) editor; - (void) lflg; - (void) nflg; - (void) rflg; - (void) sflg; - (void) firststr; - (void) laststr; - (void) pat; - (void) repl; - (void) efp; - (void) argc; - (void) argv; -#endif if (hist == NULL) error(history not active); @@ -232,19 +218,19 @@ histcmd(int argc, char **argv) */ if (lflg == 0 || editor || sflg) { lflg = 0; /* ignore */ - editfile[0] = '\0'; + editfile = NULL; /* * Catch interrupts to reset active counter and * cleanup temp files. */ + savehandler = handler; if (setjmp(jmploc.loc)) { active = 0; - if (*editfile) + if (editfile) unlink(editfile); handler = savehandler; longjmp(handler-loc, 1); } - savehandler = handler; handler = jmploc; if
svn commit: r194774 - head/bin/sh
Author: jilles Date: Tue Jun 23 21:50:06 2009 New Revision: 194774 URL: http://svn.freebsd.org/changeset/base/194774 Log: Do not fork for a subshell if it is the last thing this shell is doing (EV_EXIT). The fork is still done as normal if any traps are active. In many cases, the fork can be avoided even without this change by using {} instead of (), but in practice many scripts use (), likely because the syntax is simpler. Example: sh -c '(/bin/sleep 10) sleep 1;ps -p $! -o comm=' Now prints sleep instead of sh. $! is more useful this way. Most shells (dash, bash, pdksh, ksh93, zsh) seem to print sleep for this. Example: sh -c '( ( ( (ps jT' Now shows no waiting shell processes instead of four. Most shells (dash, bash, pdksh, ksh93, zsh) seem to show zero or one. PR: bin/74404 Approved by: ed (mentor) (implicit) Modified: head/bin/sh/eval.c Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Tue Jun 23 21:48:04 2009(r194773) +++ head/bin/sh/eval.c Tue Jun 23 21:50:06 2009(r194774) @@ -401,8 +401,8 @@ evalsubshell(union node *n, int flags) int backgnd = (n-type == NBACKGND); expredir(n-nredir.redirect); - jp = makejob(n, 1); - if (forkshell(jp, n, backgnd) == 0) { + if ((!backgnd flags EV_EXIT !have_traps()) || + forkshell(jp = makejob(n, 1), n, backgnd) == 0) { if (backgnd) flags =~ EV_TESTED; redirect(n-nredir.redirect, 0); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r194775 - head/tools/regression/bin/sh/execution
Author: jilles Date: Tue Jun 23 22:03:56 2009 New Revision: 194775 URL: http://svn.freebsd.org/changeset/base/194775 Log: Add tests for r194774. Approved by: ed (mentor) (implicit) Added: head/tools/regression/bin/sh/execution/fork2.0 (contents, props changed) Added: head/tools/regression/bin/sh/execution/fork2.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/execution/fork2.0 Tue Jun 23 22:03:56 2009(r194775) @@ -0,0 +1,9 @@ +# $FreeBSD$ + +result=$(sh -c '(/bin/sleep 1) sleep 0.1; ps -p $! -o comm=; kill $!') +test $result = sleep || exit 1 + +result=$(sh -c '{ trap echo trapped EXIT; (/usr/bin/true); } wait') +test $result = trapped || exit 1 + +exit 0 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r194786 - head/bin/sh
Author: jilles Date: Tue Jun 23 22:53:34 2009 New Revision: 194786 URL: http://svn.freebsd.org/changeset/base/194786 Log: Quote -x tracing output so it is unambiguous. It is usually but not always suitable for re-input to the shell. Approved by: ed (mentor) (implicit) Modified: head/bin/sh/eval.c Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Tue Jun 23 22:47:34 2009(r194785) +++ head/bin/sh/eval.c Tue Jun 23 22:53:34 2009(r194786) @@ -642,17 +642,32 @@ evalcommand(union node *cmd, int flags, /* Print the command if xflag is set. */ if (xflag) { char sep = 0; + const char *p; out2str(ps4val()); for (sp = varlist.list ; sp ; sp = sp-next) { if (sep != 0) outc(' ', errout); - out2str(sp-text); + p = sp-text; + while (*p != '=' *p != '\0') + out2c(*p++); + if (*p != '\0') { + out2c(*p++); + out2qstr(p); + } sep = ' '; } for (sp = arglist.list ; sp ; sp = sp-next) { if (sep != 0) outc(' ', errout); - out2str(sp-text); + /* Disambiguate command looking like assignment. */ + if (sp == arglist.list + strchr(sp-text, '=') != NULL + strchr(sp-text, '\'') == NULL) { + out2c('\''); + out2str(sp-text); + out2c('\''); + } else + out2qstr(sp-text); sep = ' '; } outc('\n', errout); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r194922 - in head: bin/sh tools/regression/bin/sh/builtins
Author: jilles Date: Wed Jun 24 22:04:04 2009 New Revision: 194922 URL: http://svn.freebsd.org/changeset/base/194922 Log: Designate special builtins as such in command -V and type. Also document various properties of special builtins that we implement. Approved by: ed (mentor) (implicit) Modified: head/bin/sh/exec.c head/bin/sh/sh.1 head/tools/regression/bin/sh/builtins/command5.0.stdout Modified: head/bin/sh/exec.c == --- head/bin/sh/exec.c Wed Jun 24 21:56:05 2009(r194921) +++ head/bin/sh/exec.c Wed Jun 24 22:04:04 2009(r194922) @@ -756,6 +756,7 @@ typecmd_impl(int argc, char **argv, int if ((cmdp = cmdlookup(argv[i], 0)) != NULL) { entry.cmdtype = cmdp-cmdtype; entry.u = cmdp-param; + entry.special = cmdp-special; } else { /* Finally use brute force */ @@ -804,6 +805,9 @@ typecmd_impl(int argc, char **argv, int case CMDBUILTIN: if (cmd == TYPECMD_SMALLV) out1fmt(%s\n, argv[i]); + else if (entry.special) + out1fmt(%s is a special shell builtin\n, + argv[i]); else out1fmt(%s is a shell builtin\n, argv[i]); break; Modified: head/bin/sh/sh.1 == --- head/bin/sh/sh.1Wed Jun 24 21:56:05 2009(r194921) +++ head/bin/sh/sh.1Wed Jun 24 22:04:04 2009(r194922) @@ -606,6 +606,12 @@ This all occurs within the current shell .Pp Shell built-in commands are executed internally to the shell, without spawning a new process. +There are two kinds of built-in commands: regular and special. +Assignments before special builtins persist after they finish +executing and assignment errors, redirection errors and certain +operand errors cause a script to be aborted. +Both regular and special builtins can affect the shell in ways +normal programs cannot. .Pp Otherwise, if the command name does not match a function or built-in command, the command is searched for as a normal @@ -885,7 +891,7 @@ loops. The .Ic continue command continues with the next iteration of the innermost loop. -These are implemented as built-in commands. +These are implemented as special built-in commands. .Pp The syntax of the .Ic case @@ -1001,7 +1007,7 @@ It terminates the current executional sc nested function, sourced script, or shell instance, in that order. The .Ic return -command is implemented as a built-in command. +command is implemented as a special built-in command. .Ss Variables and Parameters The shell maintains a set of parameters. A parameter @@ -1590,6 +1596,7 @@ where is either the path name to .Ar utility , +a special shell builtin, a shell builtin, a shell function, a shell keyword @@ -2114,7 +2121,8 @@ Interpret each .Ar name as a command and print the resolution of the command search. Possible resolutions are: -shell keyword, alias, shell built-in command, command, tracked alias +shell keyword, alias, special shell builtin, shell builtin, command, +tracked alias and not found. For aliases the alias expansion is printed; for commands and tracked aliases Modified: head/tools/regression/bin/sh/builtins/command5.0.stdout == --- head/tools/regression/bin/sh/builtins/command5.0.stdout Wed Jun 24 21:56:05 2009(r194921) +++ head/tools/regression/bin/sh/builtins/command5.0.stdout Wed Jun 24 22:04:04 2009(r194922) @@ -2,7 +2,7 @@ ls is /bin/ls true is a shell builtin /bin/ls is /bin/ls fun is a shell function -break is a shell builtin +break is a special shell builtin if is a shell keyword { is a shell keyword foo is an alias for bar ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r194975 - head/bin/sh
Author: jilles Date: Thu Jun 25 17:10:51 2009 New Revision: 194975 URL: http://svn.freebsd.org/changeset/base/194975 Log: Improve IFS expansion using code from NetBSD. We now pass the ifs.sh testsuite. PR: standards/79067 Approved by: ed (mentor) (implicit) Obtained from:NetBSD Modified: head/bin/sh/expand.c Modified: head/bin/sh/expand.c == --- head/bin/sh/expand.cThu Jun 25 16:48:13 2009(r194974) +++ head/bin/sh/expand.cThu Jun 25 17:10:51 2009(r194975) @@ -82,7 +82,7 @@ struct ifsregion { struct ifsregion *next; /* next region in list */ int begoff; /* offset of start of region */ int endoff; /* offset of end of region */ - int nulonly;/* search for nul bytes only */ + int inquotes; /* search for nul bytes only */ }; @@ -936,13 +936,19 @@ numvar: */ STATIC void -recordregion(int start, int end, int nulonly) +recordregion(int start, int end, int inquotes) { struct ifsregion *ifsp; if (ifslastp == NULL) { ifsp = ifsfirst; } else { + if (ifslastp-endoff == start +ifslastp-inquotes == inquotes) { + /* extend previous area */ + ifslastp-endoff = end; + return; + } ifsp = (struct ifsregion *)ckmalloc(sizeof (struct ifsregion)); ifslastp-next = ifsp; } @@ -950,7 +956,7 @@ recordregion(int start, int end, int nul ifslastp-next = NULL; ifslastp-begoff = start; ifslastp-endoff = end; - ifslastp-nulonly = nulonly; + ifslastp-inquotes = inquotes; } @@ -969,75 +975,88 @@ ifsbreakup(char *string, struct arglist char *p; char *q; char *ifs; - int ifsspc; - int nulonly; - + const char *ifsspc; + int had_param_ch = 0; start = string; - ifsspc = 0; - nulonly = 0; - if (ifslastp != NULL) { - ifsp = ifsfirst; - do { - p = string + ifsp-begoff; - nulonly = ifsp-nulonly; - ifs = nulonly ? nullstr : - ( ifsset() ? ifsval() : \t\n ); - ifsspc = 0; - while (p string + ifsp-endoff) { - q = p; - if (*p == CTLESC) + + if (ifslastp == NULL) { + /* Return entire argument, IFS doesn't apply to any of it */ + sp = (struct strlist *)stalloc(sizeof *sp); + sp-text = start; + *arglist-lastp = sp; + arglist-lastp = sp-next; + return; + } + + ifs = ifsset() ? ifsval() : \t\n; + + for (ifsp = ifsfirst; ifsp != NULL; ifsp = ifsp-next) { + p = string + ifsp-begoff; + while (p string + ifsp-endoff) { + had_param_ch = 1; + q = p; + if (*p == CTLESC) + p++; + if (ifsp-inquotes) { + /* Only NULs (should be from $@) end args */ + if (*p != 0) { p++; - if (strchr(ifs, *p)) { - if (!nulonly) - ifsspc = (strchr( \t\n, *p) != NULL); - /* Ignore IFS whitespace at start */ - if (q == start ifsspc) { - p++; - start = p; - continue; - } - *q = '\0'; - sp = (struct strlist *)stalloc(sizeof *sp); - sp-text = start; - *arglist-lastp = sp; - arglist-lastp = sp-next; + continue; + } + ifsspc = NULL; + } else { + if (!strchr(ifs, *p)) { p++; - if (!nulonly) { - for (;;) { - if (p = string + ifsp-endoff) { - break; - } -
svn commit: r194981 - head/tools/regression/bin/sh/expansion
Author: jilles Date: Thu Jun 25 17:36:08 2009 New Revision: 194981 URL: http://svn.freebsd.org/changeset/base/194981 Log: Add some tests for r194975 and r194977. Approved by: ed (mentor) (implicit) Added: head/tools/regression/bin/sh/expansion/ head/tools/regression/bin/sh/expansion/ifs1.0 (contents, props changed) Added: head/tools/regression/bin/sh/expansion/ifs1.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/expansion/ifs1.0 Thu Jun 25 17:36:08 2009(r194981) @@ -0,0 +1,35 @@ +# $FreeBSD$ + +c=: e= s=' ' +failures='' +ok='' + +check_result() { + if [ x$2 = x$3 ]; then + ok=x$ok + else + failures=x$failures + echo For $1, expected $3 actual $2 + fi +} + +IFS=' +' +set -- a '' +set -- $@ +check_result 'set -- $@' ($#)($1)($2) (2)(a)() + +set -- a '' +set -- $@$e +check_result 'set -- $@$e' ($#)($1)($2) (2)(a)() + +set -- a '' +set -- $@$s +check_result 'set -- $@$s' ($#)($1)($2) (2)(a)() + +IFS=$c +set -- a '' +set -- $@$c +check_result 'set -- $@$c' ($#)($1)($2) (2)(a)() + +test x$failures = x ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r195243 - head/bin/chmod
On Wed, Jul 01, 2009 at 03:52:19PM +, Edward Tomasz Napierala wrote: + ret = pathconf(ent-fts_accpath, _PC_ACL_NFS4); There doesn't seem to be anything like lpathconf() or fpathconfat(AT_SYMLINK_NOFOLLOW), so this may not work properly for symlinks (chmod -h). -- Jilles Tjoelker ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r195458 - in head: include lib/libc/sys sys/bsm sys/compat/freebsd32 sys/compat/svr4 sys/i386/ibcs2 sys/kern sys/sys
On Tue, Jul 14, 2009 at 09:02:35AM -0700, Tim Kientzle wrote: Another data point: I've started looking at the *at() functions for libarchive's deep directory handling. The current code uses chdir() to manipulate files with very long pathnames, but that causes complications for libarchive clients that I'd like to eliminate. Using *at() functions to manage a virtual current directory looks a lot more robust. Unfortunately, there are still a few operations that are unavailable with this paradigm: * ACL functions * extattr functions Right. As with pathconf(), at variants with AT_SYMLINK_NOFOLLOW option would be useful here. * link() * symlink() linkat() and symlinkat() exist. In addition to providing the at functionality, linkat() allows creating hard links to symlinks. -- Jilles Tjoelker ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r195763 - head/lib/libc/sys
Author: jilles Date: Sun Jul 19 16:48:25 2009 New Revision: 195763 URL: http://svn.freebsd.org/changeset/base/195763 Log: Correct AT_SYMLINK_FOLLOW flag name in linkat(2) man page. Approved by: re (kib), ed (mentor) Modified: head/lib/libc/sys/link.2 Modified: head/lib/libc/sys/link.2 == --- head/lib/libc/sys/link.2Sun Jul 19 16:44:26 2009(r195762) +++ head/lib/libc/sys/link.2Sun Jul 19 16:48:25 2009(r195763) @@ -110,7 +110,7 @@ are constructed by a bitwise-inclusive O list, defined in .In fcntl.h : .Bl -tag -width indent -.It Dv AT_SYMLINK_NOFOLLOW +.It Dv AT_SYMLINK_FOLLOW If .Fa name1 names a symbolic link, a new link for the target of the symbolic link is ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r195768 - head/bin/ln
Author: jilles Date: Sun Jul 19 17:35:23 2009 New Revision: 195768 URL: http://svn.freebsd.org/changeset/base/195768 Log: Allow creating hard links to symlinks using ln(1). This implements the POSIX.1-2008 -L and -P flags. The default remains to create hard links to the target of symlinks. Approved by: re (kib), ed (mentor) Modified: head/bin/ln/ln.1 head/bin/ln/ln.c Modified: head/bin/ln/ln.1 == --- head/bin/ln/ln.1Sun Jul 19 17:25:24 2009(r195767) +++ head/bin/ln/ln.1Sun Jul 19 17:35:23 2009(r195768) @@ -32,7 +32,7 @@ .\@(#)ln.18.2 (Berkeley) 12/30/93 .\ $FreeBSD$ .\ -.Dd June 6, 2008 +.Dd July 17, 2009 .Dt LN 1 .Os .Sh NAME @@ -41,13 +41,13 @@ .Nd link files .Sh SYNOPSIS .Nm -.Op Fl s Op Fl F +.Op Fl L | Fl P | Fl s Op Fl F .Op Fl f | iw .Op Fl hnv .Ar source_file .Op Ar target_file .Nm -.Op Fl s Op Fl F +.Op Fl L | Fl P | Fl s Op Fl F .Op Fl f | iw .Op Fl hnv .Ar source_file ... @@ -77,16 +77,6 @@ to a file is one of the differences betw .Pp The options are as follows: .Bl -tag -width flag -.It Fl f -If the target file already exists, -then unlink it so that the link may occur. -(The -.Fl f -option overrides any previous -.Fl i -and -.Fl w -options.) .It Fl F If the target file already exists and is a directory, then remove it so that the link may occur. @@ -105,6 +95,29 @@ The option is a no-op unless .Fl s option is specified. +.It Fl L +When creating a hard link to a symbolic link, +create a hard link to the target of the symbolic link. +This is the default. +This option cancels the +.Fl P +option. +.It Fl P +When creating a hard link to a symbolic link, +create a hard link to the symbolic link itself. +This option cancels the +.Fl L +option. +.It Fl f +If the target file already exists, +then unlink it so that the link may occur. +(The +.Fl f +option overrides any previous +.Fl i +and +.Fl w +options.) .It Fl h If the .Ar target_file Modified: head/bin/ln/ln.c == --- head/bin/ln/ln.cSun Jul 19 17:25:24 2009(r195767) +++ head/bin/ln/ln.cSun Jul 19 17:35:23 2009(r195768) @@ -46,6 +46,7 @@ __FBSDID($FreeBSD$); #include err.h #include errno.h +#include fcntl.h #include limits.h #include stdio.h #include stdlib.h @@ -56,12 +57,11 @@ int fflag; /* Unlink existing files. intFflag; /* Remove empty directories also. */ inthflag; /* Check new name for symlink first. */ intiflag; /* Interactive mode. */ +intPflag; /* Create hard links to symlinks. */ intsflag; /* Symbolic, not hard, link. */ intvflag; /* Verbose output. */ intwflag; /* Warn if symlink target does not * exist, and -f is not enabled. */ - /* System link call. */ -int (*linkf)(const char *, const char *); char linkch; intlinkit(const char *, const char *, int); @@ -90,15 +90,20 @@ main(int argc, char *argv[]) argv += optind; if (argc != 2) usage(); - linkf = link; exit(linkit(argv[0], argv[1], 0)); } - while ((ch = getopt(argc, argv, Ffhinsvw)) != -1) + while ((ch = getopt(argc, argv, FLPfhinsvw)) != -1) switch (ch) { case 'F': Fflag = 1; break; + case 'L': + Pflag = 0; + break; + case 'P': + Pflag = 1; + break; case 'f': fflag = 1; iflag = 0; @@ -129,7 +134,6 @@ main(int argc, char *argv[]) argv += optind; argc -= optind; - linkf = sflag ? symlink : link; linkch = sflag ? '-' : '='; if (sflag == 0) Fflag = 0; @@ -179,7 +183,7 @@ linkit(const char *source, const char *t if (!sflag) { /* If source doesn't exist, quit now. */ - if (stat(source, sb)) { + if ((Pflag ? lstat : stat)(source, sb)) { warn(%s, source); return (1); } @@ -276,7 +280,9 @@ linkit(const char *source, const char *t } /* Attempt the link. */ - if ((*linkf)(source, target)) { + if (sflag ? symlink(source, target) : + linkat(AT_FDCWD, source, AT_FDCWD, target, + Pflag ? 0 : AT_SYMLINK_FOLLOW)) { warn(%s, target); return (1); } @@ -289,8 +295,8 @@ void usage(void) {
svn commit: r196483 - in head: bin/sh tools/regression/bin/sh/execution
Author: jilles Date: Sun Aug 23 21:09:46 2009 New Revision: 196483 URL: http://svn.freebsd.org/changeset/base/196483 Log: sh: Fix crash when undefining or redefining a currently executing function. Add a reference count to function definitions. Memory may leak if multiple SIGINTs arrive in interactive mode, this will be fixed later by changing SIGINT handling. PR: bin/137640 Added: head/tools/regression/bin/sh/execution/func1.0 (contents, props changed) Modified: head/bin/sh/eval.c head/bin/sh/exec.c head/bin/sh/exec.h head/bin/sh/mknodes.c head/bin/sh/nodes.c.pat Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Sun Aug 23 21:00:21 2009(r196482) +++ head/bin/sh/eval.c Sun Aug 23 21:09:46 2009(r196483) @@ -785,6 +785,7 @@ evalcommand(union node *cmd, int flags, INTOFF; savelocalvars = localvars; localvars = NULL; + reffunc(cmdentry.u.func); INTON; savehandler = handler; if (setjmp(jmploc.loc)) { @@ -794,6 +795,7 @@ evalcommand(union node *cmd, int flags, freeparam(shellparam); shellparam = saveparam; } + unreffunc(cmdentry.u.func); poplocalvars(); localvars = savelocalvars; handler = savehandler; @@ -805,11 +807,12 @@ evalcommand(union node *cmd, int flags, funcnest++; exitstatus = oexitstatus; if (flags EV_TESTED) - evaltree(cmdentry.u.func, EV_TESTED); + evaltree(cmdentry.u.func-n, EV_TESTED); else - evaltree(cmdentry.u.func, 0); + evaltree(cmdentry.u.func-n, 0); funcnest--; INTOFF; + unreffunc(cmdentry.u.func); poplocalvars(); localvars = savelocalvars; freeparam(shellparam); Modified: head/bin/sh/exec.c == --- head/bin/sh/exec.c Sun Aug 23 21:00:21 2009(r196482) +++ head/bin/sh/exec.c Sun Aug 23 21:09:46 2009(r196483) @@ -286,7 +286,7 @@ printentry(struct tblentry *cmdp, int ve out1fmt(function %s, cmdp-cmdname); if (verbose) { INTOFF; - name = commandtext(cmdp-param.func); + name = commandtext(cmdp-param.func-n); out1c(' '); out1str(name); ckfree(name); @@ -583,7 +583,7 @@ deletefuncs(void) while ((cmdp = *pp) != NULL) { if (cmdp-cmdtype == CMDFUNCTION) { *pp = cmdp-next; - freefunc(cmdp-param.func); + unreffunc(cmdp-param.func); ckfree(cmdp); } else { pp = cmdp-next; @@ -670,7 +670,7 @@ addcmdentry(char *name, struct cmdentry INTOFF; cmdp = cmdlookup(name, 1); if (cmdp-cmdtype == CMDFUNCTION) { - freefunc(cmdp-param.func); + unreffunc(cmdp-param.func); } cmdp-cmdtype = entry-cmdtype; cmdp-param = entry-u; @@ -705,7 +705,7 @@ unsetfunc(char *name) struct tblentry *cmdp; if ((cmdp = cmdlookup(name, 0)) != NULL cmdp-cmdtype == CMDFUNCTION) { - freefunc(cmdp-param.func); + unreffunc(cmdp-param.func); delete_cmd_entry(); return (0); } Modified: head/bin/sh/exec.h == --- head/bin/sh/exec.h Sun Aug 23 21:00:21 2009(r196482) +++ head/bin/sh/exec.h Sun Aug 23 21:09:46 2009(r196483) @@ -46,11 +46,12 @@ enum { TYPECMD_TYPE/* type */ }; +union node; struct cmdentry { int cmdtype; union param { int index; - union node *func; + struct funcdef *func; } u; int special; }; Modified: head/bin/sh/mknodes.c == --- head/bin/sh/mknodes.c Sun Aug 23 21:00:21 2009(r196482) +++ head/bin/sh/mknodes.c Sun Aug 23 21:09:46 2009(r196483) @@ -248,8 +248,13 @@ output(char *file) fputs(\tstruct nodelist *next;\n, hfile); fputs(\tunion node *n;\n, hfile); fputs(};\n\n\n, hfile); - fputs(union node *copyfunc(union node *);\n, hfile); - fputs(void freefunc(union node *);\n, hfile); +
Re: svn commit: r196460 - head/sys/kern
On Sun, Aug 23, 2009 at 12:44:15PM +, Konstantin Belousov wrote: Author: kib Date: Sun Aug 23 12:44:15 2009 New Revision: 196460 URL: http://svn.freebsd.org/changeset/base/196460 Log: Fix the conformance of poll(2) for sockets after r195423 by returning POLLHUP instead of POLLIN for several cases. Now, the tools/regression/poll results for FreeBSD are closer to that of the Solaris and Linux. Also, improve the POSIX conformance by explicitely clearing POLLOUT when POLLHUP is reported in pollscan(), making the fix global. Submitted by: bde Reviewed by:rwatson MFC after: 1 week Modified: head/sys/kern/sys_generic.c head/sys/kern/uipc_socket.c Modified: head/sys/kern/sys_generic.c == --- head/sys/kern/sys_generic.c Sun Aug 23 12:23:24 2009 (r196459) +++ head/sys/kern/sys_generic.c Sun Aug 23 12:44:15 2009 (r196460) @@ -1228,6 +1228,13 @@ pollscan(td, fds, nfd) selfdalloc(td, fds); fds-revents = fo_poll(fp, fds-events, td-td_ucred, td); + /* + * POSIX requires POLLOUT to be never + * set simultaneously with POLLHUP. + */ + if ((fds-revents POLLHUP) != 0) + fds-revents = ~POLLOUT; + if (fds-revents != 0) n++; } This looks useful. Modified: head/sys/kern/uipc_socket.c == --- head/sys/kern/uipc_socket.c Sun Aug 23 12:23:24 2009 (r196459) +++ head/sys/kern/uipc_socket.c Sun Aug 23 12:44:15 2009 (r196460) @@ -2898,13 +2898,11 @@ sopoll_generic(struct socket *so, int ev if (so-so_oobmark || (so-so_rcv.sb_state SBS_RCVATMARK)) revents |= events (POLLPRI | POLLRDBAND); - if ((events POLLINIGNEOF) == 0) { - if (so-so_rcv.sb_state SBS_CANTRCVMORE) { - revents |= events (POLLIN | POLLRDNORM); - if (so-so_snd.sb_state SBS_CANTSENDMORE) - revents |= POLLHUP; - } - } + if ((events POLLINIGNEOF) == 0) + if (so-so_rcv.sb_state SBS_CANTRCVMORE) + revents |= POLLHUP; + if (so-so_snd.sb_state SBS_CANTSENDMORE) + revents |= POLLHUP; if (revents == 0) { if (events (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) { This sets POLLHUP when either of the directions has shut down, instead of the entire connection. This breaks use of select and poll with shutdown(2): * sending some data, shutdown(SHUT_WR) then polling for input * (the other side for the above) receiving some data, getting EOF on that direction then polling for output * a paranoid HTTP-like server that wants to wait for the client to close the read end after shutting down the write end Either some data is lost or the program busy-waits for the data. I think the POLLHUP setting before this commit was correct for sockets: POLLHUP is set if both directions are closed/error. An EOF that only affects one direction sets the corresponding POLLIN/POLLOUT so that the EOF becomes known but the other direction can still be used normally. (The POSIX spec explicitly describes something like this for POLLIN (zero length message) although it erroneously restricts it to STREAMS files only; the POLLOUT case has to be derived from the fact that the read end should still work normally but the EOF should be notified.) I think poll on fifos should instead be fixed by closing the half-connection corresponding to writing from fi_readsock to fi_writesock. I have tried this out, see attached patch. With the patch, pipepoll only gives expected POLLHUP; got POLLIN | POLLHUP errors and an error in fifo case 6b caused by our distinction between new and old readers. tools/regression/poll does not test shutdown(2) interaction, so it does not find this problem. -- Jilles Tjoelker Index: sys/kern/uipc_socket.c === --- sys/kern/uipc_socket.c (revision 196469) +++ sys/kern/uipc_socket.c (working copy) @@ -2898,11 +2898,13 @@ if (so-so_oobmark || (so-so_rcv.sb_state SBS_RCVATMARK)) revents |= events (POLLPRI | POLLRDBAND); - if ((events POLLINIGNEOF) == 0) - if (so-so_rcv.sb_state SBS_CANTRCVMORE) - revents |= POLLHUP; - if (so-so_snd.sb_state SBS_CANTSENDMORE) - revents |= POLLHUP; + if ((events POLLINIGNEOF) == 0) { + if (so-so_rcv.sb_state SBS_CANTRCVMORE) { + revents |= events (POLLIN | POLLRDNORM); + if (so
svn commit: r196554 - head/tools/regression/poll
Author: jilles Date: Tue Aug 25 20:33:37 2009 New Revision: 196554 URL: http://svn.freebsd.org/changeset/base/196554 Log: Add some tests for poll(2)/shutdown(2) interaction. Added: head/tools/regression/poll/sockpoll.c (contents, props changed) Modified: head/tools/regression/poll/Makefile Modified: head/tools/regression/poll/Makefile == --- head/tools/regression/poll/Makefile Tue Aug 25 20:21:16 2009 (r196553) +++ head/tools/regression/poll/Makefile Tue Aug 25 20:33:37 2009 (r196554) @@ -3,14 +3,15 @@ # Nothing yet works with gmake for the path to the sources. .PATH: .. -PROG= pipepoll pipeselect +PROG= pipepoll pipeselect sockpoll CFLAGS+= -Werror -Wall all: ${PROG} pipepoll: pipepoll.c pipeselect: pipeselect.c +sockpoll: sockpoll.c -pipepoll pipeselect: +pipepoll pipeselect sockpoll: ${CC} ${CFLAGS} ${LDFLAGS} -o $@ $...@.c test: all Added: head/tools/regression/poll/sockpoll.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/poll/sockpoll.c Tue Aug 25 20:33:37 2009 (r196554) @@ -0,0 +1,202 @@ +/* $FreeBSD$ */ + +#include sys/poll.h +#include sys/socket.h +#include sys/stat.h + +#include err.h +#include fcntl.h +#include signal.h +#include stdio.h +#include stdlib.h +#include unistd.h + +static const char * +decode_events(int events) +{ + char *ncresult; + const char *result; + + switch (events) { + case POLLIN: + result = POLLIN; + break; + case POLLOUT: + result = POLLOUT; + break; + case POLLIN | POLLOUT: + result = POLLIN | POLLOUT; + break; + case POLLHUP: + result = POLLHUP; + break; + case POLLIN | POLLHUP: + result = POLLIN | POLLHUP; + break; + case POLLOUT | POLLHUP: + result = POLLOUT | POLLHUP; + break; + case POLLIN | POLLOUT | POLLHUP: + result = POLLIN | POLLOUT | POLLHUP; + break; + default: + asprintf(ncresult, %#x, events); + result = ncresult; + break; + } + return (result); +} + +static void +report(int num, const char *state, int expected, int got) +{ + if (expected == got) + printf(ok %-2d, num); + else + printf(not ok %-2d, num); + printf( state %s: expected %s; got %s\n, + state, decode_events(expected), decode_events(got)); + fflush(stdout); +} + +static int +set_nonblocking(int sck) +{ + int flags; + + flags = fcntl(sck, F_GETFL, 0); + flags |= O_NONBLOCK; + + if (fcntl(sck, F_SETFL, flags)) + return -1; + + return 0; +} + +static char largeblock[1048576]; /* should be more than AF_UNIX sockbuf size */ +static int fd[2]; +static struct pollfd pfd0; +static struct pollfd pfd1; + +void +setup(void) +{ + if (socketpair(AF_UNIX, SOCK_STREAM, 0, fd) != 0) + err(1, socketpair); + if (set_nonblocking(fd[0]) == -1) + err(1, fcntl); + if (set_nonblocking(fd[1]) == -1) + err(1, fcntl); + pfd0.fd = fd[0]; + pfd0.events = POLLIN | POLLOUT; + pfd1.fd = fd[1]; + pfd1.events = POLLIN | POLLOUT; +} + +int +main(void) +{ + int num; + + num = 1; + printf(1..18\n); + fflush(stdout); + + /* Large write with close */ + setup(); + if (poll(pfd0, 1, 0) == -1) + err(1, poll); + report(num++, initial 0, POLLOUT, pfd0.revents); + if (poll(pfd1, 1, 0) == -1) + err(1, poll); + report(num++, initial 1, POLLOUT, pfd1.revents); + if (write(fd[0], largeblock, sizeof(largeblock)) == -1) + err(1, write); + if (poll(pfd0, 1, 0) == -1) + err(1, poll); + report(num++, after large write, 0, pfd0.revents); + if (poll(pfd1, 1, 0) == -1) + err(1, poll); + report(num++, other side after large write, POLLIN | POLLOUT, pfd1.revents); + close(fd[0]); + if (poll(pfd1, 1, 0) == -1) + err(1, poll); + report(num++, other side after close, POLLIN | POLLHUP, pfd1.revents); + if (read(fd[1], largeblock, sizeof(largeblock)) == -1) + err(1, read); + if (poll(pfd1, 1, 0) == -1) + err(1, poll); + report(num++, other side after reading input, POLLHUP, pfd1.revents); + close(fd[1]); + + /* With shutdown(SHUT_WR) */ + setup(); + if (shutdown(fd[0], SHUT_WR) == -1) + err(1, shutdown); + if (poll(pfd0, 1, 0) == -1) + err(1, poll); + report(num++, after shutdown(SHUT_WR),
Re: svn commit: r196460 - head/sys/kern
On Tue, Aug 25, 2009 at 04:07:11AM +1000, Bruce Evans wrote: On Sun, 23 Aug 2009, Jilles Tjoelker wrote: I think poll on fifos should instead be fixed by closing the half-connection corresponding to writing from fi_readsock to fi_writesock. I have tried this out, see attached patch. With the patch, pipepoll only gives expected POLLHUP; got POLLIN | POLLHUP errors and an error in fifo case 6b caused by our distinction between new and old readers. This sort of worked for me, but has several problems: % Index: sys/fs/fifofs/fifo_vnops.c % === % --- sys/fs/fifofs/fifo_vnops.c (revision 196459) % +++ sys/fs/fifofs/fifo_vnops.c (working copy) % @@ -193,6 +193,10 @@ % goto fail2; % fip-fi_writesock = wso; % error = soconnect2(wso, rso); % + if (error == 0) % + error = soshutdown(rso, SHUT_WR); % + if (error == 0) % + error = soshutdown(wso, SHUT_RD); % if (error) { % (void)soclose(wso); % fail2: The second soshutdown() is only harmful. I see the following state changes - the first soshutdown() sets SBS_CANTRCVMORE on rso like you would expect, and also sets SBS_CANTSENDMORE on wso. This gives the desired state. - the second soshutdown() then clears SBS_CANTRCVMORE on rso (without the first soshutdown() it leaves both flags clear in both directions). This clobbers the desired state. The failure shows in just one of my uncommitted regression tests (when there is a writer and there was a reader, poll() returns POLLOUT for the writer, but should return POLLHUP; the missing SBS_CANTRCVMORE on rso prevents it ever returning POLLHUP for writers). After removing the second soshutdown() and fixing a spurious POLLIN (see below), all my tests pass. I have removed the second shutdown, it is not necessary. Elsewhere, fifo_vnops.c hacks on SBS_CANT*MORE directly. Perhaps it should call soshutdown(), or if the direct access there is safe then it is probably safe above. That's for a later commit to fix. % Index: sys/kern/uipc_socket.c % === % --- sys/kern/uipc_socket.c (revision 196469) % +++ sys/kern/uipc_socket.c (working copy) % @@ -2898,11 +2898,13 @@ % if (so-so_oobmark || (so-so_rcv.sb_state SBS_RCVATMARK)) % revents |= events (POLLPRI | POLLRDBAND); % % - if ((events POLLINIGNEOF) == 0) % - if (so-so_rcv.sb_state SBS_CANTRCVMORE) % - revents |= POLLHUP; % - if (so-so_snd.sb_state SBS_CANTSENDMORE) % - revents |= POLLHUP; % + if ((events POLLINIGNEOF) == 0) { Old problems become larger: I don't like POLLINIGNEOF (for input) affecting POLLHUP for output. This seems to cause no problems for fifos, at least when the kernel sets POLLINIGNEOF, but it is hard to understand even why it doesn't cause problems, and kib@ wants POLLINIGNEOF to remain user-settable, so the complications might remain exported to userland for for fifos and sockets, where they are harder to document and understand. I do not like userland POLLINIGNEOF either. I think programs can do fine with the standard functionality (closing and reopening a fifo to reset the POLLHUP state). % + revents |= events (POLLIN | POLLRDNORM); This gives spurious POLLINs when POLLHUP is also returned, and thus defeats the point of soreadable_data() being different from soreadable(). Tests 6a-6d show the spurious POLLIN. I don't understand how tests 6a and 6c-6d passed for you. Same problem here. I think kib@ wants to keep this in 8.x for the sake of buggy programs that do not check for POLLHUP. I suppose we can do it properly in 9.x. % + if (so-so_snd.sb_state SBS_CANTSENDMORE) % + revents |= POLLHUP; Tests 6a-6d pass with the above 3 lines changed to: if (so-so_snd.sb_state SBS_CANTSENDMORE) revents |= POLLHUP; else revents |= events (POLLIN | POLLRDNORM); Returning POLLIN will cause poll() to not block on input descriptors, but this seems to be as correct as possible since there really is a read-EOF. Applications just can't see this EOF as POLLHUP -- they will see POLLIN and have to try to read(), and then interpret read() returning 0 as meaning EOF. Device-independent applications must do precisely this anyway since the input descriptor might be a regular file and there is no POLLHUP for regular files. Yes. Even more, any program must handle it because it is also possible that an EOF happens between poll() and read(). -- Jilles Tjoelker ___ svn-src-all@freebsd.org mailing list http
svn commit: r196556 - in head/sys: fs/fifofs kern
Author: jilles Date: Tue Aug 25 21:44:14 2009 New Revision: 196556 URL: http://svn.freebsd.org/changeset/base/196556 Log: Fix poll() on half-closed sockets, while retaining POLLHUP for fifos. This reverts part of r196460, so that sockets only return POLLHUP if both directions are closed/error. Fifos get POLLHUP by closing the unused direction immediately after creating the sockets. The tools/regression/poll/*poll.c tests now pass except for two other things: - if POLLHUP is returned, POLLIN is always returned as well instead of only when there is data left in the buffer to be read - fifo old/new reader distinction does not work the way POSIX specs it Reviewed by: kib, bde Modified: head/sys/fs/fifofs/fifo_vnops.c head/sys/kern/uipc_socket.c Modified: head/sys/fs/fifofs/fifo_vnops.c == --- head/sys/fs/fifofs/fifo_vnops.c Tue Aug 25 20:35:57 2009 (r196555) +++ head/sys/fs/fifofs/fifo_vnops.c Tue Aug 25 21:44:14 2009 (r196556) @@ -193,6 +193,9 @@ fifo_open(ap) goto fail2; fip-fi_writesock = wso; error = soconnect2(wso, rso); + /* Close the direction we do not use, so we can get POLLHUP. */ + if (error == 0) + error = soshutdown(rso, SHUT_WR); if (error) { (void)soclose(wso); fail2: Modified: head/sys/kern/uipc_socket.c == --- head/sys/kern/uipc_socket.c Tue Aug 25 20:35:57 2009(r196555) +++ head/sys/kern/uipc_socket.c Tue Aug 25 21:44:14 2009(r196556) @@ -2898,11 +2898,13 @@ sopoll_generic(struct socket *so, int ev if (so-so_oobmark || (so-so_rcv.sb_state SBS_RCVATMARK)) revents |= events (POLLPRI | POLLRDBAND); - if ((events POLLINIGNEOF) == 0) - if (so-so_rcv.sb_state SBS_CANTRCVMORE) - revents |= POLLHUP; - if (so-so_snd.sb_state SBS_CANTSENDMORE) - revents |= POLLHUP; + if ((events POLLINIGNEOF) == 0) { + if (so-so_rcv.sb_state SBS_CANTRCVMORE) { + revents |= events (POLLIN | POLLRDNORM); + if (so-so_snd.sb_state SBS_CANTSENDMORE) + revents |= POLLHUP; + } + } if (revents == 0) { if (events (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r196460 - head/sys/kern
On Wed, Aug 26, 2009 at 05:08:57PM +1000, Bruce Evans wrote: On Tue, 25 Aug 2009, Jilles Tjoelker wrote: On Tue, Aug 25, 2009 at 04:07:11AM +1000, Bruce Evans wrote: On Sun, 23 Aug 2009, Jilles Tjoelker wrote: % Index: sys/fs/fifofs/fifo_vnops.c % === % --- sys/fs/fifofs/fifo_vnops.c (revision 196459) % +++ sys/fs/fifofs/fifo_vnops.c (working copy) % @@ -193,6 +193,10 @@ % goto fail2; % fip-fi_writesock = wso; % error = soconnect2(wso, rso); % +if (error == 0) % +error = soshutdown(rso, SHUT_WR); % +if (error == 0) % +error = soshutdown(wso, SHUT_RD); % if (error) { % (void)soclose(wso); % fail2: The second shutdown became harmless for me when I fixed the clobbering of sb_state. Does it have any effect? It seems not. shutdown(SHUT_RD) basically calls the pru_flush protocol function (which uipc_usrreq.c does not provide), calls socantrecvmore (which uipc_usrreq.c had already done synchronously with the first shutdown) and clears the receive socket buffer (which is already empty). Regarding the direct access to SBS_CANTRCVMORE and SBS_CANTSENDMORE, this seems related to the special property of fifos that they can disconnect and reconnect a stream using the same object. The socket layer normally does not allow clearing SBS_CANTRCVMORE and SBS_CANTSENDMORE. The only case where fifo_vnops.c touches these flags directly where a so* function call could be used is the setting of SBS_CANTRCVMORE on the read side at initial creation (possibly because a wakeup is not necessary there). I suppose the new fifo implementation will avoid abusing sockets this way. -- Jilles Tjoelker ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196634 - in head: bin/sh tools/regression/bin/sh/execution
Author: jilles Date: Fri Aug 28 22:41:25 2009 New Revision: 196634 URL: http://svn.freebsd.org/changeset/base/196634 Log: sh: Fix crash with empty functions (f() { }) introduced in r196483 Empty pairs of braces are represented by a NULL node pointer, just like empty lines at the top level. Support for empty pairs of braces may be removed later. They make the code more complex, have inconsistent behaviour (may or may not change $?), are not specified by POSIX and are not allowed by some other shells like bash, dash and ksh93. Reported by: kan Added: head/tools/regression/bin/sh/execution/func2.0 (contents, props changed) Modified: head/bin/sh/eval.c head/bin/sh/exec.c head/bin/sh/mknodes.c head/bin/sh/nodes.c.pat Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Fri Aug 28 22:30:55 2009(r196633) +++ head/bin/sh/eval.c Fri Aug 28 22:41:25 2009(r196634) @@ -807,9 +807,9 @@ evalcommand(union node *cmd, int flags, funcnest++; exitstatus = oexitstatus; if (flags EV_TESTED) - evaltree(cmdentry.u.func-n, EV_TESTED); + evaltree(getfuncnode(cmdentry.u.func), EV_TESTED); else - evaltree(cmdentry.u.func-n, 0); + evaltree(getfuncnode(cmdentry.u.func), 0); funcnest--; INTOFF; unreffunc(cmdentry.u.func); Modified: head/bin/sh/exec.c == --- head/bin/sh/exec.c Fri Aug 28 22:30:55 2009(r196633) +++ head/bin/sh/exec.c Fri Aug 28 22:41:25 2009(r196634) @@ -286,7 +286,7 @@ printentry(struct tblentry *cmdp, int ve out1fmt(function %s, cmdp-cmdname); if (verbose) { INTOFF; - name = commandtext(cmdp-param.func-n); + name = commandtext(getfuncnode(cmdp-param.func)); out1c(' '); out1str(name); ckfree(name); Modified: head/bin/sh/mknodes.c == --- head/bin/sh/mknodes.c Fri Aug 28 22:30:55 2009(r196633) +++ head/bin/sh/mknodes.c Fri Aug 28 22:41:25 2009(r196634) @@ -248,11 +248,9 @@ output(char *file) fputs(\tstruct nodelist *next;\n, hfile); fputs(\tunion node *n;\n, hfile); fputs(};\n\n\n, hfile); - fputs(struct funcdef {\n, hfile); - fputs(\tunsigned int refcount;\n, hfile); - fputs(\tunion node n;\n, hfile); - fputs(};\n\n\n, hfile); + fputs(struct funcdef;\n, hfile); fputs(struct funcdef *copyfunc(union node *);\n, hfile); + fputs(union node *getfuncnode(struct funcdef *);\n, hfile); fputs(void reffunc(struct funcdef *);\n, hfile); fputs(void unreffunc(struct funcdef *);\n, hfile); Modified: head/bin/sh/nodes.c.pat == --- head/bin/sh/nodes.c.pat Fri Aug 28 22:30:55 2009(r196633) +++ head/bin/sh/nodes.c.pat Fri Aug 28 22:41:25 2009(r196634) @@ -61,6 +61,10 @@ STATIC struct nodelist *copynodelist(str STATIC char *nodesavestr(char *); +struct funcdef { + unsigned int refcount; + union node n; +}; /* * Make a copy of a parse tree. @@ -85,6 +89,12 @@ copyfunc(union node *n) } +union node * +getfuncnode(struct funcdef *fn) +{ + return fn == NULL ? NULL : fn-n; +} + STATIC void calcsize(union node *n) @@ -153,7 +163,8 @@ nodesavestr(char *s) void reffunc(struct funcdef *fn) { - fn-refcount++; + if (fn) + fn-refcount++; } Added: head/tools/regression/bin/sh/execution/func2.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/execution/func2.0 Fri Aug 28 22:41:25 2009(r196634) @@ -0,0 +1,11 @@ +# $FreeBSD$ + +f() { } +f +hash -v f /dev/null +f() { { }; } +f +hash -v f /dev/null +f() { { } } +f +hash -v f /dev/null ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r196741 - in stable/8: sys sys/amd64/include/xen sys/cddl/contrib/opensolaris sys/contrib/dev/acpica sys/contrib/pf sys/dev/xen/xenpci sys/fs/fifofs sys/kern tools/regression/poll
Author: jilles Date: Tue Sep 1 20:58:41 2009 New Revision: 196741 URL: http://svn.freebsd.org/changeset/base/196741 Log: MFC r196460 Fix the conformance of poll(2) for sockets after r195423 by returning POLLHUP instead of POLLIN for several cases. Now, the tools/regression/poll results for FreeBSD are closer to that of the Solaris and Linux. Also, improve the POSIX conformance by explicitely clearing POLLOUT when POLLHUP is reported in pollscan(), making the fix global. Submitted by: bde Reviewed by:rwatson MFC r196556 Fix poll() on half-closed sockets, while retaining POLLHUP for fifos. This reverts part of r196460, so that sockets only return POLLHUP if both directions are closed/error. Fifos get POLLHUP by closing the unused direction immediately after creating the sockets. The tools/regression/poll/*poll.c tests now pass except for two other things: - if POLLHUP is returned, POLLIN is always returned as well instead of only when there is data left in the buffer to be read - fifo old/new reader distinction does not work the way POSIX specs it Reviewed by:kib, bde MFC r196554 Add some tests for poll(2)/shutdown(2) interaction. Approved by: re (kensmith) Added: stable/8/tools/regression/poll/sockpoll.c - copied unchanged from r196554, head/tools/regression/poll/sockpoll.c Modified: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/fs/fifofs/fifo_vnops.c stable/8/sys/kern/sys_generic.c stable/8/tools/regression/poll/ (props changed) stable/8/tools/regression/poll/Makefile Modified: stable/8/sys/fs/fifofs/fifo_vnops.c == --- stable/8/sys/fs/fifofs/fifo_vnops.c Tue Sep 1 18:30:17 2009 (r196740) +++ stable/8/sys/fs/fifofs/fifo_vnops.c Tue Sep 1 20:58:41 2009 (r196741) @@ -193,6 +193,9 @@ fifo_open(ap) goto fail2; fip-fi_writesock = wso; error = soconnect2(wso, rso); + /* Close the direction we do not use, so we can get POLLHUP. */ + if (error == 0) + error = soshutdown(rso, SHUT_WR); if (error) { (void)soclose(wso); fail2: Modified: stable/8/sys/kern/sys_generic.c == --- stable/8/sys/kern/sys_generic.c Tue Sep 1 18:30:17 2009 (r196740) +++ stable/8/sys/kern/sys_generic.c Tue Sep 1 20:58:41 2009 (r196741) @@ -1228,6 +1228,13 @@ pollscan(td, fds, nfd) selfdalloc(td, fds); fds-revents = fo_poll(fp, fds-events, td-td_ucred, td); + /* +* POSIX requires POLLOUT to be never +* set simultaneously with POLLHUP. +*/ + if ((fds-revents POLLHUP) != 0) + fds-revents = ~POLLOUT; + if (fds-revents != 0) n++; } Modified: stable/8/tools/regression/poll/Makefile == --- stable/8/tools/regression/poll/Makefile Tue Sep 1 18:30:17 2009 (r196740) +++ stable/8/tools/regression/poll/Makefile Tue Sep 1 20:58:41 2009 (r196741) @@ -3,14 +3,15 @@ # Nothing yet works with gmake for the path to the sources. .PATH: .. -PROG= pipepoll pipeselect +PROG= pipepoll pipeselect sockpoll CFLAGS+= -Werror -Wall all: ${PROG} pipepoll: pipepoll.c pipeselect: pipeselect.c +sockpoll: sockpoll.c -pipepoll pipeselect: +pipepoll pipeselect sockpoll: ${CC} ${CFLAGS} ${LDFLAGS} -o $@ $...@.c test: all Copied: stable/8/tools/regression/poll/sockpoll.c (from r196554, head/tools/regression/poll/sockpoll.c) == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/poll/sockpoll.c Tue Sep 1 20:58:41 2009 (r196741, copy of r196554, head/tools/regression/poll/sockpoll.c) @@ -0,0 +1,202 @@ +/* $FreeBSD$ */ + +#include sys/poll.h +#include sys/socket.h +#include sys/stat.h + +#include err.h +#include fcntl.h +#include signal.h +#include stdio.h +#include stdlib.h +#include unistd.h + +static const char * +decode_events(int events) +{ + char *ncresult; + const char
svn commit: r197363 - head/usr.bin/find
Author: jilles Date: Sun Sep 20 16:47:56 2009 New Revision: 197363 URL: http://svn.freebsd.org/changeset/base/197363 Log: Update find(1) man page for -L/-delete interaction. It is a bit unfortunate that the example to delete broken symlinks now uses rm(1), but allowing this with -delete would require fixing fts(3) to not imply FTS_NOCHDIR if FTS_LOGICAL is given (or hacks in the -delete option). PR: bin/90687 MFC after:2 weeks Modified: head/usr.bin/find/find.1 Modified: head/usr.bin/find/find.1 == --- head/usr.bin/find/find.1Sun Sep 20 15:47:31 2009(r197362) +++ head/usr.bin/find/find.1Sun Sep 20 16:47:56 2009(r197363) @@ -312,6 +312,7 @@ character in its pathname relative to .Dq Pa \. for security reasons. Depth-first traversal processing is implied by this option. +Following symlinks is incompatible with this option. .It Ic -depth Always true; same as the @@ -920,7 +921,7 @@ recent than the current time minus one m Use the .Xr echo 1 command to print out a list of all the files. -.It Li find -L /usr/ports/packages -type l -delete +.It Li find -L /usr/ports/packages -type l -exec rm -- {} + Delete all broken symbolic links in .Pa /usr/ports/packages . .It Li find /usr/src -name CVS -prune -o -depth +6 -print ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197371 - head/bin/sh
Author: jilles Date: Sun Sep 20 21:42:38 2009 New Revision: 197371 URL: http://svn.freebsd.org/changeset/base/197371 Log: Mention that NUL characters are not allowed in sh(1) input. I do not consider this a bug because POSIX permits it and argument strings and environment variables cannot contain '\0' anyway. PR: bin/25542 MFC after:2 weeks Modified: head/bin/sh/sh.1 Modified: head/bin/sh/sh.1 == --- head/bin/sh/sh.1Sun Sep 20 19:32:10 2009(r197370) +++ head/bin/sh/sh.1Sun Sep 20 21:42:38 2009(r197371) @@ -375,6 +375,10 @@ introduces a comment if used at the begi The word starting with .Ql # and the rest of the line are ignored. +.Pp +.Tn ASCII +.Dv NUL +characters (character code 0) are not allowed in shell input. .Ss Quoting Quoting is used to remove the special meaning of certain characters or words to the shell, such as operators, whitespace, keywords, ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197625 - head/usr.sbin/lpr/lp
Author: jilles Date: Tue Sep 29 21:28:32 2009 New Revision: 197625 URL: http://svn.freebsd.org/changeset/base/197625 Log: Fix using lp(1) without the new -t option after r194171. PR: standards/129554 Tested by:Steve Kargl MFC after:1 week Modified: head/usr.sbin/lpr/lp/lp.sh Modified: head/usr.sbin/lpr/lp/lp.sh == --- head/usr.sbin/lpr/lp/lp.sh Tue Sep 29 21:25:59 2009(r197624) +++ head/usr.sbin/lpr/lp/lp.sh Tue Sep 29 21:28:32 2009(r197625) @@ -70,7 +70,7 @@ do s) # (silent option) : ;; t) # title for banner page - title=-J${OPTARG};; + title=${OPTARG};; *) # (error msg printed by getopts) exit 2;; esac @@ -78,4 +78,4 @@ done shift $(($OPTIND - 1)) -exec /usr/bin/lpr -P${dest} ${symlink} ${ncopies} ${mailafter} ${title} $@ +exec /usr/bin/lpr -P${dest} ${symlink} ${ncopies} ${mailafter} ${title:+-J${title}} $@ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197691 - in head: bin/sh tools/regression/bin/sh/errors
Author: jilles Date: Thu Oct 1 21:40:08 2009 New Revision: 197691 URL: http://svn.freebsd.org/changeset/base/197691 Log: sh: Disallow mismatched quotes in backticks (`...`). Due to the amount of code removed by this, it seems that allowing unmatched quotes was a deliberate imitation of System V sh and real ksh. Most other shells do not allow unmatched quotes (e.g. bash, zsh, pdksh, NetBSD /bin/sh, dash). PR: bin/137657 Added: head/tools/regression/bin/sh/errors/backquote-error2.0 (contents, props changed) Modified: head/bin/sh/parser.c Modified: head/bin/sh/parser.c == --- head/bin/sh/parser.cThu Oct 1 21:14:40 2009(r197690) +++ head/bin/sh/parser.cThu Oct 1 21:40:08 2009(r197691) @@ -82,7 +82,6 @@ struct heredoc { STATIC struct heredoc *heredoclist;/* list of here documents to read */ -STATIC int parsebackquote; /* nonzero if we are inside backquotes */ STATIC int doprompt; /* if set, prompt the user */ STATIC int needprompt; /* true if interactive and at start of line */ STATIC int lasttoken; /* last token read */ @@ -1043,7 +1042,7 @@ readtoken1(int firstc, char const *synta endword: if (syntax == ARISYNTAX) synerror(Missing '))'); - if (syntax != BASESYNTAX ! parsebackquote eofmark == NULL) + if (syntax != BASESYNTAX eofmark == NULL) synerror(Unterminated quoted string); if (varnest != 0) { startlinno = plinno; @@ -1303,7 +1302,6 @@ parsesub: { parsebackq: { struct nodelist **nlpp; - int savepbq; union node *n; char *volatile str; struct jmploc jmploc; @@ -1311,11 +1309,9 @@ parsebackq: { int savelen; int saveprompt; - savepbq = parsebackquote; if (setjmp(jmploc.loc)) { if (str) ckfree(str); - parsebackquote = 0; handler = savehandler; longjmp(handler-loc, 1); } @@ -1397,7 +1393,6 @@ done: nlpp = (*nlpp)-next; *nlpp = (struct nodelist *)stalloc(sizeof (struct nodelist)); (*nlpp)-next = NULL; - parsebackquote = oldstyle; if (oldstyle) { saveprompt = doprompt; @@ -1433,7 +1428,6 @@ done: str = NULL; INTON; } - parsebackquote = savepbq; handler = savehandler; if (arinest || dblquote) USTPUTC(CTLBACKQ | CTLQUOTE, out); Added: head/tools/regression/bin/sh/errors/backquote-error2.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/errors/backquote-error2.0 Thu Oct 1 21:40:08 2009(r197691) @@ -0,0 +1,7 @@ +# $FreeBSD$ + +sh -c 'echo `echo .BADCODE.` +echo .BADCODE.' 21 | grep -q BADCODE exit 1 +echo '``' | sh -n 2/dev/null exit 1 +echo '`'''`' | sh -n 2/dev/null exit 1 +exit 0 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197748 - stable/7/bin/sh
Author: jilles Date: Sun Oct 4 17:16:11 2009 New Revision: 197748 URL: http://svn.freebsd.org/changeset/base/197748 Log: MFC r197371: Mention that NUL characters are not allowed in sh(1) input. I do not consider this a bug because POSIX permits it and argument strings and environment variables cannot contain '\0' anyway. PR: bin/25542 Modified: stable/7/bin/sh/ (props changed) stable/7/bin/sh/sh.1 Modified: stable/7/bin/sh/sh.1 == --- stable/7/bin/sh/sh.1Sun Oct 4 16:30:33 2009(r197747) +++ stable/7/bin/sh/sh.1Sun Oct 4 17:16:11 2009(r197748) @@ -375,6 +375,10 @@ introduces a comment if used at the begi The word starting with .Ql # and the rest of the line are ignored. +.Pp +.Tn ASCII +.Dv NUL +characters (character code 0) are not allowed in shell input. .Ss Quoting Quoting is used to remove the special meaning of certain characters or words to the shell, such as operators, whitespace, keywords, ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197749 - stable/7/usr.bin/find
Author: jilles Date: Sun Oct 4 17:22:51 2009 New Revision: 197749 URL: http://svn.freebsd.org/changeset/base/197749 Log: MFC r197363: Update find(1) man page for -L/-delete interaction. It is a bit unfortunate that the example to delete broken symlinks now uses rm(1), but allowing this with -delete would require fixing fts(3) to not imply FTS_NOCHDIR if FTS_LOGICAL is given (or hacks in the -delete option). PR: bin/90687 Modified: stable/7/usr.bin/find/ (props changed) stable/7/usr.bin/find/find.1 Modified: stable/7/usr.bin/find/find.1 == --- stable/7/usr.bin/find/find.1Sun Oct 4 17:16:11 2009 (r197748) +++ stable/7/usr.bin/find/find.1Sun Oct 4 17:22:51 2009 (r197749) @@ -306,6 +306,7 @@ character in its pathname relative to .Dq Pa \. for security reasons. Depth-first traversal processing is implied by this option. +Following symlinks is incompatible with this option. .It Ic -depth Always true; same as the @@ -843,7 +844,7 @@ recent than the current time minus one m Use the .Xr echo 1 command to print out a list of all the files. -.It Li find -L /usr/ports/packages -type l -delete +.It Li find -L /usr/ports/packages -type l -exec rm -- {} + Delete all broken symbolic links in .Pa /usr/ports/packages . .It Li find /usr/src -name CVS -prune -o -depth +6 -print ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197815 - in stable/8/usr.sbin/lpr: . lp
Author: jilles Date: Tue Oct 6 21:23:49 2009 New Revision: 197815 URL: http://svn.freebsd.org/changeset/base/197815 Log: MFC r197625: Fix using lp(1) without the new -t option after r194171. Approved by: re (kib) Modified: stable/8/usr.sbin/lpr/ (props changed) stable/8/usr.sbin/lpr/lp/lp.sh Modified: stable/8/usr.sbin/lpr/lp/lp.sh == --- stable/8/usr.sbin/lpr/lp/lp.sh Tue Oct 6 20:35:41 2009 (r197814) +++ stable/8/usr.sbin/lpr/lp/lp.sh Tue Oct 6 21:23:49 2009 (r197815) @@ -70,7 +70,7 @@ do s) # (silent option) : ;; t) # title for banner page - title=-J${OPTARG};; + title=${OPTARG};; *) # (error msg printed by getopts) exit 2;; esac @@ -78,4 +78,4 @@ done shift $(($OPTIND - 1)) -exec /usr/bin/lpr -P${dest} ${symlink} ${ncopies} ${mailafter} ${title} $@ +exec /usr/bin/lpr -P${dest} ${symlink} ${ncopies} ${mailafter} ${title:+-J${title}} $@ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197819 - in stable/7/usr.sbin/lpr: . lp
Author: jilles Date: Tue Oct 6 21:49:13 2009 New Revision: 197819 URL: http://svn.freebsd.org/changeset/base/197819 Log: MFC r197625: Fix using lp(1) without the new -t option after r195349. Modified: stable/7/usr.sbin/lpr/ (props changed) stable/7/usr.sbin/lpr/lp/lp.sh Modified: stable/7/usr.sbin/lpr/lp/lp.sh == --- stable/7/usr.sbin/lpr/lp/lp.sh Tue Oct 6 21:46:03 2009 (r197818) +++ stable/7/usr.sbin/lpr/lp/lp.sh Tue Oct 6 21:49:13 2009 (r197819) @@ -70,7 +70,7 @@ do s) # (silent option) : ;; t) # title for banner page - title=-J${OPTARG};; + title=${OPTARG};; *) # (error msg printed by getopts) exit 2;; esac @@ -78,4 +78,4 @@ done shift $(($OPTIND - 1)) -exec /usr/bin/lpr -P${dest} ${symlink} ${ncopies} ${mailafter} ${title} $@ +exec /usr/bin/lpr -P${dest} ${symlink} ${ncopies} ${mailafter} ${title:+-J${title}} $@ ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197820 - in head: bin/sh tools/regression/bin/sh/execution
Author: jilles Date: Tue Oct 6 22:00:14 2009 New Revision: 197820 URL: http://svn.freebsd.org/changeset/base/197820 Log: sh: Send the xyz: not found message to redirected fd 2. This also fixes that trying to execute a non-regular file with a command name without '/' returns 127 instead of 126. The fix is rather simplistic: treat CMDUNKNOWN as if the command were found as an external program. The resulting fork is a bit wasteful but executing unknown commands should not be very frequent. PR: bin/137659 Added: head/tools/regression/bin/sh/execution/unknown1.0 (contents, props changed) Modified: head/bin/sh/eval.c head/bin/sh/exec.c Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Tue Oct 6 21:49:13 2009(r197819) +++ head/bin/sh/eval.c Tue Oct 6 22:00:14 2009(r197820) @@ -713,12 +713,7 @@ evalcommand(union node *cmd, int flags, do_clearcmdentry = 1; } - find_command(argv[0], cmdentry, 1, path); - if (cmdentry.cmdtype == CMDUNKNOWN) { /* command not found */ - exitstatus = 127; - flushout(errout); - return; - } + find_command(argv[0], cmdentry, 0, path); /* implement the bltin builtin here */ if (cmdentry.cmdtype == CMDBUILTIN cmdentry.u.index == BLTINCMD) { for (;;) { @@ -740,7 +735,7 @@ evalcommand(union node *cmd, int flags, /* Fork off a child process if necessary. */ if (cmd-ncmd.backgnd -|| (cmdentry.cmdtype == CMDNORMAL +|| ((cmdentry.cmdtype == CMDNORMAL || cmdentry.cmdtype == CMDUNKNOWN) ((flags EV_EXIT) == 0 || have_traps())) || ((flags EV_BACKCMD) != 0 (cmdentry.cmdtype != CMDBUILTIN Modified: head/bin/sh/exec.c == --- head/bin/sh/exec.c Tue Oct 6 21:49:13 2009(r197819) +++ head/bin/sh/exec.c Tue Oct 6 22:00:14 2009(r197820) @@ -429,6 +429,7 @@ loop: outfmt(out2, %s: %s\n, name, strerror(e)); } entry-cmdtype = CMDUNKNOWN; + entry-u.index = 0; return; success: Added: head/tools/regression/bin/sh/execution/unknown1.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/execution/unknown1.0 Tue Oct 6 22:00:14 2009(r197820) @@ -0,0 +1,29 @@ +# $FreeBSD$ + +nosuchtool 2/dev/null +[ $? -ne 127 ] exit 1 +/var/empty/nosuchtool 2/dev/null +[ $? -ne 127 ] exit 1 +(nosuchtool) 2/dev/null +[ $? -ne 127 ] exit 1 +(/var/empty/nosuchtool) 2/dev/null +[ $? -ne 127 ] exit 1 +/ 2/dev/null +[ $? -ne 126 ] exit 1 +PATH=/usr bin 2/dev/null +[ $? -ne 126 ] exit 1 + +dummy=$(nosuchtool 2/dev/null) +[ $? -ne 127 ] exit 1 +dummy=$(/var/empty/nosuchtool 2/dev/null) +[ $? -ne 127 ] exit 1 +dummy=$( (nosuchtool) 2/dev/null) +[ $? -ne 127 ] exit 1 +dummy=$( (/var/empty/nosuchtool) 2/dev/null) +[ $? -ne 127 ] exit 1 +dummy=$(/ 2/dev/null) +[ $? -ne 126 ] exit 1 +dummy=$(PATH=/usr bin 2/dev/null) +[ $? -ne 126 ] exit 1 + +exit 0 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197848 - head/bin/sh
Author: jilles Date: Wed Oct 7 22:21:53 2009 New Revision: 197848 URL: http://svn.freebsd.org/changeset/base/197848 Log: Clarify quoting of word in ${v=word} in sh(1). Modified: head/bin/sh/sh.1 Modified: head/bin/sh/sh.1 == --- head/bin/sh/sh.1Wed Oct 7 21:14:45 2009(r197847) +++ head/bin/sh/sh.1Wed Oct 7 22:21:53 2009(r197848) @@ -1227,6 +1227,9 @@ In all cases, the final value of .Ar parameter is substituted. +Quoting inside +.Ar word +does not prevent field splitting or pathname expansion. Only variables, not positional parameters or special parameters, can be assigned in this way. ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r197959 - in stable/8: bin/sh tools/regression/bin/sh tools/regression/bin/sh/execution
Author: jilles Date: Sun Oct 11 16:35:12 2009 New Revision: 197959 URL: http://svn.freebsd.org/changeset/base/197959 Log: MFC r196483,r196634: sh: Fix crash when undefining or redefining a currently executing function Add a reference count to function definitions. Memory may leak if a SIGINT arrives in interactive mode at exactly the wrong time, this will be fixed later by changing SIGINT handling. PR: bin/137640 Approved by: re (kib) Added: stable/8/tools/regression/bin/sh/execution/func1.0 - copied unchanged from r196483, head/tools/regression/bin/sh/execution/func1.0 stable/8/tools/regression/bin/sh/execution/func2.0 - copied unchanged from r196634, head/tools/regression/bin/sh/execution/func2.0 Modified: stable/8/bin/sh/ (props changed) stable/8/bin/sh/eval.c stable/8/bin/sh/exec.c stable/8/bin/sh/exec.h stable/8/bin/sh/mknodes.c stable/8/bin/sh/nodes.c.pat stable/8/tools/regression/bin/sh/ (props changed) Modified: stable/8/bin/sh/eval.c == --- stable/8/bin/sh/eval.c Sun Oct 11 16:23:11 2009(r197958) +++ stable/8/bin/sh/eval.c Sun Oct 11 16:35:12 2009(r197959) @@ -785,6 +785,7 @@ evalcommand(union node *cmd, int flags, INTOFF; savelocalvars = localvars; localvars = NULL; + reffunc(cmdentry.u.func); INTON; savehandler = handler; if (setjmp(jmploc.loc)) { @@ -794,6 +795,7 @@ evalcommand(union node *cmd, int flags, freeparam(shellparam); shellparam = saveparam; } + unreffunc(cmdentry.u.func); poplocalvars(); localvars = savelocalvars; handler = savehandler; @@ -805,11 +807,12 @@ evalcommand(union node *cmd, int flags, funcnest++; exitstatus = oexitstatus; if (flags EV_TESTED) - evaltree(cmdentry.u.func, EV_TESTED); + evaltree(getfuncnode(cmdentry.u.func), EV_TESTED); else - evaltree(cmdentry.u.func, 0); + evaltree(getfuncnode(cmdentry.u.func), 0); funcnest--; INTOFF; + unreffunc(cmdentry.u.func); poplocalvars(); localvars = savelocalvars; freeparam(shellparam); Modified: stable/8/bin/sh/exec.c == --- stable/8/bin/sh/exec.c Sun Oct 11 16:23:11 2009(r197958) +++ stable/8/bin/sh/exec.c Sun Oct 11 16:35:12 2009(r197959) @@ -286,7 +286,7 @@ printentry(struct tblentry *cmdp, int ve out1fmt(function %s, cmdp-cmdname); if (verbose) { INTOFF; - name = commandtext(cmdp-param.func); + name = commandtext(getfuncnode(cmdp-param.func)); out1c(' '); out1str(name); ckfree(name); @@ -583,7 +583,7 @@ deletefuncs(void) while ((cmdp = *pp) != NULL) { if (cmdp-cmdtype == CMDFUNCTION) { *pp = cmdp-next; - freefunc(cmdp-param.func); + unreffunc(cmdp-param.func); ckfree(cmdp); } else { pp = cmdp-next; @@ -670,7 +670,7 @@ addcmdentry(char *name, struct cmdentry INTOFF; cmdp = cmdlookup(name, 1); if (cmdp-cmdtype == CMDFUNCTION) { - freefunc(cmdp-param.func); + unreffunc(cmdp-param.func); } cmdp-cmdtype = entry-cmdtype; cmdp-param = entry-u; @@ -705,7 +705,7 @@ unsetfunc(char *name) struct tblentry *cmdp; if ((cmdp = cmdlookup(name, 0)) != NULL cmdp-cmdtype == CMDFUNCTION) { - freefunc(cmdp-param.func); + unreffunc(cmdp-param.func); delete_cmd_entry(); return (0); } Modified: stable/8/bin/sh/exec.h == --- stable/8/bin/sh/exec.h Sun Oct 11 16:23:11 2009(r197958) +++ stable/8/bin/sh/exec.h Sun Oct 11 16:35:12 2009(r197959) @@ -46,11 +46,12 @@ enum { TYPECMD_TYPE/* type */ }; +union node; struct cmdentry { int cmdtype; union param { int index; - union node *func; + struct funcdef *func; } u; int special; }; Modified: stable/8/bin/sh/mknodes.c
svn commit: r197968 - in head/lib: libc/include libc/sys libthr libthr/thread
Author: jilles Date: Sun Oct 11 20:19:45 2009 New Revision: 197968 URL: http://svn.freebsd.org/changeset/base/197968 Log: Make openat(2) a cancellation point. This is required by POSIX and matches open(2). Reviewed by: kib, jhb MFC after:1 month Modified: head/lib/libc/include/namespace.h head/lib/libc/include/un-namespace.h head/lib/libc/sys/Symbol.map head/lib/libthr/pthread.map head/lib/libthr/thread/thr_private.h head/lib/libthr/thread/thr_syscalls.c Modified: head/lib/libc/include/namespace.h == --- head/lib/libc/include/namespace.h Sun Oct 11 18:21:55 2009 (r197967) +++ head/lib/libc/include/namespace.h Sun Oct 11 20:19:45 2009 (r197968) @@ -80,6 +80,7 @@ #definelisten _listen #definenanosleep _nanosleep #defineopen_open +#defineopenat _openat #definepoll_poll #definepthread_atfork _pthread_atfork #definepthread_attr_destroy_pthread_attr_destroy Modified: head/lib/libc/include/un-namespace.h == --- head/lib/libc/include/un-namespace.hSun Oct 11 18:21:55 2009 (r197967) +++ head/lib/libc/include/un-namespace.hSun Oct 11 20:19:45 2009 (r197968) @@ -61,6 +61,7 @@ #undef listen #undef nanosleep #undef open +#undef openat #undef poll #undef pthread_atfork #undef pthread_attr_destroy Modified: head/lib/libc/sys/Symbol.map == --- head/lib/libc/sys/Symbol.mapSun Oct 11 18:21:55 2009 (r197967) +++ head/lib/libc/sys/Symbol.mapSun Oct 11 20:19:45 2009 (r197968) @@ -769,6 +769,8 @@ FBSDprivate_1.0 { __sys_olio_listio; _open; __sys_open; + _openat; + __sys_openat; _pathconf; __sys_pathconf; _pipe; Modified: head/lib/libthr/pthread.map == --- head/lib/libthr/pthread.map Sun Oct 11 18:21:55 2009(r197967) +++ head/lib/libthr/pthread.map Sun Oct 11 20:19:45 2009(r197968) @@ -195,6 +195,7 @@ FBSDprivate_1.0 { __msync; __nanosleep; __open; + __openat; __poll; __pthread_cond_timedwait; __pthread_cond_wait; @@ -406,3 +407,7 @@ FBSD_1.1 { pthread_mutex_setspinloops_np; pthread_mutex_setyieldloops_np; }; + +FBSD_1.2 { + openat; +}; Modified: head/lib/libthr/thread/thr_private.h == --- head/lib/libthr/thread/thr_private.hSun Oct 11 18:21:55 2009 (r197967) +++ head/lib/libthr/thread/thr_private.hSun Oct 11 20:19:45 2009 (r197968) @@ -668,6 +668,7 @@ void_pthread_cleanup_pop(int); #ifdef _SYS_FCNTL_H_ int __sys_fcntl(int, int, ...); int __sys_open(const char *, int, ...); +int __sys_openat(int, const char *, int, ...); #endif /* #include signal.h */ Modified: head/lib/libthr/thread/thr_syscalls.c == --- head/lib/libthr/thread/thr_syscalls.c Sun Oct 11 18:21:55 2009 (r197967) +++ head/lib/libthr/thread/thr_syscalls.c Sun Oct 11 20:19:45 2009 (r197968) @@ -139,6 +139,7 @@ int __fsync(int); int__msync(void *, size_t, int); int__nanosleep(const struct timespec *, struct timespec *); int__open(const char *, int,...); +int__openat(int, const char *, int,...); int__poll(struct pollfd *, unsigned int, int); ssize_t__read(int, void *buf, size_t); ssize_t__readv(int, const struct iovec *, int); @@ -341,6 +342,33 @@ __open(const char *path, int flags,...) return ret; } +__weak_reference(__openat, openat); + +int +__openat(int fd, const char *path, int flags, ...) +{ + struct pthread *curthread = _get_curthread(); + int ret; + int mode = 0; + va_list ap; + + _thr_cancel_enter(curthread); + + /* Check if the file is being created: */ + if (flags O_CREAT) { + /* Get the creation mode: */ + va_start(ap, flags); + mode = va_arg(ap, int); + va_end(ap); + } + + ret = __sys_openat(fd, path, flags, mode); + + _thr_cancel_leave(curthread); + + return ret; +} + __weak_reference(__poll, poll); int ___ svn-src-all@freebsd.org mailing list
svn commit: r198053 - head/lib/libc/gen
Author: jilles Date: Tue Oct 13 20:58:22 2009 New Revision: 198053 URL: http://svn.freebsd.org/changeset/base/198053 Log: Make getcwd(3) faster, simpler and more compliant using *at syscalls. It is no longer necessary to construct long paths consisting of repeated ../ which may be slow to process and may exceed PATH_MAX. Modified: head/lib/libc/gen/getcwd.c Modified: head/lib/libc/gen/getcwd.c == --- head/lib/libc/gen/getcwd.c Tue Oct 13 20:48:05 2009(r198052) +++ head/lib/libc/gen/getcwd.c Tue Oct 13 20:58:22 2009(r198053) @@ -62,13 +62,14 @@ getcwd(pt, size) dev_t dev; ino_t ino; int first; - char *bpt, *bup; + char *bpt; struct stat s; dev_t root_dev; ino_t root_ino; - size_t ptsize, upsize; + size_t ptsize; int save_errno; - char *ept, *eup, *up, c; + char *ept, c; + int fd; /* * If no buffer specified by the user, allocate one as necessary. @@ -106,18 +107,6 @@ getcwd(pt, size) bpt = ept - 1; *bpt = '\0'; - /* -* Allocate 1024 bytes for the string of ../'s. -* Should always be enough. If it's not, allocate -* as necessary. Special case the first stat, it's ., not ... -*/ - if ((up = malloc(upsize = 1024)) == NULL) - goto err; - eup = up + upsize; - bup = up; - up[0] = '.'; - up[1] = '\0'; - /* Save root values, so know when to stop. */ if (stat(/, s)) goto err; @@ -128,7 +117,7 @@ getcwd(pt, size) for (first = 1;; first = 0) { /* Stat the current level. */ - if (lstat(up, s)) + if (dir != NULL ? _fstat(dirfd(dir), s) : lstat(., s)) goto err; /* Save current node values. */ @@ -144,32 +133,22 @@ getcwd(pt, size) * been that way and stuff would probably break. */ bcopy(bpt, pt, ept - bpt); - free(up); + if (dir) + (void) closedir(dir); return (pt); } - /* -* Build pointer to the parent directory, allocating memory -* as necessary. Max length is 3 for ../, the largest -* possible component name, plus a trailing NUL. -*/ - while (bup + 3 + MAXNAMLEN + 1 = eup) { - if ((up = reallocf(up, upsize *= 2)) == NULL) - goto err; - bup = up; - eup = up + upsize; - } - *bup++ = '.'; - *bup++ = '.'; - *bup = '\0'; - /* Open and stat parent directory. */ - if (!(dir = opendir(up)) || _fstat(dirfd(dir), s)) + fd = _openat(dir != NULL ? dirfd(dir) : AT_FDCWD, + .., O_RDONLY); + if (fd == -1) goto err; - - /* Add trailing slash for next directory. */ - *bup++ = '/'; - *bup = '\0'; + if (dir) + (void) closedir(dir); + if (!(dir = fdopendir(fd)) || _fstat(dirfd(dir), s)) { + _close(fd); + goto err; + } /* * If it's a mount point, have to stat each element because @@ -190,10 +169,10 @@ getcwd(pt, size) goto notfound; if (ISDOT(dp)) continue; - bcopy(dp-d_name, bup, dp-d_namlen + 1); /* Save the first error for later. */ - if (lstat(up, s)) { + if (fstatat(dirfd(dir), dp-d_name, s, + AT_SYMLINK_NOFOLLOW)) { if (!save_errno) save_errno = errno; errno = 0; @@ -227,11 +206,6 @@ getcwd(pt, size) *--bpt = '/'; bpt -= dp-d_namlen; bcopy(dp-d_name, bpt, dp-d_namlen); - (void) closedir(dir); - dir = NULL; - - /* Truncate any file name. */ - *bup = '\0'; } notfound: @@ -250,7 +224,6 @@ err: free(pt); if (dir) (void) closedir(dir); - free(up); errno = save_errno; return (NULL); ___ svn-src-all@freebsd.org mailing list
svn commit: r198056 - head/bin/ls
Author: jilles Date: Tue Oct 13 21:51:50 2009 New Revision: 198056 URL: http://svn.freebsd.org/changeset/base/198056 Log: ls: Make -p not inhibit following symlinks. According to the man page, when neither -H/-L nor -F/-d/-l are given, -H is implied. This agrees with POSIX, GNU ls and Solaris ls. This means that -p, although it is very similar to -F, does not prevent the implicit following of symlinks. PR: standards/128546 Modified: head/bin/ls/ls.c Modified: head/bin/ls/ls.c == --- head/bin/ls/ls.cTue Oct 13 21:28:51 2009(r198055) +++ head/bin/ls/ls.cTue Oct 13 21:51:50 2009(r198056) @@ -399,7 +399,7 @@ main(int argc, char *argv[]) * If not -F, -d or -l options, follow any symbolic links listed on * the command line. */ - if (!f_longform !f_listdir !f_type) + if (!f_longform !f_listdir (!f_type || f_slash)) fts_options |= FTS_COMFOLLOW; /* ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r198173 - head/bin/sh
Author: jilles Date: Fri Oct 16 16:17:57 2009 New Revision: 198173 URL: http://svn.freebsd.org/changeset/base/198173 Log: sh: Show more information about syntax errors in command substitution: the line number where the command substitution started. This applies to both the $() and `` forms but is most useful for `` because the other line number is relative to the enclosed text there. (For older versions, -v can be used as a workaround.) Modified: head/bin/sh/parser.c Modified: head/bin/sh/parser.c == --- head/bin/sh/parser.cFri Oct 16 12:42:02 2009(r198172) +++ head/bin/sh/parser.cFri Oct 16 16:17:57 2009(r198173) @@ -1308,11 +1308,16 @@ parsebackq: { struct jmploc *const savehandler = handler; int savelen; int saveprompt; + const int bq_startlinno = plinno; if (setjmp(jmploc.loc)) { if (str) ckfree(str); handler = savehandler; + if (exception == EXERROR) { + startlinno = bq_startlinno; + synerror(Error in command substitution); + } longjmp(handler-loc, 1); } INTOFF; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r198406 - in head: lib/libc/gen tools/regression/lib/libc/gen
Author: jilles Date: Fri Oct 23 14:50:11 2009 New Revision: 198406 URL: http://svn.freebsd.org/changeset/base/198406 Log: wordexp(3): fix some bugs with signals and long outputs * retry various system calls on EINTR * retry the rest after a short read (common if there is more than about 1K of output) * block SIGCHLD like system(3) does (note that this does not and cannot work fully in threaded programs, they will need to be careful with wait functions) PR: 90580 MFC after:1 month Modified: head/lib/libc/gen/wordexp.c head/tools/regression/lib/libc/gen/test-wordexp.c Modified: head/lib/libc/gen/wordexp.c == --- head/lib/libc/gen/wordexp.c Fri Oct 23 14:43:17 2009(r198405) +++ head/lib/libc/gen/wordexp.c Fri Oct 23 14:50:11 2009(r198406) @@ -28,8 +28,10 @@ #include sys/cdefs.h #include sys/types.h #include sys/wait.h +#include errno.h #include fcntl.h #include paths.h +#include signal.h #include stdio.h #include stdlib.h #include string.h @@ -73,6 +75,24 @@ wordexp(const char * __restrict words, w return (0); } +static size_t +we_read_fully(int fd, char *buffer, size_t len) +{ + size_t done; + ssize_t nread; + + done = 0; + do { + nread = _read(fd, buffer + done, len - done); + if (nread == -1 errno == EINTR) + continue; + if (nread = 0) + break; + done += nread; + } while (done != len); + return done; +} + /* * we_askshell -- * Use the `wordexp' /bin/sh builtin function to do most of the work @@ -90,20 +110,31 @@ we_askshell(const char *words, wordexp_t size_t sofs;/* Offset into we-we_strings */ size_t vofs;/* Offset into we-we_wordv */ pid_t pid; /* Process ID of child */ + pid_t wpid; /* waitpid return value */ int status; /* Child exit status */ + int error; /* Our return value */ + int serrno; /* errno to return */ char *ifs; /* IFS env. var. */ char *np, *p; /* Handy pointers */ char *nstrings; /* Temporary for realloc() */ char **nwv; /* Temporary for realloc() */ + sigset_t newsigblock, oldsigblock; + serrno = errno; if ((ifs = getenv(IFS)) == NULL) ifs = \t\n; if (pipe(pdes) 0) return (WRDE_NOSPACE); /* XXX */ + (void)sigemptyset(newsigblock); + (void)sigaddset(newsigblock, SIGCHLD); + (void)_sigprocmask(SIG_BLOCK, newsigblock, oldsigblock); if ((pid = fork()) 0) { + serrno = errno; _close(pdes[0]); _close(pdes[1]); + (void)_sigprocmask(SIG_SETMASK, oldsigblock, NULL); + errno = serrno; return (WRDE_NOSPACE); /* XXX */ } else if (pid == 0) { @@ -114,6 +145,7 @@ we_askshell(const char *words, wordexp_t int devnull; char *cmd; + (void)_sigprocmask(SIG_SETMASK, oldsigblock, NULL); _close(pdes[0]); if (_dup2(pdes[1], STDOUT_FILENO) 0) _exit(1); @@ -139,10 +171,11 @@ we_askshell(const char *words, wordexp_t * the expanded words separated by nulls. */ _close(pdes[1]); - if (_read(pdes[0], wbuf, 8) != 8 || _read(pdes[0], bbuf, 8) != 8) { - _close(pdes[0]); - _waitpid(pid, status, 0); - return (flags WRDE_UNDEF ? WRDE_BADVAL : WRDE_SYNTAX); + if (we_read_fully(pdes[0], wbuf, 8) != 8 || + we_read_fully(pdes[0], bbuf, 8) != 8) { + error = flags WRDE_UNDEF ? WRDE_BADVAL : WRDE_SYNTAX; + serrno = errno; + goto cleanup; } wbuf[8] = bbuf[8] = '\0'; nwords = strtol(wbuf, NULL, 16); @@ -162,33 +195,38 @@ we_askshell(const char *words, wordexp_t if ((nwv = realloc(we-we_wordv, (we-we_wordc + 1 + (flags WRDE_DOOFFS ? we-we_offs : 0)) * sizeof(char *))) == NULL) { - _close(pdes[0]); - _waitpid(pid, status, 0); - return (WRDE_NOSPACE); + error = WRDE_NOSPACE; + goto cleanup; } we-we_wordv = nwv; if ((nstrings = realloc(we-we_strings, we-we_nbytes)) == NULL) { - _close(pdes[0]); - _waitpid(pid, status, 0); - return (WRDE_NOSPACE); + error = WRDE_NOSPACE; + goto cleanup; } for (i = 0; i vofs; i++) if (we-we_wordv[i] != NULL)
svn commit: r198453 - head/tools/regression/bin/sh/expansion
Author: jilles Date: Sat Oct 24 20:57:11 2009 New Revision: 198453 URL: http://svn.freebsd.org/changeset/base/198453 Log: Add some tests for ${var?} and set -u. Added: head/tools/regression/bin/sh/expansion/question1.0 (contents, props changed) head/tools/regression/bin/sh/expansion/set-u1.0 (contents, props changed) Added: head/tools/regression/bin/sh/expansion/question1.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/expansion/question1.0 Sat Oct 24 20:57:11 2009(r198453) @@ -0,0 +1,22 @@ +# $FreeBSD$ + +x=a\ b +[ $x = ${x?} ] || exit 1 +set -- ${x?} +{ [ $# = 2 ] [ $1 = a ] [ $2 = b ]; } || exit 1 +unset x +(echo ${x?abcdefg}) 21 | grep -q abcdefg || exit 1 +sh -c 'unset foo; echo ${foo?}' 2/dev/null exit 1 +sh -c 'foo=; echo ${foo:?}' 2/dev/null exit 1 +sh -c 'foo=; echo ${foo?}' /dev/null || exit 1 +sh -c 'foo=1; echo ${foo:?}' /dev/null || exit 1 +sh -c 'echo ${!?}' 2/dev/null exit 1 +sh -c ': echo ${!?}' /dev/null || exit 1 +sh -c 'echo ${#?}' /dev/null || exit 1 +sh -c 'echo ${*?}' 2/dev/null exit 1 +sh -c 'echo ${*?}' sh x /dev/null || exit 1 +sh -c 'echo ${1?}' 2/dev/null exit 1 +sh -c 'echo ${1?}' sh x /dev/null || exit 1 +sh -c 'echo ${2?}' sh x 2/dev/null exit 1 +sh -c 'echo ${2?}' sh x y /dev/null || exit 1 +exit 0 Added: head/tools/regression/bin/sh/expansion/set-u1.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/expansion/set-u1.0 Sat Oct 24 20:57:11 2009(r198453) @@ -0,0 +1,29 @@ +# $FreeBSD$ + +sh -uc 'unset foo; echo $foo' 2/dev/null exit 1 +sh -uc 'foo=; echo $foo' /dev/null || exit 1 +sh -uc 'foo=1; echo $foo' /dev/null || exit 1 +# -/+/= are unaffected by set -u +sh -uc 'unset foo; echo ${foo-}' /dev/null || exit 1 +sh -uc 'unset foo; echo ${foo+}' /dev/null || exit 1 +sh -uc 'unset foo; echo ${foo=}' /dev/null || exit 1 +# length/trimming are affected +sh -uc 'unset foo; echo ${#foo}' 2/dev/null exit 1 +sh -uc 'foo=; echo ${#foo}' /dev/null || exit 1 +sh -uc 'unset foo; echo ${foo#?}' 2/dev/null exit 1 +sh -uc 'foo=1; echo ${foo#?}' /dev/null || exit 1 +sh -uc 'unset foo; echo ${foo##?}' 2/dev/null exit 1 +sh -uc 'foo=1; echo ${foo##?}' /dev/null || exit 1 +sh -uc 'unset foo; echo ${foo%?}' 2/dev/null exit 1 +sh -uc 'foo=1; echo ${foo%?}' /dev/null || exit 1 +sh -uc 'unset foo; echo ${foo%%?}' 2/dev/null exit 1 +sh -uc 'foo=1; echo ${foo%%?}' /dev/null || exit 1 + +sh -uc 'echo $!' 2/dev/null exit 1 +sh -uc ': echo $!' /dev/null || exit 1 +sh -uc 'echo $#' /dev/null || exit 1 +sh -uc 'echo $1' 2/dev/null exit 1 +sh -uc 'echo $1' sh x /dev/null || exit 1 +sh -uc 'echo $2' sh x 2/dev/null exit 1 +sh -uc 'echo $2' sh x y /dev/null || exit 1 +exit 0 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r198454 - in head: bin/sh tools/regression/bin/sh/expansion
Author: jilles Date: Sat Oct 24 21:20:04 2009 New Revision: 198454 URL: http://svn.freebsd.org/changeset/base/198454 Log: sh: Exempt $@ and $* from set -u This seems more useful and will likely be in the next POSIX standard. Also document more precisely in the man page what set -u does (note that $@, $* and $! are the only special parameters that can ever be unset, all the others are always set, although they may be empty). Added: head/tools/regression/bin/sh/expansion/set-u2.0 (contents, props changed) Modified: head/bin/sh/expand.c head/bin/sh/sh.1 Modified: head/bin/sh/expand.c == --- head/bin/sh/expand.cSat Oct 24 20:57:11 2009(r198453) +++ head/bin/sh/expand.cSat Oct 24 21:20:04 2009(r198454) @@ -657,7 +657,7 @@ again: /* jump here after setting a vari } varlen = 0; startloc = expdest - stackblock(); - if (!set uflag) { + if (!set uflag *var != '@' *var != '*') { switch (subtype) { case VSNORMAL: case VSTRIMLEFT: Modified: head/bin/sh/sh.1 == --- head/bin/sh/sh.1Sat Oct 24 20:57:11 2009(r198453) +++ head/bin/sh/sh.1Sat Oct 24 21:20:04 2009(r198454) @@ -32,7 +32,7 @@ .\from: @(#)sh.1 8.6 (Berkeley) 5/4/95 .\ $FreeBSD$ .\ -.Dd May 31, 2009 +.Dd October 24, 2009 .Dt SH 1 .Os .Sh NAME @@ -296,7 +296,10 @@ sh -T -c trap 'exit 1' 2 ; some-blockin .Ed .It Fl u Li nounset Write a message to standard error when attempting -to expand a variable that is not set, and if the +to expand a variable, a positional parameter or +the special parameter +.Va \! +that is not set, and if the shell is not interactive, exit immediately. .It Fl V Li vi Enable the built-in Added: head/tools/regression/bin/sh/expansion/set-u2.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/expansion/set-u2.0 Sat Oct 24 21:20:04 2009(r198454) @@ -0,0 +1,12 @@ +# $FreeBSD$ + +set -u +: $* $@ $@ $* +set -- x +: $* $@ $@ $* +shift $# +: $* $@ $@ $* +set -- y +set -- +: $* $@ $@ $* +exit 0 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r198624 - stable/8/bin/sh
Author: jilles Date: Thu Oct 29 21:13:57 2009 New Revision: 198624 URL: http://svn.freebsd.org/changeset/base/198624 Log: MFC r197371: Mention that NUL characters are not allowed in sh(1) input. I do not consider this a bug because POSIX permits it and argument strings and environment variables cannot contain '\0' anyway. PR: bin/25542 Modified: stable/8/bin/sh/ (props changed) stable/8/bin/sh/sh.1 Modified: stable/8/bin/sh/sh.1 == --- stable/8/bin/sh/sh.1Thu Oct 29 20:53:26 2009(r198623) +++ stable/8/bin/sh/sh.1Thu Oct 29 21:13:57 2009(r198624) @@ -375,6 +375,10 @@ introduces a comment if used at the begi The word starting with .Ql # and the rest of the line are ignored. +.Pp +.Tn ASCII +.Dv NUL +characters (character code 0) are not allowed in shell input. .Ss Quoting Quoting is used to remove the special meaning of certain characters or words to the shell, such as operators, whitespace, keywords, ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r198628 - stable/8/usr.bin/find
Author: jilles Date: Thu Oct 29 21:25:16 2009 New Revision: 198628 URL: http://svn.freebsd.org/changeset/base/198628 Log: MFC r197363: Update find(1) man page for -L/-delete interaction. It is a bit unfortunate that the example to delete broken symlinks now uses rm(1), but allowing this with -delete would require fixing fts(3) to not imply FTS_NOCHDIR if FTS_LOGICAL is given (or hacks in the -delete option). PR: bin/90687 Modified: stable/8/usr.bin/find/ (props changed) stable/8/usr.bin/find/find.1 Modified: stable/8/usr.bin/find/find.1 == --- stable/8/usr.bin/find/find.1Thu Oct 29 21:23:44 2009 (r198627) +++ stable/8/usr.bin/find/find.1Thu Oct 29 21:25:16 2009 (r198628) @@ -312,6 +312,7 @@ character in its pathname relative to .Dq Pa \. for security reasons. Depth-first traversal processing is implied by this option. +Following symlinks is incompatible with this option. .It Ic -depth Always true; same as the @@ -920,7 +921,7 @@ recent than the current time minus one m Use the .Xr echo 1 command to print out a list of all the files. -.It Li find -L /usr/ports/packages -type l -delete +.It Li find -L /usr/ports/packages -type l -exec rm -- {} + Delete all broken symbolic links in .Pa /usr/ports/packages . .It Li find /usr/src -name CVS -prune -o -depth +6 -print ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r198963 - head/bin/sh
Author: jilles Date: Thu Nov 5 20:44:39 2009 New Revision: 198963 URL: http://svn.freebsd.org/changeset/base/198963 Log: sh: Fix memory leak when using a variable in arithmetic like $((x)). MFC after:3 weeks Modified: head/bin/sh/arith_lex.l Modified: head/bin/sh/arith_lex.l == --- head/bin/sh/arith_lex.l Thu Nov 5 19:55:42 2009(r198962) +++ head/bin/sh/arith_lex.l Thu Nov 5 20:44:39 2009(r198963) @@ -51,6 +51,13 @@ __FBSDID($FreeBSD$); int yylex(void); +struct varname +{ + struct varname *next; + char name[1]; +}; +static struct varname *varnames; + #undef YY_INPUT #define YY_INPUT(buf,result,max) \ result = (*buf = *arith_buf++) ? 1 : YY_NULL; @@ -80,11 +87,14 @@ int yylex(void); * If variable doesn't exist, we should initialize * it to zero. */ - char *temp; + struct varname *temp; if (lookupvar(yytext) == NULL) setvarsafe(yytext, 0, 0); - temp = (char *)ckmalloc(strlen(yytext) + 1); - yylval.s_value = strcpy(temp, yytext); + temp = ckmalloc(sizeof(struct varname) + + strlen(yytext)); + temp-next = varnames; + varnames = temp; + yylval.s_value = strcpy(temp-name, yytext); return ARITH_VAR; } @@ -130,5 +140,15 @@ int yylex(void); void arith_lex_reset(void) { + struct varname *name, *next; + YY_NEW_FILE; + + name = varnames; + while (name != NULL) { + next = name-next; + ckfree(name); + name = next; + } + varnames = NULL; } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r199205 - head/bin/sh
Author: jilles Date: Wed Nov 11 23:13:24 2009 New Revision: 199205 URL: http://svn.freebsd.org/changeset/base/199205 Log: sh: Use sigaction instead of signal/siginterrupt combination. Modified: head/bin/sh/trap.c Modified: head/bin/sh/trap.c == --- head/bin/sh/trap.c Wed Nov 11 22:37:17 2009(r199204) +++ head/bin/sh/trap.c Wed Nov 11 23:13:24 2009(r199205) @@ -244,7 +244,8 @@ void setsignal(int signo) { int action; - sig_t sig, sigact = SIG_DFL; + sig_t sigact = SIG_DFL; + struct sigaction sa; char *t; if ((t = trap[signo]) == NULL) @@ -320,9 +321,10 @@ setsignal(int signo) case S_IGN: sigact = SIG_IGN; break; } *t = action; - sig = signal(signo, sigact); - if (sig != SIG_ERR action == S_CATCH) - siginterrupt(signo, 1); + sa.sa_handler = sigact; + sa.sa_flags = 0; + sigemptyset(sa.sa_mask); + sigaction(signo, sa, NULL); } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r199282 - in head: bin/sh tools/regression/bin/sh/parser
Author: jilles Date: Sat Nov 14 22:08:32 2009 New Revision: 199282 URL: http://svn.freebsd.org/changeset/base/199282 Log: sh: Allow a newline before in in a for command, as required by POSIX. Added: head/tools/regression/bin/sh/parser/for1.0 (contents, props changed) Modified: head/bin/sh/parser.c Modified: head/bin/sh/parser.c == --- head/bin/sh/parser.cSat Nov 14 20:30:42 2009(r199281) +++ head/bin/sh/parser.cSat Nov 14 22:08:32 2009(r199282) @@ -364,7 +364,9 @@ TRACE((expecting DO got %s %s\n, tokna n1 = (union node *)stalloc(sizeof (struct nfor)); n1-type = NFOR; n1-nfor.var = wordtext; - if (readtoken() == TWORD ! quoteflag equal(wordtext, in)) { + while (readtoken() == TNL) + ; + if (lasttoken == TWORD ! quoteflag equal(wordtext, in)) { app = ap; while (readtoken() == TWORD) { n2 = (union node *)stalloc(sizeof (struct narg)); Added: head/tools/regression/bin/sh/parser/for1.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/parser/for1.0 Sat Nov 14 22:08:32 2009 (r199282) @@ -0,0 +1,29 @@ +# $FreeBSD$ + +nl=' +' +list=' a b c' +for s1 in $nl ; do + for s2 in $nl ;; do + for s3 in $nl ; do + r='' + eval for i${s1}in ${list}${s2}do${s3}r=\\$r \$i\; done + [ $r = $list ] || exit 1 + done + done +done +set -- $list +for s2 in $nl ;; do # s2=; is an extension to POSIX + for s3 in $nl ; do + r='' + eval for i${s2}do${s3}r=\\$r \$i\; done + [ $r = $list ] || exit 1 + done +done +for s1 in $nl ; do + for s2 in $nl ;; do + for s3 in $nl ; do + eval for i${s1}in${s2}do${s3}exit 1; done + done + done +done ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r194783 - head/lib/libc/stdtime
On Tue, Nov 17, 2009 at 01:50:32AM +0200, Dmitry Pryanishnikov wrote: Author: edwin Date: Tue Jun 23 22:28:44 2009 New Revision: 194783 URL: http://svn.freebsd.org/changeset/base/194783 Log: Remove duplicate if-statement on gmt_is_set in gmtsub(). MFC after:1 week Modified: head/lib/libc/stdtime/localtime.c This change looks like a (small?) pessimization to me: before it, _MUTEX_LOCK/_MUTEX_UNLOCK pair would be skipped for the case gmt_is_set == TRUE (all invocations except the first one), now it won't. I'm not sure whether this is critical here though... It is certainly less efficient, but the old code was (most likely) wrong. It used an idiom known as double checked locking, which is incorrect in most memory models. The problem is that the store to gmt_is_set may become visible without stores to other memory (gmtptr and what it points to) becoming visible. -- Jilles Tjoelker ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r199458 - in head/bin: . pwait
Author: jilles Date: Tue Nov 17 22:47:20 2009 New Revision: 199458 URL: http://svn.freebsd.org/changeset/base/199458 Log: Add pwait utility, which waits for any process to terminate. This is similar to the Solaris utility of the same name. Some use cases: * rc.subr's wait_for_pids * interactive use, e.g. to shut down the computer when some task is done even if the task is already running Discussed on: hackers@ Added: head/bin/pwait/ head/bin/pwait/Makefile (contents, props changed) head/bin/pwait/pwait.1 (contents, props changed) head/bin/pwait/pwait.c (contents, props changed) Modified: head/bin/Makefile Modified: head/bin/Makefile == --- head/bin/Makefile Tue Nov 17 21:56:12 2009(r199457) +++ head/bin/Makefile Tue Nov 17 22:47:20 2009(r199458) @@ -27,6 +27,7 @@ SUBDIR= cat \ pax \ pkill \ ps \ + pwait \ pwd \ ${_rcp} \ realpath \ Added: head/bin/pwait/Makefile == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/pwait/Makefile Tue Nov 17 22:47:20 2009(r199458) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +PROG= pwait + +.include bsd.prog.mk Added: head/bin/pwait/pwait.1 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/pwait/pwait.1 Tue Nov 17 22:47:20 2009(r199458) @@ -0,0 +1,78 @@ +.\ +.\ Copyright (c) 2004-2009, Jilles Tjoelker +.\ All rights reserved. +.\ +.\ Redistribution and use in source and binary forms, with +.\ or without modification, are permitted provided that the +.\ following conditions are met: +.\ +.\ 1. Redistributions of source code must retain the above +.\copyright notice, this list of conditions and the +.\following disclaimer. +.\ 2. Redistributions in binary form must reproduce the +.\above copyright notice, this list of conditions and +.\the following disclaimer in the documentation and/or +.\other materials provided with the distribution. +.\ +.\ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +.\ CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED +.\ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +.\ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +.\ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +.\ COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY +.\ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +.\ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +.\ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +.\ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +.\ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +.\ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY +.\ OF SUCH DAMAGE. +.\ +.\ $FreeBSD$ +.\ +.Dd November 1, 2009 +.Os +.Dt PWAIT 1 +.Sh NAME +.Nm pwait +.Nd wait for processes to terminate +.Sh SYNOPSIS +.Nm +.Op Fl v +.Ar pid +\... +.Sh DESCRIPTION +The +.Nm +utility will wait until each of the given processes has terminated. +.Pp +The following option is available: +.Bl -tag -width indent +.It Fl v +Print the exit status when each process terminates. +.El +.Sh DIAGNOSTICS +.Pp +The +.Nm +utility returns 0 on success, and 0 if an error occurs. +.Pp +Invalid pids elicit a warning message but are otherwise ignored. +.Sh SEE ALSO +.Xr kill 1 , +.Xr pkill 1 , +.Xr ps 1 , +.Xr wait 1 , +.Xr kqueue 2 +.Sh NOTES +.Nm +is not a substitute for the +.Xr wait 1 +builtin +as it will not clean up any zombies or state in the parent process. +.Sh HISTORY +A +.Nm +command first appeared in SunOS 5.8. Added: head/bin/pwait/pwait.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/bin/pwait/pwait.c Tue Nov 17 22:47:20 2009(r199458) @@ -0,0 +1,145 @@ +/*- + * Copyright (c) 2004-2009, Jilles Tjoelker + * All rights reserved. + * + * Redistribution and use in source and binary forms, with + * or without modification, are permitted provided that the + * following conditions are met: + * + * 1. Redistributions of source code must retain the above + *copyright notice, this list of conditions and the + *following disclaimer. + * 2. Redistributions in binary form must reproduce the + *above copyright notice, this list of conditions and + *the following disclaimer in the documentation and/or + *other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS
svn commit: r206473 - head/bin/sh
Author: jilles Date: Sun Apr 11 12:24:47 2010 New Revision: 206473 URL: http://svn.freebsd.org/changeset/base/206473 Log: sh: Partially revert r206146, allowing double-quotes in arithmetic. These do pretty much nothing (except that parentheses are ignored), but people seem to use them and allowing them does not hurt much. Single-quotes seem not to be used and cause silently different behaviour with ksh93 character constants. Modified: head/bin/sh/mksyntax.c head/bin/sh/parser.c Modified: head/bin/sh/mksyntax.c == --- head/bin/sh/mksyntax.c Sun Apr 11 12:07:03 2010(r206472) +++ head/bin/sh/mksyntax.c Sun Apr 11 12:24:47 2010(r206473) @@ -232,6 +232,7 @@ main(int argc __unused, char **argv __un add(\n, CNL); add(\\, CBACK); add(`, CBQUOTE); + add(\, CDQUOTE); add($, CVAR); add(}, CENDVAR); add((, CLP); Modified: head/bin/sh/parser.c == --- head/bin/sh/parser.cSun Apr 11 12:07:03 2010(r206472) +++ head/bin/sh/parser.cSun Apr 11 12:24:47 2010(r206473) @@ -1223,7 +1223,10 @@ readtoken1(int firstc, char const *initi if (eofmark != NULL newvarnest == 0) USTPUTC(c, out); else { - state[level].syntax = BASESYNTAX; + if (state[level].category == TSTATE_ARITH) + state[level].syntax = ARISYNTAX; + else + state[level].syntax = BASESYNTAX; quotef++; } break; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r206491 - head/tools/regression/bin/sh/parameters
Author: jilles Date: Sun Apr 11 20:21:34 2010 New Revision: 206491 URL: http://svn.freebsd.org/changeset/base/206491 Log: sh: Test that bogus values of PWD are not imported from the environment. Current versions pass this test trivially by never importing PWD, but I plan to change sh to import PWD if it is an absolute pathname for the current directory, possibly containing symlinks. Added: head/tools/regression/bin/sh/parameters/pwd1.0 (contents, props changed) Added: head/tools/regression/bin/sh/parameters/pwd1.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/parameters/pwd1.0 Sun Apr 11 20:21:34 2010(r206491) @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Check that bogus PWD values are not accepted from the environment. + +cd / || exit 3 +failures=0 +[ $(PWD=foo sh -c 'pwd') = / ] || : $((failures += 1)) +[ $(PWD=/var/empty sh -c 'pwd') = / ] || : $((failures += 1)) +[ $(PWD=/var/empty/foo sh -c 'pwd') = / ] || : $((failures += 1)) +[ $(PWD=/bin/ls sh -c 'pwd') = / ] || : $((failures += 1)) + +exit $((failures != 0)) ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r206710 - head/tools/regression/lib/libc/gen
Author: jilles Date: Fri Apr 16 22:15:26 2010 New Revision: 206710 URL: http://svn.freebsd.org/changeset/base/206710 Log: Add some tests for fnmatch(3). MFC after:1 week Added: head/tools/regression/lib/libc/gen/test-fnmatch.c (contents, props changed) Modified: head/tools/regression/lib/libc/gen/Makefile Modified: head/tools/regression/lib/libc/gen/Makefile == --- head/tools/regression/lib/libc/gen/Makefile Fri Apr 16 20:07:24 2010 (r206709) +++ head/tools/regression/lib/libc/gen/Makefile Fri Apr 16 22:15:26 2010 (r206710) @@ -1,6 +1,6 @@ # $FreeBSD$ -TESTS= test-fmtcheck test-fpclassify test-wordexp +TESTS= test-fmtcheck test-fnmatch test-fpclassify test-wordexp .PHONY: tests tests: ${TESTS} Added: head/tools/regression/lib/libc/gen/test-fnmatch.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/lib/libc/gen/test-fnmatch.c Fri Apr 16 22:15:26 2010(r206710) @@ -0,0 +1,335 @@ +/*- + * Copyright (c) 2010 Jilles Tjoelker + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include sys/cdefs.h +__FBSDID($FreeBSD$); + +#include errno.h +#include stdio.h +#include stdlib.h +#include string.h +#include fnmatch.h + +struct testcase { + const char *pattern; + const char *string; + int flags; + int result; +} testcases[] = { + , , 0, 0, + a, a, 0, 0, + a, b, 0, FNM_NOMATCH, + a, A, 0, FNM_NOMATCH, + *, a, 0, 0, + *, aa, 0, 0, + *a, a, 0, 0, + *a, b, 0, FNM_NOMATCH, + *a*, b, 0, FNM_NOMATCH, + *a*b*, ab, 0, 0, + *a*b*, qaqbq, 0, 0, + *a*bb*, qaqbqbbq, 0, 0, + *a*bc*, qaqbqbcq, 0, 0, + *a*bb*, qaqbqbb, 0, 0, + *a*bc*, qaqbqbc, 0, 0, + *a*bb, qaqbqbb, 0, 0, + *a*bc, qaqbqbc, 0, 0, + *a*bb, qaqbqbbq, 0, FNM_NOMATCH, + *a*bc, qaqbqbcq, 0, FNM_NOMATCH, + *a*a*a*a*a*a*a*a*a*a*, a, 0, FNM_NOMATCH, + *a*a*a*a*a*a*a*a*a*a*, aa, 0, 0, + *a*a*a*a*a*a*a*a*a*a*, aaa, 0, 0, + .*.*.*.*.*.*.*.*.*.*, ., 0, FNM_NOMATCH, + .*.*.*.*.*.*.*.*.*.*, .., 0, 0, + .*.*.*.*.*.*.*.*.*.*, ..., 0, 0, + *?*?*?*?*?*?*?*?*?*?*, 123456789, 0, FNM_NOMATCH, + ??*, 123456789, 0, FNM_NOMATCH, + *??, 123456789, 0, FNM_NOMATCH, + *?*?*?*?*?*?*?*?*?*?*, 1234567890, 0, 0, + ??*, 1234567890, 0, 0, + *??, 1234567890, 0, 0, + *?*?*?*?*?*?*?*?*?*?*, 12345678901, 0, 0, + ??*, 12345678901, 0, 0, + *??, 12345678901, 0, 0, + [x], x, 0, 0, + [*], *, 0, 0, + [?], ?, 0, 0, + [, [, 0, 0, + [[], [, 0, 0, + [[], x, 0, FNM_NOMATCH, + [*], , 0, FNM_NOMATCH, + [*], x, 0, FNM_NOMATCH, + [?], x, 0, FNM_NOMATCH, + *[*]*, foo*foo, 0, 0, + *[*]*, foo, 0, FNM_NOMATCH, + [0-9], 0, 0, 0, + [0-9], 5, 0, 0, + [0-9], 9, 0, 0, + [0-9], /, 0, FNM_NOMATCH, + [0-9], :, 0, FNM_NOMATCH, + [0-9], *, 0, FNM_NOMATCH, + [!0-9], 0, 0, FNM_NOMATCH, + [!0-9], 5, 0, FNM_NOMATCH, + [!0-9], 9, 0, FNM_NOMATCH, + [!0-9], /, 0, 0, + [!0-9], :, 0, 0, + [!0-9], *, 0, 0, + *[0-9], a0, 0, 0, + *[0-9], a5, 0, 0, + *[0-9], a9, 0, 0, + *[0-9], a/, 0, FNM_NOMATCH, + *[0-9], a:, 0, FNM_NOMATCH, + *[0-9], a*, 0, FNM_NOMATCH, + *[!0-9], a0, 0, FNM_NOMATCH, + *[!0-9], a5, 0, FNM_NOMATCH, + *[!0
svn commit: r206711 - in head: lib/libc/gen tools/regression/lib/libc/gen
Author: jilles Date: Fri Apr 16 22:29:24 2010 New Revision: 206711 URL: http://svn.freebsd.org/changeset/base/206711 Log: fnmatch: Fix bad FNM_PERIOD disabling if an asterisk has been seen. Example: fnmatch(a*b/*, abbb/.x, FNM_PATHNAME | FNM_PERIOD) PR: 116074 MFC after:1 week Modified: head/lib/libc/gen/fnmatch.c head/tools/regression/lib/libc/gen/test-fnmatch.c Modified: head/lib/libc/gen/fnmatch.c == --- head/lib/libc/gen/fnmatch.c Fri Apr 16 22:15:26 2010(r206710) +++ head/lib/libc/gen/fnmatch.c Fri Apr 16 22:29:24 2010(r206711) @@ -67,7 +67,8 @@ __FBSDID($FreeBSD$); #define RANGE_ERROR (-1) static int rangematch(const char *, wchar_t, int, char **, mbstate_t *); -static int fnmatch1(const char *, const char *, int, mbstate_t, mbstate_t); +static int fnmatch1(const char *, const char *, const char *, int, mbstate_t, + mbstate_t); int fnmatch(pattern, string, flags) @@ -76,22 +77,21 @@ fnmatch(pattern, string, flags) { static const mbstate_t initial; - return (fnmatch1(pattern, string, flags, initial, initial)); + return (fnmatch1(pattern, string, string, flags, initial, initial)); } static int -fnmatch1(pattern, string, flags, patmbs, strmbs) - const char *pattern, *string; +fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs) + const char *pattern, *string, *stringstart; int flags; mbstate_t patmbs, strmbs; { - const char *stringstart; char *newp; char c; wchar_t pc, sc; size_t pclen, sclen; - for (stringstart = string;;) { + for (;;) { pclen = mbrtowc(pc, pattern, MB_LEN_MAX, patmbs); if (pclen == (size_t)-1 || pclen == (size_t)-2) return (FNM_NOMATCH); @@ -145,8 +145,8 @@ fnmatch1(pattern, string, flags, patmbs, /* General case, use recursion. */ while (sc != EOS) { - if (!fnmatch1(pattern, string, - flags ~FNM_PERIOD, patmbs, strmbs)) + if (!fnmatch1(pattern, string, stringstart, + flags, patmbs, strmbs)) return (0); sclen = mbrtowc(sc, string, MB_LEN_MAX, strmbs); Modified: head/tools/regression/lib/libc/gen/test-fnmatch.c == --- head/tools/regression/lib/libc/gen/test-fnmatch.c Fri Apr 16 22:15:26 2010(r206710) +++ head/tools/regression/lib/libc/gen/test-fnmatch.c Fri Apr 16 22:29:24 2010(r206711) @@ -174,6 +174,7 @@ struct testcase { *a, .a/b, FNM_PATHNAME | FNM_LEADING_DIR, 0, *, .a/b, FNM_PATHNAME | FNM_PERIOD | FNM_LEADING_DIR, FNM_NOMATCH, *a, .a/b, FNM_PATHNAME | FNM_PERIOD | FNM_LEADING_DIR, FNM_NOMATCH, + a*b/*, abbb/.x, FNM_PATHNAME | FNM_PERIOD, FNM_NOMATCH, }; static const char * ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r206759 - in head: bin/sh tools/regression/bin/sh/parameters
Author: jilles Date: Sat Apr 17 14:35:46 2010 New Revision: 206759 URL: http://svn.freebsd.org/changeset/base/206759 Log: sh: On startup of the shell, use PWD from the environment if it is valid. Unset PWD if it is incorrect and no value for it can be determined. This preserves the logical current directory across shell invocations. Example (assuming /home is a symlink): $ cd $ pwd /home/foo $ sh $ pwd /home/foo Formerly the second pwd would show the physical path (symlinks resolved). Added: head/tools/regression/bin/sh/parameters/pwd2.0 (contents, props changed) Modified: head/bin/sh/cd.c head/bin/sh/cd.h head/bin/sh/main.c Modified: head/bin/sh/cd.c == --- head/bin/sh/cd.cSat Apr 17 12:22:44 2010(r206758) +++ head/bin/sh/cd.cSat Apr 17 14:35:46 2010(r206759) @@ -70,6 +70,7 @@ STATIC int docd(char *, int, int); STATIC char *getcomponent(void); STATIC char *findcwd(char *); STATIC void updatepwd(char *); +STATIC char *getpwd(void); STATIC char *getpwd2(void); STATIC char *curdir = NULL;/* current working directory */ @@ -351,7 +352,7 @@ pwdcmd(int argc, char **argv) /* * Get the current directory and cache the result in curdir. */ -char * +STATIC char * getpwd(void) { char *p; @@ -374,7 +375,6 @@ getpwd(void) STATIC char * getpwd2(void) { - struct stat stdot, stpwd; char *pwd; int i; @@ -387,12 +387,29 @@ getpwd2(void) break; } - pwd = getenv(PWD); + return NULL; +} + +/* + * Initialize PWD in a new shell. + * If the shell is interactive, we need to warn if this fails. + */ +void +pwd_init(int warn) +{ + char *pwd; + struct stat stdot, stpwd; + + pwd = lookupvar(PWD); if (pwd *pwd == '/' stat(., stdot) != -1 stat(pwd, stpwd) != -1 stdot.st_dev == stpwd.st_dev stdot.st_ino == stpwd.st_ino) { - return pwd; + if (curdir) + ckfree(curdir); + curdir = savestr(pwd); } - return NULL; + if (getpwd() == NULL warn) + out2fmt_flush(sh: cannot determine working directory\n); + setvar(PWD, curdir, VEXPORT); } Modified: head/bin/sh/cd.h == --- head/bin/sh/cd.hSat Apr 17 12:22:44 2010(r206758) +++ head/bin/sh/cd.hSat Apr 17 14:35:46 2010(r206759) @@ -29,6 +29,6 @@ * $FreeBSD$ */ -char *getpwd(void); +voidpwd_init(int); int cdcmd (int, char **); int pwdcmd(int, char **); Modified: head/bin/sh/main.c == --- head/bin/sh/main.c Sat Apr 17 12:22:44 2010(r206758) +++ head/bin/sh/main.c Sat Apr 17 14:35:46 2010(r206759) @@ -153,10 +153,7 @@ main(int argc, char *argv[]) init(); setstackmark(smark); procargs(argc, argv); - if (getpwd() == NULL iflag) - out2fmt_flush(sh: cannot determine working directory\n); - if (getpwd() != NULL) - setvar (PWD, getpwd(), VEXPORT); + pwd_init(iflag); if (iflag) chkmail(1); if (argv[0] argv[0][0] == '-') { Added: head/tools/regression/bin/sh/parameters/pwd2.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/parameters/pwd2.0 Sat Apr 17 14:35:46 2010(r206759) @@ -0,0 +1,24 @@ +# $FreeBSD$ +# Check that PWD is exported and accepted from the environment. +set -e + +T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XX) +trap 'rm -rf $T' 0 +cd -P $T +TP=$(pwd) +mkdir test1 +ln -s test1 link +cd link +[ $PWD = $TP/link ] +[ $(pwd) = $TP/link ] +[ $(pwd -P) = $TP/test1 ] +[ $(sh -c pwd) = $TP/link ] +[ $(sh -c pwd\ -P) = $TP/test1 ] +cd .. +[ $(pwd) = $TP ] +cd -P link +[ $PWD = $TP/test1 ] +[ $(pwd) = $TP/test1 ] +[ $(pwd -P) = $TP/test1 ] +[ $(sh -c pwd) = $TP/test1 ] +[ $(sh -c pwd\ -P) = $TP/test1 ] ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r206760 - head/lib/libc/gen
Author: jilles Date: Sat Apr 17 15:52:50 2010 New Revision: 206760 URL: http://svn.freebsd.org/changeset/base/206760 Log: getcwd(3): Clarify that EACCES may or may not be checked. POSIX permits but does not require checking access on the current and parent directories. Because various programs do not like it if getcwd(3) fails, it seems best to avoid checking access as much as possible. There are various reports in GNATS about this (search for getcwd). Our getcwd(3) implementation first queries the kernel for the pathname directly, which does not check any permissions but sometimes fails, and then falls back to reading all parent directories for the names. PR: standards/44425 MFC after:2 weeks Modified: head/lib/libc/gen/getcwd.3 Modified: head/lib/libc/gen/getcwd.3 == --- head/lib/libc/gen/getcwd.3 Sat Apr 17 14:35:46 2010(r206759) +++ head/lib/libc/gen/getcwd.3 Sat Apr 17 15:52:50 2010(r206760) @@ -28,7 +28,7 @@ .\ @(#)getcwd.3 8.2 (Berkeley) 12/11/93 .\ $FreeBSD$ .\ -.Dd November 24, 1997 +.Dd April 17, 2010 .Dt GETCWD 3 .Os .Sh NAME @@ -108,8 +108,6 @@ The function will fail if: .Bl -tag -width Er -.It Bq Er EACCES -Read or search permission was denied for a component of the pathname. .It Bq Er EINVAL The .Fa size @@ -124,6 +122,16 @@ The argument is greater than zero but smaller than the length of the pathname plus 1. .El +.Pp +The +.Fn getcwd +function +may fail if: +.Bl -tag -width Er +.It Bq Er EACCES +Read or search permission was denied for a component of the pathname. +This is only checked in limited cases, depending on implementation details. +.El .Sh SEE ALSO .Xr chdir 2 , .Xr fchdir 2 , ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r206773 - head/bin/ln
Author: jilles Date: Sat Apr 17 22:39:53 2010 New Revision: 206773 URL: http://svn.freebsd.org/changeset/base/206773 Log: ln: Refuse deleting a directory entry by hardlinking it to itself. Two pathnames refer to the same directory entry iff the directories match and the final components' names match. Example: (assuming file1 is an existing file) ln -f file1 file1 This now fails while leaving file1 intact. It used to delete file1 and then complain it cannot be linked because it is gone. With -i, this error is detected before the question is asked. MFC after:2 weeks Modified: head/bin/ln/ln.c Modified: head/bin/ln/ln.c == --- head/bin/ln/ln.cSat Apr 17 22:38:16 2010(r206772) +++ head/bin/ln/ln.cSat Apr 17 22:39:53 2010(r206773) @@ -172,6 +172,52 @@ main(int argc, char *argv[]) exit(exitval); } +/* + * Two pathnames refer to the same directory entry if the directories match + * and the final components' names match. + */ +static int +samedirent(const char *path1, const char *path2) +{ + const char *file1, *file2; + char pathbuf[PATH_MAX]; + struct stat sb1, sb2; + + if (strcmp(path1, path2) == 0) + return 1; + file1 = strrchr(path1, '/'); + if (file1 != NULL) + file1++; + else + file1 = path1; + file2 = strrchr(path2, '/'); + if (file2 != NULL) + file2++; + else + file2 = path2; + if (strcmp(file1, file2) != 0) + return 0; + if (file1 - path1 = PATH_MAX || file2 - path2 = PATH_MAX) + return 0; + if (file1 == path1) + memcpy(pathbuf, ., 2); + else { + memcpy(pathbuf, path1, file1 - path1); + pathbuf[file1 - path1] = '\0'; + } + if (stat(pathbuf, sb1) != 0) + return 0; + if (file2 == path2) + memcpy(pathbuf, ., 2); + else { + memcpy(pathbuf, path2, file2 - path2); + pathbuf[file2 - path2] = '\0'; + } + if (stat(pathbuf, sb2) != 0) + return 0; + return sb1.st_dev == sb2.st_dev sb1.st_ino == sb2.st_ino; +} + int linkit(const char *source, const char *target, int isdir) { @@ -215,7 +261,6 @@ linkit(const char *source, const char *t target = path; } - exists = !lstat(target, sb); /* * If the link source doesn't exist, and a symbolic link was * requested, and -w was specified, give a warning. @@ -242,8 +287,20 @@ linkit(const char *source, const char *t warn(warning: %s, source); } } + + /* +* If the file exists, first check it is not the same directory entry. +*/ + exists = !lstat(target, sb); + if (exists) { + if (!sflag samedirent(source, target)) { + warnx(%s and %s are the same directory entry, + source, target); + return (1); + } + } /* -* If the file exists, then unlink it forcibly if -f was specified +* Then unlink it forcibly if -f was specified * and interactively if -i was specified. */ if (fflag exists) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r206817 - head/tools/regression/bin/sh/expansion
Author: jilles Date: Sun Apr 18 22:13:45 2010 New Revision: 206817 URL: http://svn.freebsd.org/changeset/base/206817 Log: sh: Add testcases for double-quotes within quoted ${var+-...} (non-POSIX). POSIX leaves things like ${var+word} undefined. We follow traditional ash behaviour here. Hence, these testcases also work on stable/8. Added: head/tools/regression/bin/sh/expansion/plus-minus3.0 (contents, props changed) Added: head/tools/regression/bin/sh/expansion/plus-minus3.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/expansion/plus-minus3.0Sun Apr 18 22:13:45 2010(r206817) @@ -0,0 +1,44 @@ +# $FreeBSD$ + +e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' +h='##' +failures='' +ok='' + +testcase() { + code=$1 + expected=$2 + oIFS=$IFS + eval $code + IFS='|' + result=$#|$* + IFS=$oIFS + if [ x$result = x$expected ]; then + ok=x$ok + else + failures=x$failures + echo For $code, expected $expected actual $result + fi +} + +# We follow original ash behaviour for quoted ${var+-=?} expansions: +# a double-quote in one switches back to unquoted state. +# This allows expanding a variable as a single word if it is set +# and substituting multiple words otherwise. +# It is also close to the Bourne and Korn shells. +# POSIX leaves this undefined, and various other shells treat +# such double-quotes as introducing a second level of quoting +# which does not do much except quoting close braces. + +testcase 'set -- ${p+/et[c]/}' '1|/etc/' +testcase 'set -- ${p-/et[c]/}' '1|/et[c]/' +testcase 'set -- ${p+$p}' '1|/etc/' +testcase 'set -- ${p-$p}' '1|/et[c]/' +testcase 'set -- ${p+/et[c]/}' '1|/etc/' +testcase 'set -- ${p-/et[c]/}' '1|/et[c]/' +testcase 'set -- ${p+$p}''1|/etc/' +testcase 'set -- ${p-$p}''1|/et[c]/' +testcase 'set -- ${p+\@}' '1|@' +testcase 'set -- ${p+'\''/et[c]/'\''}' '1|/et[c]/' + +test x$failures = x ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r206942 - in stable/8: bin/sh tools/regression/bin/sh/parser
Author: jilles Date: Tue Apr 20 22:20:31 2010 New Revision: 206942 URL: http://svn.freebsd.org/changeset/base/206942 Log: MFC r199282: sh: Allow a newline before in in a for command, as required by POSIX. Added: stable/8/tools/regression/bin/sh/parser/for1.0 - copied unchanged from r199282, head/tools/regression/bin/sh/parser/for1.0 Modified: stable/8/bin/sh/parser.c Directory Properties: stable/8/bin/sh/ (props changed) stable/8/tools/regression/bin/sh/ (props changed) Modified: stable/8/bin/sh/parser.c == --- stable/8/bin/sh/parser.cTue Apr 20 22:15:41 2010(r206941) +++ stable/8/bin/sh/parser.cTue Apr 20 22:20:31 2010(r206942) @@ -365,7 +365,9 @@ TRACE((expecting DO got %s %s\n, tokna n1 = (union node *)stalloc(sizeof (struct nfor)); n1-type = NFOR; n1-nfor.var = wordtext; - if (readtoken() == TWORD ! quoteflag equal(wordtext, in)) { + while (readtoken() == TNL) + ; + if (lasttoken == TWORD ! quoteflag equal(wordtext, in)) { app = ap; while (readtoken() == TWORD) { n2 = (union node *)stalloc(sizeof (struct narg)); Copied: stable/8/tools/regression/bin/sh/parser/for1.0 (from r199282, head/tools/regression/bin/sh/parser/for1.0) == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/parser/for1.0 Tue Apr 20 22:20:31 2010(r206942, copy of r199282, head/tools/regression/bin/sh/parser/for1.0) @@ -0,0 +1,29 @@ +# $FreeBSD$ + +nl=' +' +list=' a b c' +for s1 in $nl ; do + for s2 in $nl ;; do + for s3 in $nl ; do + r='' + eval for i${s1}in ${list}${s2}do${s3}r=\\$r \$i\; done + [ $r = $list ] || exit 1 + done + done +done +set -- $list +for s2 in $nl ;; do # s2=; is an extension to POSIX + for s3 in $nl ; do + r='' + eval for i${s2}do${s3}r=\\$r \$i\; done + [ $r = $list ] || exit 1 + done +done +for s1 in $nl ; do + for s2 in $nl ;; do + for s3 in $nl ; do + eval for i${s1}in${s2}do${s3}exit 1; done + done + done +done ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r206944 - stable/8/bin/sh
Author: jilles Date: Tue Apr 20 22:32:34 2010 New Revision: 206944 URL: http://svn.freebsd.org/changeset/base/206944 Log: MFC r200943: sh: Remove setting variables from dotcmd/exportcmd. It is already done by evalcommand(), unless special-ness has been removed, in which case variable assignments should not persist. (These are currently always special builtins, but this may change later: command builtin, command substitution.) This also fixes a memory leak when calling . with variable assignments. Example: valgrind --leak-check=full sh -c 'x=1 . /dev/null; x=2' Modified: stable/8/bin/sh/main.c stable/8/bin/sh/var.c Directory Properties: stable/8/bin/sh/ (props changed) Modified: stable/8/bin/sh/main.c == --- stable/8/bin/sh/main.c Tue Apr 20 22:24:35 2010(r206943) +++ stable/8/bin/sh/main.c Tue Apr 20 22:32:34 2010(r206944) @@ -315,7 +315,6 @@ find_dot_file(char *basename) int dotcmd(int argc, char **argv) { - struct strlist *sp; char *fullname; if (argc 2) @@ -323,9 +322,6 @@ dotcmd(int argc, char **argv) exitstatus = 0; - for (sp = cmdenviron; sp ; sp = sp-next) - setvareq(savestr(sp-text), VSTRFIXED|VTEXTFIXED); - fullname = find_dot_file(argv[1]); setinputfile(fullname, 1); commandname = fullname; Modified: stable/8/bin/sh/var.c == --- stable/8/bin/sh/var.c Tue Apr 20 22:24:35 2010(r206943) +++ stable/8/bin/sh/var.c Tue Apr 20 22:32:34 2010(r206944) @@ -604,7 +604,6 @@ exportcmd(int argc, char **argv) if (values argc != 0) error(-p requires no arguments); - listsetvar(cmdenviron); if (argc != 0) { while ((name = *argv++) != NULL) { if ((p = strchr(name, '=')) != NULL) { ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r206950 - in stable/8: bin/sh tools/regression/bin/sh/parameters
Author: jilles Date: Tue Apr 20 22:52:28 2010 New Revision: 206950 URL: http://svn.freebsd.org/changeset/base/206950 Log: MFC r203576,r203677: sh: Don't stat() $MAIL/$MAILPATH if not interactive. These may be NFS mounted, and we should not touch them unless we are going to do something useful with the information. Added: stable/8/tools/regression/bin/sh/parameters/mail1.0 - copied unchanged from r203576, head/tools/regression/bin/sh/parameters/mail1.0 stable/8/tools/regression/bin/sh/parameters/mail2.0 - copied, changed from r203576, head/tools/regression/bin/sh/parameters/mail2.0 Modified: stable/8/bin/sh/main.c stable/8/bin/sh/var.c Directory Properties: stable/8/bin/sh/ (props changed) stable/8/tools/regression/bin/sh/ (props changed) Modified: stable/8/bin/sh/main.c == --- stable/8/bin/sh/main.c Tue Apr 20 22:52:13 2010(r206949) +++ stable/8/bin/sh/main.c Tue Apr 20 22:52:28 2010(r206950) @@ -157,6 +157,8 @@ main(int argc, char *argv[]) out2str(sh: cannot determine working directory\n); if (getpwd() != NULL) setvar (PWD, getpwd(), VEXPORT); + if (iflag) + chkmail(1); if (argv[0] argv[0][0] == '-') { state = 1; read_profile(/etc/profile); Modified: stable/8/bin/sh/var.c == --- stable/8/bin/sh/var.c Tue Apr 20 22:52:13 2010(r206949) +++ stable/8/bin/sh/var.c Tue Apr 20 22:52:28 2010(r206950) @@ -335,8 +335,13 @@ setvareq(char *s, int flags) /* * We could roll this to a function, to handle it as * a regular variable function callback, but why bother? +* +* Note: this assumes iflag is not set to 1 initially. +* As part of init(), this is called before arguments +* are looked at. */ - if (vp == vmpath || (vp == vmail ! mpathset())) + if ((vp == vmpath || (vp == vmail ! mpathset())) + iflag == 1) chkmail(1); if ((vp-flags VEXPORT) localevar(s)) { change_env(s, 1); Copied: stable/8/tools/regression/bin/sh/parameters/mail1.0 (from r203576, head/tools/regression/bin/sh/parameters/mail1.0) == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/parameters/mail1.0 Tue Apr 20 22:52:28 2010(r206950, copy of r203576, head/tools/regression/bin/sh/parameters/mail1.0) @@ -0,0 +1,15 @@ +# $FreeBSD$ +# Test that a non-interactive shell does not access $MAIL. + +goodfile=/var/empty/sh-test-goodfile +mailfile=/var/empty/sh-test-mailfile +T=$(mktemp sh-test.XX) || exit +MAIL=$mailfile ktrace -i -f $T sh -c [ -s $goodfile ] 2/dev/null +if ! grep -q $goodfile $T; then + # ktrace problem + rc=0 +elif ! grep -q $mailfile $T; then + rc=0 +fi +rm $T +exit ${rc:-3} Copied and modified: stable/8/tools/regression/bin/sh/parameters/mail2.0 (from r203576, head/tools/regression/bin/sh/parameters/mail2.0) == --- head/tools/regression/bin/sh/parameters/mail2.0 Sat Feb 6 22:57:24 2010(r203576, copy source) +++ stable/8/tools/regression/bin/sh/parameters/mail2.0 Tue Apr 20 22:52:28 2010(r206950) @@ -4,7 +4,7 @@ goodfile=/var/empty/sh-test-goodfile mailfile=/var/empty/sh-test-mailfile T=$(mktemp sh-test.XX) || exit -MAIL=$mailfile ktrace -i -f $T sh +m -i /dev/null /dev/null 21 +ENV=$goodfile MAIL=$mailfile ktrace -i -f $T sh +m -i /dev/null /dev/null 21 if ! grep -q $goodfile $T; then # ktrace problem rc=0 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207021 - head/bin/ln
Author: jilles Date: Wed Apr 21 21:57:03 2010 New Revision: 207021 URL: http://svn.freebsd.org/changeset/base/207021 Log: ln: Allow a trailing slash when creating a link to a directory. In the 'ln source... directory' synopsis, the basename of each source determines the name of the created link. Determine this using basename(3) instead of strrchr(..., '/') which is incorrect if the pathname ends in a slash. The patch is somewhat changed to allow for basename(3) implementations that change the passed pathname, and to fix the -w option's checking also. The code to compare directory entries only applies to hard links, which cannot be created to directories using ln. Example: ln -s /etc/defaults/ /tmp This should create a symlink named defaults. PR: 121568 Submitted by: Ighighi MFC after:1 week Modified: head/bin/ln/ln.c Modified: head/bin/ln/ln.c == --- head/bin/ln/ln.cWed Apr 21 21:51:14 2010(r207020) +++ head/bin/ln/ln.cWed Apr 21 21:57:03 2010(r207021) @@ -47,6 +47,7 @@ __FBSDID($FreeBSD$); #include err.h #include errno.h #include fcntl.h +#include libgen.h #include limits.h #include stdio.h #include stdlib.h @@ -226,6 +227,7 @@ linkit(const char *source, const char *t int ch, exists, first; char path[PATH_MAX]; char wbuf[PATH_MAX]; + char bbuf[PATH_MAX]; if (!sflag) { /* If source doesn't exist, quit now. */ @@ -248,11 +250,9 @@ linkit(const char *source, const char *t if (isdir || (lstat(target, sb) == 0 S_ISDIR(sb.st_mode)) || (!hflag stat(target, sb) == 0 S_ISDIR(sb.st_mode))) { - if ((p = strrchr(source, '/')) == NULL) - p = source; - else - ++p; - if (snprintf(path, sizeof(path), %s/%s, target, p) = + if (strlcpy(bbuf, source, sizeof(bbuf)) = sizeof(bbuf) || + (p = basename(bbuf)) == NULL || + snprintf(path, sizeof(path), %s/%s, target, p) = (ssize_t)sizeof(path)) { errno = ENAMETOOLONG; warn(%s, source); @@ -276,15 +276,14 @@ linkit(const char *source, const char *t * absolute path of the source, by appending `source' * to the parent directory of the target. */ - p = strrchr(target, '/'); - if (p != NULL) - p++; - else - p = target; - (void)snprintf(wbuf, sizeof(wbuf), %.*s%s, - (int)(p - target), target, source); - if (stat(wbuf, sb) != 0) - warn(warning: %s, source); + strlcpy(bbuf, target, sizeof(bbuf)); + p = dirname(bbuf); + if (p != NULL) { + (void)snprintf(wbuf, sizeof(wbuf), %s/%s, + p, source); + if (stat(wbuf, sb) != 0) + warn(warning: %s, source); + } } } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207127 - head/tools/regression/bin/sh/expansion
Author: jilles Date: Fri Apr 23 17:26:49 2010 New Revision: 207127 URL: http://svn.freebsd.org/changeset/base/207127 Log: sh: Add some more tests for ${v#...} and ${v%...}. These pass on stable/8 as well. Added: head/tools/regression/bin/sh/expansion/trim3.0 (contents, props changed) Added: head/tools/regression/bin/sh/expansion/trim3.0 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/expansion/trim3.0 Fri Apr 23 17:26:49 2010(r207127) @@ -0,0 +1,46 @@ +# $FreeBSD$ + +e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' +h='##' c='' +failures='' +ok='' + +testcase() { + code=$1 + expected=$2 + oIFS=$IFS + eval $code + IFS='|' + result=$#|$* + IFS=$oIFS + if [ x$result = x$expected ]; then + ok=x$ok + else + failures=x$failures + echo For $code, expected $expected actual $result + fi +} + +# This doesn't make much sense, but it fails in dash so I'm adding it here: +testcase 'set -- ${w%${w#???}}' '1|a b' + +testcase 'set -- ${p#/et[}''1|c]/' +testcase 'set -- ${p#/et[}' '1|c]/' +testcase 'set -- ${p%${p#}}' '1|/et[' + +testcase 'set -- ${b%'\'}\''}' '1|{{(#)}' + +testcase 'set -- ${c#\\}' '1|\\\' +testcase 'set -- ${c#}''1|\\' +testcase 'set -- ${c#\\}' '1|\' +testcase 'set -- ${c#}''0|' +testcase 'set -- ${c#\\}''1|\\\' +testcase 'set -- ${c#}' '1|\\' +testcase 'set -- ${c#\\}''1|\' +testcase 'set -- ${c#}' '1|' +testcase 'set -- ${c#$c}' '1|' +testcase 'set -- ${c#$c}''0|' +testcase 'set -- ${c%$c}' '1|' +testcase 'set -- ${c%$c}''0|' + +test x$failures = x ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207128 - stable/8/tools/regression/lib/libc/gen
Author: jilles Date: Fri Apr 23 17:52:36 2010 New Revision: 207128 URL: http://svn.freebsd.org/changeset/base/207128 Log: MFC r206710: Add some tests for fnmatch(3). Added: stable/8/tools/regression/lib/libc/gen/test-fnmatch.c - copied unchanged from r206710, head/tools/regression/lib/libc/gen/test-fnmatch.c Modified: stable/8/tools/regression/lib/libc/gen/Makefile Directory Properties: stable/8/tools/regression/lib/libc/ (props changed) Modified: stable/8/tools/regression/lib/libc/gen/Makefile == --- stable/8/tools/regression/lib/libc/gen/Makefile Fri Apr 23 17:26:49 2010(r207127) +++ stable/8/tools/regression/lib/libc/gen/Makefile Fri Apr 23 17:52:36 2010(r207128) @@ -1,6 +1,6 @@ # $FreeBSD$ -TESTS= test-fmtcheck test-fpclassify test-wordexp +TESTS= test-fmtcheck test-fnmatch test-fpclassify test-wordexp .PHONY: tests tests: ${TESTS} Copied: stable/8/tools/regression/lib/libc/gen/test-fnmatch.c (from r206710, head/tools/regression/lib/libc/gen/test-fnmatch.c) == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/lib/libc/gen/test-fnmatch.c Fri Apr 23 17:52:36 2010(r207128, copy of r206710, head/tools/regression/lib/libc/gen/test-fnmatch.c) @@ -0,0 +1,335 @@ +/*- + * Copyright (c) 2010 Jilles Tjoelker + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include sys/cdefs.h +__FBSDID($FreeBSD$); + +#include errno.h +#include stdio.h +#include stdlib.h +#include string.h +#include fnmatch.h + +struct testcase { + const char *pattern; + const char *string; + int flags; + int result; +} testcases[] = { + , , 0, 0, + a, a, 0, 0, + a, b, 0, FNM_NOMATCH, + a, A, 0, FNM_NOMATCH, + *, a, 0, 0, + *, aa, 0, 0, + *a, a, 0, 0, + *a, b, 0, FNM_NOMATCH, + *a*, b, 0, FNM_NOMATCH, + *a*b*, ab, 0, 0, + *a*b*, qaqbq, 0, 0, + *a*bb*, qaqbqbbq, 0, 0, + *a*bc*, qaqbqbcq, 0, 0, + *a*bb*, qaqbqbb, 0, 0, + *a*bc*, qaqbqbc, 0, 0, + *a*bb, qaqbqbb, 0, 0, + *a*bc, qaqbqbc, 0, 0, + *a*bb, qaqbqbbq, 0, FNM_NOMATCH, + *a*bc, qaqbqbcq, 0, FNM_NOMATCH, + *a*a*a*a*a*a*a*a*a*a*, a, 0, FNM_NOMATCH, + *a*a*a*a*a*a*a*a*a*a*, aa, 0, 0, + *a*a*a*a*a*a*a*a*a*a*, aaa, 0, 0, + .*.*.*.*.*.*.*.*.*.*, ., 0, FNM_NOMATCH, + .*.*.*.*.*.*.*.*.*.*, .., 0, 0, + .*.*.*.*.*.*.*.*.*.*, ..., 0, 0, + *?*?*?*?*?*?*?*?*?*?*, 123456789, 0, FNM_NOMATCH, + ??*, 123456789, 0, FNM_NOMATCH, + *??, 123456789, 0, FNM_NOMATCH, + *?*?*?*?*?*?*?*?*?*?*, 1234567890, 0, 0, + ??*, 1234567890, 0, 0, + *??, 1234567890, 0, 0, + *?*?*?*?*?*?*?*?*?*?*, 12345678901, 0, 0, + ??*, 12345678901, 0, 0, + *??, 12345678901, 0, 0, + [x], x, 0, 0, + [*], *, 0, 0, + [?], ?, 0, 0, + [, [, 0, 0, + [[], [, 0, 0, + [[], x, 0, FNM_NOMATCH, + [*], , 0, FNM_NOMATCH, + [*], x, 0, FNM_NOMATCH, + [?], x, 0, FNM_NOMATCH, + *[*]*, foo*foo, 0, 0, + *[*]*, foo, 0, FNM_NOMATCH, + [0-9], 0, 0, 0, + [0-9], 5, 0, 0, + [0-9], 9, 0, 0, + [0-9], /, 0, FNM_NOMATCH, + [0-9], :, 0, FNM_NOMATCH, + [0-9], *, 0, FNM_NOMATCH, + [!0-9], 0, 0, FNM_NOMATCH, + [!0-9], 5, 0, FNM_NOMATCH, + [!0-9], 9, 0, FNM_NOMATCH, + [!0-9], /, 0, 0, + [!0-9
svn commit: r207129 - in stable/8: lib/libc/gen tools/regression/lib/libc/gen
Author: jilles Date: Fri Apr 23 18:01:19 2010 New Revision: 207129 URL: http://svn.freebsd.org/changeset/base/207129 Log: MFC r206711: fnmatch: Fix bad FNM_PERIOD disabling if an asterisk has been seen. Example: fnmatch(a*b/*, abbb/.x, FNM_PATHNAME | FNM_PERIOD) PR: 116074 Modified: stable/8/lib/libc/gen/fnmatch.c stable/8/tools/regression/lib/libc/gen/test-fnmatch.c Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) stable/8/tools/regression/lib/libc/ (props changed) Modified: stable/8/lib/libc/gen/fnmatch.c == --- stable/8/lib/libc/gen/fnmatch.c Fri Apr 23 17:52:36 2010 (r207128) +++ stable/8/lib/libc/gen/fnmatch.c Fri Apr 23 18:01:19 2010 (r207129) @@ -67,7 +67,8 @@ __FBSDID($FreeBSD$); #define RANGE_ERROR (-1) static int rangematch(const char *, wchar_t, int, char **, mbstate_t *); -static int fnmatch1(const char *, const char *, int, mbstate_t, mbstate_t); +static int fnmatch1(const char *, const char *, const char *, int, mbstate_t, + mbstate_t); int fnmatch(pattern, string, flags) @@ -76,22 +77,21 @@ fnmatch(pattern, string, flags) { static const mbstate_t initial; - return (fnmatch1(pattern, string, flags, initial, initial)); + return (fnmatch1(pattern, string, string, flags, initial, initial)); } static int -fnmatch1(pattern, string, flags, patmbs, strmbs) - const char *pattern, *string; +fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs) + const char *pattern, *string, *stringstart; int flags; mbstate_t patmbs, strmbs; { - const char *stringstart; char *newp; char c; wchar_t pc, sc; size_t pclen, sclen; - for (stringstart = string;;) { + for (;;) { pclen = mbrtowc(pc, pattern, MB_LEN_MAX, patmbs); if (pclen == (size_t)-1 || pclen == (size_t)-2) return (FNM_NOMATCH); @@ -145,8 +145,8 @@ fnmatch1(pattern, string, flags, patmbs, /* General case, use recursion. */ while (sc != EOS) { - if (!fnmatch1(pattern, string, - flags ~FNM_PERIOD, patmbs, strmbs)) + if (!fnmatch1(pattern, string, stringstart, + flags, patmbs, strmbs)) return (0); sclen = mbrtowc(sc, string, MB_LEN_MAX, strmbs); Modified: stable/8/tools/regression/lib/libc/gen/test-fnmatch.c == --- stable/8/tools/regression/lib/libc/gen/test-fnmatch.c Fri Apr 23 17:52:36 2010(r207128) +++ stable/8/tools/regression/lib/libc/gen/test-fnmatch.c Fri Apr 23 18:01:19 2010(r207129) @@ -174,6 +174,7 @@ struct testcase { *a, .a/b, FNM_PATHNAME | FNM_LEADING_DIR, 0, *, .a/b, FNM_PATHNAME | FNM_PERIOD | FNM_LEADING_DIR, FNM_NOMATCH, *a, .a/b, FNM_PATHNAME | FNM_PERIOD | FNM_LEADING_DIR, FNM_NOMATCH, + a*b/*, abbb/.x, FNM_PATHNAME | FNM_PERIOD, FNM_NOMATCH, }; static const char * ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207132 - stable/8/bin/sh
Author: jilles Date: Fri Apr 23 19:26:03 2010 New Revision: 207132 URL: http://svn.freebsd.org/changeset/base/207132 Log: MFC r197848: Clarify quoting of word in ${v=word} in sh(1). Modified: stable/8/bin/sh/sh.1 Directory Properties: stable/8/bin/sh/ (props changed) Modified: stable/8/bin/sh/sh.1 == --- stable/8/bin/sh/sh.1Fri Apr 23 19:20:56 2010(r207131) +++ stable/8/bin/sh/sh.1Fri Apr 23 19:26:03 2010(r207132) @@ -1227,6 +1227,9 @@ In all cases, the final value of .Ar parameter is substituted. +Quoting inside +.Ar word +does not prevent field splitting or pathname expansion. Only variables, not positional parameters or special parameters, can be assigned in this way. ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207153 - head/usr.bin/stat
Author: jilles Date: Sat Apr 24 13:53:12 2010 New Revision: 207153 URL: http://svn.freebsd.org/changeset/base/207153 Log: stat: Allow -f %Sf to display the file flags symbolically. I have changed the patch slightly to show '-' if there are no flags just like ls -ldo does. PR: 124349 Submitted by: Ighighi MFC after:1 week Modified: head/usr.bin/stat/stat.1 head/usr.bin/stat/stat.c Modified: head/usr.bin/stat/stat.1 == --- head/usr.bin/stat/stat.1Sat Apr 24 12:49:52 2010(r207152) +++ head/usr.bin/stat/stat.1Sat Apr 24 13:53:12 2010(r207153) @@ -29,7 +29,7 @@ .\ .\ $FreeBSD$ .\ -.Dd April 27, 2007 +.Dd April 24, 2010 .Dt STAT 1 .Os .Sh NAME @@ -232,6 +232,11 @@ Display date in format. .It Cm dr Display actual device name. +.It Cm f +Display the flags of +.Ar file +as in +.Nm ls Fl lTdo . .It Cm gu Display group or user name. .It Cm p Modified: head/usr.bin/stat/stat.c == --- head/usr.bin/stat/stat.cSat Apr 24 12:49:52 2010(r207152) +++ head/usr.bin/stat/stat.cSat Apr 24 13:53:12 2010(r207153) @@ -182,6 +182,9 @@ int format1(const struct stat *,/* stat char *, size_t, /* a place to put the output */ int, int, int, int, /* the parsed format */ int, int); +#if HAVE_STRUCT_STAT_ST_FLAGS +char *xfflagstostr(unsigned long); +#endif char *timefmt; int linkfail; @@ -333,6 +336,25 @@ main(int argc, char *argv[]) return (am_readlink ? linkfail : errs); } +#if HAVE_STRUCT_STAT_ST_FLAGS +/* + * fflagstostr() wrapper that leaks only once + */ +char * +xfflagstostr(unsigned long fflags) +{ + static char *str = NULL; + + if (str != NULL) + free(str); + + str = fflagstostr(fflags); + if (str == NULL) + err(1, fflagstostr); + return (str); +} +#endif /* HAVE_STRUCT_STAT_ST_FLAGS */ + void usage(const char *synopsis) { @@ -725,8 +747,11 @@ format1(const struct stat *st, case SHOW_st_flags: small = (sizeof(st-st_flags) == 4); data = st-st_flags; - sdata = NULL; - formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX; + sdata = xfflagstostr(st-st_flags); + if (*sdata == '\0') + sdata = -; + formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX | + FMTF_STRING; if (ofmt == 0) ofmt = FMTF_UNSIGNED; break; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207166 - head/share/man/man1
Author: jilles Date: Sat Apr 24 22:16:01 2010 New Revision: 207166 URL: http://svn.freebsd.org/changeset/base/207166 Log: builtin(1): Mention [ sh builtin. MFC after:1 week Modified: head/share/man/man1/builtin.1 Modified: head/share/man/man1/builtin.1 == --- head/share/man/man1/builtin.1 Sat Apr 24 22:09:13 2010 (r207165) +++ head/share/man/man1/builtin.1 Sat Apr 24 22:16:01 2010 (r207166) @@ -26,7 +26,7 @@ .\ .\ $FreeBSD$ .\ -.Dd October 14, 2006 +.Dd April 25, 2010 .Dt BUILTIN 1 .Os .Sh NAME @@ -36,6 +36,7 @@ .Nm \. , .Nm \: , .Nm @ , +.Nm \[ , .Nm { , .Nm } , .Nm alias , @@ -200,6 +201,7 @@ but are implemented as scripts using a b .It Ic . Ta \No Ta \No Ta Yes .It Ic : Ta \No Ta Yes Ta Yes .It Ic @ Ta \No Ta Yes Ta Yes +.It Ic \[ Ta Yes Ta \No Ta Yes .It Ic { Ta \No Ta \No Ta Yes .It Ic } Ta \No Ta \No Ta Yes .It Ic alias Ta No** Ta Yes Ta Yes ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207168 - head/share/man/man1
Author: jilles Date: Sat Apr 24 22:24:26 2010 New Revision: 207168 URL: http://svn.freebsd.org/changeset/base/207168 Log: builtin(1): Add missing escaping for !, . and : in the table. This caused these commands to look differently (not bold) from the other commands in the table (bold). MFC after:1 week Modified: head/share/man/man1/builtin.1 Modified: head/share/man/man1/builtin.1 == --- head/share/man/man1/builtin.1 Sat Apr 24 22:23:49 2010 (r207167) +++ head/share/man/man1/builtin.1 Sat Apr 24 22:24:26 2010 (r207168) @@ -196,10 +196,10 @@ but are implemented as scripts using a b .It Xo .Em Command External Ta Xr csh 1 Ta Xr sh 1 .Xc -.It Ic ! Ta \No Ta \No Ta Yes +.It Ic \! Ta \No Ta \No Ta Yes .It Ic % Ta \No Ta Yes Ta \No -.It Ic . Ta \No Ta \No Ta Yes -.It Ic : Ta \No Ta Yes Ta Yes +.It Ic \. Ta \No Ta \No Ta Yes +.It Ic \: Ta \No Ta Yes Ta Yes .It Ic @ Ta \No Ta Yes Ta Yes .It Ic \[ Ta Yes Ta \No Ta Yes .It Ic { Ta \No Ta \No Ta Yes ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207186 - head/lib/libc/gen
Author: jilles Date: Sun Apr 25 12:35:39 2010 New Revision: 207186 URL: http://svn.freebsd.org/changeset/base/207186 Log: sysctl(3): Update description of various kern.* variables. Also add xrefs for confstr(3) (as sysconf(3) but for strings) and kvm(3) (which is a more convenient way to access some of the variables). PR: 116480 MFC after:1 week Modified: head/lib/libc/gen/sysctl.3 Modified: head/lib/libc/gen/sysctl.3 == --- head/lib/libc/gen/sysctl.3 Sun Apr 25 05:09:08 2010(r207185) +++ head/lib/libc/gen/sysctl.3 Sun Apr 25 12:35:39 2010(r207186) @@ -28,7 +28,7 @@ .\@(#)sysctl.38.4 (Berkeley) 5/9/95 .\ $FreeBSD$ .\ -.Dd February 21, 2010 +.Dd April 25, 2010 .Dt SYSCTL 3 .Os .Sh NAME @@ -325,7 +325,7 @@ information. .It KERN_BOOTFILE string yes .It KERN_BOOTTIME struct timeval no .It KERN_CLOCKRATEstruct clockinfono -.It KERN_FILE struct file no +.It KERN_FILE struct xfileno .It KERN_HOSTID integer yes .It KERN_HOSTUUID string yes .It KERN_HOSTNAME string yes @@ -342,14 +342,14 @@ information. .It KERN_OSREVinteger no .It KERN_OSTYPE string no .It KERN_POSIX1 integer no -.It KERN_PROC struct proc no +.It KERN_PROC nodenot applicable .It KERN_PROF nodenot applicable .It KERN_QUANTUM integer yes .It KERN_SAVED_IDSinteger no .It KERN_SECURELVLinteger raise only .It KERN_UPDATEINTERVAL integer no .It KERN_VERSION string no -.It KERN_VNODEstruct vnodeno +.It KERN_VNODEstruct xvnode no .El .Bl -tag -width 6n .It Li KERN_ARGMAX @@ -370,10 +370,8 @@ This structure contains the clock, stati frequencies, the number of micro-seconds per hz tick and the skew rate. .It Li KERN_FILE Return the entire file table. -The returned data consists of a single -.Va struct filehead -followed by an array of -.Va struct file , +The returned data consists of an array of +.Va struct xfile , whose size depends on the current number of such objects in the system. .It Li KERN_HOSTID Get or set the host ID. @@ -525,10 +523,8 @@ Note, the vnode table is not necessarily the system. The returned data consists of an array whose size depends on the current number of such objects in the system. -Each element of the array contains the kernel address of a vnode -.Va struct vnode * -followed by the vnode itself -.Va struct vnode . +Each element of the array consists of a +.Va struct xvnode . .El .Ss CTL_NET The string and integer information available for the CTL_NET level @@ -854,6 +850,8 @@ An attempt is made to set a read-only va A process without appropriate privilege attempts to set a value. .El .Sh SEE ALSO +.Xr confstr 3 , +.Xr kvm 3 , .Xr sysconf 3 , .Xr sysctl 8 .Sh HISTORY ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207187 - head/lib/libkvm
Author: jilles Date: Sun Apr 25 12:50:30 2010 New Revision: 207187 URL: http://svn.freebsd.org/changeset/base/207187 Log: kvm(3): Mention that some of the functions use sysctl(3) instead of kmem. Additionally, because of sysctl(3) use (which is generally good), behaviour for crash dumps differs slightly from behaviour for live kernels and this will probably never be fixed entirely, so weaken that claim. MFC after:1 week Modified: head/lib/libkvm/kvm.3 Modified: head/lib/libkvm/kvm.3 == --- head/lib/libkvm/kvm.3 Sun Apr 25 12:35:39 2010(r207186) +++ head/lib/libkvm/kvm.3 Sun Apr 25 12:50:30 2010(r207187) @@ -32,7 +32,7 @@ .\ @(#)kvm.3 8.1 (Berkeley) 6/4/93 .\ $FreeBSD$ .\ -.Dd January 29, 2004 +.Dd April 25, 2010 .Dt KVM 3 .Os .Sh NAME @@ -46,12 +46,15 @@ The library provides a uniform interface for accessing kernel virtual memory images, including live systems and crash dumps. Access to live systems is via +.Xr sysctl 3 +for some functions, and .Xr mem 4 and .Xr kmem 4 +for other functions, while crash dumps can be examined via the core file generated by .Xr savecore 8 . -The interface behaves identically in both cases. +The interface behaves similarly in both cases. Memory can be read and written, kernel symbol addresses can be looked up efficiently, and information about user processes can be gathered. @@ -112,5 +115,6 @@ given descriptor. .Xr kvm_openfiles 3 , .Xr kvm_read 3 , .Xr kvm_write 3 , +.Xr sysctl 3 , .Xr kmem 4 , .Xr mem 4 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207188 - head/bin/ln
Author: jilles Date: Sun Apr 25 13:13:23 2010 New Revision: 207188 URL: http://svn.freebsd.org/changeset/base/207188 Log: symlink(7): The ownership of symlinks is used by the system, in at least three ways, so do not say it is ignored: * who may delete/rename a symlink in a sticky directory * who may do lchflags(2)/lchown(2)/lchmod(2) * whose inode quota is charged MFC after:1 week Modified: head/bin/ln/symlink.7 Modified: head/bin/ln/symlink.7 == --- head/bin/ln/symlink.7 Sun Apr 25 12:50:30 2010(r207187) +++ head/bin/ln/symlink.7 Sun Apr 25 13:13:23 2010(r207188) @@ -29,7 +29,7 @@ .\@(#)symlink.7 8.3 (Berkeley) 3/31/94 .\ $FreeBSD$ .\ -.Dd March 31, 1994 +.Dd April 25, 2010 .Dt SYMLINK 7 .Os .Sh NAME @@ -138,8 +138,8 @@ an existing symbolic link can be changed and .Xr lutimes 2 system calls, respectively. -Of these, only the flags are used by the system; -the access permissions and ownership are ignored. +Of these, only the flags and ownership are used by the system; +the access permissions are ignored. .Pp The .Bx 4.4 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207189 - head/bin/ln
Author: jilles Date: Sun Apr 25 13:29:59 2010 New Revision: 207189 URL: http://svn.freebsd.org/changeset/base/207189 Log: symlink(7): Add lpathconf(2) and *at system calls. MFC after:1 week Modified: head/bin/ln/symlink.7 Modified: head/bin/ln/symlink.7 == --- head/bin/ln/symlink.7 Sun Apr 25 13:13:23 2010(r207188) +++ head/bin/ln/symlink.7 Sun Apr 25 13:29:59 2010(r207189) @@ -103,19 +103,23 @@ the system call would return a file descriptor to the file .Dq afile . .Pp -There are nine system calls that do not follow links, and which operate +There are thirteen system calls that do not follow links, and which operate on the symbolic link itself. They are: .Xr lchflags 2 , .Xr lchmod 2 , .Xr lchown 2 , +.Xr lpathconf 2 , .Xr lstat 2 , .Xr lutimes 2 , .Xr readlink 2 , +.Xr readlinkat 2 , .Xr rename 2 , +.Xr renameat 2 , .Xr rmdir 2 , +.Xr unlink 2 , and -.Xr unlink 2 . +.Xr unlinkat 2 . Because .Xr remove 3 is an alias for @@ -123,9 +127,30 @@ is an alias for it also does not follow symbolic links. When .Xr rmdir 2 +or +.Xr unlinkat 2 +with the +.Dv AT_REMOVEDIR +flag is applied to a symbolic link, it fails with the error .Er ENOTDIR . .Pp +The +.Xr linkat 2 +system call does not follow symbolic links +unless given the +.Dv AT_SYMLINK_FOLLOW +flag. +.Pp +The following system calls follow symbolic links +unless given the +.Dv AT_SYMLINK_NOFOLLOW +flag: +.Xr fchmodat 2 , +.Xr fchownat 2 +and +.Xr fstatat 2 . +.Pp The owner and group of an existing symbolic link can be changed by means of the .Xr lchown 2 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207190 - head/lib/libc/sys
Author: jilles Date: Sun Apr 25 13:55:52 2010 New Revision: 207190 URL: http://svn.freebsd.org/changeset/base/207190 Log: unlinkat(2): unlinkat(AT_REMOVEDIR) fails with ENOTEMPTY like rmdir() for non-empty directories. POSIX permits both ENOTEMPTY and EEXIST, but we use the clearer ENOTEMPTY, following BSD tradition. MFC after:1 week Modified: head/lib/libc/sys/unlink.2 Modified: head/lib/libc/sys/unlink.2 == --- head/lib/libc/sys/unlink.2 Sun Apr 25 13:29:59 2010(r207189) +++ head/lib/libc/sys/unlink.2 Sun Apr 25 13:55:52 2010(r207190) @@ -28,7 +28,7 @@ .\ @(#)unlink.2 8.1 (Berkeley) 6/4/93 .\ $FreeBSD$ .\ -.Dd April 10, 2008 +.Dd April 25, 2010 .Dt UNLINK 2 .Os .Sh NAME @@ -167,7 +167,7 @@ argument does not specify an absolute pa argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. -.It Bq Er EEXIST +.It Bq Er ENOTEMPTY The .Fa flag parameter has the ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207196 - in head: share/man/man1 usr.bin/alias
Author: jilles Date: Sun Apr 25 17:38:53 2010 New Revision: 207196 URL: http://svn.freebsd.org/changeset/base/207196 Log: Make hash, type and ulimit available via execve(). These are specified by POSIX but are not special builtins, and therefore need to be available via execve() and utilities like time, nohup, xargs. (Note that hash was moved from the XSI option to the base in the 2008 standard.) Like most of the POSIX regular builtin commands, these need to be executed in a shell environment for full functionality, although they may still be of some use outside one. Unlike the POSIX special and regular builtin commands, POSIX does not require these to be found before a PATH search, although that could be an oversight. Like some of the utilities already provided by usr.bin/alias, these may lead to confusing results when invoked from csh(1). Modified: head/share/man/man1/builtin.1 head/usr.bin/alias/Makefile Modified: head/share/man/man1/builtin.1 == --- head/share/man/man1/builtin.1 Sun Apr 25 16:43:41 2010 (r207195) +++ head/share/man/man1/builtin.1 Sun Apr 25 17:38:53 2010 (r207196) @@ -245,7 +245,7 @@ but are implemented as scripts using a b .It Ic getopts Ta No** Ta \No Ta Yes .It Ic glob Ta \No Ta Yes Ta \No .It Ic goto Ta \No Ta Yes Ta \No -.It Ic hash Ta \No Ta \No Ta Yes +.It Ic hash Ta No** Ta \No Ta Yes .It Ic hashstat Ta \No Ta Yes Ta \No .It Ic history Ta \No Ta Yes Ta \No .It Ic hup Ta \No Ta Yes Ta \No @@ -290,8 +290,8 @@ but are implemented as scripts using a b .It Ic times Ta \No Ta \No Ta Yes .It Ic trap Ta \No Ta \No Ta Yes .It Ic true Ta Yes Ta \No Ta Yes -.It Ic type Ta \No Ta \No Ta Yes -.It Ic ulimit Ta \No Ta \No Ta Yes +.It Ic type Ta No** Ta \No Ta Yes +.It Ic ulimit Ta No** Ta \No Ta Yes .It Ic umask Ta No** Ta Yes Ta Yes .It Ic unalias Ta No** Ta Yes Ta Yes .It Ic uncomplete Ta \No Ta Yes Ta \No Modified: head/usr.bin/alias/Makefile == --- head/usr.bin/alias/Makefile Sun Apr 25 16:43:41 2010(r207195) +++ head/usr.bin/alias/Makefile Sun Apr 25 17:38:53 2010(r207196) @@ -10,8 +10,11 @@ LINKS= ${BINDIR}/alias ${BINDIR}/bg \ ${BINDIR}/alias ${BINDIR}/fc \ ${BINDIR}/alias ${BINDIR}/fg \ ${BINDIR}/alias ${BINDIR}/getopts \ + ${BINDIR}/alias ${BINDIR}/hash \ ${BINDIR}/alias ${BINDIR}/jobs \ ${BINDIR}/alias ${BINDIR}/read \ + ${BINDIR}/alias ${BINDIR}/type \ + ${BINDIR}/alias ${BINDIR}/ulimit \ ${BINDIR}/alias ${BINDIR}/umask \ ${BINDIR}/alias ${BINDIR}/unalias \ ${BINDIR}/alias ${BINDIR}/wait ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207206 - head/bin/sh
Author: jilles Date: Sun Apr 25 20:43:19 2010 New Revision: 207206 URL: http://svn.freebsd.org/changeset/base/207206 Log: sh: Use stalloc for arith variable names. This is simpler than the custom memory tracker I added earlier, and is also needed by the dash arith code I plan to import. Modified: head/bin/sh/arith.y head/bin/sh/arith_lex.l head/bin/sh/expand.c Modified: head/bin/sh/arith.y == --- head/bin/sh/arith.y Sun Apr 25 20:40:45 2010(r207205) +++ head/bin/sh/arith.y Sun Apr 25 20:43:19 2010(r207206) @@ -287,7 +287,9 @@ arith_t arith(const char *s) { arith_t result; + struct stackmark smark; + setstackmark(smark); arith_buf = arith_startbuf = s; INTOFF; @@ -295,6 +297,8 @@ arith(const char *s) arith_lex_reset(); /* Reprime lex. */ INTON; + popstackmark(smark); + return result; } Modified: head/bin/sh/arith_lex.l == --- head/bin/sh/arith_lex.l Sun Apr 25 20:40:45 2010(r207205) +++ head/bin/sh/arith_lex.l Sun Apr 25 20:43:19 2010(r207206) @@ -51,13 +51,6 @@ __FBSDID($FreeBSD$); int yylex(void); -struct varname -{ - struct varname *next; - char name[1]; -}; -static struct varname *varnames; - #undef YY_INPUT #define YY_INPUT(buf,result,max) \ result = (*buf = *arith_buf++) ? 1 : YY_NULL; @@ -87,14 +80,11 @@ static struct varname *varnames; * If variable doesn't exist, we should initialize * it to zero. */ - struct varname *temp; + char *temp; if (lookupvar(yytext) == NULL) setvarsafe(yytext, 0, 0); - temp = ckmalloc(sizeof(struct varname) + - strlen(yytext)); - temp-next = varnames; - varnames = temp; - yylval.s_value = strcpy(temp-name, yytext); + temp = stalloc(strlen(yytext) + 1); + yylval.s_value = strcpy(temp, yytext); return ARITH_VAR; } @@ -140,15 +130,5 @@ static struct varname *varnames; void arith_lex_reset(void) { - struct varname *name, *next; - YY_NEW_FILE; - - name = varnames; - while (name != NULL) { - next = name-next; - ckfree(name); - name = next; - } - varnames = NULL; } Modified: head/bin/sh/expand.c == --- head/bin/sh/expand.cSun Apr 25 20:40:45 2010(r207205) +++ head/bin/sh/expand.cSun Apr 25 20:43:19 2010(r207206) @@ -360,7 +360,7 @@ removerecordregions(int endoff) void expari(int flag) { - char *p, *start; + char *p, *q, *start; arith_t result; int begoff; int quotes = flag (EXP_FULL | EXP_CASE | EXP_REDIR); @@ -398,7 +398,9 @@ expari(int flag) removerecordregions(begoff); if (quotes) rmescapes(p+2); + q = grabstackstr(expdest); result = arith(p+2); + ungrabstackstr(q, expdest); fmtstr(p, DIGITS(result), ARITH_FORMAT_STR, result); while (*p++) ; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
Re: svn commit: r207206 - head/bin/sh
On Tue, Apr 27, 2010 at 07:52:25AM +0400, Andrey Chernov wrote: On Sun, Apr 25, 2010 at 08:43:19PM +, Jilles Tjoelker wrote: Author: jilles Date: Sun Apr 25 20:43:19 2010 New Revision: 207206 URL: http://svn.freebsd.org/changeset/base/207206 Log: sh: Use stalloc for arith variable names. This is simpler than the custom memory tracker I added earlier, and is also needed by the dash arith code I plan to import. Just wonder, do you have plans to implement ${!variable} sometimes? This bashism is very useful: VAR_a1=foo x=VAR_a1 echo ${!x} This doesn't do anything you cannot do with eval: eval echo \$$x Furthermore, note that ksh93 and recent versions of mksh have almost the opposite meaning for ${!variable}, for example VAR_a1=foo typeset -n x=VAR_a1 echo $x:${!x} which prints foo:VAR_a1 (Explanation: typeset -n creates a nameref which redirects assignment and expansion to the variable name specified in the initial assignment. ${!X} expands to the name of the variable which is X unless X is a nameref.) We do have the setvar builtin for the reverse operation, inherited from the original ash, but I wouldn't have added this as it is likewise easily done with eval. The list assignment syntax setvar var word1 ... wordN has never been implemented, and I don't think it adds anything above ksh's syntaxes var=(word1 ... wordN) and set -A var word1 ... wordN -- Jilles Tjoelker ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207449 - head/contrib/telnet/telnet
Author: jilles Date: Fri Apr 30 19:52:35 2010 New Revision: 207449 URL: http://svn.freebsd.org/changeset/base/207449 Log: telnet: Fix infinite loop if local output generates SIGPIPE. Instead of catching SIGPIPE and jumping out of the signal handler with longjmp, ignore it and handle write errors to the local output by exiting from there. I have changed the error message to mention the local output instead of NetBSD's wrong Connection closed by foreign host. Write errors to the network were already handled by exiting immediately and this now applies to EPIPE too. The code assumed that SIGPIPE could only be generated by the network connection; if it was generated by the local output, it would longjmp out of the signal handler and write an error message which caused another SIGPIPE. PR: 19773 Obtained from:NetBSD MFC after:1 week Modified: head/contrib/telnet/telnet/commands.c head/contrib/telnet/telnet/externs.h head/contrib/telnet/telnet/network.c head/contrib/telnet/telnet/sys_bsd.c head/contrib/telnet/telnet/telnet.c head/contrib/telnet/telnet/terminal.c Modified: head/contrib/telnet/telnet/commands.c == --- head/contrib/telnet/telnet/commands.c Fri Apr 30 19:40:37 2010 (r207448) +++ head/contrib/telnet/telnet/commands.c Fri Apr 30 19:52:35 2010 (r207449) @@ -2491,8 +2491,7 @@ tn(int argc, char *argv[]) env_export(USER); } (void) call(status, status, notmuch, 0); -if (setjmp(peerdied) == 0) - telnet(user); +telnet(user); (void) NetClose(net); ExitString(Connection closed by foreign host.\n,1); /*NOTREACHED*/ Modified: head/contrib/telnet/telnet/externs.h == --- head/contrib/telnet/telnet/externs.hFri Apr 30 19:40:37 2010 (r207448) +++ head/contrib/telnet/telnet/externs.hFri Apr 30 19:52:35 2010 (r207449) @@ -233,7 +233,6 @@ extern void SetNetTrace(char *); /* Function to change where debugging goes */ extern jmp_buf -peerdied, toplevel; /* For error conditions. */ extern void Modified: head/contrib/telnet/telnet/network.c == --- head/contrib/telnet/telnet/network.cFri Apr 30 19:40:37 2010 (r207448) +++ head/contrib/telnet/telnet/network.cFri Apr 30 19:52:35 2010 (r207449) @@ -158,7 +158,7 @@ netflush(void) perror(hostname); (void)NetClose(net); ring_clear_mark(netoring); - longjmp(peerdied, -1); + ExitString(Connection closed by foreign host.\n, 1); /*NOTREACHED*/ } n = 0; Modified: head/contrib/telnet/telnet/sys_bsd.c == --- head/contrib/telnet/telnet/sys_bsd.cFri Apr 30 19:40:37 2010 (r207448) +++ head/contrib/telnet/telnet/sys_bsd.cFri Apr 30 19:52:35 2010 (r207449) @@ -809,14 +809,6 @@ NetNonblockingIO(int fd, int onoff) */ /* ARGSUSED */ -static SIG_FUNC_RET -deadpeer(int sig __unused) -{ - setcommandmode(); - longjmp(peerdied, -1); -} - -/* ARGSUSED */ SIG_FUNC_RET intr(int sig __unused) { @@ -884,7 +876,7 @@ sys_telnet_init(void) { (void) signal(SIGINT, intr); (void) signal(SIGQUIT, intr2); -(void) signal(SIGPIPE, deadpeer); +(void) signal(SIGPIPE, SIG_IGN); #ifdef SIGWINCH (void) signal(SIGWINCH, sendwin); #endif Modified: head/contrib/telnet/telnet/telnet.c == --- head/contrib/telnet/telnet/telnet.c Fri Apr 30 19:40:37 2010 (r207448) +++ head/contrib/telnet/telnet/telnet.c Fri Apr 30 19:52:35 2010 (r207449) @@ -146,7 +146,6 @@ unsigned char telopt_environ = TELOPT_NE #endif jmp_buftoplevel; -jmp_bufpeerdied; intflushline; intlinemode; Modified: head/contrib/telnet/telnet/terminal.c == --- head/contrib/telnet/telnet/terminal.c Fri Apr 30 19:40:37 2010 (r207448) +++ head/contrib/telnet/telnet/terminal.c Fri Apr 30 19:52:35 2010 (r207449) @@ -111,7 +111,8 @@ init_terminal(void) } /* - * Send as much data as possible to the terminal. + * Send as much data as possible to the terminal, else exits if + * it encounters a permanent failure when writing to the tty. * * Return value: * -1: No useful work done, data waiting to go out. @@ -152,8 +153,19 @@ ttyflush(int drop) } ring_consumed(ttyoring, n); } -if (n 0) +if (n 0) { + if (errno == EAGAIN || errno == EINTR)
svn commit: r207465 - stable/8/bin/ln
Author: jilles Date: Sat May 1 14:33:26 2010 New Revision: 207465 URL: http://svn.freebsd.org/changeset/base/207465 Log: MFC r207021: ln: Allow a trailing slash when creating a link to a directory. In the 'ln source... directory' synopsis, the basename of each source determines the name of the created link. Determine this using basename(3) instead of strrchr(..., '/') which is incorrect if the pathname ends in a slash. PR: 121568 Modified: stable/8/bin/ln/ln.c Directory Properties: stable/8/bin/ln/ (props changed) Modified: stable/8/bin/ln/ln.c == --- stable/8/bin/ln/ln.cSat May 1 14:29:33 2010(r207464) +++ stable/8/bin/ln/ln.cSat May 1 14:33:26 2010(r207465) @@ -47,6 +47,7 @@ __FBSDID($FreeBSD$); #include err.h #include errno.h #include fcntl.h +#include libgen.h #include limits.h #include stdio.h #include stdlib.h @@ -226,6 +227,7 @@ linkit(const char *source, const char *t int ch, exists, first; char path[PATH_MAX]; char wbuf[PATH_MAX]; + char bbuf[PATH_MAX]; if (!sflag) { /* If source doesn't exist, quit now. */ @@ -248,11 +250,9 @@ linkit(const char *source, const char *t if (isdir || (lstat(target, sb) == 0 S_ISDIR(sb.st_mode)) || (!hflag stat(target, sb) == 0 S_ISDIR(sb.st_mode))) { - if ((p = strrchr(source, '/')) == NULL) - p = source; - else - ++p; - if (snprintf(path, sizeof(path), %s/%s, target, p) = + if (strlcpy(bbuf, source, sizeof(bbuf)) = sizeof(bbuf) || + (p = basename(bbuf)) == NULL || + snprintf(path, sizeof(path), %s/%s, target, p) = (ssize_t)sizeof(path)) { errno = ENAMETOOLONG; warn(%s, source); @@ -276,15 +276,14 @@ linkit(const char *source, const char *t * absolute path of the source, by appending `source' * to the parent directory of the target. */ - p = strrchr(target, '/'); - if (p != NULL) - p++; - else - p = target; - (void)snprintf(wbuf, sizeof(wbuf), %.*s%s, - (int)(p - target), target, source); - if (stat(wbuf, sb) != 0) - warn(warning: %s, source); + strlcpy(bbuf, target, sizeof(bbuf)); + p = dirname(bbuf); + if (p != NULL) { + (void)snprintf(wbuf, sizeof(wbuf), %s/%s, + p, source); + if (stat(wbuf, sb) != 0) + warn(warning: %s, source); + } } } ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207466 - stable/8/usr.bin/stat
Author: jilles Date: Sat May 1 14:36:04 2010 New Revision: 207466 URL: http://svn.freebsd.org/changeset/base/207466 Log: MFC r207153: stat: Allow -f %Sf to display the file flags symbolically. PR: 124349 Modified: stable/8/usr.bin/stat/stat.1 stable/8/usr.bin/stat/stat.c Directory Properties: stable/8/usr.bin/stat/ (props changed) Modified: stable/8/usr.bin/stat/stat.1 == --- stable/8/usr.bin/stat/stat.1Sat May 1 14:33:26 2010 (r207465) +++ stable/8/usr.bin/stat/stat.1Sat May 1 14:36:04 2010 (r207466) @@ -36,7 +36,7 @@ .\ .\ $FreeBSD$ .\ -.Dd April 27, 2007 +.Dd April 24, 2010 .Dt STAT 1 .Os .Sh NAME @@ -239,6 +239,11 @@ Display date in format. .It Cm dr Display actual device name. +.It Cm f +Display the flags of +.Ar file +as in +.Nm ls Fl lTdo . .It Cm gu Display group or user name. .It Cm p Modified: stable/8/usr.bin/stat/stat.c == --- stable/8/usr.bin/stat/stat.cSat May 1 14:33:26 2010 (r207465) +++ stable/8/usr.bin/stat/stat.cSat May 1 14:36:04 2010 (r207466) @@ -189,6 +189,9 @@ int format1(const struct stat *,/* stat char *, size_t, /* a place to put the output */ int, int, int, int, /* the parsed format */ int, int); +#if HAVE_STRUCT_STAT_ST_FLAGS +char *xfflagstostr(unsigned long); +#endif char *timefmt; int linkfail; @@ -340,6 +343,25 @@ main(int argc, char *argv[]) return (am_readlink ? linkfail : errs); } +#if HAVE_STRUCT_STAT_ST_FLAGS +/* + * fflagstostr() wrapper that leaks only once + */ +char * +xfflagstostr(unsigned long fflags) +{ + static char *str = NULL; + + if (str != NULL) + free(str); + + str = fflagstostr(fflags); + if (str == NULL) + err(1, fflagstostr); + return (str); +} +#endif /* HAVE_STRUCT_STAT_ST_FLAGS */ + void usage(const char *synopsis) { @@ -732,8 +754,11 @@ format1(const struct stat *st, case SHOW_st_flags: small = (sizeof(st-st_flags) == 4); data = st-st_flags; - sdata = NULL; - formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX; + sdata = xfflagstostr(st-st_flags); + if (*sdata == '\0') + sdata = -; + formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX | + FMTF_STRING; if (ofmt == 0) ofmt = FMTF_UNSIGNED; break; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207467 - stable/8/share/man/man1
Author: jilles Date: Sat May 1 14:41:37 2010 New Revision: 207467 URL: http://svn.freebsd.org/changeset/base/207467 Log: MFC r207166: builtin(1): Mention [ sh builtin. Modified: stable/8/share/man/man1/builtin.1 Directory Properties: stable/8/share/man/man1/ (props changed) Modified: stable/8/share/man/man1/builtin.1 == --- stable/8/share/man/man1/builtin.1 Sat May 1 14:36:04 2010 (r207466) +++ stable/8/share/man/man1/builtin.1 Sat May 1 14:41:37 2010 (r207467) @@ -26,7 +26,7 @@ .\ .\ $FreeBSD$ .\ -.Dd October 14, 2006 +.Dd April 25, 2010 .Dt BUILTIN 1 .Os .Sh NAME @@ -36,6 +36,7 @@ .Nm \. , .Nm \: , .Nm @ , +.Nm \[ , .Nm { , .Nm } , .Nm alias , @@ -200,6 +201,7 @@ but are implemented as scripts using a b .It Ic . Ta \No Ta \No Ta Yes .It Ic : Ta \No Ta Yes Ta Yes .It Ic @ Ta \No Ta Yes Ta Yes +.It Ic \[ Ta Yes Ta \No Ta Yes .It Ic { Ta \No Ta \No Ta Yes .It Ic } Ta \No Ta \No Ta Yes .It Ic alias Ta No** Ta Yes Ta Yes ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207469 - stable/8/share/man/man1
Author: jilles Date: Sat May 1 14:49:20 2010 New Revision: 207469 URL: http://svn.freebsd.org/changeset/base/207469 Log: MFC r207168: builtin(1): Add missing escaping for !, . and : in the table. This caused these commands to look differently (not bold) from the other commands in the table (bold). Modified: stable/8/share/man/man1/builtin.1 Directory Properties: stable/8/share/man/man1/ (props changed) Modified: stable/8/share/man/man1/builtin.1 == --- stable/8/share/man/man1/builtin.1 Sat May 1 14:46:17 2010 (r207468) +++ stable/8/share/man/man1/builtin.1 Sat May 1 14:49:20 2010 (r207469) @@ -196,10 +196,10 @@ but are implemented as scripts using a b .It Xo .Em Command External Ta Xr csh 1 Ta Xr sh 1 .Xc -.It Ic ! Ta \No Ta \No Ta Yes +.It Ic \! Ta \No Ta \No Ta Yes .It Ic % Ta \No Ta Yes Ta \No -.It Ic . Ta \No Ta \No Ta Yes -.It Ic : Ta \No Ta Yes Ta Yes +.It Ic \. Ta \No Ta \No Ta Yes +.It Ic \: Ta \No Ta Yes Ta Yes .It Ic @ Ta \No Ta Yes Ta Yes .It Ic \[ Ta Yes Ta \No Ta Yes .It Ic { Ta \No Ta \No Ta Yes ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207470 - stable/7/share/man/man1
Author: jilles Date: Sat May 1 14:57:35 2010 New Revision: 207470 URL: http://svn.freebsd.org/changeset/base/207470 Log: MFC r207166: builtin(1): Mention [ sh builtin. Modified: stable/7/share/man/man1/builtin.1 Directory Properties: stable/7/share/man/man1/ (props changed) Modified: stable/7/share/man/man1/builtin.1 == --- stable/7/share/man/man1/builtin.1 Sat May 1 14:49:20 2010 (r207469) +++ stable/7/share/man/man1/builtin.1 Sat May 1 14:57:35 2010 (r207470) @@ -26,7 +26,7 @@ .\ .\ $FreeBSD$ .\ -.Dd October 14, 2006 +.Dd April 25, 2010 .Dt BUILTIN 1 .Os .Sh NAME @@ -36,6 +36,7 @@ .Nm \. , .Nm \: , .Nm @ , +.Nm \[ , .Nm { , .Nm } , .Nm alias , @@ -200,6 +201,7 @@ but are implemented as scripts using a b .It Ic . Ta \No Ta \No Ta Yes .It Ic : Ta \No Ta Yes Ta Yes .It Ic @ Ta \No Ta Yes Ta Yes +.It Ic \[ Ta Yes Ta \No Ta Yes .It Ic { Ta \No Ta \No Ta Yes .It Ic } Ta \No Ta \No Ta Yes .It Ic alias Ta No** Ta Yes Ta Yes ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207471 - stable/7/share/man/man1
Author: jilles Date: Sat May 1 15:00:00 2010 New Revision: 207471 URL: http://svn.freebsd.org/changeset/base/207471 Log: MFC r207168: builtin(1): Add missing escaping for !, . and : in the table. This caused these commands to look differently (not bold) from the other commands in the table (bold). Modified: stable/7/share/man/man1/builtin.1 Directory Properties: stable/7/share/man/man1/ (props changed) Modified: stable/7/share/man/man1/builtin.1 == --- stable/7/share/man/man1/builtin.1 Sat May 1 14:57:35 2010 (r207470) +++ stable/7/share/man/man1/builtin.1 Sat May 1 15:00:00 2010 (r207471) @@ -196,10 +196,10 @@ but are implemented as scripts using a b .It Xo .Em Command External Ta Xr csh 1 Ta Xr sh 1 .Xc -.It Ic ! Ta \No Ta \No Ta Yes +.It Ic \! Ta \No Ta \No Ta Yes .It Ic % Ta \No Ta Yes Ta \No -.It Ic . Ta \No Ta \No Ta Yes -.It Ic : Ta \No Ta Yes Ta Yes +.It Ic \. Ta \No Ta \No Ta Yes +.It Ic \: Ta \No Ta Yes Ta Yes .It Ic @ Ta \No Ta Yes Ta Yes .It Ic \[ Ta Yes Ta \No Ta Yes .It Ic { Ta \No Ta \No Ta Yes ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207483 - head/usr.bin/pathchk
Author: jilles Date: Sat May 1 22:00:28 2010 New Revision: 207483 URL: http://svn.freebsd.org/changeset/base/207483 Log: pathchk: Add the new POSIX -P option. This option checks for empty pathnames and components starting with '-'. Our -p option also checks for the latter, which remains the case. MFC after:1 week Modified: head/usr.bin/pathchk/pathchk.1 head/usr.bin/pathchk/pathchk.c Modified: head/usr.bin/pathchk/pathchk.1 == --- head/usr.bin/pathchk/pathchk.1 Sat May 1 21:59:06 2010 (r207482) +++ head/usr.bin/pathchk/pathchk.1 Sat May 1 22:00:28 2010 (r207483) @@ -27,7 +27,7 @@ .\ .\ $FreeBSD$ .\ -.Dd May 21, 2002 +.Dd May 1, 2010 .Dt PATHCHK 1 .Os .Sh NAME @@ -35,7 +35,7 @@ .Nd check pathnames .Sh SYNOPSIS .Nm -.Op Fl p +.Op Fl pP .Ar pathname ... .Sh DESCRIPTION The @@ -95,6 +95,16 @@ No component may start with the hyphen .Pq Ql \- character. .El +.It Fl P +In addition to the default or +.Fl p +checks, write a diagnostic for each argument that: +.Bl -bullet +.It +Is empty. +.It +Contains a component that starts with a hyphen. +.El .El .Sh EXIT STATUS .Ex -std Modified: head/usr.bin/pathchk/pathchk.c == --- head/usr.bin/pathchk/pathchk.c Sat May 1 21:59:06 2010 (r207482) +++ head/usr.bin/pathchk/pathchk.c Sat May 1 22:00:28 2010 (r207483) @@ -51,6 +51,7 @@ static int portable(const char *); static void usage(void); static int pflag; /* Perform portability checks */ +static int Pflag; /* Check for empty paths, leading '-' */ int main(int argc, char *argv[]) @@ -58,11 +59,14 @@ main(int argc, char *argv[]) int ch, rval; const char *arg; - while ((ch = getopt(argc, argv, p)) 0) { + while ((ch = getopt(argc, argv, pP)) 0) { switch (ch) { case 'p': pflag = 1; break; + case 'P': + Pflag = 1; + break; default: usage(); /*NOTREACHED*/ @@ -102,6 +106,15 @@ check(const char *path) p = pathd; + if (Pflag *p == '\0') { + warnx(%s: empty pathname, path); + goto bad; + } + if ((Pflag || pflag) (*p == '-' || strstr(p, /-) != NULL)) { + warnx(%s: contains a component starting with '-', path); + goto bad; + } + if (!pflag) { errno = 0; namemax = pathconf(*p == '/' ? / : ., _PC_NAME_MAX); @@ -182,9 +195,6 @@ portable(const char *path) 0123456789._-; long s; - if (*path == '-') - return (*path); - s = strspn(path, charset); if (path[s] != '\0') return (path[s]); ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207485 - head/usr.bin/pathchk
Author: jilles Date: Sat May 1 22:10:45 2010 New Revision: 207485 URL: http://svn.freebsd.org/changeset/base/207485 Log: pathchk(1): Fix the example so it allows arbitrary pathnames. Spaces and various other characters in pathnames are not passed through literally by xargs in its default mode. Instead, use find . -exec ... {} + Although the -- argument is not strictly required here, add it anyway to avoid surprises when modifying the code to find -f -somedir ... MFC after:1 week Modified: head/usr.bin/pathchk/pathchk.1 Modified: head/usr.bin/pathchk/pathchk.1 == --- head/usr.bin/pathchk/pathchk.1 Sat May 1 22:04:58 2010 (r207484) +++ head/usr.bin/pathchk/pathchk.1 Sat May 1 22:10:45 2010 (r207485) @@ -114,7 +114,7 @@ other .Tn POSIX systems: .Pp -.Dl find . -print | xargs pathchk -p +.Dl find . -exec pathchk -p -- {} + .Sh SEE ALSO .Xr getconf 1 , .Xr pathconf 2 , ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207501 - stable/8/lib/libkvm
Author: jilles Date: Sun May 2 12:38:59 2010 New Revision: 207501 URL: http://svn.freebsd.org/changeset/base/207501 Log: MFC r207187: kvm(3): Mention that some of the functions use sysctl(3) instead of kmem. Additionally, because of sysctl(3) use (which is generally good), behaviour for crash dumps differs slightly from behaviour for live kernels and this will probably never be fixed entirely, so weaken that claim. Modified: stable/8/lib/libkvm/kvm.3 Directory Properties: stable/8/lib/libkvm/ (props changed) Modified: stable/8/lib/libkvm/kvm.3 == --- stable/8/lib/libkvm/kvm.3 Sun May 2 12:08:15 2010(r207500) +++ stable/8/lib/libkvm/kvm.3 Sun May 2 12:38:59 2010(r207501) @@ -32,7 +32,7 @@ .\ @(#)kvm.3 8.1 (Berkeley) 6/4/93 .\ $FreeBSD$ .\ -.Dd January 29, 2004 +.Dd April 25, 2010 .Dt KVM 3 .Os .Sh NAME @@ -46,12 +46,15 @@ The library provides a uniform interface for accessing kernel virtual memory images, including live systems and crash dumps. Access to live systems is via +.Xr sysctl 3 +for some functions, and .Xr mem 4 and .Xr kmem 4 +for other functions, while crash dumps can be examined via the core file generated by .Xr savecore 8 . -The interface behaves identically in both cases. +The interface behaves similarly in both cases. Memory can be read and written, kernel symbol addresses can be looked up efficiently, and information about user processes can be gathered. @@ -112,5 +115,6 @@ given descriptor. .Xr kvm_openfiles 3 , .Xr kvm_read 3 , .Xr kvm_write 3 , +.Xr sysctl 3 , .Xr kmem 4 , .Xr mem 4 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207504 - stable/8/bin/ln
Author: jilles Date: Sun May 2 12:43:18 2010 New Revision: 207504 URL: http://svn.freebsd.org/changeset/base/207504 Log: MFC r207188: symlink(7): The ownership of symlinks is used by the system, in at least three ways, so do not say it is ignored: * who may delete/rename a symlink in a sticky directory * who may do lchflags(2)/lchown(2)/lchmod(2) * whose inode quota is charged Modified: stable/8/bin/ln/symlink.7 Directory Properties: stable/8/bin/ln/ (props changed) Modified: stable/8/bin/ln/symlink.7 == --- stable/8/bin/ln/symlink.7 Sun May 2 12:40:54 2010(r207503) +++ stable/8/bin/ln/symlink.7 Sun May 2 12:43:18 2010(r207504) @@ -29,7 +29,7 @@ .\@(#)symlink.7 8.3 (Berkeley) 3/31/94 .\ $FreeBSD$ .\ -.Dd March 31, 1994 +.Dd April 25, 2010 .Dt SYMLINK 7 .Os .Sh NAME @@ -138,8 +138,8 @@ an existing symbolic link can be changed and .Xr lutimes 2 system calls, respectively. -Of these, only the flags are used by the system; -the access permissions and ownership are ignored. +Of these, only the flags and ownership are used by the system; +the access permissions are ignored. .Pp The .Bx 4.4 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207508 - stable/8/bin/ln
Author: jilles Date: Sun May 2 13:36:23 2010 New Revision: 207508 URL: http://svn.freebsd.org/changeset/base/207508 Log: MFC r207189: symlink(7): Add lpathconf(2) and *at system calls. Modified: stable/8/bin/ln/symlink.7 Directory Properties: stable/8/bin/ln/ (props changed) Modified: stable/8/bin/ln/symlink.7 == --- stable/8/bin/ln/symlink.7 Sun May 2 12:50:29 2010(r207507) +++ stable/8/bin/ln/symlink.7 Sun May 2 13:36:23 2010(r207508) @@ -103,19 +103,23 @@ the system call would return a file descriptor to the file .Dq afile . .Pp -There are nine system calls that do not follow links, and which operate +There are thirteen system calls that do not follow links, and which operate on the symbolic link itself. They are: .Xr lchflags 2 , .Xr lchmod 2 , .Xr lchown 2 , +.Xr lpathconf 2 , .Xr lstat 2 , .Xr lutimes 2 , .Xr readlink 2 , +.Xr readlinkat 2 , .Xr rename 2 , +.Xr renameat 2 , .Xr rmdir 2 , +.Xr unlink 2 , and -.Xr unlink 2 . +.Xr unlinkat 2 . Because .Xr remove 3 is an alias for @@ -123,9 +127,30 @@ is an alias for it also does not follow symbolic links. When .Xr rmdir 2 +or +.Xr unlinkat 2 +with the +.Dv AT_REMOVEDIR +flag is applied to a symbolic link, it fails with the error .Er ENOTDIR . .Pp +The +.Xr linkat 2 +system call does not follow symbolic links +unless given the +.Dv AT_SYMLINK_FOLLOW +flag. +.Pp +The following system calls follow symbolic links +unless given the +.Dv AT_SYMLINK_NOFOLLOW +flag: +.Xr fchmodat 2 , +.Xr fchownat 2 +and +.Xr fstatat 2 . +.Pp The owner and group of an existing symbolic link can be changed by means of the .Xr lchown 2 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207509 - stable/7/bin/ln
Author: jilles Date: Sun May 2 13:38:08 2010 New Revision: 207509 URL: http://svn.freebsd.org/changeset/base/207509 Log: MFC r207188: symlink(7): The ownership of symlinks is used by the system, in at least three ways, so do not say it is ignored: * who may delete/rename a symlink in a sticky directory * who may do lchflags(2)/lchown(2)/lchmod(2) * whose inode quota is charged Modified: stable/7/bin/ln/symlink.7 Directory Properties: stable/7/bin/ln/ (props changed) Modified: stable/7/bin/ln/symlink.7 == --- stable/7/bin/ln/symlink.7 Sun May 2 13:36:23 2010(r207508) +++ stable/7/bin/ln/symlink.7 Sun May 2 13:38:08 2010(r207509) @@ -29,7 +29,7 @@ .\@(#)symlink.7 8.3 (Berkeley) 3/31/94 .\ $FreeBSD$ .\ -.Dd March 31, 1994 +.Dd April 25, 2010 .Dt SYMLINK 7 .Os .Sh NAME @@ -138,8 +138,8 @@ an existing symbolic link can be changed and .Xr lutimes 2 system calls, respectively. -Of these, only the flags are used by the system; -the access permissions and ownership are ignored. +Of these, only the flags and ownership are used by the system; +the access permissions are ignored. .Pp The .Bx 4.4 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207510 - stable/7/lib/libkvm
Author: jilles Date: Sun May 2 13:53:08 2010 New Revision: 207510 URL: http://svn.freebsd.org/changeset/base/207510 Log: MFC r207187: kvm(3): Mention that some of the functions use sysctl(3) instead of kmem. Additionally, because of sysctl(3) use (which is generally good), behaviour for crash dumps differs slightly from behaviour for live kernels and this will probably never be fixed entirely, so weaken that claim. Modified: stable/7/lib/libkvm/kvm.3 Directory Properties: stable/7/lib/libkvm/ (props changed) Modified: stable/7/lib/libkvm/kvm.3 == --- stable/7/lib/libkvm/kvm.3 Sun May 2 13:38:08 2010(r207509) +++ stable/7/lib/libkvm/kvm.3 Sun May 2 13:53:08 2010(r207510) @@ -32,7 +32,7 @@ .\ @(#)kvm.3 8.1 (Berkeley) 6/4/93 .\ $FreeBSD$ .\ -.Dd January 29, 2004 +.Dd April 25, 2010 .Dt KVM 3 .Os .Sh NAME @@ -46,12 +46,15 @@ The library provides a uniform interface for accessing kernel virtual memory images, including live systems and crash dumps. Access to live systems is via +.Xr sysctl 3 +for some functions, and .Xr mem 4 and .Xr kmem 4 +for other functions, while crash dumps can be examined via the core file generated by .Xr savecore 8 . -The interface behaves identically in both cases. +The interface behaves similarly in both cases. Memory can be read and written, kernel symbol addresses can be looked up efficiently, and information about user processes can be gathered. @@ -112,5 +115,6 @@ given descriptor. .Xr kvm_openfiles 3 , .Xr kvm_read 3 , .Xr kvm_write 3 , +.Xr sysctl 3 , .Xr kmem 4 , .Xr mem 4 ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207538 - stable/7/lib/csu/i386-elf
Author: jilles Date: Sun May 2 20:12:20 2010 New Revision: 207538 URL: http://svn.freebsd.org/changeset/base/207538 Log: MFC r205398: Do not create *.gmon files for PIE executables on i386. Scrt1_c.o was accidentally compiled with -DGCRT (profiling), like gcrt1_c.o. This problem is i386-specific, the other architectures are OK. If you have problems with PIE executables such as samba and cups leaving behind gmon files, rebuild them after installing this change. PR: ports/143924 Modified: stable/7/lib/csu/i386-elf/Makefile Directory Properties: stable/7/lib/csu/ (props changed) Modified: stable/7/lib/csu/i386-elf/Makefile == --- stable/7/lib/csu/i386-elf/Makefile Sun May 2 19:38:17 2010 (r207537) +++ stable/7/lib/csu/i386-elf/Makefile Sun May 2 20:12:20 2010 (r207538) @@ -24,7 +24,7 @@ crt1.o: crt1_c.o crt1_s.o objcopy --localize-symbol _start1 crt1.o Scrt1_c.o: crt1_c.c - ${CC} ${CFLAGS} -DGCRT -fPIC -DPIC -c -o Scrt1_c.o ${.CURDIR}/crt1_c.c + ${CC} ${CFLAGS} -fPIC -DPIC -c -o Scrt1_c.o ${.CURDIR}/crt1_c.c Scrt1.o: Scrt1_c.o crt1_s.o ${LD} ${LDFLAGS} -o Scrt1.o -r crt1_s.o Scrt1_c.o ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207636 - stable/7/usr.bin/stat
Author: jilles Date: Tue May 4 21:56:16 2010 New Revision: 207636 URL: http://svn.freebsd.org/changeset/base/207636 Log: MFC r207153: stat: Allow -f %Sf to display the file flags symbolically. PR: 124349 Modified: stable/7/usr.bin/stat/stat.1 stable/7/usr.bin/stat/stat.c Directory Properties: stable/7/usr.bin/stat/ (props changed) Modified: stable/7/usr.bin/stat/stat.1 == --- stable/7/usr.bin/stat/stat.1Tue May 4 21:23:59 2010 (r207635) +++ stable/7/usr.bin/stat/stat.1Tue May 4 21:56:16 2010 (r207636) @@ -36,7 +36,7 @@ .\ .\ $FreeBSD$ .\ -.Dd April 27, 2007 +.Dd April 24, 2010 .Dt STAT 1 .Os .Sh NAME @@ -239,6 +239,11 @@ Display date in format. .It Cm dr Display actual device name. +.It Cm f +Display the flags of +.Ar file +as in +.Nm ls Fl lTdo . .It Cm gu Display group or user name. .It Cm p Modified: stable/7/usr.bin/stat/stat.c == --- stable/7/usr.bin/stat/stat.cTue May 4 21:23:59 2010 (r207635) +++ stable/7/usr.bin/stat/stat.cTue May 4 21:56:16 2010 (r207636) @@ -187,6 +187,9 @@ int format1(const struct stat *,/* stat char *, size_t, /* a place to put the output */ int, int, int, int, /* the parsed format */ int, int); +#if HAVE_STRUCT_STAT_ST_FLAGS +char *xfflagstostr(unsigned long); +#endif char *timefmt; int linkfail; @@ -329,6 +332,25 @@ main(int argc, char *argv[]) return (am_readlink ? linkfail : errs); } +#if HAVE_STRUCT_STAT_ST_FLAGS +/* + * fflagstostr() wrapper that leaks only once + */ +char * +xfflagstostr(unsigned long fflags) +{ + static char *str = NULL; + + if (str != NULL) + free(str); + + str = fflagstostr(fflags); + if (str == NULL) + err(1, fflagstostr); + return (str); +} +#endif /* HAVE_STRUCT_STAT_ST_FLAGS */ + void usage(const char *synopsis) { @@ -721,8 +743,11 @@ format1(const struct stat *st, case SHOW_st_flags: small = (sizeof(st-st_flags) == 4); data = st-st_flags; - sdata = NULL; - formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX; + sdata = xfflagstostr(st-st_flags); + if (*sdata == '\0') + sdata = -; + formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX | + FMTF_STRING; if (ofmt == 0) ofmt = FMTF_UNSIGNED; break; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207678 - in head: bin/sh tools/regression/bin/sh/builtins
Author: jilles Date: Wed May 5 21:48:40 2010 New Revision: 207678 URL: http://svn.freebsd.org/changeset/base/207678 Log: sh: Apply locale vars on builtins, recognize LC_MESSAGES as a locale var. This allows doing things like LC_ALL=C some_builtin to run a builtin under a different locale, just like is possible with external programs. The immediate reason is that this allows making printf(1) a builtin without breaking things like LC_NUMERIC=C printf '%f\n' 1.2 This change also affects special builtins, as even though the assignment is persistent, the export is only to the builtin (unless the variable was already exported). Note: for this to work for builtins that also exist as external programs such as /bin/test, the setlocale() call must be under #ifndef SHELL. The shell will do the setlocale() calls which may not agree with the environment variables. Added: head/tools/regression/bin/sh/builtins/locale1.0 (contents, props changed) Modified: head/bin/sh/eval.c head/bin/sh/var.c head/bin/sh/var.h Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Wed May 5 21:24:18 2010(r207677) +++ head/bin/sh/eval.c Wed May 5 21:48:40 2010(r207678) @@ -937,6 +937,8 @@ evalcommand(union node *cmd, int flags, cmdentry.special = 1; if (cmdentry.special) listsetvar(cmdenviron); + if (argc 0) + bltinsetlocale(); commandname = argv[0]; argptr = argv + 1; nextopt_optptr = NULL; /* initialize nextopt */ @@ -944,6 +946,8 @@ evalcommand(union node *cmd, int flags, exitstatus = (*builtinfunc[cmdentry.u.index])(argc, argv); flushall(); cmddone: + if (argc 0) + bltinunsetlocale(); cmdenviron = NULL; out1 = output; out2 = errout; Modified: head/bin/sh/var.c == --- head/bin/sh/var.c Wed May 5 21:24:18 2010(r207677) +++ head/bin/sh/var.c Wed May 5 21:48:40 2010(r207678) @@ -122,6 +122,14 @@ STATIC const struct varinit varinit[] = STATIC struct var *vartab[VTABSIZE]; +STATIC const char *const locale_names[7] = { + LC_COLLATE, LC_CTYPE, LC_MONETARY, + LC_NUMERIC, LC_TIME, LC_MESSAGES, NULL +}; +STATIC const int locale_categories[7] = { + LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME, LC_MESSAGES, 0 +}; + STATIC struct var **hashvar(const char *); STATIC int varequal(const char *, const char *); STATIC int localevar(const char *); @@ -258,11 +266,7 @@ setvar(const char *name, const char *val STATIC int localevar(const char *s) { - static const char *lnames[7] = { - ALL, COLLATE, CTYPE, MONETARY, - NUMERIC, TIME, NULL - }; - const char **ss; + const char *const *ss; if (*s != 'L') return 0; @@ -270,8 +274,10 @@ localevar(const char *s) return 1; if (strncmp(s + 1, C_, 2) != 0) return 0; - for (ss = lnames; *ss ; ss++) - if (varequal(s + 3, *ss)) + if (varequal(s + 3, ALL)) + return 1; + for (ss = locale_names; *ss ; ss++) + if (varequal(s + 3, *ss + 3)) return 1; return 0; } @@ -437,6 +443,61 @@ bltinlookup(const char *name, int doall) } +/* + * Set up locale for a builtin (LANG/LC_* assignments). + */ +void +bltinsetlocale(void) +{ + struct strlist *lp; + int act = 0; + char *loc, *locdef; + int i; + + for (lp = cmdenviron ; lp ; lp = lp-next) { + if (localevar(lp-text)) { + act = 1; + break; + } + } + if (!act) + return; + loc = bltinlookup(LC_ALL, 0); + INTOFF; + if (loc != NULL) { + setlocale(LC_ALL, loc); + INTON; + return; + } + locdef = bltinlookup(LANG, 0); + for (i = 0; locale_names[i] != NULL; i++) { + loc = bltinlookup(locale_names[i], 0); + if (loc == NULL) + loc = locdef; + if (loc != NULL) + setlocale(locale_categories[i], loc); + } + INTON; +} + +/* + * Undo the effect of bltinlocaleset(). + */ +void +bltinunsetlocale(void) +{ + struct strlist *lp; + + INTOFF; + for (lp = cmdenviron ; lp ; lp = lp-next) { + if (localevar(lp-text)) { + setlocale(LC_ALL, ); + return; + } + } + INTON; +} + /* * Generate a list of exported variables. This routine is used to
svn commit: r207679 - stable/8/lib/libc/gen
Author: jilles Date: Wed May 5 22:00:57 2010 New Revision: 207679 URL: http://svn.freebsd.org/changeset/base/207679 Log: MFC r207186: sysctl(3): Update description of various kern.* variables. Also add xrefs for confstr(3) (as sysconf(3) but for strings) and kvm(3) (which is a more convenient way to access some of the variables). PR: 116480 Modified: stable/8/lib/libc/gen/sysctl.3 Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) Modified: stable/8/lib/libc/gen/sysctl.3 == --- stable/8/lib/libc/gen/sysctl.3 Wed May 5 21:48:40 2010 (r207678) +++ stable/8/lib/libc/gen/sysctl.3 Wed May 5 22:00:57 2010 (r207679) @@ -28,7 +28,7 @@ .\@(#)sysctl.38.4 (Berkeley) 5/9/95 .\ $FreeBSD$ .\ -.Dd January 28, 2009 +.Dd April 25, 2010 .Dt SYSCTL 3 .Os .Sh NAME @@ -326,7 +326,7 @@ information. .It KERN_BOOTFILE string yes .It KERN_BOOTTIME struct timeval no .It KERN_CLOCKRATEstruct clockinfono -.It KERN_FILE struct file no +.It KERN_FILE struct xfileno .It KERN_HOSTID integer yes .It KERN_HOSTUUID string yes .It KERN_HOSTNAME string yes @@ -343,14 +343,14 @@ information. .It KERN_OSREVinteger no .It KERN_OSTYPE string no .It KERN_POSIX1 integer no -.It KERN_PROC struct proc no +.It KERN_PROC nodenot applicable .It KERN_PROF nodenot applicable .It KERN_QUANTUM integer yes .It KERN_SAVED_IDSinteger no .It KERN_SECURELVLinteger raise only .It KERN_UPDATEINTERVAL integer no .It KERN_VERSION string no -.It KERN_VNODEstruct vnodeno +.It KERN_VNODEstruct xvnode no .El .Pp .Bl -tag -width 6n @@ -372,10 +372,8 @@ This structure contains the clock, stati frequencies, the number of micro-seconds per hz tick and the skew rate. .It Li KERN_FILE Return the entire file table. -The returned data consists of a single -.Va struct filehead -followed by an array of -.Va struct file , +The returned data consists of an array of +.Va struct xfile , whose size depends on the current number of such objects in the system. .It Li KERN_HOSTID Get or set the host ID. @@ -527,10 +525,8 @@ Note, the vnode table is not necessarily the system. The returned data consists of an array whose size depends on the current number of such objects in the system. -Each element of the array contains the kernel address of a vnode -.Va struct vnode * -followed by the vnode itself -.Va struct vnode . +Each element of the array consists of a +.Va struct xvnode . .El .Ss CTL_NET The string and integer information available for the CTL_NET level @@ -859,6 +855,8 @@ An attempt is made to set a read-only va A process without appropriate privilege attempts to set a value. .El .Sh SEE ALSO +.Xr confstr 3 , +.Xr kvm 3 , .Xr sysconf 3 , .Xr sysctl 8 .Sh HISTORY ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207681 - stable/7/lib/libc/gen
Author: jilles Date: Wed May 5 22:07:28 2010 New Revision: 207681 URL: http://svn.freebsd.org/changeset/base/207681 Log: MFC r207186: sysctl(3): Update description of various kern.* variables. Also add xrefs for confstr(3) (as sysconf(3) but for strings) and kvm(3) (which is a more convenient way to access some of the variables). PR: 116480 Modified: stable/7/lib/libc/gen/sysctl.3 Directory Properties: stable/7/lib/libc/ (props changed) stable/7/lib/libc/stdtime/ (props changed) Modified: stable/7/lib/libc/gen/sysctl.3 == --- stable/7/lib/libc/gen/sysctl.3 Wed May 5 22:06:05 2010 (r207680) +++ stable/7/lib/libc/gen/sysctl.3 Wed May 5 22:07:28 2010 (r207681) @@ -28,7 +28,7 @@ .\@(#)sysctl.38.4 (Berkeley) 5/9/95 .\ $FreeBSD$ .\ -.Dd April 10, 2007 +.Dd April 25, 2010 .Dt SYSCTL 3 .Os .Sh NAME @@ -323,7 +323,7 @@ information. .It KERN_BOOTFILE string yes .It KERN_BOOTTIME struct timeval no .It KERN_CLOCKRATEstruct clockinfono -.It KERN_FILE struct file no +.It KERN_FILE struct xfileno .It KERN_HOSTID integer yes .It KERN_HOSTUUID string yes .It KERN_HOSTNAME string yes @@ -340,14 +340,14 @@ information. .It KERN_OSREVinteger no .It KERN_OSTYPE string no .It KERN_POSIX1 integer no -.It KERN_PROC struct proc no +.It KERN_PROC nodenot applicable .It KERN_PROF nodenot applicable .It KERN_QUANTUM integer yes .It KERN_SAVED_IDSinteger no .It KERN_SECURELVLinteger raise only .It KERN_UPDATEINTERVAL integer no .It KERN_VERSION string no -.It KERN_VNODEstruct vnodeno +.It KERN_VNODEstruct xvnode no .El .Pp .Bl -tag -width 6n @@ -369,10 +369,8 @@ This structure contains the clock, stati frequencies, the number of micro-seconds per hz tick and the skew rate. .It Li KERN_FILE Return the entire file table. -The returned data consists of a single -.Va struct filehead -followed by an array of -.Va struct file , +The returned data consists of an array of +.Va struct xfile , whose size depends on the current number of such objects in the system. .It Li KERN_HOSTID Get or set the host ID. @@ -526,10 +524,8 @@ Note, the vnode table is not necessarily the system. The returned data consists of an array whose size depends on the current number of such objects in the system. -Each element of the array contains the kernel address of a vnode -.Va struct vnode * -followed by the vnode itself -.Va struct vnode . +Each element of the array consists of a +.Va struct xvnode . .El .Ss CTL_MACHDEP The set of variables defined is architecture dependent. @@ -869,6 +865,8 @@ An attempt is made to set a read-only va A process without appropriate privilege attempts to set a value. .El .Sh SEE ALSO +.Xr confstr 3 , +.Xr kvm 3 , .Xr sysconf 3 , .Xr sysctl 8 .Sh HISTORY ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207682 - stable/8/lib/libc/sys
Author: jilles Date: Wed May 5 22:12:56 2010 New Revision: 207682 URL: http://svn.freebsd.org/changeset/base/207682 Log: MFC r207190: unlinkat(2): unlinkat(AT_REMOVEDIR) fails with ENOTEMPTY like rmdir() for non-empty directories. POSIX permits both ENOTEMPTY and EEXIST, but we use the clearer ENOTEMPTY, following BSD tradition. Modified: stable/8/lib/libc/sys/unlink.2 Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) Modified: stable/8/lib/libc/sys/unlink.2 == --- stable/8/lib/libc/sys/unlink.2 Wed May 5 22:07:28 2010 (r207681) +++ stable/8/lib/libc/sys/unlink.2 Wed May 5 22:12:56 2010 (r207682) @@ -28,7 +28,7 @@ .\ @(#)unlink.2 8.1 (Berkeley) 6/4/93 .\ $FreeBSD$ .\ -.Dd April 10, 2008 +.Dd April 25, 2010 .Dt UNLINK 2 .Os .Sh NAME @@ -165,7 +165,7 @@ argument does not specify an absolute pa argument is neither .Dv AT_FDCWD nor a valid file descriptor open for searching. -.It Bq Er EEXIST +.It Bq Er ENOTEMPTY The .Fa flag parameter has the ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207684 - stable/8/lib/libc/gen
Author: jilles Date: Wed May 5 22:17:17 2010 New Revision: 207684 URL: http://svn.freebsd.org/changeset/base/207684 Log: MFC r206760: getcwd(3): Clarify that EACCES may or may not be checked. POSIX permits but does not require checking access on the current and parent directories. Because various programs do not like it if getcwd(3) fails, it seems best to avoid checking access as much as possible. There are various reports in GNATS about this (search for getcwd). Our getcwd(3) implementation first queries the kernel for the pathname directly, which does not check any permissions but sometimes fails, and then falls back to reading all parent directories for the names. PR: standards/44425 Modified: stable/8/lib/libc/gen/getcwd.3 Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/stdtime/ (props changed) Modified: stable/8/lib/libc/gen/getcwd.3 == --- stable/8/lib/libc/gen/getcwd.3 Wed May 5 22:15:20 2010 (r207683) +++ stable/8/lib/libc/gen/getcwd.3 Wed May 5 22:17:17 2010 (r207684) @@ -28,7 +28,7 @@ .\ @(#)getcwd.3 8.2 (Berkeley) 12/11/93 .\ $FreeBSD$ .\ -.Dd November 24, 1997 +.Dd April 17, 2010 .Dt GETCWD 3 .Os .Sh NAME @@ -108,8 +108,6 @@ The function will fail if: .Bl -tag -width Er -.It Bq Er EACCES -Read or search permission was denied for a component of the pathname. .It Bq Er EINVAL The .Fa size @@ -124,6 +122,16 @@ The argument is greater than zero but smaller than the length of the pathname plus 1. .El +.Pp +The +.Fn getcwd +function +may fail if: +.Bl -tag -width Er +.It Bq Er EACCES +Read or search permission was denied for a component of the pathname. +This is only checked in limited cases, depending on implementation details. +.El .Sh SEE ALSO .Xr chdir 2 , .Xr fchdir 2 , ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207686 - stable/6/lib/libc/gen
Author: jilles Date: Wed May 5 22:23:29 2010 New Revision: 207686 URL: http://svn.freebsd.org/changeset/base/207686 Log: MFC r206760: getcwd(3): Clarify that EACCES may or may not be checked. POSIX permits but does not require checking access on the current and parent directories. Because various programs do not like it if getcwd(3) fails, it seems best to avoid checking access as much as possible. There are various reports in GNATS about this (search for getcwd). Our getcwd(3) implementation first queries the kernel for the pathname directly, which does not check any permissions but sometimes fails, and then falls back to reading all parent directories for the names. PR: standards/44425 Modified: stable/6/lib/libc/gen/getcwd.3 Directory Properties: stable/6/lib/libc/ (props changed) Modified: stable/6/lib/libc/gen/getcwd.3 == --- stable/6/lib/libc/gen/getcwd.3 Wed May 5 22:19:52 2010 (r207685) +++ stable/6/lib/libc/gen/getcwd.3 Wed May 5 22:23:29 2010 (r207686) @@ -32,7 +32,7 @@ .\ @(#)getcwd.3 8.2 (Berkeley) 12/11/93 .\ $FreeBSD$ .\ -.Dd November 24, 1997 +.Dd April 17, 2010 .Dt GETCWD 3 .Os .Sh NAME @@ -112,8 +112,6 @@ The function will fail if: .Bl -tag -width Er -.It Bq Er EACCES -Read or search permission was denied for a component of the pathname. .It Bq Er EINVAL The .Fa size @@ -128,6 +126,16 @@ The argument is greater than zero but smaller than the length of the pathname plus 1. .El +.Pp +The +.Fn getcwd +function +may fail if: +.Bl -tag -width Er +.It Bq Er EACCES +Read or search permission was denied for a component of the pathname. +This is only checked in limited cases, depending on implementation details. +.El .Sh SEE ALSO .Xr chdir 2 , .Xr fchdir 2 , ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207734 - head/lib/libc/sys
Author: jilles Date: Thu May 6 22:06:14 2010 New Revision: 207734 URL: http://svn.freebsd.org/changeset/base/207734 Log: sigaltstack(2): document some modernizations: * un-document 'struct sigaltstack' tag for stack_t as this is BSD-specific; this doesn't seem useful enough to document as such * alternate stacks are per thread, not per process * update error codes to what the kernel does and POSIX requires MFC after:1 week Modified: head/lib/libc/sys/sigaltstack.2 Modified: head/lib/libc/sys/sigaltstack.2 == --- head/lib/libc/sys/sigaltstack.2 Thu May 6 21:57:38 2010 (r207733) +++ head/lib/libc/sys/sigaltstack.2 Thu May 6 22:06:14 2010 (r207734) @@ -28,7 +28,7 @@ .\ @(#)sigaltstack.2 8.2 (Berkeley) 5/1/95 .\ $FreeBSD$ .\ -.Dd May 1, 1995 +.Dd May 6, 2010 .Dt SIGALTSTACK 2 .Os .Sh NAME @@ -39,7 +39,7 @@ .Sh SYNOPSIS .In signal.h .Bd -literal -typedef struct sigaltstack { +typedef struct { char*ss_sp; size_t ss_size; int ss_flags; @@ -51,25 +51,25 @@ typedef struct sigaltstack { The .Fn sigaltstack system call -allows users to define an alternate stack on which signals -are to be processed. +allows defining an alternate stack on which signals +are to be processed for the current thread. If .Fa ss is non-zero, it specifies a pointer to and the size of a .Em signal stack -on which to deliver signals, -and tells the system if the process is currently executing -on that stack. +on which to deliver signals. When a signal's action indicates its handler should execute on the signal stack (specified with a .Xr sigaction 2 system call), the system checks to see -if the process is currently executing on that stack. -If the process is not currently executing on the signal stack, +if the thread is currently executing on that stack. +If the thread is not currently executing on the signal stack, the system arranges a switch to the signal stack for the duration of the signal handler's execution. .Pp +An active stack cannot be modified. +.Pp If .Dv SS_DISABLE is set in @@ -78,12 +78,6 @@ is set in and .Fa ss_size are ignored and the signal stack will be disabled. -Trying to disable an active stack will cause -.Fn sigaltstack -to return -1 with -.Va errno -set to -.Er EINVAL . A disabled stack will cause all signals to be taken on the regular user stack. If the stack is later re-enabled then all signals that were specified @@ -96,7 +90,7 @@ The .Fa ss_flags field will contain the value .Dv SS_ONSTACK -if the process is currently on a signal stack and +if the thread is currently on a signal stack and .Dv SS_DISABLE if the signal stack is currently disabled. .Sh NOTES @@ -146,8 +140,12 @@ or .Fa oss points to memory that is not a valid part of the process address space. +.It Bq Er EPERM +An attempt was made to modify an active stack. .It Bq Er EINVAL -An attempt was made to disable an active stack. +The +.Fa ss_flags +field was invalid. .It Bq Er ENOMEM Size of alternate stack area is less than or equal to .Dv MINSIGSTKSZ . ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207735 - in head: lib/libc/gen lib/libc/sys usr.bin/lastcomm
Author: jilles Date: Thu May 6 22:49:54 2010 New Revision: 207735 URL: http://svn.freebsd.org/changeset/base/207735 Log: Update xrefs from 4.3BSD to modern signal functions in various man pages. sigvec(2) references have been updated to sigaction(2), sigsetmask(2) and sigblock(2) to sigprocmask(2), sigpause(2) to sigsuspend(2). Some legacy man pages still refer to them, that is OK. Modified: head/lib/libc/gen/alarm.3 head/lib/libc/gen/siginterrupt.3 head/lib/libc/gen/ualarm.3 head/lib/libc/sys/execve.2 head/lib/libc/sys/fcntl.2 head/lib/libc/sys/getitimer.2 head/lib/libc/sys/getrlimit.2 head/lib/libc/sys/sigaction.2 head/lib/libc/sys/sigreturn.2 head/lib/libc/sys/vfork.2 head/usr.bin/lastcomm/lastcomm.1 Modified: head/lib/libc/gen/alarm.3 == --- head/lib/libc/gen/alarm.3 Thu May 6 22:06:14 2010(r207734) +++ head/lib/libc/gen/alarm.3 Thu May 6 22:49:54 2010(r207735) @@ -76,8 +76,7 @@ If no alarm is currently set, the return .Sh SEE ALSO .Xr setitimer 2 , .Xr sigaction 2 , -.Xr sigpause 2 , -.Xr sigvec 2 , +.Xr sigsuspend 2 , .Xr signal 3 , .Xr sleep 3 , .Xr ualarm 3 , Modified: head/lib/libc/gen/siginterrupt.3 == --- head/lib/libc/gen/siginterrupt.3Thu May 6 22:06:14 2010 (r207734) +++ head/lib/libc/gen/siginterrupt.3Thu May 6 22:49:54 2010 (r207735) @@ -109,9 +109,8 @@ is not a valid signal number. .El .Sh SEE ALSO .Xr sigaction 2 , -.Xr sigblock 2 , -.Xr sigpause 2 , -.Xr sigsetmask 2 , +.Xr sigprocmask 2 , +.Xr sigsuspend 2 , .Xr signal 3 .Sh HISTORY The Modified: head/lib/libc/gen/ualarm.3 == --- head/lib/libc/gen/ualarm.3 Thu May 6 22:06:14 2010(r207734) +++ head/lib/libc/gen/ualarm.3 Thu May 6 22:49:54 2010(r207735) @@ -84,8 +84,8 @@ A microsecond is 0.01 seconds. .Sh SEE ALSO .Xr getitimer 2 , .Xr setitimer 2 , -.Xr sigpause 2 , -.Xr sigvec 2 , +.Xr sigaction 2 , +.Xr sigsuspend 2 , .Xr alarm 3 , .Xr signal 3 , .Xr sleep 3 , Modified: head/lib/libc/sys/execve.2 == --- head/lib/libc/sys/execve.2 Thu May 6 22:06:14 2010(r207734) +++ head/lib/libc/sys/execve.2 Thu May 6 22:49:54 2010(r207735) @@ -189,8 +189,8 @@ the calling process: .It interval timers Ta see Xr getitimer 2 .It resource limits Ta see Xr getrlimit 2 .It file mode mask Ta see Xr umask 2 -.It signal mask Ta see Xr sigvec 2 , -.Xr sigsetmask 2 +.It signal mask Ta see Xr sigaction 2 , +.Xr sigprocmask 2 .El .Pp When a program is executed as a result of an Modified: head/lib/libc/sys/fcntl.2 == --- head/lib/libc/sys/fcntl.2 Thu May 6 22:06:14 2010(r207734) +++ head/lib/libc/sys/fcntl.2 Thu May 6 22:49:54 2010(r207735) @@ -618,7 +618,7 @@ for the reasons as stated in .Xr flock 2 , .Xr getdtablesize 2 , .Xr open 2 , -.Xr sigvec 2 , +.Xr sigaction 2 , .Xr lockf 3 , .Xr tcgetpgrp 3 , .Xr tcsetpgrp 3 Modified: head/lib/libc/sys/getitimer.2 == --- head/lib/libc/sys/getitimer.2 Thu May 6 22:06:14 2010 (r207734) +++ head/lib/libc/sys/getitimer.2 Thu May 6 22:49:54 2010 (r207735) @@ -171,7 +171,7 @@ to be handled. .Sh SEE ALSO .Xr gettimeofday 2 , .Xr select 2 , -.Xr sigvec 2 , +.Xr sigaction 2 , .Xr clocks 7 .Sh HISTORY The Modified: head/lib/libc/sys/getrlimit.2 == --- head/lib/libc/sys/getrlimit.2 Thu May 6 22:06:14 2010 (r207734) +++ head/lib/libc/sys/getrlimit.2 Thu May 6 22:49:54 2010 (r207735) @@ -193,7 +193,7 @@ raised the maximum limit value, and the .Xr quota 1 , .Xr quotactl 2 , .Xr sigaltstack 2 , -.Xr sigvec 2 , +.Xr sigaction 2 , .Xr sysctl 3 , .Xr ulimit 3 .Sh HISTORY Modified: head/lib/libc/sys/sigaction.2 == --- head/lib/libc/sys/sigaction.2 Thu May 6 22:06:14 2010 (r207734) +++ head/lib/libc/sys/sigaction.2 Thu May 6 22:49:54 2010 (r207735) @@ -609,13 +609,9 @@ or .Xr kill 2 , .Xr ptrace 2 , .Xr sigaltstack 2 , -.Xr sigblock 2 , -.Xr sigpause 2 , .Xr sigpending 2 , .Xr sigprocmask 2 , -.Xr sigsetmask 2 , .Xr sigsuspend 2 , -.Xr sigvec 2 , .Xr wait 2 , .Xr fpsetmask 3 , .Xr setjmp 3 , Modified: head/lib/libc/sys/sigreturn.2 == --- head/lib/libc/sys/sigreturn.2 Thu May 6 22:06:14 2010 (r207734) +++ head/lib/libc/sys/sigreturn.2 Thu May 6
svn commit: r207749 - head/lib/libc/gen
Author: jilles Date: Fri May 7 17:20:15 2010 New Revision: 207749 URL: http://svn.freebsd.org/changeset/base/207749 Log: raise(3): Note that this sends a signal to the current thread, not process. This is how it works (with threading libraries loaded) and what POSIX requires. MFC after:1 week Modified: head/lib/libc/gen/raise.3 Modified: head/lib/libc/gen/raise.3 == --- head/lib/libc/gen/raise.3 Fri May 7 16:43:00 2010(r207748) +++ head/lib/libc/gen/raise.3 Fri May 7 17:20:15 2010(r207749) @@ -32,12 +32,12 @@ .\ @(#)raise.38.1 (Berkeley) 6/4/93 .\ $FreeBSD$ .\ -.Dd June 4, 1993 +.Dd May 7, 2010 .Dt RAISE 3 .Os .Sh NAME .Nm raise -.Nd send a signal to the current process +.Nd send a signal to the current thread .Sh LIBRARY .Lb libc .Sh SYNOPSIS @@ -49,7 +49,7 @@ The .Fn raise function sends the signal .Fa sig -to the current process. +to the current thread. .Sh RETURN VALUES .Rv -std raise .Sh ERRORS ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207757 - head/lib/libc/sys
Author: jilles Date: Fri May 7 20:46:22 2010 New Revision: 207757 URL: http://svn.freebsd.org/changeset/base/207757 Log: sigprocmask(2): pthread_sigmask(3) must be used in threaded processes. Although libthr's pthread_sigmask() just calls sigprocmask() and this is unlikely to change, mention this POSIX requirement on applications. MFC after:1 week Modified: head/lib/libc/sys/sigprocmask.2 Modified: head/lib/libc/sys/sigprocmask.2 == --- head/lib/libc/sys/sigprocmask.2 Fri May 7 20:02:36 2010 (r207756) +++ head/lib/libc/sys/sigprocmask.2 Fri May 7 20:46:22 2010 (r207757) @@ -28,7 +28,7 @@ .\@(#)sigprocmask.2 8.1 (Berkeley) 6/4/93 .\ $FreeBSD$ .\ -.Dd June 4, 1993 +.Dd May 7, 2010 .Dt SIGPROCMASK 2 .Os .Sh NAME @@ -96,6 +96,11 @@ quietly disallows or .Dv SIGSTOP to be blocked. +.Pp +In threaded applications, +.Xr pthread_sigmask 3 +must be used instead of +.Fn sigprocmask . .Sh RETURN VALUES .Rv -std sigprocmask .Sh ERRORS @@ -116,6 +121,7 @@ has a value other than those listed here .Xr sigpending 2 , .Xr sigsuspend 2 , .Xr fpsetmask 3 , +.Xr pthread_sigmask 3 , .Xr sigsetops 3 .Sh STANDARDS The ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org
svn commit: r207758 - stable/8/contrib/telnet/telnet
Author: jilles Date: Fri May 7 20:58:50 2010 New Revision: 207758 URL: http://svn.freebsd.org/changeset/base/207758 Log: MFC r207449: telnet: Fix infinite loop if local output generates SIGPIPE. Instead of catching SIGPIPE and jumping out of the signal handler with longjmp, ignore it and handle write errors to the local output by exiting from there. I have changed the error message to mention the local output instead of NetBSD's wrong Connection closed by foreign host. Write errors to the network were already handled by exiting immediately and this now applies to EPIPE too. The code assumed that SIGPIPE could only be generated by the network connection; if it was generated by the local output, it would longjmp out of the signal handler and write an error message which caused another SIGPIPE. PR: 19773 Obtained from:NetBSD Modified: stable/8/contrib/telnet/telnet/commands.c stable/8/contrib/telnet/telnet/externs.h stable/8/contrib/telnet/telnet/network.c stable/8/contrib/telnet/telnet/sys_bsd.c stable/8/contrib/telnet/telnet/telnet.c stable/8/contrib/telnet/telnet/terminal.c Directory Properties: stable/8/contrib/telnet/ (props changed) Modified: stable/8/contrib/telnet/telnet/commands.c == --- stable/8/contrib/telnet/telnet/commands.c Fri May 7 20:46:22 2010 (r207757) +++ stable/8/contrib/telnet/telnet/commands.c Fri May 7 20:58:50 2010 (r207758) @@ -2491,8 +2491,7 @@ tn(int argc, char *argv[]) env_export(USER); } (void) call(status, status, notmuch, 0); -if (setjmp(peerdied) == 0) - telnet(user); +telnet(user); (void) NetClose(net); ExitString(Connection closed by foreign host.\n,1); /*NOTREACHED*/ Modified: stable/8/contrib/telnet/telnet/externs.h == --- stable/8/contrib/telnet/telnet/externs.hFri May 7 20:46:22 2010 (r207757) +++ stable/8/contrib/telnet/telnet/externs.hFri May 7 20:58:50 2010 (r207758) @@ -233,7 +233,6 @@ extern void SetNetTrace(char *); /* Function to change where debugging goes */ extern jmp_buf -peerdied, toplevel; /* For error conditions. */ extern void Modified: stable/8/contrib/telnet/telnet/network.c == --- stable/8/contrib/telnet/telnet/network.cFri May 7 20:46:22 2010 (r207757) +++ stable/8/contrib/telnet/telnet/network.cFri May 7 20:58:50 2010 (r207758) @@ -158,7 +158,7 @@ netflush(void) perror(hostname); (void)NetClose(net); ring_clear_mark(netoring); - longjmp(peerdied, -1); + ExitString(Connection closed by foreign host.\n, 1); /*NOTREACHED*/ } n = 0; Modified: stable/8/contrib/telnet/telnet/sys_bsd.c == --- stable/8/contrib/telnet/telnet/sys_bsd.cFri May 7 20:46:22 2010 (r207757) +++ stable/8/contrib/telnet/telnet/sys_bsd.cFri May 7 20:58:50 2010 (r207758) @@ -809,14 +809,6 @@ NetNonblockingIO(int fd, int onoff) */ /* ARGSUSED */ -static SIG_FUNC_RET -deadpeer(int sig __unused) -{ - setcommandmode(); - longjmp(peerdied, -1); -} - -/* ARGSUSED */ SIG_FUNC_RET intr(int sig __unused) { @@ -884,7 +876,7 @@ sys_telnet_init(void) { (void) signal(SIGINT, intr); (void) signal(SIGQUIT, intr2); -(void) signal(SIGPIPE, deadpeer); +(void) signal(SIGPIPE, SIG_IGN); #ifdef SIGWINCH (void) signal(SIGWINCH, sendwin); #endif Modified: stable/8/contrib/telnet/telnet/telnet.c == --- stable/8/contrib/telnet/telnet/telnet.c Fri May 7 20:46:22 2010 (r207757) +++ stable/8/contrib/telnet/telnet/telnet.c Fri May 7 20:58:50 2010 (r207758) @@ -146,7 +146,6 @@ unsigned char telopt_environ = TELOPT_NE #endif jmp_buftoplevel; -jmp_bufpeerdied; intflushline; intlinemode; Modified: stable/8/contrib/telnet/telnet/terminal.c == --- stable/8/contrib/telnet/telnet/terminal.c Fri May 7 20:46:22 2010 (r207757) +++ stable/8/contrib/telnet/telnet/terminal.c Fri May 7 20:58:50 2010 (r207758) @@ -111,7 +111,8 @@ init_terminal(void) } /* - * Send as much data as possible to the terminal. + * Send as much data as possible to the terminal, else exits if + * it encounters a permanent failure when writing to the tty. * * Return value: * -1: No useful work done, data waiting to go out. @@ -152,8 +153,19 @@ ttyflush(int drop) }
svn commit: r207783 - head/bin/sh
Author: jilles Date: Sat May 8 14:00:01 2010 New Revision: 207783 URL: http://svn.freebsd.org/changeset/base/207783 Log: sh: Have only one copy of _PATH_STDPATH in the binary. Modified: head/bin/sh/eval.c Modified: head/bin/sh/eval.c == --- head/bin/sh/eval.c Sat May 8 13:49:43 2010(r207782) +++ head/bin/sh/eval.c Sat May 8 14:00:01 2010(r207783) @@ -1089,8 +1089,7 @@ breakcmd(int argc, char **argv) int commandcmd(int argc, char **argv) { - static char stdpath[] = _PATH_STDPATH; - char *path; + const char *path; int ch; int cmd = -1; @@ -1101,7 +1100,7 @@ commandcmd(int argc, char **argv) while ((ch = getopt(argc, argv, pvV)) != -1) { switch (ch) { case 'p': - path = stdpath; + path = _PATH_STDPATH; break; case 'v': cmd = TYPECMD_SMALLV; ___ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to svn-src-all-unsubscr...@freebsd.org