Re: massage volume control task
> On 2 Jan 2015, at 9:55 pm, Mark Kettenis wrote: > >> Date: Fri, 2 Jan 2015 16:15:07 +1000 >> From: David Gwynne >> >> can someone test this? >> >> it allocates storage for the volume change details rather than cast >> arguments to a single global task. >> >> adds some safety while there if audio0 is a hotplug device. >> >> ok? > > The problem with this approach is that things silently fail when > memory allocation fails. Exactly the problem that workq_add_task() > had. Perhaps the best thing is to store the "event" in the softc, > although then you'd probably need some locking to make sure the task > sees a consistent dir/out pair. is "silently fail" a pun here? you can lose events either way. if you get more than one keypress before the task runs, you'll lose. if you are in a situation where you cant allocate memory, you lose. i think the code generally is bogus so im trying to do as little as possible to it. the more i look at it the more i want to just remove it. its been unreliable in all incarnations. > >> Index: audio.c >> === >> RCS file: /cvs/src/sys/dev/audio.c,v >> retrieving revision 1.125 >> diff -u -p -r1.125 audio.c >> --- audio.c 19 Dec 2014 22:44:58 - 1.125 >> +++ audio.c 2 Jan 2015 06:08:39 - >> @@ -465,11 +465,6 @@ audioattach(struct device *parent, struc >> } >> DPRINTF(("audio_attach: inputs ports=0x%x, output ports=0x%x\n", >> sc->sc_inports.allports, sc->sc_outports.allports)); >> - >> -#if NWSKBD > 0 >> -task_set(&sc->sc_mixer_task, wskbd_set_mixervolume_callback, NULL, >> -NULL); >> -#endif /* NWSKBD > 0 */ >> } >> >> int >> @@ -3432,27 +3427,39 @@ filt_audiowrite(struct knote *kn, long h >> } >> >> #if NWSKBD > 0 >> +struct wskbd_vol_change { >> +struct task t; >> +long dir; >> +long out; >> +}; >> + >> int >> wskbd_set_mixervolume(long dir, long out) >> { >> struct audio_softc *sc; >> +struct wskbd_vol_change *ch; >> >> if (audio_cd.cd_ndevs == 0 || (sc = audio_cd.cd_devs[0]) == NULL) { >> DPRINTF(("wskbd_set_mixervolume: audio_cd\n")); >> return (ENXIO); >> } >> >> -task_del(systq, &sc->sc_mixer_task); >> -task_set(&sc->sc_mixer_task, wskbd_set_mixervolume_callback, >> -(void *)dir, (void *)out); >> -task_add(systq, &sc->sc_mixer_task); >> +ch = malloc(sizeof(*ch), M_TEMP, M_NOWAIT); >> +if (ch == NULL) >> +return (ENOMEM); >> + >> +task_set(&ch->t, wskbd_set_mixervolume_callback, ch, NULL); >> +ch->dir = dir; >> +ch->out = out; >> +task_add(systq, &ch->t); >> >> return (0); >> } >> >> void >> -wskbd_set_mixervolume_callback(void *arg1, void *arg2) >> +wskbd_set_mixervolume_callback(void *xch, void *null) >> { >> +struct wskbd_vol_change *ch = xch; >> struct audio_softc *sc; >> struct au_mixer_ports *ports; >> mixer_devinfo_t mi; >> @@ -3461,19 +3468,19 @@ wskbd_set_mixervolume_callback(void *arg >> u_int gain; >> int error; >> >> -if (audio_cd.cd_ndevs == 0 || (sc = audio_cd.cd_devs[0]) == NULL) { >> -DPRINTF(("%s: audio_cd\n", __func__)); >> -return; >> -} >> +dir = ch->dir; >> +out = ch->out; >> +free(ch, M_TEMP, sizeof(*ch)); >> >> -dir = (long)arg1; >> -out = (long)arg2; >> +sc = (struct audio_softc *)device_lookup(&audio_cd, 0); >> +if (sc == NULL) >> +return; >> >> ports = out ? &sc->sc_outports : &sc->sc_inports; >> >> if (ports->master == -1) { >> DPRINTF(("%s: master == -1\n", __func__)); >> -return; >> +goto done; >> } >> >> if (dir == 0) { >> @@ -3482,7 +3489,7 @@ wskbd_set_mixervolume_callback(void *arg >> error = au_get_mute(sc, ports, &mute); >> if (error != 0) { >> DPRINTF(("%s: au_get_mute: %d\n", __func__, error)); >> -return; >> +goto done; >> } >> >> mute = !mute; >> @@ -3490,7 +3497,7 @@ wskbd_set_mixervolume_callback(void *arg >> error = au_set_mute(sc, ports, mute); >> if (error != 0) { >> DPRINTF(("%s: au_set_mute: %d\n", __func__, error)); >> -return; >> +goto done; >> } >> } else { >> /* Raise or lower volume */ >> @@ -3499,7 +3506,7 @@ wskbd_set_mixervolume_callback(void *arg >> error = sc->hw_if->query_devinfo(sc->hw_hdl, &mi); >> if (error != 0) { >> DPRINTF(("%s: query_devinfo: %d\n", __func__, error)); >> -return; >> +goto done; >> } >> >> au_get_gain(sc, ports, &gain, &balance); >> @@ -3512,8 +3519,11 @@ wskbd_set_mixervolume_callback(void *arg >> error = au_set_gain(sc, ports, ga
Re: disk quotas bug fix [was: quotas grace period "none" right away]
On Fri, Jan 02, 2015 at 02:32:39PM -0800, Philip Guenther wrote: > On Fri, Jan 2, 2015 at 1:28 PM, Boris Goldberg wrote: > > Philip is right. It's embarrassing I haven't checked the case with hard > > quota myself. > > We'll look into it. Philip is actually suggesting the way. I suppose he > > doesn't have time to implement it himself, does he? Don't want to work on > > something he is already working on. > > I don't have anything in the works for this; just followed the chain > far enough to understand why passing a different cred seemed wrong and > where the right direction might be. > > > Philip For this case it also good to check freebsd. Although theirs and our quota code are diverged, the structure is still similar. NetBSD did a complete rewrite. -Otto
Re: disk quotas bug fix [was: quotas grace period "none" right away]
On Fri, Jan 2, 2015 at 1:28 PM, Boris Goldberg wrote: > Philip is right. It's embarrassing I haven't checked the case with hard > quota myself. > We'll look into it. Philip is actually suggesting the way. I suppose he > doesn't have time to implement it himself, does he? Don't want to work on > something he is already working on. I don't have anything in the works for this; just followed the chain far enough to understand why passing a different cred seemed wrong and where the right direction might be. Philip
Re: disk quotas bug fix [was: quotas grace period "none" right away]
On Fri, Jan 02, 2015 at 03:28:46PM -0600, Boris Goldberg wrote: > What about our second patch? I'd rather stay in line with FreeBSD and document quoaoff/quotaon is needed for the new grace period to take effect. https://svnweb.freebsd.org/base/head/usr.sbin/edquota/edquota.8?r1=140442&r2=166496&pathrev=166496 -Otto
Re: disk quotas bug fix [was: quotas grace period "none" right away]
Hello Otto, Philip is right. It's embarrassing I haven't checked the case with hard quota myself. We'll look into it. Philip is actually suggesting the way. I suppose he doesn't have time to implement it himself, does he? Don't want to work on something he is already working on. What about our second patch? Friday, January 2, 2015, 2:38:23 PM, you wrote: OM> On Tue, Dec 30, 2014 at 02:37:58PM -0600, Boris Goldberg wrote: >> Hello tech, >> >> Is there a particular reason why that path hasn't been committed? It's >> not in the cvs tree and the bug is reproducible on the latest snapshot. >> It's the first patch we are trying to commit and we might not understand >> some internal development mechanics. OM> Hi, OM> we discussed the first diff and Philip Guenther made this comment OM> below. Although I was originally ok with the diff, I now think OM> Philip's point is valid. Care to investigate this further and comment OM> on this? >> It doesn't make sense to me. The creds argument is used here to control >> things like whether to uprintf() a "write failed, %s disk limit reached" >> message. With this change, won't root be unable to chown a file to a user >> that would putting them over a hardlimit? That seems wrong. >> >> I think the issue is that when run as root, >> ufs_quota_alloc_{blocks,inode}2() skip the calls to chk[di]qchg() where >> the dq_[bi]time values are reset. We need those times to be reset, even >> when the chown is being done by root, right? >> >> >> Philip -- Best regards, Borismailto:bo...@twopoint.com
Sort APs by signal strength
Hello, 31C3 had lots of access points sharing a network ID. Coming up with an AWK script to determine the network with the best coverage is easy, but still harder than simply choosing the first one that ifconfig iwn0 scan would spit out if only its output was sorted by signal strength (and in decreasing order, as by convention). Index: ifconfig.c === RCS file: /cvs/src/sbin/ifconfig/ifconfig.c,v retrieving revision 1.290 diff -u -p -u -r1.290 ifconfig.c --- ifconfig.c 1 Jan 2015 22:53:39 - 1.290 +++ ifconfig.c 2 Jan 2015 18:29:06 - @@ -2221,6 +2221,17 @@ ieee80211_listchans(void) } } +/* + * Returns an integer less than, equal to, or greater than zero if nr1's + * RSSI is respectively greater than, equal to, or less than nr2's RSSI. + */ +static int +rssicmp(const void *nr1, const void *nr2) +{ + const struct ieee80211_nodereq *x = nr1, *y = nr2; + return y->nr_rssi < x->nr_rssi ? -1 : y->nr_rssi > x->nr_rssi; +} + void ieee80211_listnodes(void) { @@ -2256,6 +2267,8 @@ ieee80211_listnodes(void) if (!na.na_nodes) printf("\t\tnone\n"); + else + qsort(nr, na.na_nodes, sizeof(*nr), rssicmp); for (i = 0; i < na.na_nodes; i++) { printf("\t\t"); -- Simon Nicolussi http{s,}://{www.,}sinic.name/
Re: [PATCH 05/16] rename the s_un socket to avoid a variable called 'sun'
On Fri, Jan 2, 2015 at 2:46 PM, Mark Kettenis wrote: >> From: Brent Cook >> Date: Fri, 2 Jan 2015 14:27:10 -0600 >> >> From: Brent Cook >> >> Solaris build environments seem to define 'sun' as a constant. >> Hilarity ensues. > > Hmm, sock is a bit of a bad choice. At least I associate it with > being the file descriptor of a socket. Looking through the tree, > "addr" or "sa" seem to be the canonical names for a sockaddr_un > variable. Make sense, 'sa' sounds better. Thanks. >> --- >> src/usr.sbin/ntpd/control.c | 18 +- >> src/usr.sbin/ntpd/ntpd.c| 12 ++-- >> 2 files changed, 15 insertions(+), 15 deletions(-) >> >> diff --git a/src/usr.sbin/ntpd/control.c b/src/usr.sbin/ntpd/control.c >> index 6c5b05d..eb3575b 100644 >> --- a/src/usr.sbin/ntpd/control.c >> +++ b/src/usr.sbin/ntpd/control.c >> @@ -36,7 +36,7 @@ >> int >> control_init(char *path) >> { >> - struct sockaddr_un sun; >> + struct sockaddr_un sock; >> int fd; >> mode_t old_umask; >> >> @@ -45,10 +45,10 @@ control_init(char *path) >> return (-1); >> } >> >> - bzero(&sun, sizeof(sun)); >> - sun.sun_family = AF_UNIX; >> - if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >= >> - sizeof(sun.sun_path)) >> + bzero(&sock, sizeof(sock)); >> + sock.sun_family = AF_UNIX; >> + if (strlcpy(sock.sun_path, path, sizeof(sock.sun_path)) >= >> + sizeof(sock.sun_path)) >> errx(1, "ctl socket name too long"); >> >> if (unlink(path) == -1) >> @@ -59,7 +59,7 @@ control_init(char *path) >> } >> >> old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH); >> - if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) { >> + if (bind(fd, (struct sockaddr *)&sock, sizeof(sock)) == -1) { >> log_warn("control_init: bind: %s", path); >> close(fd); >> umask(old_umask); >> @@ -108,12 +108,12 @@ control_accept(int listenfd) >> { >> int connfd; >> socklen_tlen; >> - struct sockaddr_un sun; >> + struct sockaddr_un sock; >> struct ctl_conn *ctl_conn; >> >> - len = sizeof(sun); >> + len = sizeof(sock); >> if ((connfd = accept(listenfd, >> - (struct sockaddr *)&sun, &len)) == -1) { >> + (struct sockaddr *)&sock, &len)) == -1) { >> if (errno != EWOULDBLOCK && errno != EINTR) >> log_warn("control_accept: accept"); >> return (0); >> diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c >> index 17ebf67..d764a50 100644 >> --- a/src/usr.sbin/ntpd/ntpd.c >> +++ b/src/usr.sbin/ntpd/ntpd.c >> @@ -527,7 +527,7 @@ writefreq(double d) >> void >> ctl_main(int argc, char *argv[]) >> { >> - struct sockaddr_un sun; >> + struct sockaddr_un sock; >> struct imsg imsg; >> struct imsgbuf *ibuf_ctl; >> int fd, n, done, ch, action; >> @@ -580,12 +580,12 @@ ctl_main(int argc, char *argv[]) >> if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) >> err(1, "ntpctl: socket"); >> >> - bzero(&sun, sizeof(sun)); >> - sun.sun_family = AF_UNIX; >> - if (strlcpy(sun.sun_path, sockname, sizeof(sun.sun_path)) >= >> - sizeof(sun.sun_path)) >> + bzero(&sock, sizeof(sock)); >> + sock.sun_family = AF_UNIX; >> + if (strlcpy(sock.sun_path, sockname, sizeof(sock.sun_path)) >= >> + sizeof(sock.sun_path)) >> errx(1, "ctl socket name too long"); >> - if (connect(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) >> + if (connect(fd, (struct sockaddr *)&sock, sizeof(sock)) == -1) >> err(1, "connect: %s", sockname); >> >> if ((ibuf_ctl = malloc(sizeof(struct imsgbuf))) == NULL) >> -- >> 1.9.1 >> >>
Re: [PATCH 05/16] rename the s_un socket to avoid a variable called 'sun'
> From: Brent Cook > Date: Fri, 2 Jan 2015 14:27:10 -0600 > > From: Brent Cook > > Solaris build environments seem to define 'sun' as a constant. > Hilarity ensues. Hmm, sock is a bit of a bad choice. At least I associate it with being the file descriptor of a socket. Looking through the tree, "addr" or "sa" seem to be the canonical names for a sockaddr_un variable. > --- > src/usr.sbin/ntpd/control.c | 18 +- > src/usr.sbin/ntpd/ntpd.c| 12 ++-- > 2 files changed, 15 insertions(+), 15 deletions(-) > > diff --git a/src/usr.sbin/ntpd/control.c b/src/usr.sbin/ntpd/control.c > index 6c5b05d..eb3575b 100644 > --- a/src/usr.sbin/ntpd/control.c > +++ b/src/usr.sbin/ntpd/control.c > @@ -36,7 +36,7 @@ > int > control_init(char *path) > { > - struct sockaddr_un sun; > + struct sockaddr_un sock; > int fd; > mode_t old_umask; > > @@ -45,10 +45,10 @@ control_init(char *path) > return (-1); > } > > - bzero(&sun, sizeof(sun)); > - sun.sun_family = AF_UNIX; > - if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >= > - sizeof(sun.sun_path)) > + bzero(&sock, sizeof(sock)); > + sock.sun_family = AF_UNIX; > + if (strlcpy(sock.sun_path, path, sizeof(sock.sun_path)) >= > + sizeof(sock.sun_path)) > errx(1, "ctl socket name too long"); > > if (unlink(path) == -1) > @@ -59,7 +59,7 @@ control_init(char *path) > } > > old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH); > - if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) { > + if (bind(fd, (struct sockaddr *)&sock, sizeof(sock)) == -1) { > log_warn("control_init: bind: %s", path); > close(fd); > umask(old_umask); > @@ -108,12 +108,12 @@ control_accept(int listenfd) > { > int connfd; > socklen_tlen; > - struct sockaddr_un sun; > + struct sockaddr_un sock; > struct ctl_conn *ctl_conn; > > - len = sizeof(sun); > + len = sizeof(sock); > if ((connfd = accept(listenfd, > - (struct sockaddr *)&sun, &len)) == -1) { > + (struct sockaddr *)&sock, &len)) == -1) { > if (errno != EWOULDBLOCK && errno != EINTR) > log_warn("control_accept: accept"); > return (0); > diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c > index 17ebf67..d764a50 100644 > --- a/src/usr.sbin/ntpd/ntpd.c > +++ b/src/usr.sbin/ntpd/ntpd.c > @@ -527,7 +527,7 @@ writefreq(double d) > void > ctl_main(int argc, char *argv[]) > { > - struct sockaddr_un sun; > + struct sockaddr_un sock; > struct imsg imsg; > struct imsgbuf *ibuf_ctl; > int fd, n, done, ch, action; > @@ -580,12 +580,12 @@ ctl_main(int argc, char *argv[]) > if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) > err(1, "ntpctl: socket"); > > - bzero(&sun, sizeof(sun)); > - sun.sun_family = AF_UNIX; > - if (strlcpy(sun.sun_path, sockname, sizeof(sun.sun_path)) >= > - sizeof(sun.sun_path)) > + bzero(&sock, sizeof(sock)); > + sock.sun_family = AF_UNIX; > + if (strlcpy(sock.sun_path, sockname, sizeof(sock.sun_path)) >= > + sizeof(sock.sun_path)) > errx(1, "ctl socket name too long"); > - if (connect(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) > + if (connect(fd, (struct sockaddr *)&sock, sizeof(sock)) == -1) > err(1, "connect: %s", sockname); > > if ((ibuf_ctl = malloc(sizeof(struct imsgbuf))) == NULL) > -- > 1.9.1 > >
uslhcom(4) driver for USB HID based UART
Hello, Here is the driver for Silicon Labs CP2110 USB HID based UART. It called uhidcom(4) and now renamed to uslhcom(4). Now working on -current. -- SASANO Takayoshi Index: arch/i386/conf/GENERIC === RCS file: /cvs/src/sys/arch/i386/conf/GENERIC,v retrieving revision 1.792 diff -u -p -r1.792 GENERIC --- arch/i386/conf/GENERIC 11 Dec 2014 19:44:17 - 1.792 +++ arch/i386/conf/GENERIC 2 Jan 2015 20:36:19 - @@ -274,6 +274,8 @@ ukbd* at uhidev? # USB keyboard wskbd* at ukbd? mux 1 ucycom*at uhidev? # Cypress serial ucom* at ucycom? +uslhcom* at uhidev?# Silicon Labs CP2110 USB HID UART +ucom* at uslhcom? uticom* at uhub? # TI serial ucom* at uticom? uhid* at uhidev? # USB generic HID support Index: dev/usb/files.usb === RCS file: /cvs/src/sys/dev/usb/files.usb,v retrieving revision 1.120 diff -u -p -r1.120 files.usb --- dev/usb/files.usb 11 Dec 2014 19:44:17 - 1.120 +++ dev/usb/files.usb 2 Jan 2015 20:36:23 - @@ -110,6 +110,11 @@ device ucycom: hid, ucombus attach ucycom at uhidbus file dev/usb/ucycom.cucycom needs-flag +# Silicon Labs USB HID based UART controller +device uslhcom: hid, ucombus +attach uslhcom at uhidbus +file dev/usb/uslhcom.c uslhcom needs-flag + # Printers device ulpt: firmload attach ulpt at uhub Index: dev/usb/uslhcom.c === RCS file: dev/usb/uslhcom.c diff -N dev/usb/uslhcom.c --- /dev/null 1 Jan 1970 00:00:00 - +++ dev/usb/uslhcom.c 2 Jan 2015 20:36:24 - @@ -0,0 +1,504 @@ +/* $OpenBSD: */ + +/* + * Copyright (c) 2015 SASANO Takayoshi + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Device driver for Silicon Labs CP2110 USB HID-UART bridge. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#ifdef USLHCOM_DEBUG +#defineDPRINTF(x) if (uslhcomdebug) printf x +#else +#defineDPRINTF(x) +#endif + +struct uslhcom_softc { + struct uhidevsc_hdev; + struct usbd_device *sc_udev; + + u_char *sc_ibuf; + u_intsc_icnt; + + u_char sc_lsr; + u_char sc_msr; + + struct device *sc_subdev; +}; + +void uslhcom_get_status(void *, int, u_char *, u_char *); +void uslhcom_set(void *, int, int, int); +intuslhcom_param(void *, int, struct termios *); +intuslhcom_open(void *, int); +void uslhcom_close(void *, int); +void uslhcom_write(void *, int, u_char *, u_char *, u_int32_t *); +void uslhcom_read(void *, int, u_char **, u_int32_t *); +void uslhcom_intr(struct uhidev *, void *, u_int); + +intuslhcom_match(struct device *, void *, void *); +void uslhcom_attach(struct device *, struct device *, void *); +intuslhcom_detach(struct device *, int); + +intuslhcom_uart_endis(struct uslhcom_softc *, int); +intuslhcom_clear_fifo(struct uslhcom_softc *, int); +intuslhcom_get_version(struct uslhcom_softc *, struct uslhcom_version_info *); +intuslhcom_get_uart_status(struct uslhcom_softc *, struct uslhcom_uart_status *); +intuslhcom_set_break(struct uslhcom_softc *, int); +intuslhcom_set_config(struct uslhcom_softc *, struct uslhcom_uart_config *); +void uslhcom_set_baud_rate(struct uslhcom_uart_config *, u_int32_t); +intuslhcom_create_config(struct uslhcom_uart_config *, struct termios *); +intuslhcom_setup(struct uslhcom_softc *, struct uslhcom_uart_config *); + +struct ucom_methods uslhcom_methods = { + uslhcom_get_status, + uslhcom_set, + uslhcom_param, + NULL, + uslhcom_open, + uslhcom_close, + uslhcom_read, + uslhcom_write, +}; + +static const s
Re: disk quotas bug fix [was: quotas grace period "none" right away]
On Tue, Dec 30, 2014 at 02:37:58PM -0600, Boris Goldberg wrote: > Hello tech, > > Is there a particular reason why that path hasn't been committed? It's > not in the cvs tree and the bug is reproducible on the latest snapshot. > It's the first patch we are trying to commit and we might not understand > some internal development mechanics. Hi, we discussed the first diff and Philip Guenther made this comment below. Although I was originally ok with the diff, I now think Philip's point is valid. Care to investigate this further and comment on this? > It doesn't make sense to me. The creds argument is used here to control > things like whether to uprintf() a "write failed, %s disk limit reached" > message. With this change, won't root be unable to chown a file to a user > that would putting them over a hardlimit? That seems wrong. > > I think the issue is that when run as root, > ufs_quota_alloc_{blocks,inode}2() skip the calls to chk[di]qchg() where > the dq_[bi]time values are reset. We need those times to be reset, even > when the chown is being done by root, right? > > > Philip
[PATCH 05/16] rename the s_un socket to avoid a variable called 'sun'
From: Brent Cook Solaris build environments seem to define 'sun' as a constant. Hilarity ensues. --- src/usr.sbin/ntpd/control.c | 18 +- src/usr.sbin/ntpd/ntpd.c| 12 ++-- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/usr.sbin/ntpd/control.c b/src/usr.sbin/ntpd/control.c index 6c5b05d..eb3575b 100644 --- a/src/usr.sbin/ntpd/control.c +++ b/src/usr.sbin/ntpd/control.c @@ -36,7 +36,7 @@ int control_init(char *path) { - struct sockaddr_un sun; + struct sockaddr_un sock; int fd; mode_t old_umask; @@ -45,10 +45,10 @@ control_init(char *path) return (-1); } - bzero(&sun, sizeof(sun)); - sun.sun_family = AF_UNIX; - if (strlcpy(sun.sun_path, path, sizeof(sun.sun_path)) >= - sizeof(sun.sun_path)) + bzero(&sock, sizeof(sock)); + sock.sun_family = AF_UNIX; + if (strlcpy(sock.sun_path, path, sizeof(sock.sun_path)) >= + sizeof(sock.sun_path)) errx(1, "ctl socket name too long"); if (unlink(path) == -1) @@ -59,7 +59,7 @@ control_init(char *path) } old_umask = umask(S_IXUSR|S_IXGRP|S_IWOTH|S_IROTH|S_IXOTH); - if (bind(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) { + if (bind(fd, (struct sockaddr *)&sock, sizeof(sock)) == -1) { log_warn("control_init: bind: %s", path); close(fd); umask(old_umask); @@ -108,12 +108,12 @@ control_accept(int listenfd) { int connfd; socklen_tlen; - struct sockaddr_un sun; + struct sockaddr_un sock; struct ctl_conn *ctl_conn; - len = sizeof(sun); + len = sizeof(sock); if ((connfd = accept(listenfd, - (struct sockaddr *)&sun, &len)) == -1) { + (struct sockaddr *)&sock, &len)) == -1) { if (errno != EWOULDBLOCK && errno != EINTR) log_warn("control_accept: accept"); return (0); diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c index 17ebf67..d764a50 100644 --- a/src/usr.sbin/ntpd/ntpd.c +++ b/src/usr.sbin/ntpd/ntpd.c @@ -527,7 +527,7 @@ writefreq(double d) void ctl_main(int argc, char *argv[]) { - struct sockaddr_un sun; + struct sockaddr_un sock; struct imsg imsg; struct imsgbuf *ibuf_ctl; int fd, n, done, ch, action; @@ -580,12 +580,12 @@ ctl_main(int argc, char *argv[]) if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) err(1, "ntpctl: socket"); - bzero(&sun, sizeof(sun)); - sun.sun_family = AF_UNIX; - if (strlcpy(sun.sun_path, sockname, sizeof(sun.sun_path)) >= - sizeof(sun.sun_path)) + bzero(&sock, sizeof(sock)); + sock.sun_family = AF_UNIX; + if (strlcpy(sock.sun_path, sockname, sizeof(sock.sun_path)) >= + sizeof(sock.sun_path)) errx(1, "ctl socket name too long"); - if (connect(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) + if (connect(fd, (struct sockaddr *)&sock, sizeof(sock)) == -1) err(1, "connect: %s", sockname); if ((ibuf_ctl = malloc(sizeof(struct imsgbuf))) == NULL) -- 1.9.1
[PATCH 04/16] add MAX macro, used in a few places in ntpd
From: Brent Cook Do not assume that the system #includes happen to include a MAX macro somewhere along the way. --- src/usr.sbin/ntpd/ntpd.h | 4 1 file changed, 4 insertions(+) diff --git a/src/usr.sbin/ntpd/ntpd.h b/src/usr.sbin/ntpd/ntpd.h index aa9858b..61a447f 100644 --- a/src/usr.sbin/ntpd/ntpd.h +++ b/src/usr.sbin/ntpd/ntpd.h @@ -72,6 +72,10 @@ #defineSENSOR_SCAN_INTERVAL(5*60) #defineSENSOR_DEFAULT_REFID"HARD" +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif + enum client_state { STATE_NONE, STATE_DNS_INPROGRESS, -- 1.9.1
OpenNTPD-portable updated and ready for early testing
Happy new year, here is a late (or very early?) present. I spent some time this holiday season getting OpenNTPD-portable back into shape with a new build tree. I hope to do an initial release in a few days to go with the OpenBSD 5.7 beta switch. In the mean time, I have published the source tree to: https://github.com/openntpd-portable/ Like LibreSSL-portable, it uses scripts to generate a release directly from the OpenBSD source tree. It also shares portions with LibreSSL, like the arc4random/getentropy compatibility code. In the course of porting, Ineeded to make a few patches to the source tree in order to get things working. To make the port easier to maintain over time, it is nice to get the general fixes applied upstream as long as they don't muddy the waters too much. Following this email, I am sending the first batch of 5 easy build-related patches to help make OpenNTPD more platform-independent. [PATCH 01/16] include time.h for strftime, clock_gettime [PATCH 02/16] removed unused libevent header and structures in ntpd.h [PATCH 03/16] remove unused dns_pid [PATCH 04/16] add MAX macro, used in a few places in ntpd [PATCH 05/16] rename the s_un socket to avoid a variable called 'sun' There are more patches that I can send later. They get less interesting from an OpenBSD PoV the higher they get. I don't want to create a patch deluge or abuse your bandwidth more than necessary, but you can check them out here: https://github.com/openntpd-portable/openntpd-portable/tree/master/patches Thanks to everyone who has helped so far with initial testing, feedback, and support. - Brent
[PATCH 03/16] remove unused dns_pid
From: Brent Cook dns_pid is returned, but nothing is done with it. Was then intent to do some extra error handling here? --- src/usr.sbin/ntpd/ntp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/usr.sbin/ntpd/ntp.c b/src/usr.sbin/ntpd/ntp.c index 2eb4285..ddbcedd 100644 --- a/src/usr.sbin/ntpd/ntp.c +++ b/src/usr.sbin/ntpd/ntp.c @@ -79,7 +79,7 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf, u_intpfd_elms = 0, idx2peer_elms = 0; u_intlistener_cnt, new_cnt, sent_cnt, trial_cnt; u_intctl_cnt; - pid_tpid, dns_pid; + pid_tpid; struct pollfd *pfd = NULL; struct servent *se; struct listen_addr *la; @@ -118,7 +118,7 @@ ntp_main(int pipe_prnt[2], int fd_ctl, struct ntpd_conf *nconf, close(pipe_prnt[0]); if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_dns) == -1) fatal("socketpair"); - dns_pid = ntp_dns(pipe_dns, nconf, pw); + ntp_dns(pipe_dns, nconf, pw); close(pipe_dns[1]); if (stat(pw->pw_dir, &stb) == -1) -- 1.9.1
[PATCH 02/16] removed unused libevent header and structures in ntpd.h
From: Brent Cook It does not appear anything actually uses libevent in ntpd, so remove the libevent-using structures from ntpd.h --- src/usr.sbin/ntpd/ntpd.h | 10 -- 1 file changed, 10 deletions(-) diff --git a/src/usr.sbin/ntpd/ntpd.h b/src/usr.sbin/ntpd/ntpd.h index 8095be3..aa9858b 100644 --- a/src/usr.sbin/ntpd/ntpd.h +++ b/src/usr.sbin/ntpd/ntpd.h @@ -28,7 +28,6 @@ #include #include #include -#include #include #include "ntp.h" @@ -190,14 +189,6 @@ struct ntpd_conf { u_int8_tfilters; }; -struct imsgev { - struct imsgbuf ibuf; - void(*handler)(int, short, void *); - struct event ev; - void*data; - shortevents; -}; - struct ctl_show_status { u_intpeercnt; u_intsensorcnt; @@ -240,7 +231,6 @@ enum blockmodes { struct ctl_conn { TAILQ_ENTRY(ctl_conn) entry; - struct imsgev iev; struct imsgbuf ibuf; }; -- 1.9.1
[PATCH 01/16] include time.h for strftime, clock_gettime
From: Brent Cook Add a missing include for time.h to get the definitions of clock_gettime and strftime. --- src/usr.sbin/ntpd/ntpd.c | 1 + src/usr.sbin/ntpd/util.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c index 4634fae..17ebf67 100644 --- a/src/usr.sbin/ntpd/ntpd.c +++ b/src/usr.sbin/ntpd/ntpd.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include diff --git a/src/usr.sbin/ntpd/util.c b/src/usr.sbin/ntpd/util.c index 9d78d6e..638dc92 100644 --- a/src/usr.sbin/ntpd/util.c +++ b/src/usr.sbin/ntpd/util.c @@ -17,8 +17,10 @@ */ #include + #include #include +#include #include "ntpd.h" -- 1.9.1
Re: [PATCH] root.mail: fix date
On Friday, 2 January 2015 11:28:49 CEST, Janne Johansson wrote: May 01 2015 will be a Friday, no? Good catch. deraadt@ changed it now but he changed the day to Sunday instead of Friday. Patch below addresses the issue. Index: etc/root/root.mail === RCS file: /cvs/src/etc/root/root.mail,v retrieving revision 1.106 diff -u -p -u -r1.106 root.mail --- etc/root/root.mail 2 Jan 2015 11:03:50 - 1.106 +++ etc/root/root.mail 2 Jan 2015 19:13:03 - @@ -1,4 +1,4 @@ -From dera...@do-not-reply.openbsd.org Sun May 1 07:56:56 MST 2015 +From dera...@do-not-reply.openbsd.org Fri May 1 07:56:56 MST 2015 Return-Path: root Date: May 1 07:56:56 MST 2015 From: dera...@do-not-reply.openbsd.org (Theo de Raadt)
Re: wc(1) and -m flag
On Fri, Jan 02, 2015 at 12:03:31PM +0100, Ingo Schwarze wrote: > Hi, > > i'm certainly not known for enthusiasm with respect to multibyte > character support, but wc(1) is one example of a program where > respecting LC_CTYPE would really make sense even to me, so i > consider it a bug that wc -m currently is an alias for wc -c. > > I'm proposing the somewhat simpler patch below for now. > i'm fine with this. jmc > * No need to change .Nd. Counting characters is among the >standardized purposes of wc(1), knowing that is useful >for people developing shell scripts on OpenBSD because >their scripts might do that when run elsewhere, and hopefully >one day, they will even on OpenBSD. > > * No need to change [-c | -m] to [-cm] in the SYNOPSIS. >even though our implementation currently doesn't enforce >it, you should code like that for portability. > > * No need to specifically state that -c and -m are mutually >exclusive, it's already clear from the SYNOPSIS, POSIX >doesn't stress it explicitly either, and at least as long >as we don't enforce it, it seems counter-productive to >over-emphasize it. > > * No need to remove "(or characters)" from the format >description. In the (only supported) C/POSIX locale, >bytes and characters are synonyms, so it isn't wrong, >and it does no harm to hint at how character counts >are supposed to be displayed. > > OK? > Ingo > > > Index: wc.1 > === > RCS file: /cvs/src/usr.bin/wc/wc.1,v > retrieving revision 1.23 > diff -u -r1.23 wc.1 > --- wc.1 15 Nov 2014 13:55:25 - 1.23 > +++ wc.1 2 Jan 2015 10:48:23 - > @@ -72,8 +72,9 @@ > The number of lines in each input file > is written to the standard output. > .It Fl m > -The number of characters in each input file > -is written to the standard output. > +Intended to count characters instead of bytes; > +currently an alias for > +.Fl c . > .It Fl w > The number of words in each input file > is written to the standard output. > @@ -85,11 +86,6 @@ > The default action is equivalent to the flags > .Fl clw > having been specified. > -The > -.Fl c > -and > -.Fl m > -options are mutually exclusive. > .Pp > If no file names are specified, the standard input is used > and a file name is not output. > @@ -103,11 +99,6 @@ > lines words bytes file_name > .Ed > .Pp > -If the > -.Fl m > -option is specified, > -the number of bytes is replaced by > -the number of characters in the listing above. > The counts for lines, words, and bytes > .Pq or characters > are integers separated by spaces. > @@ -120,7 +111,7 @@ > .Nm > utility is compliant with the > .St -p1003.1-2008 > -specification. > +specification, except that it ignores the locale. > .Pp > The flag > .Op Fl h > @@ -130,3 +121,7 @@ > .Nm > utility appeared in > .At v1 . > +.Sh BUGS > +The > +.Fl m > +option counts bytes instead of characters.
libtls connect read write again
Hi, I think the connect function of libtls needs the same logic to read and write again like the read, write, accept functions for non-blocking sockets. All the connect checks should be done only once. ok? bluhm Index: lib/libtls/tls_client.c === RCS file: /data/mirror/openbsd/cvs/src/lib/libtls/tls_client.c,v retrieving revision 1.7 diff -u -p -r1.7 tls_client.c --- lib/libtls/tls_client.c 2 Jan 2015 16:38:07 - 1.7 +++ lib/libtls/tls_client.c 2 Jan 2015 17:46:45 - @@ -135,7 +135,10 @@ tls_connect_fds(struct tls *ctx, int fd_ { union { struct in_addr ip4; struct in6_addr ip6; } addrbuf; X509 *cert = NULL; - int ret; + int ret, ssl_err; + + if (ctx->flags & TLS_CONNECTING) + goto connecting; if ((ctx->flags & TLS_CLIENT) == 0) { tls_set_error(ctx, "not a client context"); @@ -198,11 +201,22 @@ tls_connect_fds(struct tls *ctx, int fd_ } } + connecting: if ((ret = SSL_connect(ctx->ssl_conn)) != 1) { - tls_set_error(ctx, "SSL connect failed: %i", - SSL_get_error(ctx->ssl_conn, ret)); - goto err; + ssl_err = SSL_get_error(ctx->ssl_conn, ret); + switch (ssl_err) { + case SSL_ERROR_WANT_READ: + ctx->flags |= TLS_CONNECTING; + return (TLS_READ_AGAIN); + case SSL_ERROR_WANT_WRITE: + ctx->flags |= TLS_CONNECTING; + return (TLS_WRITE_AGAIN); + default: + tls_set_error(ctx, "SSL connect failed: %i", ssl_err); + goto err; + } } + ctx->flags &= ~TLS_CONNECTING; if (ctx->config->verify_host) { cert = SSL_get_peer_certificate(ctx->ssl_conn); Index: lib/libtls/tls_internal.h === RCS file: /data/mirror/openbsd/cvs/src/lib/libtls/tls_internal.h,v retrieving revision 1.5 diff -u -p -r1.5 tls_internal.h --- lib/libtls/tls_internal.h 17 Dec 2014 17:51:33 - 1.5 +++ lib/libtls/tls_internal.h 2 Jan 2015 17:46:45 - @@ -44,7 +44,8 @@ struct tls_config { #define TLS_CLIENT (1 << 0) #define TLS_SERVER (1 << 1) -#define TLS_SERVER_CONN(1 << 2) +#define TLS_SERVER_CONN(1 << 2) +#define TLS_CONNECTING (1 << 3) struct tls { struct tls_config *config;
Subscribe
Subscribe Sincerely, Spencer Streeter IT Specialist, Sr. Department of Biology University of Utah email: stree...@biology.utah.edu phone: (801)581-4587
Re: your mail
In OpenBSD we just write that as "free(mp)", the "if" isn't required. Will remember it ;-) Index: fuse.c === RCS file: /cvs/src/lib/libfuse/fuse.c,v retrieving revision 1.24 diff -u -p -r1.24 fuse.c --- fuse.c 20 May 2014 13:32:22 - 1.24 +++ fuse.c 2 Jan 2015 16:53:30 - @@ -493,5 +493,7 @@ fuse_main(int argc, char **argv, const s if (!fuse) return (-1); + free(mp); + return (fuse_loop(fuse)); } > >
Re: wc(1) and -m flag
I agree, it's better this way - with the prospect that the locale support might be added some day. On Fri, Jan 02, 2015 at 12:03:31PM +0100, Ingo Schwarze wrote: > Hi, > > i'm certainly not known for enthusiasm with respect to multibyte > character support, but wc(1) is one example of a program where > respecting LC_CTYPE would really make sense even to me, so i > consider it a bug that wc -m currently is an alias for wc -c. > > I'm proposing the somewhat simpler patch below for now. > > * No need to change .Nd. Counting characters is among the >standardized purposes of wc(1), knowing that is useful >for people developing shell scripts on OpenBSD because >their scripts might do that when run elsewhere, and hopefully >one day, they will even on OpenBSD. > > * No need to change [-c | -m] to [-cm] in the SYNOPSIS. >even though our implementation currently doesn't enforce >it, you should code like that for portability. > > * No need to specifically state that -c and -m are mutually >exclusive, it's already clear from the SYNOPSIS, POSIX >doesn't stress it explicitly either, and at least as long >as we don't enforce it, it seems counter-productive to >over-emphasize it. > > * No need to remove "(or characters)" from the format >description. In the (only supported) C/POSIX locale, >bytes and characters are synonyms, so it isn't wrong, >and it does no harm to hint at how character counts >are supposed to be displayed. > > OK? > Ingo > > > Index: wc.1 > === > RCS file: /cvs/src/usr.bin/wc/wc.1,v > retrieving revision 1.23 > diff -u -r1.23 wc.1 > --- wc.1 15 Nov 2014 13:55:25 - 1.23 > +++ wc.1 2 Jan 2015 10:48:23 - > @@ -72,8 +72,9 @@ > The number of lines in each input file > is written to the standard output. > .It Fl m > -The number of characters in each input file > -is written to the standard output. > +Intended to count characters instead of bytes; > +currently an alias for > +.Fl c . > .It Fl w > The number of words in each input file > is written to the standard output. > @@ -85,11 +86,6 @@ > The default action is equivalent to the flags > .Fl clw > having been specified. > -The > -.Fl c > -and > -.Fl m > -options are mutually exclusive. > .Pp > If no file names are specified, the standard input is used > and a file name is not output. > @@ -103,11 +99,6 @@ > lines words bytes file_name > .Ed > .Pp > -If the > -.Fl m > -option is specified, > -the number of bytes is replaced by > -the number of characters in the listing above. > The counts for lines, words, and bytes > .Pq or characters > are integers separated by spaces. > @@ -120,7 +111,7 @@ > .Nm > utility is compliant with the > .St -p1003.1-2008 > -specification. > +specification, except that it ignores the locale. > .Pp > The flag > .Op Fl h > @@ -130,3 +121,7 @@ > .Nm > utility appeared in > .At v1 . > +.Sh BUGS > +The > +.Fl m > +option counts bytes instead of characters.
[no subject]
Hi again after discussins with Helg, second change is not relevant, so only the first should remains. Kind regards. Index: fuse.c === RCS file: /cvs/src/lib/libfuse/fuse.c,v retrieving revision 1.24 diff -u -p -r1.24 fuse.c --- fuse.c 20 May 2014 13:32:22 - 1.24 +++ fuse.c 1 Jan 2015 13:17:02 - @@ -493,5 +493,8 @@ fuse_main(int argc, char **argv, const s if (!fuse) return (-1); + if (mp) + free(mp); + return (fuse_loop(fuse)); }
Re: wc(1) and -m flag
> Date: Fri, 2 Jan 2015 07:47:29 + > From: Jason McIntyre > > On Fri, Jan 02, 2015 at 02:11:34AM +0200, Kaspars Bankovskis wrote: > > On Thu, Jan 01, 2015 at 10:28:44PM +0001, Jason McIntyre wrote: > > > it's not exactly that we updated wc knowing that it was not posix > > > conformant. i think the general explanation is that the current > > > implementation of obsd treats characters and bytes the same, but they > > > might not on other systems, and then all the multibyte stuff that kills > > > my brain. > > > > Well, the current implementation of wc in OpenBSD doesn't treat > > characters, -m option is simply aliased to the same behaviour as -c. > > > > As for multibyte stuff (and portability), I've checked wc on Linux > > (coreutils), FreeBSD and OSX, and they all deal with multibyte > > characters when wc is invoked with -m. For example, if I give A-macron > > character as an input, it's 1 for -m but 2 for -c on those systems. On > > OpenBSD it always will be 2. We have two flags for the same action, and > > one of them is working differently on majority of currently deployed > > unixes. > > > > I might be wrong, but isn't "m" standing for multibyte, to contrast with > > "c" for (byte-sized) char? > > > > > if i'm totally wrong about that, someone correct me. > > > > > > we could make that clearer in the man page, but i think we decided it > > > was best to do it the way we have now. > > > > Current text of the man page is giving wrong impression that the -m flag > > is doing something that it doesn't, especially the part about "number of > > bytes being replaced by number of characters" (nothing is replaced there). > > > > I'm not saying that multibyte character counting should be implemented > > in OpenBSD's wc. But at least the manpage should indicate that the -m is > > useless flag. > > > > let's wait till after the weekend and see if any developers state that > it's meant to be like this (or not). in the meantime i'll try and look > through my mails and see if i can dig up any past conversation about it. Our locale support is pretty poor, and our wc(1) is no exception. It indeed does not have multibyte character support. In the past we pretty much only supported single-byte character sets (i.e. the various ISO 8859 character sets) for which -c and -m are equivalent. These days, we also have some UTF-8 support for which -c and -m are not equivalent. I don't think we should really change the language in the man page, but perhaps a BUGS section that says that wc is currently not locale-aware and does not interpret multibyte character sequences is appropriate. I had a quick look at NetBSD's wc(1), and it does seem to have multibyte character support. So if somebody cares... Cheers, Mark
Re: massage volume control task
> Date: Fri, 2 Jan 2015 16:15:07 +1000 > From: David Gwynne > > can someone test this? > > it allocates storage for the volume change details rather than cast > arguments to a single global task. > > adds some safety while there if audio0 is a hotplug device. > > ok? The problem with this approach is that things silently fail when memory allocation fails. Exactly the problem that workq_add_task() had. Perhaps the best thing is to store the "event" in the softc, although then you'd probably need some locking to make sure the task sees a consistent dir/out pair. > Index: audio.c > === > RCS file: /cvs/src/sys/dev/audio.c,v > retrieving revision 1.125 > diff -u -p -r1.125 audio.c > --- audio.c 19 Dec 2014 22:44:58 - 1.125 > +++ audio.c 2 Jan 2015 06:08:39 - > @@ -465,11 +465,6 @@ audioattach(struct device *parent, struc > } > DPRINTF(("audio_attach: inputs ports=0x%x, output ports=0x%x\n", >sc->sc_inports.allports, sc->sc_outports.allports)); > - > -#if NWSKBD > 0 > - task_set(&sc->sc_mixer_task, wskbd_set_mixervolume_callback, NULL, > - NULL); > -#endif /* NWSKBD > 0 */ > } > > int > @@ -3432,27 +3427,39 @@ filt_audiowrite(struct knote *kn, long h > } > > #if NWSKBD > 0 > +struct wskbd_vol_change { > + struct task t; > + long dir; > + long out; > +}; > + > int > wskbd_set_mixervolume(long dir, long out) > { > struct audio_softc *sc; > + struct wskbd_vol_change *ch; > > if (audio_cd.cd_ndevs == 0 || (sc = audio_cd.cd_devs[0]) == NULL) { > DPRINTF(("wskbd_set_mixervolume: audio_cd\n")); > return (ENXIO); > } > > - task_del(systq, &sc->sc_mixer_task); > - task_set(&sc->sc_mixer_task, wskbd_set_mixervolume_callback, > - (void *)dir, (void *)out); > - task_add(systq, &sc->sc_mixer_task); > + ch = malloc(sizeof(*ch), M_TEMP, M_NOWAIT); > + if (ch == NULL) > + return (ENOMEM); > + > + task_set(&ch->t, wskbd_set_mixervolume_callback, ch, NULL); > + ch->dir = dir; > + ch->out = out; > + task_add(systq, &ch->t); > > return (0); > } > > void > -wskbd_set_mixervolume_callback(void *arg1, void *arg2) > +wskbd_set_mixervolume_callback(void *xch, void *null) > { > + struct wskbd_vol_change *ch = xch; > struct audio_softc *sc; > struct au_mixer_ports *ports; > mixer_devinfo_t mi; > @@ -3461,19 +3468,19 @@ wskbd_set_mixervolume_callback(void *arg > u_int gain; > int error; > > - if (audio_cd.cd_ndevs == 0 || (sc = audio_cd.cd_devs[0]) == NULL) { > - DPRINTF(("%s: audio_cd\n", __func__)); > - return; > - } > + dir = ch->dir; > + out = ch->out; > + free(ch, M_TEMP, sizeof(*ch)); > > - dir = (long)arg1; > - out = (long)arg2; > + sc = (struct audio_softc *)device_lookup(&audio_cd, 0); > + if (sc == NULL) > + return; > > ports = out ? &sc->sc_outports : &sc->sc_inports; > > if (ports->master == -1) { > DPRINTF(("%s: master == -1\n", __func__)); > - return; > + goto done; > } > > if (dir == 0) { > @@ -3482,7 +3489,7 @@ wskbd_set_mixervolume_callback(void *arg > error = au_get_mute(sc, ports, &mute); > if (error != 0) { > DPRINTF(("%s: au_get_mute: %d\n", __func__, error)); > - return; > + goto done; > } > > mute = !mute; > @@ -3490,7 +3497,7 @@ wskbd_set_mixervolume_callback(void *arg > error = au_set_mute(sc, ports, mute); > if (error != 0) { > DPRINTF(("%s: au_set_mute: %d\n", __func__, error)); > - return; > + goto done; > } > } else { > /* Raise or lower volume */ > @@ -3499,7 +3506,7 @@ wskbd_set_mixervolume_callback(void *arg > error = sc->hw_if->query_devinfo(sc->hw_hdl, &mi); > if (error != 0) { > DPRINTF(("%s: query_devinfo: %d\n", __func__, error)); > - return; > + goto done; > } > > au_get_gain(sc, ports, &gain, &balance); > @@ -3512,8 +3519,11 @@ wskbd_set_mixervolume_callback(void *arg > error = au_set_gain(sc, ports, gain, balance); > if (error != 0) { > DPRINTF(("%s: au_set_gain: %d\n", __func__, error)); > - return; > + goto done; > } > } > + > +done: > + device_unref(&sc->dev); > } > #endif /* NWSKBD > 0 */ > >
Re: wc(1) and -m flag
Hi, i'm certainly not known for enthusiasm with respect to multibyte character support, but wc(1) is one example of a program where respecting LC_CTYPE would really make sense even to me, so i consider it a bug that wc -m currently is an alias for wc -c. I'm proposing the somewhat simpler patch below for now. * No need to change .Nd. Counting characters is among the standardized purposes of wc(1), knowing that is useful for people developing shell scripts on OpenBSD because their scripts might do that when run elsewhere, and hopefully one day, they will even on OpenBSD. * No need to change [-c | -m] to [-cm] in the SYNOPSIS. even though our implementation currently doesn't enforce it, you should code like that for portability. * No need to specifically state that -c and -m are mutually exclusive, it's already clear from the SYNOPSIS, POSIX doesn't stress it explicitly either, and at least as long as we don't enforce it, it seems counter-productive to over-emphasize it. * No need to remove "(or characters)" from the format description. In the (only supported) C/POSIX locale, bytes and characters are synonyms, so it isn't wrong, and it does no harm to hint at how character counts are supposed to be displayed. OK? Ingo Index: wc.1 === RCS file: /cvs/src/usr.bin/wc/wc.1,v retrieving revision 1.23 diff -u -r1.23 wc.1 --- wc.115 Nov 2014 13:55:25 - 1.23 +++ wc.12 Jan 2015 10:48:23 - @@ -72,8 +72,9 @@ The number of lines in each input file is written to the standard output. .It Fl m -The number of characters in each input file -is written to the standard output. +Intended to count characters instead of bytes; +currently an alias for +.Fl c . .It Fl w The number of words in each input file is written to the standard output. @@ -85,11 +86,6 @@ The default action is equivalent to the flags .Fl clw having been specified. -The -.Fl c -and -.Fl m -options are mutually exclusive. .Pp If no file names are specified, the standard input is used and a file name is not output. @@ -103,11 +99,6 @@ lines words bytes file_name .Ed .Pp -If the -.Fl m -option is specified, -the number of bytes is replaced by -the number of characters in the listing above. The counts for lines, words, and bytes .Pq or characters are integers separated by spaces. @@ -120,7 +111,7 @@ .Nm utility is compliant with the .St -p1003.1-2008 -specification. +specification, except that it ignores the locale. .Pp The flag .Op Fl h @@ -130,3 +121,7 @@ .Nm utility appeared in .At v1 . +.Sh BUGS +The +.Fl m +option counts bytes instead of characters.
Re: [PATCH] root.mail: fix date
2015-01-02 10:55 GMT+01:00 Caspar Schutijser : > Index: etc/root/root.mail > === > RCS file: /cvs/src/etc/root/root.mail,v > retrieving revision 1.105 > diff -u -p -u -r1.105 root.mail > --- etc/root/root.mail 1 Jan 2015 15:50:27 - 1.105 > +++ etc/root/root.mail 2 Jan 2015 09:43:50 - > @@ -1,6 +1,6 @@ > -From dera...@do-not-reply.openbsd.org Sat May 1 07:56:56 MST 2014 > +From dera...@do-not-reply.openbsd.org Sat May 1 07:56:56 MST 2015 > May 01 2015 will be a Friday, no? -- May the most significant bit of your life be positive.
[PATCH] root.mail: fix date
Index: etc/root/root.mail === RCS file: /cvs/src/etc/root/root.mail,v retrieving revision 1.105 diff -u -p -u -r1.105 root.mail --- etc/root/root.mail 1 Jan 2015 15:50:27 - 1.105 +++ etc/root/root.mail 2 Jan 2015 09:43:50 - @@ -1,6 +1,6 @@ -From dera...@do-not-reply.openbsd.org Sat May 1 07:56:56 MST 2014 +From dera...@do-not-reply.openbsd.org Sat May 1 07:56:56 MST 2015 Return-Path: root -Date: May 1 07:56:56 MST 2014 +Date: May 1 07:56:56 MST 2015 From: dera...@do-not-reply.openbsd.org (Theo de Raadt) To: root Subject: Welcome to OpenBSD 5.7!