vi: remove awk scripts
Hello tech@, I've gotten confused by the awk scripts a few times now. They seem to unused and I had to really look where they were originally intended. For the curious: awk -f common/options.awk common/options.c > include/options_def.h awk -f ex/ex.awk ex/ex_cmd.c > include/ex_def.h The options_def.h file has moved from define to enum by bentley earlier this year, so there seems to be no motivation to move back to the awk scripts. This does however mean that we have to keep a close eye on the options and commands we expose and keep them in sync manually. Another option would be to keep the scripts and hook them into the makefile and cvs rm include/{options,ex}_def.h, but that would require some black magic I haven't mastered yet. OK to remove the scripts and to make {options,ex}_def.h consistent? martijn@ Index: common/options.awk === RCS file: common/options.awk diff -N common/options.awk --- common/options.awk 29 Jan 2001 01:58:31 - 1.3 +++ /dev/null 1 Jan 1970 00:00:00 - @@ -1,11 +0,0 @@ -# $OpenBSD: options.awk,v 1.3 2001/01/29 01:58:31 niklas Exp $ - -# @(#)options.awk 10.1 (Berkeley) 6/8/95 - -/^\/\* O_[0-9A-Z_]*/ { - printf("#define %s %d\n", $2, cnt++); - next; -} -END { - printf("#define O_OPTIONCOUNT %d\n", cnt); -} Index: ex/ex.awk === RCS file: ex/ex.awk diff -N ex/ex.awk --- ex/ex.awk 29 Jan 2001 01:58:40 - 1.2 +++ /dev/null 1 Jan 1970 00:00:00 - @@ -1,8 +0,0 @@ -# $OpenBSD: ex.awk,v 1.2 2001/01/29 01:58:40 niklas Exp $ - -# @(#)ex.awk 10.1 (Berkeley) 6/8/95 - -/^\/\* C_[0-9A-Z_]* \*\/$/ { - printf("#define %s %d\n", $2, cnt++); - next; -} Index: include/ex_def.h === RCS file: /cvs/src/usr.bin/vi/include/ex_def.h,v retrieving revision 1.5 diff -u -p -a -u -r1.5 ex_def.h --- include/ex_def.h19 Nov 2015 07:53:31 - 1.5 +++ include/ex_def.h11 Nov 2017 09:27:46 - @@ -1,76 +1,78 @@ /* $OpenBSD: ex_def.h,v 1.5 2015/11/19 07:53:31 bentley Exp $ */ -#define C_SCROLL 0 -#define C_BANG 1 -#define C_HASH 2 -#define C_SUBAGAIN 3 -#define C_STAR 4 -#define C_SHIFTL 5 -#define C_EQUAL 6 -#define C_SHIFTR 7 -#define C_AT 8 -#define C_APPEND 9 -#define C_ABBR 10 -#define C_ARGS 11 -#define C_BG 12 -#define C_CHANGE 13 -#define C_CD 14 -#define C_CHDIR 15 -#define C_COPY 16 -#define C_DELETE 17 -#define C_DISPLAY 18 -#define C_EDIT 19 -#define C_EX 20 -#define C_EXUSAGE 21 -#define C_FILE 22 -#define C_FG 23 -#define C_GLOBAL 24 -#define C_HELP 25 -#define C_INSERT 26 -#define C_JOIN 27 -#define C_K 28 -#define C_LIST 29 -#define C_MOVE 30 -#define C_MARK 31 -#define C_MAP 32 -#define C_MKEXRC 33 -#define C_NEXT 34 -#define C_NUMBER 35 -#define C_OPEN 36 -#define C_PRINT 37 -#define C_PRESERVE 38 -#define C_PREVIOUS 39 -#define C_PUT 40 -#define C_QUIT 41 -#define C_READ 42 -#define C_RECOVER 43 -#define C_RESIZE 44 -#define C_REWIND 45 -#define C_SUBSTITUTE 46 -#define C_SCRIPT 47 -#define C_SET 48 -#define C_SHELL 49 -#define C_SOURCE 50 -#define C_STOP 51 -#define C_SUSPEND 52 -#define C_T 53 -#define C_TAG 54 -#define C_TAGNEXT 55 -#define C_TAGPOP 56 -#define C_TAGPREV 57 -#define C_TAGTOP 58 -#define C_UNDO 59 -#define C_UNABBREVIATE 60 -#define C_UNMAP 61 -#define C_V 62 -#define C_VERSION 63 -#define C_VISUAL_EX 64 -#define C_VISUAL_VI 65 -#define C_VIUSAGE 66 -#define C_WRITE 67 -#define C_WN 68 -#define C_WQ 69 -#define C_XIT 70 -#define C_YANK 71 -#define C_Z 72 -#define C_SUBTILDE 73 +enum { + C_SCROLL = 0, + C_BANG, + C_HASH, + C_SUBAGAIN, + C_STAR, + C_SHIFTL, + C_EQUAL, + C_SHIFTR, + C_AT, + C_APPEND, + C_ABBR, + C_ARGS, + C_BG, + C_CHANGE, + C_CD, + C_CHDIR, + C_COPY, + C_DELETE, + C_DISPLAY, + C_EDIT, + C_EX, + C_EXUSAGE, + C_FILE, + C_FG, + C_GLOBAL, + C_HELP, + C_INSERT, + C_JOIN, + C_K, + C_LIST, + C_MOVE, + C_MARK, + C_MAP, + C_MKEXRC, + C_NEXT, + C_NUMBER, + C_OPEN, + C_PRINT, + C_PRESERVE, + C_PREVIOUS, + C_PUT, + C_QUIT, + C_READ, + C_RECOVER, + C_RESIZE, + C_REWIND, + C_SUBSTITUTE, + C_SCRIPT, + C_SET, + C_SHELL, + C_SOURCE, + C_STOP, + C_SUSPEND, + C_T, + C_TAG, + C_TAGNEXT, + C_TAGPOP, + C_TAGPREV, + C_TAGTOP, + C_UNDO, + C_UNABBREVIATE, + C_UNMAP, + C_V, + C_VERSION, + C_VISUAL_EX, + C_VISUAL_VI, + C_VIUSAGE, + C_WRITE, + C_WN, + C_WQ, + C_XIT, + C_YANK, + C_Z, + C_SUBTILDE +}; Index: include/options_def.h ==
mbuf statistics, tracking of drops
Hi people, while reading around in /sys/kern/uipc_mbuf.c to try to track down a problem with my iwm(4) that seems to correlate with mbuf allocation failures, I noticed that the MBSTAT_DROPS counter and its friends MBSTAT_{WAIT,DRAIN} don't seem to get increased anywhere in /sys. Does the patch below the signature make sense for counting MBSTAT_DROPS? I've got a similar patch for MBSTAT_WAIT, but it's pretty ugly because as far as I can see, there's no real way to notice when pool_get sleeps except for "Try pool_get with M_NOWAIT first and if that returns NULL, try again with M_WAITOK". -- Gregor Index: /sys/kern/uipc_mbuf.c === RCS file: /home/cvs/src/sys/kern/uipc_mbuf.c,v retrieving revision 1.250 diff -u -p -r1.250 uipc_mbuf.c --- /sys/kern/uipc_mbuf.c 12 Oct 2017 09:14:16 - 1.250 +++ /sys/kern/uipc_mbuf.c 11 Nov 2017 12:03:39 - @@ -233,14 +233,14 @@ m_get(int nowait, int type) KDASSERT(type < MT_NTYPES); m = pool_get(&mbpool, nowait == M_WAIT ? PR_WAITOK : PR_NOWAIT); - if (m == NULL) - return (NULL); s = splnet(); counters = counters_enter(&cr, mbstat); + if (m == NULL) { + counters[MBSTAT_DROPS]++; + goto out; + } counters[type]++; - counters_leave(&cr, mbstat); - splx(s); m->m_type = type; m->m_next = NULL; @@ -248,6 +248,10 @@ m_get(int nowait, int type) m->m_data = m->m_dat; m->m_flags = 0; +out: + counters_leave(&cr, mbstat); + splx(s); + return (m); } @@ -266,16 +270,23 @@ m_gethdr(int nowait, int type) KDASSERT(type < MT_NTYPES); m = pool_get(&mbpool, nowait == M_WAIT ? PR_WAITOK : PR_NOWAIT); - if (m == NULL) - return (NULL); s = splnet(); counters = counters_enter(&cr, mbstat); + if (m == NULL) { + counters[MBSTAT_DROPS]++; + goto out; + } counters[type]++; + + m->m_type = type; + +out: counters_leave(&cr, mbstat); splx(s); - m->m_type = type; + if (m == NULL) + return NULL; return (m_inithdr(m)); } @@ -349,7 +360,10 @@ m_clget(struct mbuf *m, int how, u_int p { struct mbuf *m0 = NULL; struct pool *pp; + struct counters_ref cr; + uint64_t *counters; caddr_t buf; + int s; pp = m_clpool(pktlen); #ifdef DIAGNOSTIC @@ -364,9 +378,16 @@ m_clget(struct mbuf *m, int how, u_int p m = m0; } + buf = pool_get(pp, how == M_WAIT ? PR_WAITOK : PR_NOWAIT); + if (buf == NULL) { m_freem(m0); + s = splnet(); + counters = counters_enter(&cr, mbstat); + counters[MBSTAT_DROPS]++; + counters_leave(&cr, mbstat); + splx(s); return (NULL); }
Re: dwiic: add pci attachment
Here is a new version of the dwiic patch that restores the acpi_attach_deps call, confirmed working by Cesare Gargano. Any other testers? Index: sys/conf/files === RCS file: /cvs/src/sys/conf/files,v retrieving revision 1.654 diff -u -p -u -p -r1.654 files --- sys/conf/files 3 Nov 2017 13:01:20 - 1.654 +++ sys/conf/files 10 Nov 2017 15:56:34 - @@ -524,6 +524,10 @@ file dev/spdmem.cspdmem device oaic: scsi filedev/ic/aic6250.coaic +# Synopsys DesignWare I2C controller +device dwiic: i2cbus +file dev/ic/dwiic.c dwiic + # legitimate pseudo-devices pseudo-device vnd: disk pseudo-device rd: disk Index: sys/dev/pci/dwiic_pci.c === RCS file: sys/dev/pci/dwiic_pci.c diff -N sys/dev/pci/dwiic_pci.c --- /dev/null 1 Jan 1970 00:00:00 - +++ sys/dev/pci/dwiic_pci.c 10 Nov 2017 15:56:34 - @@ -0,0 +1,204 @@ +/* $OpenBSD$ */ +/* + * Synopsys DesignWare I2C controller + * PCI attachment + * + * Copyright (c) 2015-2017 joshua stein + * + * Permission to use, copy, modify, and/or 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. + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include + +/* 13.3: I2C Additional Registers Summary */ +#define LPSS_RESETS0x204 +#define LPSS_RESETS_I2C (1 << 0) | (1 << 1) +#define LPSS_RESETS_IDMA (1 << 2) +#define LPSS_ACTIVELTR 0x210 +#define LPSS_IDLELTR 0x214 +#define LPSS_CAPS 0x2fc +#define LPSS_CAPS_NO_IDMA (1 << 8) +#define LPSS_CAPS_TYPE_SHIFT 4 +#define LPSS_CAPS_TYPE_MASK (0xf << LPSS_CAPS_TYPE_SHIFT) + +intdwiic_pci_match(struct device *, void *, void *); +void dwiic_pci_attach(struct device *, struct device *, void *); +intdwiic_pci_activate(struct device *, int); +void dwiic_pci_bus_scan(struct device *, + struct i2cbus_attach_args *, void *); + +#include "acpi.h" +#if NACPI > 0 +struct aml_node *acpi_pci_match(struct device *dev, struct pci_attach_args *pa); +#endif + +struct cfattach dwiic_pci_ca = { + sizeof(struct dwiic_softc), + dwiic_pci_match, + dwiic_pci_attach, + NULL, + dwiic_pci_activate, +}; + +const struct pci_matchid dwiic_pci_ids[] = { + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_I2C_1 }, + { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_100SERIES_LP_I2C_2 }, +}; + +int +dwiic_pci_match(struct device *parent, void *match, void *aux) +{ + return (pci_matchbyid(aux, dwiic_pci_ids, nitems(dwiic_pci_ids))); +} + +void +dwiic_pci_attach(struct device *parent, struct device *self, void *aux) +{ + struct dwiic_softc *sc = (struct dwiic_softc *)self; + struct pci_attach_args *pa = aux; + bus_size_t iosize; + pci_intr_handle_t ih; + const char *intrstr = NULL; + uint8_t type; + + memcpy(&sc->sc_paa, pa, sizeof(sc->sc_paa)); + + pci_set_powerstate(pa->pa_pc, pa->pa_tag, PCI_PMCSR_STATE_D0); + + if (pci_mapreg_map(pa, PCI_MAPREG_START, PCI_MAPREG_MEM_TYPE_64BIT, 0, + &sc->sc_iot, &sc->sc_ioh, NULL, &iosize, 0)) { + printf(": can't map mem space\n"); + return; + } + + sc->sc_caps = bus_space_read_4(sc->sc_iot, sc->sc_ioh, LPSS_CAPS); + type = sc->sc_caps & LPSS_CAPS_TYPE_MASK; + type >>= LPSS_CAPS_TYPE_SHIFT; + if (type != 0) { + printf(": type %d not supported\n", type); + return; + } + + /* un-reset - page 958 */ + bus_space_write_4(sc->sc_iot, sc->sc_ioh, LPSS_RESETS, + (LPSS_RESETS_I2C | LPSS_RESETS_IDMA)); + + /* fetch timing parameters */ + sc->ss_hcnt = dwiic_read(sc, DW_IC_SS_SCL_HCNT); + sc->ss_lcnt = dwiic_read(sc, DW_IC_SS_SCL_LCNT); + sc->fs_hcnt = dwiic_read(sc, DW_IC_FS_SCL_HCNT); + sc->fs_lcnt = dwiic_read(sc, DW_IC_FS_SCL_LCNT); + sc->sda_hold_time = dwiic_read(sc, DW_IC_SDA_HOLD); + + if (dwiic_init(sc)) { + printf(": failed initializing\n"); + return; + } + + /* leave the controller disabled */ + dwiic_write(sc, DW_IC_IN
xf86-video-intel patch to test
Hi, the patch below should not affect the intel(4) X.Org driver functionality. It's sole purpose is to make it compatible with the future upgrade to the X.Org 1.19 xserver. But since I don't have much hardware still using the intel driver (we switched to modesettings(4) for many devices), I'd like to have this tested against the current X server as much as possible. To test it, you need to check out the /usr/xenocara source tree and then: cd /usr/xenocara/driver/xf86-video-intel patch -p0 -E < /this/patch doas make -f Makefile.bsd-wrapper obj doas make -f Makefile.bsd-wrapper build Then restart the X server. Comments, oks are welcome too. Thanks in advance. Index: src/compat-api.h === RCS file: /cvs/OpenBSD/xenocara/driver/xf86-video-intel/src/compat-api.h,v retrieving revision 1.6 diff -u -p -u -r1.6 compat-api.h --- src/compat-api.h16 May 2016 09:54:33 - 1.6 +++ src/compat-api.h11 Nov 2017 17:39:18 - @@ -30,6 +30,7 @@ #include #include +#include #include #ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR @@ -42,6 +43,10 @@ #define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex] #endif +#if GET_ABI_MAJOR(ABI_VIDEODRV_VERSION) >= 22 +#define HAVE_NOTIFY_FD 1 +#endif + #ifndef XF86_SCRN_INTERFACE #define SCRN_ARG_TYPE int @@ -227,4 +232,14 @@ static inline void FreePixmap(PixmapPtr #if HAS_DIRTYTRACKING_ROTATION #define PixmapSyncDirtyHelper(d, dd) PixmapSyncDirtyHelper(d) +#endif + +#if ABI_VIDEODRV_VERSION >= SET_ABI_VERSION(22, 0) +#define OsBlockSIGIO() +#define OsReleaseSIGIO() +#endif + +#if !HAVE_NOTIFY_FD +#define SetNotifyFd(fd, cb, mode, data) AddGeneralSocket(fd); +#define RemoveNotifyFd(fd) RemoveGeneralSocket(fd) #endif Index: src/sna/sna.h === RCS file: /cvs/OpenBSD/xenocara/driver/xf86-video-intel/src/sna/sna.h,v retrieving revision 1.3 diff -u -p -u -r1.3 sna.h --- src/sna/sna.h 12 Apr 2015 19:42:06 - 1.3 +++ src/sna/sna.h 11 Nov 2017 17:39:18 - @@ -367,8 +367,10 @@ struct sna { EntityInfoPtr pEnt; const struct intel_device_info *info; +#if !HAVE_NOTIFY_FD ScreenBlockHandlerProcPtr BlockHandler; ScreenWakeupHandlerProcPtr WakeupHandler; +#endif CloseScreenProcPtr CloseScreen; PicturePtr clear; @@ -995,8 +997,7 @@ static inline uint32_t pixmap_size(Pixma bool sna_accel_init(ScreenPtr sreen, struct sna *sna); void sna_accel_create(struct sna *sna); -void sna_accel_block_handler(struct sna *sna, struct timeval **tv); -void sna_accel_wakeup_handler(struct sna *sna); +void sna_accel_block(struct sna *sna, struct timeval **tv); void sna_accel_watch_flush(struct sna *sna, int enable); void sna_accel_flush(struct sna *sna); void sna_accel_enter(struct sna *sna); Index: src/sna/sna_accel.c === RCS file: /cvs/OpenBSD/xenocara/driver/xf86-video-intel/src/sna/sna_accel.c,v retrieving revision 1.7 diff -u -p -u -r1.7 sna_accel.c --- src/sna/sna_accel.c 3 Dec 2015 22:36:46 - 1.7 +++ src/sna/sna_accel.c 11 Nov 2017 17:39:18 - @@ -112,6 +112,11 @@ #define MAKE_COW_OWNER(ptr) ((void*)((uintptr_t)(ptr) | 1)) #define COW(ptr) (void *)((uintptr_t)(ptr) & ~1) +#if XFONT2_CLIENT_FUNCS_VERSION >= 1 +#define AllocateFontPrivateIndex() xfont2_allocate_font_private_index() +#define FontSetPrivate(font, idx, data) xfont2_font_set_private(font, idx, data) +#endif + #if 0 static void __sna_fallback_flush(DrawablePtr d) { @@ -17676,6 +17681,13 @@ static bool sna_option_accel_blt(struct return strcasecmp(s, "blt") == 0; } +#if HAVE_NOTIFY_FD +static void sna_accel_notify(int fd, int ready, void *data) +{ + sna_mode_wakeup(data); +} +#endif + bool sna_accel_init(ScreenPtr screen, struct sna *sna) { const char *backend; @@ -17687,7 +17699,7 @@ bool sna_accel_init(ScreenPtr screen, st list_init(&sna->flush_pixmaps); list_init(&sna->active_pixmaps); - AddGeneralSocket(sna->kgem.fd); + SetNotifyFd(sna->kgem.fd, sna_accel_notify, X_NOTIFY_READ, sna); #ifdef DEBUG_MEMORY sna->timer_expire[DEBUG_MEMORY_TIMER] = GetTimeInMillis()+ 10 * 1000; @@ -17862,12 +17874,12 @@ void sna_accel_close(struct sna *sna) sna_pixmap_expire(sna); DeleteCallback(&FlushCallback, sna_accel_flush_callback, sna); - RemoveGeneralSocket(sna->kgem.fd); + RemoveNotifyFd(sna->kgem.fd); kgem_cleanup_cache(&sna->kgem); } -void sna_accel_block_handler(struct sna *sna, struct timeval **tv) +void sna_accel_block(struct sna *sna, struct timeval **tv) { sigtrap_assert_inactive(); @@ -17942,22 +17954,6 @@ set_tv: kgem_submit(&sna->kgem); sna->kgem.wedged = !sna->kgem.wedged; } -} - -void sna_accel_wakeup_handler(struct sna *sna) -{ - DBG(("%s: nbatch=%d, nee
ksh.kshrc: Fix quoting in {add,pre,del}_path() to work with spaces
pre_path()ing directories with spaces is broken due to bad quoting. This diff takes care of that by properly passing double quotes through eval and quoting the arguments for no_path() individually. Feedback? diff --git a/etc/ksh.kshrc b/etc/ksh.kshrc index 5b5bd040f79..66736da5e11 100644 --- a/etc/ksh.kshrc +++ b/etc/ksh.kshrc @@ -131,14 +131,14 @@ function no_path { } # if $1 exists and is not in path, append it function add_path { - [[ -d ${1:-.} ]] && no_path $* && eval ${2:-PATH}="\$${2:-PATH}:$1" + [[ -d "${1:-.}" ]] && no_path "$@" && eval ${2:-PATH}=\"\$${2:-PATH}:$1\" } # if $1 exists and is not in path, prepend it function pre_path { - [[ -d ${1:-.} ]] && no_path $* && eval ${2:-PATH}="$1:\$${2:-PATH}" + [[ -d "${1:-.}" ]] && no_path "$@" && eval ${2:-PATH}=\"$1:\$${2:-PATH}\" } # if $1 is in path, remove it function del_path { - no_path $* || eval ${2:-PATH}=$(eval echo :'$'${2:-PATH}: | - sed -e "s;:$1:;:;g" -e "s;^:;;" -e "s;:\$;;") + no_path "$1" || eval ${2:-PATH}=\"$(eval echo :'$'${2:-PATH}: | + sed -e "s;:$1:;:;g" -e "s;^:;;" -e "s;:\$;;")\" }
Re: ksh.kshrc: Fix quoting in {add,pre,del}_path() to work with spaces
On Sat, Nov 11, 2017 at 08:11:25PM +0100, Klemens Nanni wrote: > pre_path()ing directories with spaces is broken due to bad quoting. > > This diff takes care of that by properly passing double quotes through > eval and quoting the arguments for no_path() individually. > > Feedback? What is actually broken? Can you give examples? > diff --git a/etc/ksh.kshrc b/etc/ksh.kshrc > index 5b5bd040f79..66736da5e11 100644 > --- a/etc/ksh.kshrc > +++ b/etc/ksh.kshrc > @@ -131,14 +131,14 @@ function no_path { > } > # if $1 exists and is not in path, append it > function add_path { > - [[ -d ${1:-.} ]] && no_path $* && eval ${2:-PATH}="\$${2:-PATH}:$1" > + [[ -d "${1:-.}" ]] && no_path "$@" && eval > ${2:-PATH}=\"\$${2:-PATH}:$1\" > } > # if $1 exists and is not in path, prepend it > function pre_path { > - [[ -d ${1:-.} ]] && no_path $* && eval ${2:-PATH}="$1:\$${2:-PATH}" > + [[ -d "${1:-.}" ]] && no_path "$@" && eval > ${2:-PATH}=\"$1:\$${2:-PATH}\" > } > # if $1 is in path, remove it > function del_path { > - no_path $* || eval ${2:-PATH}=$(eval echo :'$'${2:-PATH}: | > - sed -e "s;:$1:;:;g" -e "s;^:;;" -e "s;:\$;;") > + no_path "$1" || eval ${2:-PATH}=\"$(eval echo :'$'${2:-PATH}: | > + sed -e "s;:$1:;:;g" -e "s;^:;;" -e "s;:\$;;")\" > } > -- -=[rpe]=-
Re: ksh.kshrc: Fix quoting in {add,pre,del}_path() to work with spaces
On Sat, Nov 11, 2017 at 08:03:36PM +, Robert Peichaer wrote: > On Sat, Nov 11, 2017 at 08:11:25PM +0100, Klemens Nanni wrote: > > pre_path()ing directories with spaces is broken due to bad quoting. > > > > This diff takes care of that by properly passing double quotes through > > eval and quoting the arguments for no_path() individually. > > > > Feedback? > > What is actually broken? > Can you give examples? Sure, pardon me. $ typeset -f add_path function add_path { [[ -d ${1:-.} ]] && no_path $* && eval ${2:-PATH}="\$${2:-PATH}:$1" } $ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin $ mkdir some\ bin $ add_path some\ bin add_path: bin: not found $ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin $ PATH=$PATH:some\ bin $ del_path some\ bin $ echo $? 0 $ echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:some bin/ Since the double quotes are not escaped and thus quote the string to be evaluated itself, `PATH=$PATH:some bin' is eventually being executed as seen above. pre_path() behaves the same trying to execute `PATH=some bin:$PATH'. del_path() silently fails to remove the directory. Here's another example showing how to exploit this: $ ls foo ls: foo: No such file or directory $ mkdir '. touch foo' $ add_path '. touch foo' $ ls foo foo With my patch behaviour will be as expected.
Re: 64bit DMA on amd64
Theo 2016-07-11 15:09:48, https://marc.info/?l=openbsd-tech&m=146824981122013&w=2 , https://marc.info/?l=openbsd-tech&m=146825098022380&w=2 : > And bufs don't need it either. Have you actually cranked your buffer > cache that high? I have test this, on sparc64 which has unlimited DMA > reach due to the iommu. The system comes to a crawl when there are > too many mbufs or bufs, probably due to management structures unable > to handle the pressure. Theo 2016-07-11 16:16:13 , https://marc.info/?l=openbsd-tech&m=146825379723312&w=2 : > I was simply pointing out that massive (well above 4GB) buffer cache > on a 64-bit DMA-reachable machine worked poorly. Likely due to data > structures managing the memory with rather large O... What algorithms drive the buffer cache structure now?
openssl s_time, speed: use monotime for absolute interval measurement
Hi, times(3) is okay for user CPU measurement but is inappropriate for absolute interval measurement as its output is subject to changes by both adjtime(2) and settimeofday(2). The attached diff replaces it with getrusage(2) for user CPU measurement and clock_gettime(2)'s CLOCK_MONOTONIC clock for absolute interval measurement. The attached diff also replaces time(3) in s_time with clock_gettime's CLOCK_MONOTONIC clock. This ensures that we only measure for about as long as the user said to. Neither timersub(2) nor timespecsub are standard, though many systems have them. Is this a problem for libressl-portable? Thoughts and feedback? -- Scott Cheloha Index: usr.bin/openssl/apps.h === RCS file: /cvs/src/usr.bin/openssl/apps.h,v retrieving revision 1.19 diff -u -p -r1.19 apps.h --- usr.bin/openssl/apps.h 30 Aug 2016 14:34:59 - 1.19 +++ usr.bin/openssl/apps.h 10 Nov 2017 18:38:13 - @@ -277,9 +277,8 @@ unsigned char *next_protos_parse(unsigne int app_isdir(const char *); -#define TM_START 0 -#define TM_STOP1 -double app_tminterval (int stop, int usertime); +double real_interval(int new); +double user_interval(int new); #define OPENSSL_NO_SSL_INTERN Index: usr.bin/openssl/apps_posix.c === RCS file: /cvs/src/usr.bin/openssl/apps_posix.c,v retrieving revision 1.2 diff -u -p -r1.2 apps_posix.c --- usr.bin/openssl/apps_posix.c13 Sep 2015 12:41:01 - 1.2 +++ usr.bin/openssl/apps_posix.c10 Nov 2017 18:38:13 - @@ -116,31 +116,39 @@ * Functions that need to be overridden by non-POSIX operating systems. */ -#include +#include -#include +#include #include "apps.h" double -app_tminterval(int stop, int usertime) +real_interval(int new) { - double ret = 0; - struct tms rus; - clock_t now = times(&rus); - static clock_t tmstart; - - if (usertime) - now = rus.tms_utime; - - if (stop == TM_START) - tmstart = now; - else { - long int tck = sysconf(_SC_CLK_TCK); - ret = (now - tmstart) / (double) tck; + static struct timespec elapsed, now, start; + + clock_gettime(CLOCK_MONOTONIC, &now); + if (new) { + start = now; + return 0.0; } + timespecsub(&now, &start, &elapsed); + return elapsed.tv_sec + elapsed.tv_nsec / 10.0; +} - return (ret); +double +user_interval(int new) +{ + static struct timeval elapsed, start; + static struct rusage now; + + getrusage(RUSAGE_SELF, &now); + if (new) { + start = now.ru_utime; + return 0.0; + } + timersub(&now.ru_utime, &start, &elapsed); + return elapsed.tv_sec + elapsed.tv_usec / 100.0; } int Index: usr.bin/openssl/s_time.c === RCS file: /cvs/src/usr.bin/openssl/s_time.c,v retrieving revision 1.18 diff -u -p -r1.18 s_time.c --- usr.bin/openssl/s_time.c2 Nov 2017 00:31:49 - 1.18 +++ usr.bin/openssl/s_time.c10 Nov 2017 18:38:13 - @@ -68,6 +68,7 @@ #include #include #include +#include #include #include @@ -229,14 +230,9 @@ s_time_usage(void) /*** * TIME - time functions */ -#define START 0 -#define STOP 1 - -static double -tm_Time_F(int s) -{ - return app_tminterval(s, 1); -} +#define START 1 +#define STOP 0 +#define tm_Time_F(s) user_interval(s); /*** * MAIN - main processing area for client @@ -248,7 +244,7 @@ s_time_main(int argc, char **argv) double totalTime = 0.0; int nConn = 0; SSL *scon = NULL; - time_t finishtime; + struct timespec finishtime, now; int ret = 1; char buf[1024 * 8]; int ver; @@ -330,10 +326,12 @@ s_time_main(int argc, char **argv) /* Loop and time how long it takes to make connections */ bytes_read = 0; - finishtime = time(NULL) + s_time_config.maxtime; + clock_gettime(CLOCK_MONOTONIC, &finishtime); + finishtime.tv_sec += s_time_config.maxtime; tm_Time_F(START); for (;;) { - if (finishtime < time(NULL)) + clock_gettime(CLOCK_MONOTONIC, &now); + if (timespeccmp(&finishtime, &now, <)) break; if ((scon = doConnection(NULL)) == NULL) goto end; @@ -383,7 +381,7 @@ s_time_main(int argc, char **argv) nConn, totalTime, ((double) nConn / totalTime), bytes_read); printf("%d connections in %lld real seconds, %ld bytes read per connection\n", nConn, - (long long)(time(NULL) - finishtime + s
pppd: explicit_bzero sensitive buffers
Hi, You want explicit_bzero(3) for these buffers. Zeroing a buffer is compiler- and system-dependent, so I added a new macro. I'll send a pull request upstream if this goes in. -- Scott Cheloha Index: usr.sbin/pppd/auth.c === RCS file: /cvs/src/usr.sbin/pppd/auth.c,v retrieving revision 1.38 diff -u -p -r1.38 auth.c --- usr.sbin/pppd/auth.c24 Jun 2016 17:22:56 - 1.38 +++ usr.sbin/pppd/auth.c12 Nov 2017 01:09:24 - @@ -399,7 +399,7 @@ auth_withpeer_fail(unit, protocol) int unit, protocol; { if (passwd_from_file) - BZERO(passwd, MAXSECRETLEN); + EXPLICIT_BZERO(passwd, MAXSECRETLEN); /* * We've failed to authenticate ourselves to our peer. * He'll probably take the link down, and there's not much @@ -422,12 +422,12 @@ auth_withpeer_success(unit, protocol) break; case PPP_PAP: if (passwd_from_file) - BZERO(passwd, MAXSECRETLEN); + EXPLICIT_BZERO(passwd, MAXSECRETLEN); bit = PAP_WITHPEER; break; default: syslog(LOG_WARNING, "auth_peer_success: unknown protocol %x", - protocol); + protocol); bit = 0; } @@ -718,8 +718,8 @@ check_passwd(unit, auser, userlen, apass set_allowed_addrs(unit, addrs); } -BZERO(passwd, sizeof(passwd)); -BZERO(secret, sizeof(secret)); +EXPLICIT_BZERO(passwd, sizeof(passwd)); +EXPLICIT_BZERO(secret, sizeof(secret)); return ret; } @@ -825,7 +825,7 @@ null_login(unit) i = scan_authfile(f, "", our_name, (u_int32_t)0, secret, &addrs, filename); ret = i >= 0 && (i & NONWILD_CLIENT) != 0 && secret[0] == 0; -BZERO(secret, sizeof(secret)); +EXPLICIT_BZERO(secret, sizeof(secret)); if (ret) set_allowed_addrs(unit, addrs); @@ -864,7 +864,7 @@ get_pap_passwd(passwd) return 0; if (passwd != NULL) strlcpy(passwd, secret, MAXSECRETLEN); -BZERO(secret, sizeof(secret)); +EXPLICIT_BZERO(secret, sizeof(secret)); return 1; } @@ -978,7 +978,7 @@ get_secret(unit, client, server, secret, len = MAXSECRETLEN; } BCOPY(secbuf, secret, len); -BZERO(secbuf, sizeof(secbuf)); +EXPLICIT_BZERO(secbuf, sizeof(secbuf)); *secret_len = len; return 1; Index: usr.sbin/pppd/chap.c === RCS file: /cvs/src/usr.sbin/pppd/chap.c,v retrieving revision 1.18 diff -u -p -r1.18 chap.c --- usr.sbin/pppd/chap.c15 Jan 2015 23:19:48 - 1.18 +++ usr.sbin/pppd/chap.c12 Nov 2017 01:09:24 - @@ -470,7 +470,7 @@ ChapReceiveChallenge(cstate, inp, id, le return; } -BZERO(secret, sizeof(secret)); +EXPLICIT_BZERO(secret, sizeof(secret)); ChapSendResponse(cstate); } @@ -576,7 +576,7 @@ ChapReceiveResponse(cstate, inp, id, len } } -BZERO(secret, sizeof(secret)); +EXPLICIT_BZERO(secret, sizeof(secret)); ChapSendStatus(cstate, code); if (code == CHAP_SUCCESS) { Index: usr.sbin/pppd/pppd.h === RCS file: /cvs/src/usr.sbin/pppd/pppd.h,v retrieving revision 1.21 diff -u -p -r1.21 pppd.h --- usr.sbin/pppd/pppd.h6 Dec 2015 12:00:16 - 1.21 +++ usr.sbin/pppd/pppd.h12 Nov 2017 01:09:24 - @@ -403,6 +403,7 @@ extern struct option_info devnam_info; #define BCOPY(s, d, l) memcpy(d, s, l) #define BMOVE(s, d, l) memmove(d, s, l) #define BZERO(s, n)memset(s, 0, n) +#define EXPLICIT_BZERO(s, n) explicit_bzero(s, n) #define EXIT(u)quit() #define PRINTMSG(m, l) { m[l] = '\0'; syslog(LOG_INFO, "Remote message: %s", m); } Index: usr.sbin/pppd/upap.c === RCS file: /cvs/src/usr.sbin/pppd/upap.c,v retrieving revision 1.10 diff -u -p -r1.10 upap.c --- usr.sbin/pppd/upap.c27 Oct 2009 23:59:53 - 1.10 +++ usr.sbin/pppd/upap.c12 Nov 2017 01:09:24 - @@ -402,7 +402,7 @@ upap_rauthreq(u, inp, id, len) */ retcode = check_passwd(u->us_unit, ruser, ruserlen, rpasswd, rpasswdlen, &msg, &msglen); -BZERO(rpasswd, rpasswdlen); +EXPLICIT_BZERO(rpasswd, rpasswdlen); upap_sresp(u, retcode, id, msg, msglen);
Re: 64bit DMA on amd64
On Sat, Nov 11, 2017 at 4:22 PM, wrote: > Theo 2016-07-11 15:09:48, https://marc.info/?l=openbsd- > tech&m=146824981122013&w=2 , > https://marc.info/?l=openbsd-tech&m=146825098022380&w=2 : > > And bufs don't need it either. Have you actually cranked your buffer > > cache that high? I have test this, on sparc64 which has unlimited DMA > > reach due to the iommu. The system comes to a crawl when there are > > too many mbufs or bufs, probably due to management structures unable > > to handle the pressure. > > Theo 2016-07-11 16:16:13 , https://marc.info/?l=openbsd- > tech&m=146825379723312&w=2 : > > I was simply pointing out that massive (well above 4GB) buffer cache > > on a 64-bit DMA-reachable machine worked poorly. Likely due to data > > structures managing the memory with rather large O... > > What algorithms drive the buffer cache structure now? If I recall Bob and Ted's undeadly posts correctly, the buffers are both in per-vnode red-black trees and a global 2Q structure to manage the total set of buffers. (How those names will be useful I don't know.) Philip Guenther
Re: pppd: explicit_bzero sensitive buffers
> On Nov 11, 2017, at 7:30 PM, Matthew Martin wrote: > > There's a stray whitespace change and explicit sorts below exit. [...] Whoops, here you go. -- Scott Cheloha Index: usr.sbin/pppd/auth.c === RCS file: /cvs/src/usr.sbin/pppd/auth.c,v retrieving revision 1.38 diff -u -p -r1.38 auth.c --- usr.sbin/pppd/auth.c24 Jun 2016 17:22:56 - 1.38 +++ usr.sbin/pppd/auth.c12 Nov 2017 02:38:22 - @@ -399,7 +399,7 @@ auth_withpeer_fail(unit, protocol) int unit, protocol; { if (passwd_from_file) - BZERO(passwd, MAXSECRETLEN); + EXPLICIT_BZERO(passwd, MAXSECRETLEN); /* * We've failed to authenticate ourselves to our peer. * He'll probably take the link down, and there's not much @@ -422,7 +422,7 @@ auth_withpeer_success(unit, protocol) break; case PPP_PAP: if (passwd_from_file) - BZERO(passwd, MAXSECRETLEN); + EXPLICIT_BZERO(passwd, MAXSECRETLEN); bit = PAP_WITHPEER; break; default: @@ -718,8 +718,8 @@ check_passwd(unit, auser, userlen, apass set_allowed_addrs(unit, addrs); } -BZERO(passwd, sizeof(passwd)); -BZERO(secret, sizeof(secret)); +EXPLICIT_BZERO(passwd, sizeof(passwd)); +EXPLICIT_BZERO(secret, sizeof(secret)); return ret; } @@ -825,7 +825,7 @@ null_login(unit) i = scan_authfile(f, "", our_name, (u_int32_t)0, secret, &addrs, filename); ret = i >= 0 && (i & NONWILD_CLIENT) != 0 && secret[0] == 0; -BZERO(secret, sizeof(secret)); +EXPLICIT_BZERO(secret, sizeof(secret)); if (ret) set_allowed_addrs(unit, addrs); @@ -864,7 +864,7 @@ get_pap_passwd(passwd) return 0; if (passwd != NULL) strlcpy(passwd, secret, MAXSECRETLEN); -BZERO(secret, sizeof(secret)); +EXPLICIT_BZERO(secret, sizeof(secret)); return 1; } @@ -978,7 +978,7 @@ get_secret(unit, client, server, secret, len = MAXSECRETLEN; } BCOPY(secbuf, secret, len); -BZERO(secbuf, sizeof(secbuf)); +EXPLICIT_BZERO(secbuf, sizeof(secbuf)); *secret_len = len; return 1; Index: usr.sbin/pppd/chap.c === RCS file: /cvs/src/usr.sbin/pppd/chap.c,v retrieving revision 1.18 diff -u -p -r1.18 chap.c --- usr.sbin/pppd/chap.c15 Jan 2015 23:19:48 - 1.18 +++ usr.sbin/pppd/chap.c12 Nov 2017 02:38:22 - @@ -470,7 +470,7 @@ ChapReceiveChallenge(cstate, inp, id, le return; } -BZERO(secret, sizeof(secret)); +EXPLICIT_BZERO(secret, sizeof(secret)); ChapSendResponse(cstate); } @@ -576,7 +576,7 @@ ChapReceiveResponse(cstate, inp, id, len } } -BZERO(secret, sizeof(secret)); +EXPLICIT_BZERO(secret, sizeof(secret)); ChapSendStatus(cstate, code); if (code == CHAP_SUCCESS) { Index: usr.sbin/pppd/pppd.h === RCS file: /cvs/src/usr.sbin/pppd/pppd.h,v retrieving revision 1.21 diff -u -p -r1.21 pppd.h --- usr.sbin/pppd/pppd.h6 Dec 2015 12:00:16 - 1.21 +++ usr.sbin/pppd/pppd.h12 Nov 2017 02:38:23 - @@ -404,6 +404,7 @@ extern struct option_info devnam_info; #define BMOVE(s, d, l) memmove(d, s, l) #define BZERO(s, n)memset(s, 0, n) #define EXIT(u)quit() +#define EXPLICIT_BZERO(s, n) explicit_bzero(s, n) #define PRINTMSG(m, l) { m[l] = '\0'; syslog(LOG_INFO, "Remote message: %s", m); } Index: usr.sbin/pppd/upap.c === RCS file: /cvs/src/usr.sbin/pppd/upap.c,v retrieving revision 1.10 diff -u -p -r1.10 upap.c --- usr.sbin/pppd/upap.c27 Oct 2009 23:59:53 - 1.10 +++ usr.sbin/pppd/upap.c12 Nov 2017 02:38:23 - @@ -402,7 +402,7 @@ upap_rauthreq(u, inp, id, len) */ retcode = check_passwd(u->us_unit, ruser, ruserlen, rpasswd, rpasswdlen, &msg, &msglen); -BZERO(rpasswd, rpasswdlen); +EXPLICIT_BZERO(rpasswd, rpasswdlen); upap_sresp(u, retcode, id, msg, msglen);
Re: armv7: newfs efi-partition in when choosing manual-fdisk mbr
On Fri, Nov 10, 2017 at 10:35:30PM +, Robert Peichaer wrote: > On Fri, Nov 10, 2017 at 10:27:36AM +0200, Artturi Alm wrote: > > Hi, > > > > currently, just editing the mbr to give more room for u-boot env growth, > > will result in unbootable system, as the installer will fail to mount it, > > and naturally things won't work beyond u-boot after reboot either. > > > > i'm not really sure about this diff, but it does seem like it might do, > > what i think it should? might take a while, before i can test myself, so > > i thought i'd mail and ask, if there's a reason for how it is atm.? :) > > > > -Artturi > > I do not know enough about the needed/supported armv7 filesystem layout. > The install notes talk about GPT and MBR partitioning, but the install.md > script only offers MBR. Obviously EFI boot is supported reading install.md > but from MBR. I thought that's only possible from a GPT partition. > > Anyways. I will happily help to get this right scripting wise. > But right now I don't know if this is the correct way to fix this. > > -- > -=[rpe]=- I don't think there's more to it than what can be seen from install.md md_prep_fdisk(): local bootparttype="C" local bootsectorstart="2048" local bootsectorsize="32768" and fdisk sd0: Disk: sd0 geometry: 1887/255/63 [30318592 Sectors] Offset: 0 Signature: 0xAA55 Starting Ending LBA Info: #: id C H S - C H S [ start:size ] --- *0: 0C 0 32 33 - 2 42 40 [2048: 32768 ] FAT32L 1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused 2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused 3: A6 2 42 41 - 1887 62 31 [ 34816:30283776 ] OpenBSD i'd be surprised, if anyone is currently running with anything different. i think one would have to know the exact bounds of whatever bootarm.efi was loaded from, to keep the fat partition working after MBR is written? if there is such usecase as preserve-efi-boot-partition_and_area-before-it, it should be behind (currently non-existing) oO-case, which would check only for the disk_has mbr openbsd, right? or? my diff was slightly inspired by macppc, which does newfs -t msdos unconditionally, for all cases, fwiw.. -Artturi
armv7/sxie: less ierror
Hi, i'm likely responsible, for having sent the diff that introduced this. minimal fix taken w/diff -U10, to show the obvious dup++. -Artturi diff --git a/sys/arch/armv7/sunxi/sxie.c b/sys/arch/armv7/sunxi/sxie.c index 1cd713cd52a..cb5849c7dc9 100644 --- a/sys/arch/armv7/sunxi/sxie.c +++ b/sys/arch/armv7/sunxi/sxie.c @@ -613,21 +613,20 @@ trynext: /* read the actual packet from fifo XXX through 'align buffer'.. */ if (pktlen & 3) rlen = SXIE_ROUNDUP(pktlen, 4); else rlen = pktlen; bus_space_read_multi_4(sc->sc_iot, sc->sc_ioh, SXIE_RXIO, (uint32_t *)&rxbuf[0], rlen >> 2); m = m_devget(&rxbuf[0], pktlen, ETHER_ALIGN); if (m == NULL) { - ifp->if_ierrors++; goto err_out; } ml_enqueue(&ml, m); goto trynext; err_out: ifp->if_ierrors++; done: if_input(ifp, &ml); }
Semi-OT: Paper about a new implementation of malloc
I was looking for something else and found this recent paper. They compare their implementation with the OpenBSD malloc. It's probably interesting for some of you. Paper: https://acmccs.github.io/papers/p2389-silvestroA.pdf Code: https://github.com/UTSASRG/FreeGuard -- Juan Francisco Cantero Hurtado http://juanfra.info
Re: armv7: newfs efi-partition in when choosing manual-fdisk mbr
On Fri, Nov 10, 2017 at 10:27:36AM +0200, Artturi Alm wrote: > Hi, > > currently, just editing the mbr to give more room for u-boot env growth, > will result in unbootable system, as the installer will fail to mount it, > and naturally things won't work beyond u-boot after reboot either. > > i'm not really sure about this diff, but it does seem like it might do, > what i think it should? might take a while, before i can test myself, so > i thought i'd mail and ask, if there's a reason for how it is atm.? :) > > -Artturi 0x0C is only used due to the broadcom boot rom not understanding EFI System partition (0xEF). That should not be set outside of arm*. As it is the partition is larger than it needs to be as kernels are no longer stored there. There is no reason to force MBR as both U-Boot and EDK2 should be able to cope with GPT. > > > diff --git a/distrib/armv7/ramdisk/install.md > b/distrib/armv7/ramdisk/install.md > index 23d574e4e7a..1639e06c221 100644 > --- a/distrib/armv7/ramdisk/install.md > +++ b/distrib/armv7/ramdisk/install.md > @@ -141,8 +141,14 @@ partition on the disk. > $(fdisk ${_disk}) > __EOT > fdisk -e ${_disk} > - disk_has $_disk mbr openbsd && return > - echo No OpenBSD partition in MBR, try again. ;; > + disk_has $_disk mbr efi || > + { echo No EFI(FAT id 0C) partition in MBR, try > again.; continue; } > + disk_has $_disk mbr efi_bootable || > + { echo No bootable EFI partition in MBR, try > again.; continue; } > + disk_has $_disk mbr openbsd || > + { echo No OpenBSD partition in MBR, try again.; > continue; } > + newfs -t ${bootfstype} ${newfs_args} ${_disk}i > + return ;; > esac > done > } > diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub > index ef8c069588d..e204dd49d27 100644 > --- a/distrib/miniroot/install.sub > +++ b/distrib/miniroot/install.sub > @@ -368,6 +368,8 @@ disk_has() { > local _p_mbr_openbsd='^..: A6 ' > local _p_mbr_dos='^..: 06 ' > local _p_mbr_dos_active='^\*.: 06 ' > + local _p_mbr_efi='^..: 0C ' > + local _p_mbr_efi_bootable='^\*.: 0C ' > local _p_mbr_linux='^..: 83 ' > local _p_sr='OPENBSD, SR' > local _p_sr_crypto='OPENBSD, SR CRYPTO' >
Re: libfuse: signal handler doesn't cater for "Device busy" and other errors
On Fri, 10 Nov 2017 11:55:53 + Helg Bredow wrote: > On Fri, 10 Nov 2017 10:13:35 +0100 > Anton Lindqvist wrote: > > > On Fri, Nov 10, 2017 at 09:36:25AM +0100, Martin Pieuchot wrote: > > > On 09/11/17(Thu) 09:02, Helg Bredow wrote: > > > > The current libfuse signal handling assumes that the file system will > > > > always be unmounted by the child. One obvious case where this is not > > > > true is if the file system is busy. To replicate: > > > > > > > > 1. mount a fuse file system > > > > 2. cd anywhere on the file system > > > > 3. pkill -INT > > > > > > > > The result is a zombie child process and no more response to signals > > > > even if the file system is no longer busy. > > > > > > > > This patch ensures that the child always exits and that an error is > > > > printed to stdout if the file system cannot be unmounted. Tested with > > > > fuse-exfat and ntfs_3g. Suggestions for improvement are welcome. > > > > > > Nice to see that you're fixing a bug. However I'd suggest you to go > > > much further in your improvement. > > > > > > Signal handlers are hard and instead of doing work inside the signal > > > handler you should toggle a global variable/flag and do this work > > > inside the main loop (fuse_loop()?). > > > > > > For example your code below calls fprintf(3) in the signal handler. This > > > is incorrect, this functions is not signal handler safe. What about > > > fuse_unmount()? Are you sure it can be called from a signal handler? > > > > Some more info on making signal handlers asynchronous-safe: > > > > https://www.securecoding.cert.org/confluence/display/c/SIG30-C.+Call+only+asynchronous-safe+functions+within+signal+handlers > > Thanks for the feedback and info guys. I wasn't too confident with this patch > and you've given me some good pointers to improve it. > > -- > Helg > I've completely rewritten the patch. Is this better? Index: fuse.c === RCS file: /cvs/src/lib/libfuse/fuse.c,v retrieving revision 1.34 diff -u -p -u -p -r1.34 fuse.c --- fuse.c 4 Nov 2017 13:17:18 - 1.34 +++ fuse.c 12 Nov 2017 04:28:21 - @@ -31,7 +31,7 @@ #include "fuse_private.h" #include "debug.h" -static struct fuse_session *sigse; +static volatile sig_atomic_t signum = 0; static struct fuse_context *ictx = NULL; static int max_read = FUSEBUFMAXSIZE; @@ -61,6 +61,48 @@ static struct fuse_opt fuse_core_opts[] FUSE_OPT_END }; +static void +ifuse_get_signal(int num) +{ + signum = num; +} + +static void +ifuse_child_exit(const struct fuse *f) +{ + int status; + + signal(SIGCHLD, SIG_DFL); + if (waitpid(WAIT_ANY, &status, WNOHANG) == -1) + fprintf(stderr, "fuse: %s\n", strerror(errno)); + + if (WIFEXITED(status) && (WEXITSTATUS(status) != 0)) + fprintf(stderr, "fuse: %s: %s\n", + f->fc->dir, strerror(WEXITSTATUS(status))); + + return; +} + +static void +ifuse_try_unmount(const struct fuse *f) +{ + pid_t child; + + signal(SIGCHLD, ifuse_get_signal); + child = fork(); + + if (child < 0) { + DPERROR(__func__); + return; + } + + if (child == 0) { + errno = 0; + fuse_unmount(f->fc->dir, f->fc); + _exit(errno); + } +} + int fuse_loop(struct fuse *fuse) { @@ -83,9 +125,24 @@ fuse_loop(struct fuse *fuse) while (!fuse->fc->dead) { ret = kevent(fuse->fc->kq, &fuse->fc->event, 1, &ev, 1, NULL); - if (ret == -1) - DPERROR(__func__); - else if (ret > 0) { + if (ret == -1) { + if (errno == EINTR) { + switch (signum) { + case SIGCHLD: + ifuse_child_exit(fuse); + break; + case SIGHUP: + case SIGINT: + case SIGTERM: + ifuse_try_unmount(fuse); + break; + default: + fprintf(stderr, "%s: %s\n", __func__, + strsignal(signum)); + } + } else + DPERROR(__func__); + } else if (ret > 0) { n = read(fuse->fc->fd, &fbuf, sizeof(fbuf)); if (n != sizeof(fbuf)) { fprintf(stderr, "%s: bad fusebuf read\n", @@ -298,38 +355,9 @@ fuse_destroy(struct fuse *f) free(f); } -static void -ifuse_get_signal(unused int num) -{ - struct fuse *f; - pid_t child; - int status; - - if (sigse != NULL) { -
Re: armv7: newfs efi-partition in when choosing manual-fdisk mbr
On Sun, Nov 12, 2017 at 03:17:54PM +1100, Jonathan Gray wrote: > On Fri, Nov 10, 2017 at 10:27:36AM +0200, Artturi Alm wrote: > > Hi, > > > > currently, just editing the mbr to give more room for u-boot env growth, > > will result in unbootable system, as the installer will fail to mount it, > > and naturally things won't work beyond u-boot after reboot either. > > > > i'm not really sure about this diff, but it does seem like it might do, > > what i think it should? might take a while, before i can test myself, so > > i thought i'd mail and ask, if there's a reason for how it is atm.? :) > > > > -Artturi > > 0x0C is only used due to the broadcom boot rom not understanding > EFI System partition (0xEF). That should not be set outside of arm*. > > As it is the partition is larger than it needs to be as kernels > are no longer stored there. > > There is no reason to force MBR as both U-Boot and EDK2 should be able > to cope with GPT. > ok, that explains a lot, so diff withdrawn, thanks. maybe we could use some of the now-unused EFI-partition size for bigger default partition offset? (ie. *2 to 4096(2MiB)) -Artturi > > > > > > diff --git a/distrib/armv7/ramdisk/install.md > > b/distrib/armv7/ramdisk/install.md > > index 23d574e4e7a..1639e06c221 100644 > > --- a/distrib/armv7/ramdisk/install.md > > +++ b/distrib/armv7/ramdisk/install.md > > @@ -141,8 +141,14 @@ partition on the disk. > > $(fdisk ${_disk}) > > __EOT > > fdisk -e ${_disk} > > - disk_has $_disk mbr openbsd && return > > - echo No OpenBSD partition in MBR, try again. ;; > > + disk_has $_disk mbr efi || > > + { echo No EFI(FAT id 0C) partition in MBR, try > > again.; continue; } > > + disk_has $_disk mbr efi_bootable || > > + { echo No bootable EFI partition in MBR, try > > again.; continue; } > > + disk_has $_disk mbr openbsd || > > + { echo No OpenBSD partition in MBR, try again.; > > continue; } > > + newfs -t ${bootfstype} ${newfs_args} ${_disk}i > > + return ;; > > esac > > done > > } > > diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub > > index ef8c069588d..e204dd49d27 100644 > > --- a/distrib/miniroot/install.sub > > +++ b/distrib/miniroot/install.sub > > @@ -368,6 +368,8 @@ disk_has() { > > local _p_mbr_openbsd='^..: A6 ' > > local _p_mbr_dos='^..: 06 ' > > local _p_mbr_dos_active='^\*.: 06 ' > > + local _p_mbr_efi='^..: 0C ' > > + local _p_mbr_efi_bootable='^\*.: 0C ' > > local _p_mbr_linux='^..: 83 ' > > local _p_sr='OPENBSD, SR' > > local _p_sr_crypto='OPENBSD, SR CRYPTO' > >