Re: preliminary kabylake support for inteldrm

2017-09-27 Thread Manuel Giraud
Matthieu Herrb <matth...@herrb.eu> writes:

> No visible regression so far on my IvyBridge and SandyBridge laptops.

Same here on a skylake.
-- 
Manuel Giraud



remove noises at reboot in azalia(4)

2017-06-28 Thread Manuel Giraud
Hi,

This patch removes noises in speaker (or headphone) when rebooting
(tested on only one Conexant CX20724 chip)

Index: azalia.c
===
RCS file: /cvs/src/sys/dev/pci/azalia.c,v
retrieving revision 1.235
diff -u -p -r1.235 azalia.c
--- azalia.c11 Apr 2017 14:43:49 -  1.235
+++ azalia.c28 Jun 2017 13:44:26 -
@@ -697,12 +697,25 @@ azalia_shutdown(void *v)
 {
azalia_t *az = (azalia_t *)v;
uint32_t gctl;
+   codec_t *codec;
+   int i;
 
/* disable unsolicited response */
gctl = AZ_READ_4(az, GCTL);
AZ_WRITE_4(az, GCTL, gctl & ~(HDA_GCTL_UNSOL));
 
timeout_del(>unsol_to);
+
+   /* power off all codecs */
+   for (i = 0; i < az->ncodecs; i++) {
+   codec = >codecs[i];
+   if (codec->audiofunc < 0)
+   continue;
+   azalia_comresp(codec, codec->audiofunc,
+  CORB_SET_POWER_STATE, CORB_PS_D3, NULL);
+   DELAY(100);
+   azalia_codec_delete(codec);
+   }
 
/* halt CORB/RIRB */
azalia_halt_corb(az);

-- 
Manuel Giraud



restore -t with file size

2015-11-10 Thread Manuel Giraud
tic char*map;
 static charlnkbuf[PATH_MAX + 1];
 static size_t  pathlen;
+static size_t  szcount = 0;
 
 intoldinofmt;  /* old inode format conversion required */
 intBcvt;   /* Swap Bytes (for CCI or sun) */
@@ -124,6 +125,7 @@ static void  xtrlnkskip(char *, size_t);
 static void xtrmap(char *, size_t);
 static void xtrmapskip(char *, size_t);
 static void xtrskip(char *, size_t);
+static void xtrcount(char *, size_t);
 
 /*
  * Set up an input source
@@ -547,10 +549,19 @@ extractfile(char *name)
skipfile();
return (GOOD);
}
-   Vprintf(stdout, "extract file %s\n", name);
-   return (genliteraldir(name, curfile.ino));
-
+   Vprintf(stdout, "extract directory %s\n", name);
+   if (command != 't') {
+   return (genliteraldir(name, curfile.ino));
+   } else {
+   return (GOOD);
+   }
+   
case IFLNK: {
+   if (command == 't') {
+   Tprintfile(name, curfile.ino, LINK, 0);
+   skipfile();
+   return (GOOD);
+   }
lnkbuf[0] = '\0';
pathlen = 0;
getfile(xtrlnkfile, xtrlnkskip);
@@ -568,6 +579,11 @@ extractfile(char *name)
 
case IFCHR:
case IFBLK:
+   if (command == 't') {
+   Tprintfile(name, curfile.ino, LEAF, 0);
+   skipfile();
+   return (GOOD);
+   }
Vprintf(stdout, "extract special file %s\n", name);
if (Nflag) {
skipfile();
@@ -588,6 +604,11 @@ extractfile(char *name)
return (GOOD);
 
case IFIFO:
+   if (command == 't') {
+   Tprintfile(name, curfile.ino, LEAF, 0);
+   skipfile();
+   return (GOOD);
+   }
Vprintf(stdout, "extract fifo %s\n", name);
if (Nflag) {
skipfile();
@@ -608,6 +629,12 @@ extractfile(char *name)
return (GOOD);
 
case IFREG:
+   if (command == 't') {
+   getfile(xtrcount, xtrcount);
+   Tprintfile(name, curfile.ino, LEAF, szcount);
+   szcount = 0;
+   return (GOOD);
+   }
Vprintf(stdout, "extract file %s\n", name);
if (Nflag) {
skipfile();
@@ -805,6 +832,12 @@ xtrnull(char *buf, size_t size)
 {
 
return;
+}
+
+static void
+xtrcount(char *buf, size_t size)
+{
+   szcount += size;
 }
 
 /*
Index: utilities.c
===
RCS file: /cvs/src/sbin/restore/utilities.c,v
retrieving revision 1.19
diff -u -p -r1.19 utilities.c
--- utilities.c 7 Nov 2015 21:52:55 -   1.19
+++ utilities.c 10 Nov 2015 15:51:27 -
@@ -340,6 +340,23 @@ reply(char *question)
return (FAIL);
 }
 
+void
+Tprintfile(char *name, ino_t ino, int type, size_t size)
+{
+   switch (type) {
+   case NODE:
+   Vprintf(stdout, "dir ");
+   break;
+   case LEAF:
+   Vprintf(stdout, "leaf");
+   break;
+   case LINK:
+   Vprintf(stdout, "link");
+   break;
+   }
+   fprintf(stdout, "%10d\t%10llu\t%s\n", size, (unsigned long long)ino, 
name);
+}
+
 /*
  * handle unexpected inconsistencies
  */

-- 
Manuel Giraud



restore typo

2015-11-09 Thread Manuel Giraud
Hi,

Here is a typo in the verbose mode of restore:

Index: tape.c
===
RCS file: /cvs/src/sbin/restore/tape.c,v
retrieving revision 1.46
diff -u -p -r1.46 tape.c
--- tape.c  25 Aug 2015 04:18:43 -  1.46
+++ tape.c  9 Nov 2015 16:01:27 -
@@ -547,7 +547,7 @@ extractfile(char *name)
skipfile();
return (GOOD);
}
-   Vprintf(stdout, "extract file %s\n", name);
+   Vprintf(stdout, "extract directory %s\n", name);
return (genliteraldir(name, curfile.ino));
 
    case IFLNK: {

-- 
Manuel Giraud



Cache-Control for httpd

2015-09-15 Thread Manuel Giraud
  }
+
+   media.media_maxage = $2;
}
+   |
;
 
 port   : PORT NUMBER {
@@ -1553,6 +1564,7 @@ load_config(const char *filename, struct
(void)strlcpy(m.media_subtype,
mediatypes[i].media_subtype,
sizeof(m.media_subtype));
+   m.media_maxage = mediatypes[i].media_maxage;
m.media_encoding = NULL;
 
if (media_add(conf->sc_mediatypes, ) == NULL) {
Index: server_http.c
===
RCS file: /cvs/src/usr.sbin/httpd/server_http.c,v
retrieving revision 1.75
diff -u -p -r1.75 server_http.c
--- server_http.c   23 Feb 2015 18:43:18 -  1.75
+++ server_http.c   15 Sep 2015 12:18:20 -
@@ -1130,7 +1130,7 @@ server_response_http(struct client *clt,
struct http_descriptor  *desc = clt->clt_descreq;
struct http_descriptor  *resp = clt->clt_descresp;
const char  *error;
-   struct kv   *ct, *cl;
+   struct kv   *ct, *cl, *cc;
char     tmbuf[32];
 
if (desc == NULL || (error = server_httperror_byid(code)) == NULL)
@@ -1169,6 +1169,10 @@ server_response_http(struct client *clt,
kv_set(cl, "%ld", size) == -1)
return (-1);
 
+   if ((cc = kv_add(>http_headers, "Cache-Control", NULL)) == NULL ||
+   kv_set(cc, "max-age=%lld", media->media_maxage) == -1)
+   return (-1);
+   
/* Set last modification time */
if (server_http_time(mtime, tmbuf, sizeof(tmbuf)) <= 0 ||
kv_add(>http_headers, "Last-Modified", tmbuf) == NULL)


-- 
Manuel Giraud



Re: doas failsafe

2015-07-21 Thread Manuel Giraud
tekk t...@parlementum.net writes:

 I've never used a fully qualified path with doas and it works just fine.
 (doas mount, doas pkg_add, doas mg.) Do you mean in the config file
 or something? Requiring you to specify a full path on filtered commands
 or whatever? This may just be a recent change though, I only updated
 my system 2 days ago.

Ok my bad (again): as advised by the man page, I used an absolute path
as command in /etc/doas.conf:
   permit nopass :wheel cmd /sbin/mount
with this, I should doas /sbin/mount.

Changing to:
   permit nopass :wheel cmd mount
works as you said.
-- 
Manuel Giraud



Re: doas failsafe

2015-07-21 Thread Manuel Giraud
Ted Unangst t...@tedunangst.com writes:

 Manuel Giraud wrote:
 Hi,
 
 I've just shot myself in the foot after /etc/doas.conf tweaking. This
 patch adds a failsafe permit :wheel rule in case of syntax error. Is
 this safe enough? Should it be done elsewhere (with some kind of
 visudo)?

 I think the failsafe is run su. Since it is possible to configure doas to
 even less than permit :wheel this would in some cases be a fail
 open.

You're right. I forgot about su and should have asked first. Another
question before I give this a shot: doas requires an absolute path for
command, is it feature or a behaviour that can be modified (i.e. I
prefer to type doas mount instead of doas /sbin/mount)?
-- 
Manuel Giraud



doas failsafe

2015-07-20 Thread Manuel Giraud
Hi,

I've just shot myself in the foot after /etc/doas.conf tweaking. This
patch adds a failsafe permit :wheel rule in case of syntax error. Is
this safe enough? Should it be done elsewhere (with some kind of
visudo)?

Index: doas.c
===
RCS file: /cvs/src/usr.bin/doas/doas.c,v
retrieving revision 1.14
diff -u -p -u -r1.14 doas.c
--- doas.c  20 Jul 2015 01:04:37 -  1.14
+++ doas.c  20 Jul 2015 12:16:11 -
@@ -138,12 +138,13 @@ permit(uid_t uid, gid_t *groups, int ngr
return (*lastr)-action == PERMIT;
 }
 
-static void
+static int
 parseconfig(const char *filename)
 {
extern FILE *yyfp;
extern int yyparse(void);
struct stat sb;
+   int ret;
 
yyfp = fopen(filename, r);
if (!yyfp) {
@@ -158,8 +159,9 @@ parseconfig(const char *filename)
if (sb.st_uid != 0)
errx(1, %s is not owned by root, filename);
 
-   yyparse();
+   ret = yyparse();
fclose(yyfp);
+   return ret;
 }
 
 static int
@@ -201,7 +203,7 @@ copyenv(const char **oldenvp, struct rul
int ei;
int nsafe, nbad;
int nextras = 0;
-   
+
nbad = arraylen(badset);
if ((rule-options  KEEPENV)  !rule-envlist) {
size_t i, ii;
@@ -280,8 +282,18 @@ main(int argc, char **argv, char **envp)
int ngroups;
int i, ch;
int sflag = 0;
+   const char *safeident = :wheel;
 
-   parseconfig(/etc/doas.conf);
+   if (parseconfig(/etc/doas.conf) != 0) {
+   fprintf(stderr, using failsafe rule\n);
+   if (!(rules = reallocarray(rules, 1, sizeof(*rules
+   errx(1, can't allocate rules);
+   if (!(rules[0] = calloc(1, sizeof(struct rule
+   errx(1, can't allocate rule);
+   rules[0]-action = PERMIT;
+   rules[0]-ident = safeident;
+   nrules = 1;
+   }
 
while ((ch = getopt(argc, argv, su:)) != -1) {
switch (ch) {
Index: parse.y
===
RCS file: /cvs/src/usr.bin/doas/parse.y,v
retrieving revision 1.6
diff -u -p -u -r1.6 parse.y
--- parse.y 19 Jul 2015 22:11:41 -  1.6
+++ parse.y 20 Jul 2015 12:16:11 -
@@ -149,7 +149,7 @@ yyerror(const char *fmt, ...)
va_list va;
 
va_start(va, fmt);
-   verrx(1, fmt, va);
+   vwarnx(fmt, va);
 }
 
 struct keyword {

-- 
Manuel Giraud



Re: [ping] dump -U by default

2015-05-12 Thread Manuel Giraud
)
rn = rawname(fs-fs_spec);
if (rn != NULL  strcmp(rn, key) == 0)
return (fs);
+   if (rn != NULL) {
+   uid = getduid(rn);
+   } else {
+   uid = getduid(fs-fs_spec);
+   }
+   if (uid != NULL  strcmp(uid, key) == 0)
+   return (fs);
if (key[0] != '/') {
if (*fs-fs_spec == '/' 
strcmp(fs-fs_spec + 1, key) == 0)
@@ -387,7 +394,7 @@ lastdump(int arg)
lastname = ??;
ITITERATE(i, dtwalk) {
if (strncmp(lastname, dtwalk-dd_name,
-   sizeof(dtwalk-dd_name)) == 0)
+   sizeof(dtwalk-dd_name)) == 0)
continue;
date = (char *)ctime(dtwalk-dd_ddate);
date[16] = '\0';/* blast away seconds and year */

-- 
Manuel Giraud



Re: [ping] dump -U by default

2015-05-06 Thread Manuel Giraud
Philip Guenther guent...@gmail.com writes:

 So I'll commit your diff; you wanna switch at doing the matching for
 -w/-W ?

Ok so hopefully, I think I get this right. With the following /etc/fstab:

8e26a31ab7f46c90.b none swap sw
bf16ae2b23dadbc7.a / ffs rw 1 1
swap /tmp tmpfs rw,noexec,nodev,nosuid,-s50m 0 0
bf16ae2b23dadbc7.f /home ffs rw,nodev,nosuid,softdep 1 2
bf16ae2b23dadbc7.e /usr ffs rw,nodev,softdep 1 2
bf16ae2b23dadbc7.d /var ffs rw,nodev,nosuid,softdep 1 2

bf16ae2b23dadbc7.g /usr/src ffs rw,softdep,noauto 0 0
/dev/sd0h /usr/xenocara ffs rw,softdep,noauto 1 0

and /etc/dumpdates:

/dev/sd0a 0 Wed Apr  1 10:50:27 2015
/var 0 Wed Apr 1 11:30:05 2015
bf16ae2b23dadbc7.e 0 Fri Apr 24 11:30:09 2015
bf16ae2b23dadbc7.f 0 Fri Apr 24 11:36:42 2015
bf16ae2b23dadbc7.e 1 Tue May  5 12:30:04 2015
bf16ae2b23dadbc7.f 1 Tue May  5 12:30:30 2015
bf16ae2b23dadbc7.h 0 Wed Apr  1 09:56:56 2015

dump -w gives:

Dump these file systems:
  /dev/sd0a ( /) Last dump: Level 0, Date Wed Apr  1 10:50
  /var  (  /var) Last dump: Level 0, Date Wed Apr  1 11:30
  bf16ae2b23dadbc7.h(/usr/xenocara) Last dump: Level 0, Date Wed Apr  1 
09:56

and dump -W gives:

Last dump(s) done (Dump '' file systems):
 /dev/sd0a ( /) Last dump: Level 0, Date Wed Apr  1 10:50
 /var  (  /var) Last dump: Level 0, Date Wed Apr  1 11:30
  bf16ae2b23dadbc7.e(  /usr) Last dump: Level 1, Date Tue May  5 12:30
  bf16ae2b23dadbc7.f( /home) Last dump: Level 1, Date Tue May  5 12:30
 bf16ae2b23dadbc7.h(/usr/xenocara) Last dump: Level 0, Date Wed Apr  1 
 09:56

Here is the patch:

Index: dump.h
===
RCS file: /cvs/src/sbin/dump/dump.h,v
retrieving revision 1.23
diff -u -p -r1.23 dump.h
--- dump.h  3 May 2015 01:44:34 -   1.23
+++ dump.h  6 May 2015 09:24:24 -
@@ -125,6 +125,7 @@ __dead void dumpabort(int signo);
 void   getfstab(void);
 
 char   *rawname(char *cp);
+char   *getrealpath(char *path);
 union  dinode *getino(ino_t inum, int *mode);
 
 /* rdump routines */
Index: main.c
===
RCS file: /cvs/src/sbin/dump/main.c,v
retrieving revision 1.55
diff -u -p -r1.55 main.c
--- main.c  3 May 2015 01:44:34 -   1.55
+++ main.c  6 May 2015 09:24:24 -
@@ -659,6 +659,23 @@ rawname(char *cp)
 }
 
 /*
+ * Wrapper around opendev(3) to get a realpath of a device.
+ */
+char *
+getrealpath(char *path)
+{
+   int fd;
+   char *realpath;
+
+   if ((fd = opendev(path, O_RDONLY | O_NOFOLLOW, 0,
+ realpath)) = 0) {
+   close(fd);
+   return (strdup(realpath));
+   }
+   return (NULL);
+}
+
+/*
  * obsolete --
  * Change set of key letters and ordered arguments into something
  * getopt(3) will like.
Index: optr.c
===
RCS file: /cvs/src/sbin/dump/optr.c,v
retrieving revision 1.36
diff -u -p -r1.36 optr.c
--- optr.c  15 Mar 2015 00:41:27 -  1.36
+++ optr.c  6 May 2015 09:24:24 -
@@ -337,7 +337,7 @@ fstabsearch(char *key)
 {
struct pfstab *pf;
struct fstab *fs;
-   char *rn;
+   char *rn, *rp;
 
for (pf = table; pf != NULL; pf = pf-pf_next) {
fs = pf-pf_fstab;
@@ -346,6 +346,13 @@ fstabsearch(char *key)
return (fs);
rn = rawname(fs-fs_spec);
if (rn != NULL  strcmp(rn, key) == 0)
+   return (fs);
+   rp = getrealpath(key);
+   if (rn != NULL  rp != NULL  strcmp(rn, rp) == 0)
+   return (fs);
+   rp = getrealpath(fs-fs_spec);
+   rn = rawname(key);
+   if (rn != NULL  rp != NULL  strcmp(rn, rp) == 0)
return (fs);
if (key[0] != '/') {
if (*fs-fs_spec == '/' 

-- 
Manuel Giraud



[ping] dump -U by default

2015-04-15 Thread Manuel Giraud
)
-   ;
-   else if (memcmp(lab.d_uid, zero_uid, sizeof(lab.d_uid)) == 0) {
-   msg(Cannot find DUID of disk %s\n, disk);
-   exit(X_STARTUP);
+   
+   if (memcmp(lab.d_uid, zero_uid, sizeof(lab.d_uid)) == 0) {
+   duid = NULL;
} else if (asprintf(duid,
%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx.%c,
lab.d_uid[0], lab.d_uid[1], lab.d_uid[2], lab.d_uid[3],
@@ -594,7 +588,7 @@ usage(void)
 {
extern char *__progname;
 
-   (void)fprintf(stderr, usage: %s [-0123456789acnSUuWw] [-B records] 
+   (void)fprintf(stderr, usage: %s [-0123456789acnSuWw] [-B records] 
  [-b blocksize] [-d density]\n
  \t[-f file] [-h level] [-s feet] 
  [-T date] files-to-dump\n,

-- 
Manuel Giraud



Re: [proposal] dump -U by default

2015-04-07 Thread Manuel Giraud
Philip Guenther guent...@gmail.com writes:

 On Fri, Apr 3, 2015 at 7:14 AM, Manuel Giraud man...@ledu-giraud.fr wrote:
 The following patch replaces the -U flag with a -D flag that forces
 usage of device name in /etc/dumpdates. The default is now to use DUID.

 Why?:
 - dump identification would better be unique
 - dumpdates is less human readable but not that less if need be

 I don't think this the right direction, simply adding a different
 option.  To quote what I wrote back in mid March:
 I wonder if it could be made the default by first searching for an
 entry with DUID and lower dump level, and falling back to a device
 name entry if no matching DUID entry was found or if they were just
 for higher dump levels. Once you do a level zero for a DUID it'll
 never look for a device entry again, but during the transition I think
 that strategy would find the same device entries that it would
 otherwise have found.

 This will require more invasive work, but will to the Right Thing for
 both device and DUID users and will silently and correctly handle the
 device-DUID transition.

Ok. Here is a patch that tries to do this. I've lightly tested it but
this needs way more eyeballs.

Index: dump.8
===
RCS file: /cvs/src/sbin/dump/dump.8,v
retrieving revision 1.48
diff -u -p -r1.48 dump.8
--- dump.8  17 Jul 2014 19:58:05 -  1.48
+++ dump.8  7 Apr 2015 11:28:33 -
@@ -40,7 +40,7 @@
 .Sh SYNOPSIS
 .Nm dump
 .Bk -words
-.Op Fl 0123456789acnSUuWw
+.Op Fl 0123456789acnSuWw
 .Op Fl B Ar records
 .Op Fl b Ar blocksize
 .Op Fl d Ar density
@@ -229,13 +229,6 @@ The
 flag is mutually exclusive from the
 .Fl u
 flag.
-.It Fl U
-Use the
-.Xr disklabel 8
-UID instead of the device name when updating
-.Pa /etc/dumpdates
-and when searching for the date of the latest
-lower-level dump.
 .It Fl u
 Update the file
 .Pa /etc/dumpdates
@@ -244,7 +237,9 @@ The format of
 .Pa /etc/dumpdates
 is human readable, consisting of one
 free format record per line:
-filesystem name,
+filesystem name (defaults to
+.Xr disklabel 8
+UID when possible),
 increment level
 and
 .Xr ctime 3
Index: dump.h
===
RCS file: /cvs/src/sbin/dump/dump.h,v
retrieving revision 1.22
diff -u -p -r1.22 dump.h
--- dump.h  3 Sep 2014 02:34:34 -   1.22
+++ dump.h  7 Apr 2015 11:28:33 -
@@ -60,7 +60,6 @@ char  *duid;  /* duid of the disk being d
 char   lastlevel;  /* dump level of previous dump */
 char   level;  /* dump level of this dump */
 intuflag;  /* update flag */
-intUflag;  /* use duids in dumpdates flag */
 intdiskfd; /* disk file descriptor */
 inttapefd; /* tape file descriptor */
 intpipeout;/* true = output to standard output */
Index: itime.c
===
RCS file: /cvs/src/sbin/dump/itime.c,v
retrieving revision 1.19
diff -u -p -r1.19 itime.c
--- itime.c 16 Jan 2015 06:39:57 -  1.19
+++ itime.c 7 Apr 2015 11:28:33 -
@@ -125,7 +125,7 @@ getdumptime(void)
int i;
char *fname;
 
-   fname = Uflag ? duid : disk;
+   fname = duid ? duid : disk;
 #ifdef FDEBUG
msg(Looking for name %s in dumpdates = %s for level = %c\n,
fname, dumpdates, level);
@@ -139,7 +139,8 @@ getdumptime(void)
 *  and older date
 */
ITITERATE(i, ddp) {
-   if (strncmp(fname, ddp-dd_name, sizeof(ddp-dd_name)) != 0)
+   if ((strncmp(fname, ddp-dd_name, sizeof(ddp-dd_name)) != 0) 
+   (strncmp(disk, ddp-dd_name, sizeof(ddp-dd_name)) != 0))
continue;
if (ddp-dd_level = level)
continue;
@@ -165,7 +166,7 @@ putdumptime(void)
quit(cannot rewrite %s: %s\n, dumpdates, strerror(errno));
fd = fileno(df);
(void) flock(fd, LOCK_EX);
-   fname = Uflag ? duid : disk;
+   fname = duid ? duid : disk;
free((char *)ddatev);
ddatev = 0;
nddates = 0;
@@ -176,8 +177,10 @@ putdumptime(void)
quit(fseek: %s\n, strerror(errno));
spcl.c_ddate = 0;
ITITERATE(i, dtwalk) {
-   if (strncmp(fname, dtwalk-dd_name,
-   sizeof(dtwalk-dd_name)) != 0)
+   if ((strncmp(fname, dtwalk-dd_name,
+sizeof(dtwalk-dd_name)) != 0) 
+   (strncmp(disk, dtwalk-dd_name,
+sizeof(dtwalk-dd_name)) != 0))
continue;
if (dtwalk-dd_level != level)
continue;
Index: main.c
===
RCS file: /cvs/src/sbin/dump/main.c,v
retrieving revision 1.54
diff -u -p -r1.54

[proposal] dump -U by default

2015-04-03 Thread Manuel Giraud
Hi,

The following patch replaces the -U flag with a -D flag that forces
usage of device name in /etc/dumpdates. The default is now to use DUID.

Why?:
- dump identification would better be unique
- dumpdates is less human readable but not that less if need be

Index: dump.8
===
RCS file: /cvs/src/sbin/dump/dump.8,v
retrieving revision 1.48
diff -u -p -r1.48 dump.8
--- dump.8  17 Jul 2014 19:58:05 -  1.48
+++ dump.8  3 Apr 2015 14:04:04 -
@@ -40,7 +40,7 @@
 .Sh SYNOPSIS
 .Nm dump
 .Bk -words
-.Op Fl 0123456789acnSUuWw
+.Op Fl 0123456789acnSDuWw
 .Op Fl B Ar records
 .Op Fl b Ar blocksize
 .Op Fl d Ar density
@@ -229,13 +229,13 @@ The
 flag is mutually exclusive from the
 .Fl u
 flag.
-.It Fl U
-Use the
-.Xr disklabel 8
-UID instead of the device name when updating
+.It Fl D
+Use the device name when updating
 .Pa /etc/dumpdates
 and when searching for the date of the latest
-lower-level dump.
+lower-level dump. The default is to use the
+.Xr disklabel 8
+UID.
 .It Fl u
 Update the file
 .Pa /etc/dumpdates
Index: dump.h
===
RCS file: /cvs/src/sbin/dump/dump.h,v
retrieving revision 1.22
diff -u -p -r1.22 dump.h
--- dump.h  3 Sep 2014 02:34:34 -   1.22
+++ dump.h  3 Apr 2015 14:04:04 -
@@ -60,7 +60,7 @@ char  *duid;  /* duid of the disk being d
 char   lastlevel;  /* dump level of previous dump */
 char   level;  /* dump level of this dump */
 intuflag;  /* update flag */
-intUflag;  /* use duids in dumpdates flag */
+intDflag;  /* use devices names in dumpdates flag (defaults to 
duids) */
 intdiskfd; /* disk file descriptor */
 inttapefd; /* tape file descriptor */
 intpipeout;/* true = output to standard output */
Index: itime.c
===
RCS file: /cvs/src/sbin/dump/itime.c,v
retrieving revision 1.19
diff -u -p -r1.19 itime.c
--- itime.c 16 Jan 2015 06:39:57 -  1.19
+++ itime.c 3 Apr 2015 14:04:04 -
@@ -125,7 +125,7 @@ getdumptime(void)
int i;
char *fname;
 
-   fname = Uflag ? duid : disk;
+   fname = Dflag ? disk : duid;
 #ifdef FDEBUG
msg(Looking for name %s in dumpdates = %s for level = %c\n,
fname, dumpdates, level);
@@ -165,7 +165,7 @@ putdumptime(void)
quit(cannot rewrite %s: %s\n, dumpdates, strerror(errno));
fd = fileno(df);
(void) flock(fd, LOCK_EX);
-   fname = Uflag ? duid : disk;
+   fname = Dflag ? disk : duid;
free((char *)ddatev);
ddatev = 0;
nddates = 0;
Index: main.c
===
RCS file: /cvs/src/sbin/dump/main.c,v
retrieving revision 1.54
diff -u -p -r1.54 main.c
--- main.c  20 Jan 2015 18:22:20 -  1.54
+++ main.c  3 Apr 2015 14:04:04 -
@@ -115,7 +115,7 @@ main(int argc, char *argv[])
usage();
 
obsolete(argc, argv);
-   while ((ch = getopt(argc, argv, 0123456789aB:b:cd:f:h:ns:ST:UuWw)) != 
-1)
+   while ((ch = getopt(argc, argv, 0123456789aB:b:cd:f:h:ns:ST:DuWw)) != 
-1)
switch (ch) {
/* dump level */
case '0': case '1': case '2': case '3': case '4':
@@ -183,8 +183,8 @@ main(int argc, char *argv[])
lastlevel = '?';
break;
 
-   case 'U':
-   Uflag = 1;  /* use duids */
+   case 'D':
+   Dflag = 1;  /* use devices names instead of duids */
break;
 
case 'u':   /* update /etc/dumpdates */
@@ -394,7 +394,7 @@ main(int argc, char *argv[])
}
if (ioctl(diskfd, DIOCGDINFO, (char *)lab)  0)
err(1, ioctl (DIOCGDINFO));
-   if (!Uflag)
+   if (Dflag)
;
else if (memcmp(lab.d_uid, zero_uid, sizeof(lab.d_uid)) == 0) {
msg(Cannot find DUID of disk %s\n, disk);

-- 
Manuel Giraud



exclude-list in mtree (2)

2014-06-20 Thread Manuel Giraud
, FNM_PATHNAME))
+		|| !fnmatch(e-glob, fname, FNM_PATHNAME))
+			return 1;
+	}
+	return 0;
+}
Index: extern.h
===
RCS file: /cvs/src/usr.sbin/mtree/extern.h,v
retrieving revision 1.8
diff -u -p -r1.8 extern.h
--- extern.h	10 Aug 2005 00:42:09 -	1.8
+++ extern.h	20 Jun 2014 12:45:35 -
@@ -46,3 +46,6 @@ u_int		 parsekey(char *, int *);
 char		*rlink(char *);
 struct _node	*spec(void);
 int		 verify(void);
+int		 check_excludes(const char *, const char*);
+void		 init_excludes(void);
+int		 read_excludes_file(const char*);
Index: mtree.8
===
RCS file: /cvs/src/usr.sbin/mtree/mtree.8,v
retrieving revision 1.37
diff -u -p -r1.37 mtree.8
--- mtree.8	10 Jan 2014 20:20:34 -	1.37
+++ mtree.8	20 Jun 2014 12:45:35 -
@@ -45,6 +45,7 @@
 .Op Fl k Ar keywords
 .Op Fl p Ar path
 .Op Fl s Ar seed
+.Op Fl X Ar exclude-list
 .Ek
 .Sh DESCRIPTION
 The utility
@@ -147,6 +148,20 @@ option except a status of 2 is returned 
 did not match the specification.
 .It Fl x
 Don't descend below mount points in the file hierarchy.
+.It Fl X Ar exclude-list
+The specified file contains
+.Xr fnmatch 3
+patterns matching files to be excluded from
+the specification, one to a line.
+If the pattern contains a
+.Ql \/
+character, it will be matched against entire pathnames (relative to
+the starting directory); otherwise,
+it will be matched against basenames only.
+No comments are allowed in
+the
+.Ar exclude-list
+file.
 .El
 .Pp
 Specifications are mostly composed of
Index: mtree.c
===
RCS file: /cvs/src/usr.sbin/mtree/mtree.c,v
retrieving revision 1.21
diff -u -p -r1.21 mtree.c
--- mtree.c	27 Nov 2013 13:32:02 -	1.21
+++ mtree.c	20 Jun 2014 12:45:35 -
@@ -46,6 +46,7 @@ int cflag, dflag, eflag, iflag, lflag, n
 uflag, Uflag;
 u_int keys;
 char fullpath[MAXPATHLEN];
+char *excludefile = NULL;
 
 static void usage(void);
 
@@ -60,7 +61,7 @@ main(int argc, char *argv[])
 
 	dir = NULL;
 	keys = KEYDEFAULT;
-	while ((ch = getopt(argc, argv, cdef:iK:k:lnp:qrs:tUux)) != -1)
+	while ((ch = getopt(argc, argv, cdef:iK:k:lnp:qrs:tUuxX:)) != -1)
 		switch(ch) {
 		case 'c':
 			cflag = 1;
@@ -123,6 +124,10 @@ main(int argc, char *argv[])
 		case 'x':
 			ftsoptions |= FTS_XDEV;
 			break;
+		case 'X':
+			if ((excludefile = realpath(optarg, NULL)) == NULL)
+err(1, %s, optarg);
+			break;
 		case '?':
 		default:
 			usage();
@@ -133,6 +138,15 @@ main(int argc, char *argv[])
 	if (argc)
 		usage();
 
+	if (excludefile) {
+		init_excludes();
+		if (read_excludes_file(excludefile)) {
+			warn(%s, excludefile);
+			free(excludefile);
+			excludefile = NULL;
+		}
+	}
+
 	if (dir  chdir(dir))
 		error(%s: %s, dir, strerror(errno));
 
@@ -158,6 +172,6 @@ usage(void)
 	(void)fprintf(stderr,
 	usage: mtree [-cdeilnqrtUux] [-f spec] [-K keywords] 
 	[-k keywords] [-p path]\n
-	 [-s seed]\n);
+	 [-s seed] [-X excludes]\n);
 	exit(1);
 }
Index: verify.c
===
RCS file: /cvs/src/usr.sbin/mtree/verify.c,v
retrieving revision 1.19
diff -u -p -r1.19 verify.c
--- verify.c	27 Oct 2009 23:59:53 -	1.19
+++ verify.c	20 Jun 2014 12:45:35 -
@@ -79,6 +79,10 @@ vwalk(void)
 	level = root;
 	specdepth = rval = 0;
 	while ((p = fts_read(t))) {
+		if (check_excludes(p-fts_name, p-fts_path)) {
+			fts_set(t, p, FTS_SKIP);
+			continue;
+		}
 		switch(p-fts_info) {
 		case FTS_D:
 			break;
-- 
Manuel Giraud


Re: exclude-list in mtree (2)

2014-06-20 Thread Manuel Giraud
);
+   if (strchr(e-glob, '/'))
+   e-pathname = 1;
+   else
+   e-pathname = 0;
+   LIST_INSERT_HEAD(excludes, e, link);
+   }
+   free(lbuf);
+   fclose(fp);
+
+   return 0;
+}
+
+int
+check_excludes(const char *fname, const char *path)
+{
+   struct exclude *e;
+
+   /* Remove leading dot-slash before path match */
+   if ((path[0] == '.')  (path[1] == '/'))
+   path += 2;
+
+   LIST_FOREACH(e, excludes, link) {
+   if ((e-pathname  !fnmatch(e-glob, path, FNM_PATHNAME))
+   || !fnmatch(e-glob, fname, FNM_PATHNAME))
+   return 1;
+   }
+   return 0;
+}
Index: extern.h
===
RCS file: /cvs/src/usr.sbin/mtree/extern.h,v
retrieving revision 1.8
diff -u -p -r1.8 extern.h
--- extern.h10 Aug 2005 00:42:09 -  1.8
+++ extern.h20 Jun 2014 12:45:35 -
@@ -46,3 +46,6 @@ u_int  parsekey(char *, int *);
 char   *rlink(char *);
 struct _node   *spec(void);
 int verify(void);
+int check_excludes(const char *, const char*);
+voidinit_excludes(void);
+int read_excludes_file(const char*);
Index: mtree.8
===
RCS file: /cvs/src/usr.sbin/mtree/mtree.8,v
retrieving revision 1.37
diff -u -p -r1.37 mtree.8
--- mtree.8 10 Jan 2014 20:20:34 -  1.37
+++ mtree.8 20 Jun 2014 12:45:35 -
@@ -45,6 +45,7 @@
 .Op Fl k Ar keywords
 .Op Fl p Ar path
 .Op Fl s Ar seed
+.Op Fl X Ar exclude-list
 .Ek
 .Sh DESCRIPTION
 The utility
@@ -147,6 +148,20 @@ option except a status of 2 is returned 
 did not match the specification.
 .It Fl x
 Don't descend below mount points in the file hierarchy.
+.It Fl X Ar exclude-list
+The specified file contains
+.Xr fnmatch 3
+patterns matching files to be excluded from
+the specification, one to a line.
+If the pattern contains a
+.Ql \/
+character, it will be matched against entire pathnames (relative to
+the starting directory); otherwise,
+it will be matched against basenames only.
+No comments are allowed in
+the
+.Ar exclude-list
+file.
 .El
 .Pp
 Specifications are mostly composed of
Index: mtree.c
===
RCS file: /cvs/src/usr.sbin/mtree/mtree.c,v
retrieving revision 1.21
diff -u -p -r1.21 mtree.c
--- mtree.c 27 Nov 2013 13:32:02 -  1.21
+++ mtree.c 20 Jun 2014 12:45:35 -
@@ -46,6 +46,7 @@ int cflag, dflag, eflag, iflag, lflag, n
 uflag, Uflag;
 u_int keys;
 char fullpath[MAXPATHLEN];
+char *excludefile = NULL;
 
 static void usage(void);
 
@@ -60,7 +61,7 @@ main(int argc, char *argv[])
 
dir = NULL;
keys = KEYDEFAULT;
-   while ((ch = getopt(argc, argv, cdef:iK:k:lnp:qrs:tUux)) != -1)
+   while ((ch = getopt(argc, argv, cdef:iK:k:lnp:qrs:tUuxX:)) != -1)
switch(ch) {
case 'c':
cflag = 1;
@@ -123,6 +124,10 @@ main(int argc, char *argv[])
case 'x':
ftsoptions |= FTS_XDEV;
break;
+   case 'X':
+   if ((excludefile = realpath(optarg, NULL)) == NULL)
+   err(1, %s, optarg);
+   break;
case '?':
default:
usage();
@@ -133,6 +138,15 @@ main(int argc, char *argv[])
if (argc)
usage();
 
+   if (excludefile) {
+   init_excludes();
+   if (read_excludes_file(excludefile)) {
+   warn(%s, excludefile);
+   free(excludefile);
+   excludefile = NULL;
+   }
+   }
+
if (dir  chdir(dir))
error(%s: %s, dir, strerror(errno));
 
@@ -158,6 +172,6 @@ usage(void)
(void)fprintf(stderr,
usage: mtree [-cdeilnqrtUux] [-f spec] [-K keywords] 
[-k keywords] [-p path]\n
-[-s seed]\n);
+[-s seed] [-X excludes]\n);
exit(1);
 }
Index: verify.c
===
RCS file: /cvs/src/usr.sbin/mtree/verify.c,v
retrieving revision 1.19
diff -u -p -r1.19 verify.c
--- verify.c27 Oct 2009 23:59:53 -  1.19
+++ verify.c20 Jun 2014 12:45:35 -
@@ -79,6 +79,10 @@ vwalk(void)
level = root;
specdepth = rval = 0;
while ((p = fts_read(t))) {
+   if (check_excludes(p-fts_name, p-fts_path)) {
+   fts_set(t, p, FTS_SKIP);
+   continue;
+   }
switch(p-fts_info) {
case FTS_D:
break;

-- 
Manuel Giraud



Re: exclude-list in mtree (2)

2014-06-20 Thread Manuel Giraud
Tobias Stoeckmann tob...@stoeckmann.org writes:

 On Fri, Jun 20, 2014 at 04:34:19PM +0200, Manuel Giraud wrote:
 +lbuf = NULL;
 +while ((buf = fgetln(fp, len))) {
 +if (buf[len - 1] == '\n') {
 +if (len == 1) 
 +continue;
 +buf[len - 1] = '\0';
 +} else {
 +len++;
 +if ((lbuf = malloc(len)) == NULL)
 +err(1, NULL);
 +memcpy(lbuf, buf, len - 1);
 +lbuf[len - 1] = '\0';
 +buf = lbuf;
 +}

 What is the rational behind checking for len == 1 in '\n'
 case, but not for last line without new line?

 If you want to skip empty lines, you should check after
 the if/else-block for buf[0] == '\0', imho.

Ok:
Index: Makefile
===
RCS file: /cvs/src/usr.sbin/mtree/Makefile,v
retrieving revision 1.9
diff -u -p -r1.9 Makefile
--- Makefile15 Apr 2013 06:25:18 -  1.9
+++ Makefile20 Jun 2014 15:33:51 -
@@ -3,6 +3,6 @@
 PROG=  mtree
 #CFLAGS+=-DDEBUG
 MAN=   mtree.8
-SRCS=  compare.c crc.c create.c misc.c mtree.c spec.c verify.c
+SRCS=  compare.c crc.c create.c excludes.c misc.c mtree.c spec.c verify.c
 
 .include bsd.prog.mk
Index: create.c
===
RCS file: /cvs/src/usr.sbin/mtree/create.c,v
retrieving revision 1.29
diff -u -p -r1.29 create.c
--- create.c22 Aug 2013 04:43:41 -  1.29
+++ create.c20 Jun 2014 15:33:51 -
@@ -58,6 +58,7 @@ extern int ftsoptions;
 extern int dflag, iflag, nflag, sflag;
 extern u_int keys;
 extern char fullpath[MAXPATHLEN];
+extern char *excludefile;
 
 static gid_t gid;
 static uid_t uid;
@@ -82,6 +83,8 @@ cwalk(void)
(void)printf(
#\t   user: %s\n#\tmachine: %s\n#\t   tree: %s\n#\t   date: %s,
getlogin(), host, fullpath, ctime(clock));
+   if (excludefile)
+   printf(#\texclude: %s\n, excludefile);
 
argv[0] = .;
argv[1] = NULL;
@@ -90,6 +93,10 @@ cwalk(void)
while ((p = fts_read(t))) {
if (iflag)
indent = p-fts_level * 4;
+   if (check_excludes(p-fts_name, p-fts_path)) {
+   fts_set(t, p, FTS_SKIP);
+   continue;
+   }
switch(p-fts_info) {
case FTS_D:
if (!dflag)
Index: excludes.c
===
RCS file: excludes.c
diff -N excludes.c
--- /dev/null   1 Jan 1970 00:00:00 -
+++ excludes.c  20 Jun 2014 15:33:51 -
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2000 Massachusetts Institute of Technology
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby
+ * granted, provided that both the above copyright notice and this
+ * permission notice appear in all copies, that both the above
+ * copyright notice and this permission notice appear in all
+ * supporting documentation, and that the name of M.I.T. not be used
+ * in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.  M.I.T. makes
+ * no representations about the suitability of this software for any
+ * purpose.  It is provided as is without express or implied
+ * warranty.
+ *
+ * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
+ * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL M.I.T. 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/types.h
+#include sys/queue.h
+#include err.h
+#include fnmatch.h
+#include fts.h
+#include stdio.h
+#include stdlib.h
+#include mtree.h
+#include extern.h
+
+/*
+ * We're assuming that there won't be a whole lot of excludes,
+ * so it's OK to use a stupid algorithm.
+ */
+struct exclude {
+   LIST_ENTRY(exclude) link;
+   const char *glob;
+   int pathname;
+};
+static LIST_HEAD(, exclude) excludes;
+
+void
+init_excludes(void)
+{
+   LIST_INIT(excludes);
+}
+
+int
+read_excludes_file(const char *name)
+{
+   FILE *fp;
+   char *buf, *lbuf;
+   struct exclude *e;
+   size_t len;
+
+
+   fp = fopen(name, r);
+   if (fp == NULL

exclude-list in mtree

2014-06-10 Thread Manuel Giraud
 *);
 struct _node	*spec(void);
 int		 verify(void);
+int		 check_excludes(const char *, const char*);
+void		 init_excludes(void);
+void		 read_excludes_file(const char*);
Index: mtree.8
===
RCS file: /cvs/src/usr.sbin/mtree/mtree.8,v
retrieving revision 1.37
diff -u -p -u -p -r1.37 mtree.8
--- mtree.8	10 Jan 2014 20:20:34 -	1.37
+++ mtree.8	10 Jun 2014 14:09:08 -
@@ -45,6 +45,7 @@
 .Op Fl k Ar keywords
 .Op Fl p Ar path
 .Op Fl s Ar seed
+.Op Fl X Ar exclude-list
 .Ek
 .Sh DESCRIPTION
 The utility
@@ -147,6 +148,20 @@ option except a status of 2 is returned 
 did not match the specification.
 .It Fl x
 Don't descend below mount points in the file hierarchy.
+.It Fl X Ar exclude-list
+The specified file contains
+.Xr fnmatch 3
+patterns matching files to be excluded from
+the specification, one to a line.
+If the pattern contains a
+.Ql \/
+character, it will be matched against entire pathnames (relative to
+the starting directory); otherwise,
+it will be matched against basenames only.
+No comments are allowed in
+the
+.Ar exclude-list
+file.
 .El
 .Pp
 Specifications are mostly composed of
Index: mtree.c
===
RCS file: /cvs/src/usr.sbin/mtree/mtree.c,v
retrieving revision 1.21
diff -u -p -u -p -r1.21 mtree.c
--- mtree.c	27 Nov 2013 13:32:02 -	1.21
+++ mtree.c	10 Jun 2014 14:09:08 -
@@ -55,12 +55,13 @@ main(int argc, char *argv[])
 	extern int optind;
 	extern char *optarg;
 	int ch;
-	char *dir, *p;
+	char *dir, *p, *excl;
 	int status;
 
 	dir = NULL;
+	excl = NULL;
 	keys = KEYDEFAULT;
-	while ((ch = getopt(argc, argv, cdef:iK:k:lnp:qrs:tUux)) != -1)
+	while ((ch = getopt(argc, argv, cdef:iK:k:lnp:qrs:tUuxX:)) != -1)
 		switch(ch) {
 		case 'c':
 			cflag = 1;
@@ -123,6 +124,9 @@ main(int argc, char *argv[])
 		case 'x':
 			ftsoptions |= FTS_XDEV;
 			break;
+		case 'X':
+			excl = optarg;
+			break;
 		case '?':
 		default:
 			usage();
@@ -133,6 +137,11 @@ main(int argc, char *argv[])
 	if (argc)
 		usage();
 
+	if (excl) {
+		init_excludes();
+		read_excludes_file(excl);
+	}
+
 	if (dir  chdir(dir))
 		error(%s: %s, dir, strerror(errno));
 
@@ -158,6 +167,6 @@ usage(void)
 	(void)fprintf(stderr,
 	usage: mtree [-cdeilnqrtUux] [-f spec] [-K keywords] 
 	[-k keywords] [-p path]\n
-	 [-s seed]\n);
+	 [-s seed] [-X excludes]\n);
 	exit(1);
 }
-- 
Manuel Giraud


remote dump to file

2011-08-25 Thread Manuel Giraud
Hi,

This patch makes the following command working:

$ RSH=ssh dump -0au -f remote:dump.0 /

even if dump.0 doesn't already exists on remote. Note: i cannot test
this patch on st(4) device.

Index: tape.c
===
RCS file: /cvs/src/sbin/dump/tape.c,v
retrieving revision 1.31
diff -u -p -r1.31 tape.c
--- tape.c  27 Oct 2009 23:59:32 -  1.31
+++ tape.c  25 Aug 2011 12:31:36 -
@@ -649,7 +649,7 @@ restore_check_point:
msg(Dumping volume %d on %s\n, tapeno, tape);
}
 #ifdef RDUMP
-   while ((tapefd = (host ? rmtopen(tape, 2) :
+   while ((tapefd = (host ? rmtopen(tape, O_WRONLY|O_CREAT) :
pipeout ? 1 : open(tape, O_WRONLY|O_CREAT, 0666)))  0)
 #else
while ((tapefd = (pipeout ? 1 :

-- 
Manuel Giraud



Re: softraid crypto: preallocate crypops and dma buffers.

2011-06-21 Thread Manuel Giraud
Todd T. Fries t...@fries.net writes:

 Penned by roberth on 20110620 21:05.14, we have:
 | On Mon, 20 Jun 2011 20:12:28 -0500
 | Marco Peereboom sl...@peereboom.us wrote:
 | 
 |  I am liking this diff quite a bit but it needs more testers.  So if
 |  you are using softraid crypto please try this diff.
 | 
 | Still working for me.

 And me.

 Volume  Status   Size Device  
 softraid0 0 Online  262939136 sd0 RAID1
   0 Online  262939136 0:0.0   noencl wd0a
   1 Online  262939136 0:1.0   noencl wd1a
 softraid0 1 Online99755925504 sd1 CRYPTO
   0 Online99755925504 1:0.0   noencl wd1d
 softraid0 2 Online 9228489728 sd2 CRYPTO
   0 Online 9228489728 2:0.0   noencl wd0d

And me for 2 days (on a simpler setup and already reported privately to
Owain):

Volume  Status   Size Device  
softraid0 0 Online53381796864 sd0 CRYPTO
  0 Online53381796864 0:0.0   noencl wd0d

-- 
Manuel Giraud



lprm -

2011-02-08 Thread Manuel Giraud
The following patch allowed a user of a local lpd to remove all his jobs
in queue but the active one with lprm -. I find it handy but maybe it
is not the wanted behaviour for historical reason or whatever.

--8---cut here---start-8---
Index: common_source/rmjob.c
===
RCS file: /cvs/src/usr.sbin/lpr/common_source/rmjob.c,v
retrieving revision 1.18
diff -u -p -r1.18 rmjob.c
--- common_source/rmjob.c   27 Oct 2009 23:59:51 -  1.18
+++ common_source/rmjob.c   8 Feb 2011 14:20:11 -
@@ -33,6 +33,7 @@
 #include sys/param.h
 
 #include signal.h
+#include err.h
 #include errno.h
 #include fcntl.h
 #include dirent.h
@@ -131,13 +132,14 @@ rmjob(void)
assasinated = kill(cur_daemon, SIGINT) == 0;
PRIV_END;
if (!assasinated)
-   fatal(cannot kill printer daemon);
+   warnx(cannot kill printer daemon);
}
/*
 * process the files
 */
for (i = 0; i  nitems; i++)
-   process(files[i]-d_name);
+   if (assasinated || strncmp(files[i]-d_name, current, 
NAME_MAX))
+   process(files[i]-d_name);
}
rmremote();
/*
--8---cut here---end---8---

-- 
Manuel Giraud



backquote TAB

2010-05-25 Thread Manuel Giraud
Hi, the following patch correct this:
http://cvs.openbsd.org/cgi-bin/query-pr-wrapper?full=yesnumbers=6006

but I don't know if it breaks someone else's use case (script)?

make check is ok.

Index: edit.c
===
RCS file: /cvs/src/bin/ksh/edit.c,v
retrieving revision 1.34
diff -u -p -r1.34 edit.c
--- edit.c  20 May 2010 01:13:07 -  1.34
+++ edit.c  25 May 2010 11:06:57 -
@@ -348,7 +348,7 @@ x_file_glob(int flags, const char *str, 
 {
char *toglob;
char **words;
-   int nwords, i, idx, escaping;
+   int nwords;
XPtrV w;
struct source *s, *sold;
 
@@ -356,20 +356,6 @@ x_file_glob(int flags, const char *str, 
return 0;
 
toglob = add_glob(str, slen);
-
-   /* remove all escaping backward slashes */
-   escaping = 0;
-   for (i = 0, idx = 0; toglob[i]; i++) {
-   if (toglob[i] == '\\'  !escaping) {
-   escaping = 1;
-   continue;
-   }
-
-   toglob[idx] = toglob[i];
-   idx++;
-   if (escaping) escaping = 0;
-   }
-   toglob[idx] = '\0';
 
/*
 * Convert foo* (toglob) to an array of strings (words)

-- 
Manuel Giraud



$LINENO in trap

2010-05-18 Thread Manuel Giraud
My first patch that solves this :
http://cvs.openbsd.org/cgi-bin/query-pr-wrapper?full=yesnumbers=6195

Comments?

Index: history.c
===
RCS file: /cvs/src/bin/ksh/history.c,v
retrieving revision 1.38
diff -u -p -r1.38 history.c
--- history.c   1 May 2010 21:09:23 -   1.38
+++ history.c   18 May 2010 13:42:38 -
@@ -226,7 +226,7 @@ c_fc(char **wp)
Source *sold = source;
int ret;
 
-   ret = command(editor ? editor : ${FCEDIT:-/bin/ed} $_);
+   ret = command(editor ? editor : ${FCEDIT:-/bin/ed} $_, 0);
source = sold;
if (ret)
return ret;
@@ -295,7 +295,7 @@ hist_execute(char *cmd)
 */
/* XXX: source should not get trashed by this.. */
sold = source;
-   ret = command(cmd);
+   ret = command(cmd, 0);
source = sold;
return ret;
 }
Index: main.c
===
RCS file: /cvs/src/bin/ksh/main.c,v
retrieving revision 1.45
diff -u -p -r1.45 main.c
--- main.c  29 Jan 2009 23:27:26 -  1.45
+++ main.c  18 May 2010 13:42:38 -
@@ -460,13 +460,18 @@ include(const char *name, int argc, char
return i  0xff;/*  0xff to ensure value not -1 */
 }
 
+/*
+ * spawn a command into a shell optionally keeping track of line
+ * number.
+ */
 int
-command(const char *comm)
+command(const char *comm, int line)
 {
Source *s;
 
s = pushs(SSTRING, ATEMP);
s-start = s-str = comm;
+   s-line = line;
return shell(s, false);
 }
 
Index: proto.h
===
RCS file: /cvs/src/bin/ksh/proto.h,v
retrieving revision 1.32
diff -u -p -r1.32 proto.h
--- proto.h 29 Jan 2009 23:27:26 -  1.32
+++ proto.h 18 May 2010 13:42:38 -
@@ -159,7 +159,7 @@ voidmbset(char *);
 void   mpset(char *);
 /* main.c */
 intinclude(const char *, int, char **, int);
-intcommand(const char *);
+intcommand(const char *, int);
 intshell(Source *volatile, int volatile);
 void   unwind(int) __attribute__((__noreturn__));
 void   newenv(int);
Index: trap.c
===
RCS file: /cvs/src/bin/ksh/trap.c,v
retrieving revision 1.22
diff -u -p -r1.22 trap.c
--- trap.c  30 Mar 2005 17:16:37 -  1.22
+++ trap.c  18 May 2010 13:42:38 -
@@ -235,7 +235,7 @@ runtrap(Trap *p)
/* Note: trapstr is fully parsed before anything is executed, thus
 * no problem with afree(p-trap) in settrap() while still in use.
 */
-   command(trapstr);
+   command(trapstr, current_lineno);
exstat = oexstat;
if (i == SIGEXIT_ || i == SIGERR_) {
if (p-flags  TF_CHANGED)

-- 
Manuel Giraud