CVS commit: src/doc
Module Name:src Committed By: manu Date: Tue Jul 27 12:40:07 UTC 2021 Modified Files: src/doc: CHANGES Log Message: Tie the maximum file lock per unprivilegied uid to kern.maxfiles To generate a diff of this commit: cvs rdiff -u -r1.2815 -r1.2816 src/doc/CHANGES Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/CHANGES diff -u src/doc/CHANGES:1.2815 src/doc/CHANGES:1.2816 --- src/doc/CHANGES:1.2815 Fri Jul 9 17:07:29 2021 +++ src/doc/CHANGES Tue Jul 27 12:40:07 2021 @@ -1,4 +1,4 @@ -# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2815 $> +# LIST OF CHANGES FROM LAST RELEASE: <$Revision: 1.2816 $> # # # [Note: This file does not mention every change made to the NetBSD source tree. @@ -387,3 +387,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0: acpi(4): Updated ACPICA to 20210604. [christos 20210706] hp300: Add support of multiple rd(4) disks on all punits for HPDisk. [tsutsui 20210709] + kernel: Tie the maximum file lock per unprivilegied uid to + kern.maxfiles [manu 20210727]
CVS commit: src
Module Name:src Committed By: manu Date: Tue Jul 27 09:32:55 UTC 2021 Modified Files: src/lib/libc/sys: fcntl.2 flock.2 src/share/man/man7: sysctl.7 src/sys/kern: vfs_lockf.c Log Message: Tie the maximum file lock per unprivilegied uid to kern.maxfiles This makes the limit simple to raise at run time. While there, document that fcntl(2) and flock(2) may return ENOMEM when this limit is reached. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/lib/libc/sys/fcntl.2 cvs rdiff -u -r1.22 -r1.23 src/lib/libc/sys/flock.2 cvs rdiff -u -r1.152 -r1.153 src/share/man/man7/sysctl.7 cvs rdiff -u -r1.73 -r1.74 src/sys/kern/vfs_lockf.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/sys/fcntl.2 diff -u src/lib/libc/sys/fcntl.2:1.45 src/lib/libc/sys/fcntl.2:1.46 --- src/lib/libc/sys/fcntl.2:1.45 Fri Sep 27 07:20:07 2019 +++ src/lib/libc/sys/fcntl.2 Tue Jul 27 09:32:55 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: fcntl.2,v 1.45 2019/09/27 07:20:07 wiz Exp $ +.\" $NetBSD: fcntl.2,v 1.46 2021/07/27 09:32:55 manu Exp $ .\" .\" Copyright (c) 1983, 1993 .\" The Regents of the University of California. All rights reserved. @@ -549,6 +549,17 @@ The argument is .Dv F_GETPATH and insufficient memory is available. +.Pp +The argument +.Fa cmd +is +.Dv F_GETLK , +.Dv F_SETLK , +or +.Dv F_SETLKW , +and the file lock limit for the current unprivilegied user +has been reached. It can be modifed using sysctl +.Li kern.maxfiles . .It Bq Er ERANGE The argument .Fa cmd Index: src/lib/libc/sys/flock.2 diff -u src/lib/libc/sys/flock.2:1.22 src/lib/libc/sys/flock.2:1.23 --- src/lib/libc/sys/flock.2:1.22 Sat Oct 15 21:35:50 2011 +++ src/lib/libc/sys/flock.2 Tue Jul 27 09:32:55 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: flock.2,v 1.22 2011/10/15 21:35:50 rmind Exp $ +.\" $NetBSD: flock.2,v 1.23 2021/07/27 09:32:55 manu Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -137,6 +137,10 @@ does not include exactly one of .Dv LOCK_SH , or .Dv LOCK_UN . +.It Bq Eq ENOMEM +The file lock limit for the current unprivilegied user +has been reached. It can be modifed using sysctl +.Li kern.maxfiles . .It Bq Er EOPNOTSUPP The argument .Fa fd Index: src/share/man/man7/sysctl.7 diff -u src/share/man/man7/sysctl.7:1.152 src/share/man/man7/sysctl.7:1.153 --- src/share/man/man7/sysctl.7:1.152 Tue Jul 13 16:56:43 2021 +++ src/share/man/man7/sysctl.7 Tue Jul 27 09:32:55 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: sysctl.7,v 1.152 2021/07/13 16:56:43 nia Exp $ +.\" $NetBSD: sysctl.7,v 1.153 2021/07/27 09:32:55 manu Exp $ .\" .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. @@ -756,6 +756,11 @@ Memory Mapped Files Option is available otherwise\ 0. .It Li kern.maxfiles ( Dv KERN_MAXFILES ) The maximum number of open files that may be open in the system. +This also controls the maximum file locks per unprivilegied user +enforced by +.Xr fnctl 2 +and +.Xr flock 2 . .It Li kern.maxpartitions ( Dv KERN_MAXPARTITIONS ) The maximum number of partitions allowed per disk. .It Li kern.maxlwp Index: src/sys/kern/vfs_lockf.c diff -u src/sys/kern/vfs_lockf.c:1.73 src/sys/kern/vfs_lockf.c:1.74 --- src/sys/kern/vfs_lockf.c:1.73 Mon Jan 31 08:25:32 2011 +++ src/sys/kern/vfs_lockf.c Tue Jul 27 09:32:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_lockf.c,v 1.73 2011/01/31 08:25:32 dholland Exp $ */ +/* $NetBSD: vfs_lockf.c,v 1.74 2021/07/27 09:32:55 manu Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_lockf.c,v 1.73 2011/01/31 08:25:32 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_lockf.c,v 1.74 2021/07/27 09:32:55 manu Exp $"); #include #include @@ -123,7 +123,7 @@ int lockf_debug = 0; * so that the unlock can succeed. If the unlocking causes too many splits, * however, you're totally cutoff. */ -int maxlocksperuid = 1024; +#define MAXLOCKSPERUID (2 * maxfiles) #ifdef LOCKF_DEBUG /* @@ -200,7 +200,7 @@ lf_alloc(int allowfail) uip = uid_find(uid); lcnt = atomic_inc_ulong_nv(>ui_lockcnt); if (uid && allowfail && lcnt > - (allowfail == 1 ? maxlocksperuid : (maxlocksperuid * 2))) { + (allowfail == 1 ? MAXLOCKSPERUID : (MAXLOCKSPERUID * 2))) { atomic_dec_ulong(>ui_lockcnt); return NULL; }
CVS commit: src/external/mpl/dhcp/dist/common
Module Name:src Committed By: manu Date: Fri May 15 12:31:04 UTC 2020 Modified Files: src/external/mpl/dhcp/dist/common: bpf.c discover.c lpf.c packet.c raw.c socket.c Log Message: crunchgen fix Make sure local_port is not shared within a crunchgen binary. There is more to do to get full functionnality in crunchgen, but at least this change makes dhcpd listen on the right port again. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/mpl/dhcp/dist/common/bpf.c cvs rdiff -u -r1.2 -r1.3 src/external/mpl/dhcp/dist/common/discover.c \ src/external/mpl/dhcp/dist/common/lpf.c \ src/external/mpl/dhcp/dist/common/packet.c \ src/external/mpl/dhcp/dist/common/raw.c \ src/external/mpl/dhcp/dist/common/socket.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/mpl/dhcp/dist/common/bpf.c diff -u src/external/mpl/dhcp/dist/common/bpf.c:1.3 src/external/mpl/dhcp/dist/common/bpf.c:1.4 --- src/external/mpl/dhcp/dist/common/bpf.c:1.3 Fri Jun 1 00:42:49 2018 +++ src/external/mpl/dhcp/dist/common/bpf.c Fri May 15 12:31:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: bpf.c,v 1.3 2018/06/01 00:42:49 christos Exp $ */ +/* $NetBSD: bpf.c,v 1.4 2020/05/15 12:31:03 manu Exp $ */ /* bpf.c @@ -35,7 +35,7 @@ */ #include -__RCSID("$NetBSD: bpf.c,v 1.3 2018/06/01 00:42:49 christos Exp $"); +__RCSID("$NetBSD: bpf.c,v 1.4 2020/05/15 12:31:03 manu Exp $"); #include "dhcpd.h" #if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE) \ @@ -366,7 +366,7 @@ void if_register_receive (info) dhcp_bpf_relay_filter [10].k = ntohs (relay_port); } #endif - p.bf_insns [8].k = ntohs (local_port); + p.bf_insns [8].k = ntohs (*libdhcp_callbacks.local_port); if (ioctl (info -> rfdesc, BIOCSETF, ) < 0) log_fatal ("Can't install packet filter program: %m"); Index: src/external/mpl/dhcp/dist/common/discover.c diff -u src/external/mpl/dhcp/dist/common/discover.c:1.2 src/external/mpl/dhcp/dist/common/discover.c:1.3 --- src/external/mpl/dhcp/dist/common/discover.c:1.2 Sat Apr 7 22:37:29 2018 +++ src/external/mpl/dhcp/dist/common/discover.c Fri May 15 12:31:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: discover.c,v 1.2 2018/04/07 22:37:29 christos Exp $ */ +/* $NetBSD: discover.c,v 1.3 2020/05/15 12:31:03 manu Exp $ */ /* discover.c @@ -29,7 +29,7 @@ */ #include -__RCSID("$NetBSD: discover.c,v 1.2 2018/04/07 22:37:29 christos Exp $"); +__RCSID("$NetBSD: discover.c,v 1.3 2020/05/15 12:31:03 manu Exp $"); #include "dhcpd.h" @@ -47,8 +47,6 @@ __RCSID("$NetBSD: discover.c,v 1.2 2018/ struct interface_info *interfaces, *dummy_interfaces, *fallback_interface; int interfaces_invalidated; int quiet_interface_discovery; -u_int16_t local_port; -u_int16_t remote_port; u_int16_t relay_port = 0; int dhcpv4_over_dhcpv6 = 0; int (*dhcp_interface_setup_hook) (struct interface_info *, struct iaddr *); Index: src/external/mpl/dhcp/dist/common/lpf.c diff -u src/external/mpl/dhcp/dist/common/lpf.c:1.2 src/external/mpl/dhcp/dist/common/lpf.c:1.3 --- src/external/mpl/dhcp/dist/common/lpf.c:1.2 Sat Apr 7 22:37:29 2018 +++ src/external/mpl/dhcp/dist/common/lpf.c Fri May 15 12:31:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lpf.c,v 1.2 2018/04/07 22:37:29 christos Exp $ */ +/* $NetBSD: lpf.c,v 1.3 2020/05/15 12:31:03 manu Exp $ */ /* lpf.c @@ -29,7 +29,7 @@ */ #include -__RCSID("$NetBSD: lpf.c,v 1.2 2018/04/07 22:37:29 christos Exp $"); +__RCSID("$NetBSD: lpf.c,v 1.3 2020/05/15 12:31:03 manu Exp $"); #include "dhcpd.h" #if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE) @@ -278,7 +278,7 @@ static void lpf_gen_filter_setup (info) dhcp_bpf_relay_filter [10].k = ntohs (relay_port); } #endif - dhcp_bpf_filter [8].k = ntohs (local_port); + dhcp_bpf_filter [8].k = ntohs (*libdhcp_callbacks.local_port); if (setsockopt (info -> rfdesc, SOL_SOCKET, SO_ATTACH_FILTER, , sizeof p) < 0) { Index: src/external/mpl/dhcp/dist/common/packet.c diff -u src/external/mpl/dhcp/dist/common/packet.c:1.2 src/external/mpl/dhcp/dist/common/packet.c:1.3 --- src/external/mpl/dhcp/dist/common/packet.c:1.2 Sat Apr 7 22:37:29 2018 +++ src/external/mpl/dhcp/dist/common/packet.c Fri May 15 12:31:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: packet.c,v 1.2 2018/04/07 22:37:29 christos Exp $ */ +/* $NetBSD: packet.c,v 1.3 2020/05/15 12:31:03 manu Exp $ */ /* packet.c @@ -34,7 +34,7 @@ */ #include -__RCSID("$NetBSD: packet.c,v 1.2 2018/04/07 22:37:29 christos Exp $"); +__RCSID("$NetBSD: packet.c,v 1.3 2020/05/15 12:31:03 manu Exp $"); #include "dhcpd.h" @@ -308,10 +308,10 @@ decode_udp_ip_header(struct interface_in /* Is it to the port we're serving? */ #if defined(RELAY_PORT) - if ((udp.uh_dport != local_port) && + if ((udp.uh_dport != *libdhcp_callbacks.local_port) && ((relay_port == 0) || (udp.uh_dport != relay_port))) #else - if (udp.uh_dport != local_port) + if
CVS commit: src/sys/dev/usb
Module Name:src Committed By: manu Date: Sat Feb 15 02:14:02 UTC 2020 Modified Files: src/sys/dev/usb: u3g.c umodeswitch.c Log Message: Add support for D-Link DWM-157 3G USB modem To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/dev/usb/u3g.c cvs rdiff -u -r1.4 -r1.5 src/sys/dev/usb/umodeswitch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/u3g.c diff -u src/sys/dev/usb/u3g.c:1.39 src/sys/dev/usb/u3g.c:1.40 --- src/sys/dev/usb/u3g.c:1.39 Sat Feb 8 07:53:23 2020 +++ src/sys/dev/usb/u3g.c Sat Feb 15 02:14:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: u3g.c,v 1.39 2020/02/08 07:53:23 maxv Exp $ */ +/* $NetBSD: u3g.c,v 1.40 2020/02/15 02:14:02 manu Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.39 2020/02/08 07:53:23 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: u3g.c,v 1.40 2020/02/15 02:14:02 manu Exp $"); #include #include @@ -255,6 +255,10 @@ static const struct usb_devno u3g_devs[] /* 4G Systems */ { USB_VENDOR_LONGCHEER, USB_PRODUCT_LONGCHEER_XSSTICK_P14 }, { USB_VENDOR_LONGCHEER, USB_PRODUCT_LONGCHEER_XSSTICK_W14 }, + + /* DLink */ + { USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157 }, + { USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157E }, }; /* Index: src/sys/dev/usb/umodeswitch.c diff -u src/sys/dev/usb/umodeswitch.c:1.4 src/sys/dev/usb/umodeswitch.c:1.5 --- src/sys/dev/usb/umodeswitch.c:1.4 Tue Jul 24 08:15:57 2018 +++ src/sys/dev/usb/umodeswitch.c Sat Feb 15 02:14:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: umodeswitch.c,v 1.4 2018/07/24 08:15:57 msaitoh Exp $ */ +/* $NetBSD: umodeswitch.c,v 1.5 2020/02/15 02:14:02 manu Exp $ */ /*- * Copyright (c) 2009, 2017 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: umodeswitch.c,v 1.4 2018/07/24 08:15:57 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umodeswitch.c,v 1.5 2020/02/15 02:14:02 manu Exp $"); #include #include @@ -436,6 +436,17 @@ umodeswitch_match(device_t parent, cfdat return u3g_4gsystems_reinit(uaa->uaa_device); break; + case USB_VENDOR_DLINK: + switch (uaa->uaa_product) { + case USB_PRODUCT_DLINK_DWM157E_CD: + case USB_PRODUCT_DLINK_DWM157_CD: + (void)u3g_bulk_ata_eject(uaa->uaa_device); + (void)u3g_bulk_scsi_eject(uaa->uaa_device); + return UMATCH_HIGHEST; + default: + break; + } + default: break; }
CVS commit: src/sys/dev/usb
Module Name:src Committed By: manu Date: Sat Feb 15 02:10:45 UTC 2020 Modified Files: src/sys/dev/usb: usbdevs.h usbdevs_data.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.765 -r1.766 src/sys/dev/usb/usbdevs.h \ src/sys/dev/usb/usbdevs_data.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbdevs.h diff -u src/sys/dev/usb/usbdevs.h:1.765 src/sys/dev/usb/usbdevs.h:1.766 --- src/sys/dev/usb/usbdevs.h:1.765 Fri Jan 3 12:35:57 2020 +++ src/sys/dev/usb/usbdevs.h Sat Feb 15 02:10:45 2020 @@ -1,10 +1,10 @@ -/* $NetBSD: usbdevs.h,v 1.765 2020/01/03 12:35:57 jmcneill Exp $ */ +/* $NetBSD: usbdevs.h,v 1.766 2020/02/15 02:10:45 manu Exp $ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: usbdevs,v 1.775 2020/01/03 12:35:33 jmcneill Exp + * NetBSD: usbdevs,v 1.776 2020/02/15 02:08:54 manu Exp */ /*- @@ -1430,8 +1430,10 @@ #define USB_PRODUCT_DLINK_DSB650TX3 0x400b /* 10/100 ethernet adapter */ #define USB_PRODUCT_DLINK_DSB650TX2 0x4102 /* 10/100 ethernet adapter */ #define USB_PRODUCT_DLINK_DSB650 0xabc1 /* 10/100 ethernet adapter */ +#define USB_PRODUCT_DLINK_DWM157E_CD 0xa407 /* DWM-157 CD-ROM Mode */ #define USB_PRODUCT_DLINK_DWM157_CD 0xa707 /* DWM-157 CD-ROM Mode */ #define USB_PRODUCT_DLINK_DWM157 0x7d02 /* DWM-157 LTE */ +#define USB_PRODUCT_DLINK_DWM157E 0x7d0e /* DWM-157 LTE */ #define USB_PRODUCT_DLINK_DWM222_CD 0xab00 /* DWM-222 CD-ROM Mode */ #define USB_PRODUCT_DLINK_DWM222 0x7e35 /* DWM-222 LTE */ #define USB_PRODUCT_DLINK_DWR510_CD 0xa805 /* DWR-510 CD-ROM Mode */ Index: src/sys/dev/usb/usbdevs_data.h diff -u src/sys/dev/usb/usbdevs_data.h:1.765 src/sys/dev/usb/usbdevs_data.h:1.766 --- src/sys/dev/usb/usbdevs_data.h:1.765 Fri Jan 3 12:35:57 2020 +++ src/sys/dev/usb/usbdevs_data.h Sat Feb 15 02:10:45 2020 @@ -1,10 +1,10 @@ -/* $NetBSD: usbdevs_data.h,v 1.765 2020/01/03 12:35:57 jmcneill Exp $ */ +/* $NetBSD: usbdevs_data.h,v 1.766 2020/02/15 02:10:45 manu Exp $ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: usbdevs,v 1.775 2020/01/03 12:35:33 jmcneill Exp + * NetBSD: usbdevs,v 1.776 2020/02/15 02:08:54 manu Exp */ /*- @@ -1795,10 +1795,14 @@ static const uint16_t usb_products[] = { 6665, 5138, 4927, 0, USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DSB650, 6665, 5138, 4927, 0, + USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157E_CD, + 9328, 9336, 9343, 0, USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157_CD, 9328, 9336, 9343, 0, USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157, 9328, 9348, 0, + USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM157E, + 9328, 9348, 0, USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM222_CD, 9352, 9336, 9343, 0, USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DWM222, @@ -6214,10 +6218,10 @@ static const char usb_words[] = { "." "B2\0" /* 1 refs @ 9309 */ "DWA-127\0" /* 1 refs @ 9312 */ "DWA-162\0" /* 1 refs @ 9320 */ - "DWM-157\0" /* 2 refs @ 9328 */ - "CD-ROM\0" /* 4 refs @ 9336 */ - "Mode\0" /* 3 refs @ 9343 */ - "LTE\0" /* 3 refs @ 9348 */ + "DWM-157\0" /* 4 refs @ 9328 */ + "CD-ROM\0" /* 5 refs @ 9336 */ + "Mode\0" /* 4 refs @ 9343 */ + "LTE\0" /* 4 refs @ 9348 */ "DWM-222\0" /* 2 refs @ 9352 */ "DWR-510\0" /* 2 refs @ 9360 */ "A1\0" /* 3 refs @ 9368 */
CVS commit: src/sys/dev/usb
Module Name:src Committed By: manu Date: Sat Feb 15 02:08:54 UTC 2020 Modified Files: src/sys/dev/usb: usbdevs Log Message: Add UE version of D-Link DWM-157 To generate a diff of this commit: cvs rdiff -u -r1.775 -r1.776 src/sys/dev/usb/usbdevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbdevs diff -u src/sys/dev/usb/usbdevs:1.775 src/sys/dev/usb/usbdevs:1.776 --- src/sys/dev/usb/usbdevs:1.775 Fri Jan 3 12:35:33 2020 +++ src/sys/dev/usb/usbdevs Sat Feb 15 02:08:54 2020 @@ -1,4 +1,4 @@ -$NetBSD: usbdevs,v 1.775 2020/01/03 12:35:33 jmcneill Exp $ +$NetBSD: usbdevs,v 1.776 2020/02/15 02:08:54 manu Exp $ /*- * Copyright (c) 1998-2004 The NetBSD Foundation, Inc. @@ -1423,8 +1423,10 @@ product DLINK DSB650TX_PNA 0x4003 1/10/1 product DLINK DSB650TX3 0x400b 10/100 ethernet adapter product DLINK DSB650TX2 0x4102 10/100 ethernet adapter product DLINK DSB650 0xabc1 10/100 ethernet adapter +product DLINK DWM157E_CD 0xa407 DWM-157 CD-ROM Mode product DLINK DWM157_CD 0xa707 DWM-157 CD-ROM Mode product DLINK DWM157 0x7d02 DWM-157 LTE +product DLINK DWM157E 0x7d0e DWM-157 LTE product DLINK DWM222_CD 0xab00 DWM-222 CD-ROM Mode product DLINK DWM222 0x7e35 DWM-222 LTE product DLINK DWR510_CD 0xa805 DWR-510 CD-ROM Mode
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: manu Date: Thu Jan 30 01:49:44 UTC 2020 Modified Files: src/sys/arch/x86/x86: multiboot2.c Log Message: Insert memory map with its real size, not the maximum possible. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/x86/x86/multiboot2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/multiboot2.c diff -u src/sys/arch/x86/x86/multiboot2.c:1.3 src/sys/arch/x86/x86/multiboot2.c:1.4 --- src/sys/arch/x86/x86/multiboot2.c:1.3 Tue Dec 10 02:06:07 2019 +++ src/sys/arch/x86/x86/multiboot2.c Thu Jan 30 01:49:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: multiboot2.c,v 1.3 2019/12/10 02:06:07 manu Exp $ */ +/* $NetBSD: multiboot2.c,v 1.4 2020/01/30 01:49:44 manu Exp $ */ /*- * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: multiboot2.c,v 1.3 2019/12/10 02:06:07 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: multiboot2.c,v 1.4 2020/01/30 01:49:44 manu Exp $"); #include "opt_multiboot.h" @@ -565,7 +565,7 @@ mbi_mmap(struct multiboot_tag_mmap *mbt) } bootinfo_add((struct btinfo_common *)bim, BTINFO_MEMMAP, - sizeof(bimbuf)); + (char*)>entry[bim->num] - (char *)bim); return; }
CVS commit: src/sys/arch/x86/x86
Module Name:src Committed By: manu Date: Wed Jan 29 01:54:34 UTC 2020 Modified Files: src/sys/arch/x86/x86: x86_machdep.c Log Message: Fix startup crashes caused by wrong memory map handling init_x86_vm() takes the memory map from BIOS and EFI and selects regions suitable for memory allocation. This involves removing areas used by the kernel, but the logic missed some corner cases, which led to possible allocation in regions for which later memory access would cause a panic. The typical panic from this bug in GENERIC is at SVS startup: cpu_svs_init / uvm_pagealloc_strat / pagezero We fix the bug by adding logic for the missing cases of memory regions overlapping with the kernel. While there, add more #idef'ed debug output. To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/sys/arch/x86/x86/x86_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/x86/x86/x86_machdep.c diff -u src/sys/arch/x86/x86/x86_machdep.c:1.134 src/sys/arch/x86/x86/x86_machdep.c:1.135 --- src/sys/arch/x86/x86/x86_machdep.c:1.134 Sat Dec 28 00:38:08 2019 +++ src/sys/arch/x86/x86/x86_machdep.c Wed Jan 29 01:54:34 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: x86_machdep.c,v 1.134 2019/12/28 00:38:08 pgoyette Exp $ */ +/* $NetBSD: x86_machdep.c,v 1.135 2020/01/29 01:54:34 manu Exp $ */ /*- * Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi, @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.134 2019/12/28 00:38:08 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.135 2020/01/29 01:54:34 manu Exp $"); #include "opt_modular.h" #include "opt_physmem.h" @@ -669,7 +669,7 @@ x86_parse_clusters(struct btinfo_memmap type = bim->entry[x].type; #ifdef DEBUG_MEMLOAD printf("MEMMAP: 0x%016" PRIx64 "-0x%016" PRIx64 - ", size=0x%016" PRIx64 ", type=%d(%s)\n", + "\n\tsize=0x%016" PRIx64 ", type=%d(%s)\n", addr, addr + size - 1, size, type, (type == BIM_Memory) ? "Memory" : (type == BIM_Reserved) ? "Reserved" : @@ -909,27 +909,95 @@ init_x86_vm(paddr_t pa_kend) seg_start1 = 0; seg_end1 = 0; +#ifdef DEBUG_MEMLOAD + printf("segment %" PRIx64 " - %" PRIx64 "\n", + seg_start, seg_end); +#endif + /* Skip memory before our available starting point. */ - if (seg_end <= lowmem_rsvd) + if (seg_end <= lowmem_rsvd) { +#ifdef DEBUG_MEMLOAD + printf("discard segment below starting point " + "%" PRIx64 " - %" PRIx64 "\n", seg_start, seg_end); +#endif continue; + } if (seg_start <= lowmem_rsvd && lowmem_rsvd < seg_end) { seg_start = lowmem_rsvd; - if (seg_start == seg_end) + if (seg_start == seg_end) { +#ifdef DEBUG_MEMLOAD +printf("discard segment below starting point " +"%" PRIx64 " - %" PRIx64 "\n", +seg_start, seg_end); + + +#endif continue; + } } /* * If this segment contains the kernel, split it in two, around * the kernel. + * [seg_start seg_end] + * [pa_kstart pa_kend] */ if (seg_start <= pa_kstart && pa_kend <= seg_end) { +#ifdef DEBUG_MEMLOAD + printf("split kernel overlapping to " + "%" PRIx64 " - %lx and %lx - %" PRIx64 "\n", + seg_start, pa_kstart, pa_kend, seg_end); +#endif seg_start1 = pa_kend; seg_end1 = seg_end; seg_end = pa_kstart; KASSERT(seg_end < seg_end1); } + /* + * Discard a segment inside the kernel + * [pa_kstart pa_kend] + * [seg_start seg_end] + */ + if (pa_kstart < seg_start && seg_end < pa_kend) { +#ifdef DEBUG_MEMLOAD + printf("discard complete kernel overlap " + "%" PRIx64 " - %" PRIx64 "\n", seg_start, seg_end); +#endif + continue; + } + + /* + * Discard leading hunk that overlaps the kernel + * [pa_kstart pa_kend] + *[seg_startseg_end] + */ + if (pa_kstart < seg_start && + seg_start < pa_kend && + pa_kend < seg_end) { +#ifdef DEBUG_MEMLOAD + printf("discard leading kernel overlap " + "%" PRIx64 " - %lx\n", seg_start, pa_kend); +#endif + seg_start = pa_kend; + } + + /* + * Discard trailing hunk that overlaps the kernel + * [pa_kstartpa_kend] + * [seg_start seg_end] + */ + if (seg_start < pa_kstart && + pa_kstart < seg_end && + seg_end < pa_kend) { +#ifdef DEBUG_MEMLOAD + printf("discard trailing kernel overlap " + "%lx - %" PRIx64 "\n", pa_kstart, seg_end); +#endif + seg_end = pa_kstart; + } + /* First hunk */ if (seg_start != seg_end) { x86_load_region(seg_start, seg_end);
CVS commit: src/sys/arch/amd64
Module Name:src Committed By: manu Date: Thu Jan 9 00:42:24 UTC 2020 Modified Files: src/sys/arch/amd64/amd64: locore.S machdep.c src/sys/arch/amd64/conf: GENERIC files.amd64 kern.ldscript Log Message: Rollback multiboot2 for amd64, as requested by core To generate a diff of this commit: cvs rdiff -u -r1.197 -r1.198 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.344 -r1.345 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.553 -r1.554 src/sys/arch/amd64/conf/GENERIC cvs rdiff -u -r1.114 -r1.115 src/sys/arch/amd64/conf/files.amd64 cvs rdiff -u -r1.30 -r1.31 src/sys/arch/amd64/conf/kern.ldscript Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.197 src/sys/arch/amd64/amd64/locore.S:1.198 --- src/sys/arch/amd64/amd64/locore.S:1.197 Wed Jan 8 20:59:18 2020 +++ src/sys/arch/amd64/amd64/locore.S Thu Jan 9 00:42:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.197 2020/01/08 20:59:18 skrll Exp $ */ +/* $NetBSD: locore.S,v 1.198 2020/01/09 00:42:24 manu Exp $ */ /* * Copyright-o-rama! @@ -158,7 +158,6 @@ #include "opt_compat_netbsd.h" #include "opt_compat_netbsd32.h" -#include "opt_multiboot.h" #include "opt_xen.h" #include "opt_svs.h" @@ -178,13 +177,6 @@ #include #include -#ifndef XENPV -#include -#endif - -#define CODE_SEGMENT 0x08 -#define DATA_SEGMENT 0x10 - #if NLAPIC > 0 #include #endif @@ -432,50 +424,6 @@ END(farjmp64) .space 512 tmpstk: -.section multiboot,"a" -#if defined(MULTIBOOT) - .align 8 - .globl Multiboot2_Header -_C_LABEL(Multiboot2_Header): - .int MULTIBOOT2_HEADER_MAGIC - .int MULTIBOOT2_ARCHITECTURE_I386 - .int Multiboot2_Header_end - Multiboot2_Header - .int -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_ARCHITECTURE_I386 \ - + (Multiboot2_Header_end - Multiboot2_Header)) - - .int 1 /* MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST */ - .int 12 /* sizeof(multiboot_header_tag_information_request) */ - /* + sizeof(uint32_t) * requests */ - .int 4 /* MULTIBOOT_TAG_TYPE_BASIC_MEMINFO */ - .align 8 - - .int 3 /* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS */ - .int 16 /* sizeof(struct multiboot_tag_efi64) */ - .quad (multiboot2_entry - KERNBASE) - .align 8 - - .int 9 /* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 */ - .int 16 /* sizeof(struct multiboot_tag_efi64) */ - .quad (multiboot2_entry - KERNBASE) - .align 8 - -#if notyet - /* - * Could be used to get an early console for debug, - * but this is broken. - */ - .int 7 /* MULTIBOOT_HEADER_TAG_EFI_BS */ - .int 8 /* sizeof(struct multiboot_tag) */ - .align 8 -#endif - - .int 0 /* MULTIBOOT_HEADER_TAG_END */ - .int 8 /* sizeof(struct multiboot_tag) */ - .align 8 - .globl Multiboot2_Header_end -_C_LABEL(Multiboot2_Header_end): -#endif /* MULTIBOOT */ - /* * Some hackage to deal with 64bit symbols in 32 bit mode. * This may not be needed if things are cleaned up a little. @@ -492,700 +440,6 @@ ENTRY(start) /* Warm boot */ movw $0x1234,0x472 -#if defined(MULTIBOOT) - jmp .Lnative_loader - - -multiboot2_entry: - .code64 - /* - * multiboot2 entry point. We are left here without - * stack and with no idea of where we were loaded in memory. - * The only inputs are - * %eax MULTIBOOT2_BOOTLOADER_MAGIC - * %ebx pointer to multiboot_info - * - * Here we will: - * - copy the kernel to 0x20 (KERNTEXTOFF - KERNBASE) - * as almost all the code in locore.S assume it is there. - * This is derived from - * src/sys/arch/i386/stand/efiboot/bootx64/startprog64.S - * - copy multiboot_info, as done in multiboot_pre_reloc() from - * src/sys/arch/x86/x86/multiboot2.c - * Unfortunately we cannot call that function as there is - * no simple way to build it as 32 bit code in a 64 bit kernel. - * - Copy ELF symbols, also as in multiboot_pre_reloc() - */ - - cli - - /* - * Discover our load address and use it to get start address - */ - mov $_RELOC(tmpstk),%rsp - call next -next: pop %r8 - sub $(next - start), %r8 - - /* - * Save multiboot_info for later. We cannot use - * temporary stack for that since we are going to - * overwrite it. - */ - movl %ebx, (multiboot2_info_ptr - start)(%r8) - - /* - * Get relocated multiboot2_loader entry point in %r9 - */ - mov $(KERNTEXTOFF - KERNBASE), %r9 - add $(multiboot2_loader - kernel_text), %r9 - - /* Copy kernel */ - mov $(KERNTEXTOFF - KERNBASE), %rdi /* dest */ - mov %r8, %rsi - sub $(start - kernel_text), %rsi /* src */ - mov $(__kernel_end - kernel_text), %rcx /* size */ - mov %rcx, %r12 - movq %rdi, %r11 /* for misaligned check */ - -#if !defined(NO_OVERLAP) - movq %rdi, %r13 - subq %rsi, %r13 -#endif - - shrq $3, %rcx /* count for copy by words */ - jz 8f /* j if less than 8 bytes */ - - lea -8(%rdi, %r12), %r14 /* target address of last 8 */ - mov -8(%rsi, %r12), %r15 /* get last word */ -#if !defined(NO_OVERLAP) - cmpq %r12, %r13 /* overlapping? */ -
CVS commit: src/sys/arch/i386/stand
Module Name:src Committed By: manu Date: Tue Dec 17 01:37:53 UTC 2019 Modified Files: src/sys/arch/i386/stand/efiboot: efidisk.c src/sys/arch/i386/stand/lib: biosdisk.c Log Message: Do not use NAME=label syntax when label are empty When booting sysinst from UEFI, it defaults to a GPT installation where partition have no labels. Bootstrap used the NAME=label partition anyway, with the result that both EFI and FFS root partition had the same name "NAME=" and could not be distinguished. The first matching partition for the name was used, and bootstrap looked for the kernel in the EFI partition. We fix that by not using NAME=label names for partition when label is empty. In that case we revert to old syntax such as hd0b To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/i386/stand/efiboot/efidisk.c cvs rdiff -u -r1.53 -r1.54 src/sys/arch/i386/stand/lib/biosdisk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/efiboot/efidisk.c diff -u src/sys/arch/i386/stand/efiboot/efidisk.c:1.8 src/sys/arch/i386/stand/efiboot/efidisk.c:1.9 --- src/sys/arch/i386/stand/efiboot/efidisk.c:1.8 Sun Aug 18 02:18:24 2019 +++ src/sys/arch/i386/stand/efiboot/efidisk.c Tue Dec 17 01:37:52 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: efidisk.c,v 1.8 2019/08/18 02:18:24 manu Exp $ */ +/* $NetBSD: efidisk.c,v 1.9 2019/12/17 01:37:52 manu Exp $ */ /*- * Copyright (c) 2016 Kimihiro Nonaka @@ -253,7 +253,7 @@ efi_disk_show(void) printf(" "); first = false; } - if (part[i].part_name != NULL) + if (part[i].part_name && part[i].part_name[0]) printf(" NAME=%s(", part[i].part_name); else printf(" hd%d%c(", edi->dev & 0x7f, i + 'a'); @@ -308,7 +308,7 @@ efi_disk_show(void) printf(" "); first = 0; } - if (part[j].part_name != NULL) + if (part[j].part_name && part[j].part_name[0]) printf(" NAME=%s(", part[j].part_name); else printf(" raid%d%c(", Index: src/sys/arch/i386/stand/lib/biosdisk.c diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.53 src/sys/arch/i386/stand/lib/biosdisk.c:1.54 --- src/sys/arch/i386/stand/lib/biosdisk.c:1.53 Tue Dec 10 02:02:47 2019 +++ src/sys/arch/i386/stand/lib/biosdisk.c Tue Dec 17 01:37:53 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: biosdisk.c,v 1.53 2019/12/10 02:02:47 manu Exp $ */ +/* $NetBSD: biosdisk.c,v 1.54 2019/12/17 01:37:53 manu Exp $ */ /* * Copyright (c) 1996, 1998 @@ -908,7 +908,8 @@ biosdisk_probe(void) first = 0; } #ifndef NO_GPT - if (d->part[part].part_name != NULL) + if (d->part[part].part_name && + d->part[part].part_name[0]) printf(" NAME=%s(", d->part[part].part_name); else #endif @@ -987,7 +988,8 @@ next_disk: first = 0; } #ifndef NO_GPT - if (d->part[part].part_name != NULL) + if (d->part[part].part_name && + d->part[part].part_name[0]) printf(" NAME=%s(", d->part[part].part_name); else #endif @@ -1095,7 +1097,9 @@ biosdisk_findpartition(int biosdev, dadd *partition = boot_part; #ifndef NO_GPT - if (part_name && d->part[boot_part].part_name) { + if (part_name && + d->part[boot_part].part_name && + d->part[boot_part].part_name[0]) { strlcpy(namebuf, d->part[boot_part].part_name, BIOSDISK_PART_NAME_LEN); *part_name = namebuf;
CVS commit: src/sys/arch/amd64/amd64
Module Name:src Committed By: manu Date: Sun Dec 15 02:58:22 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S Log Message: Fix typo that caused two instructions to be commented out Oddly, that did not break booting. To generate a diff of this commit: cvs rdiff -u -r1.194 -r1.195 src/sys/arch/amd64/amd64/locore.S Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.194 src/sys/arch/amd64/amd64/locore.S:1.195 --- src/sys/arch/amd64/amd64/locore.S:1.194 Sun Dec 15 02:56:40 2019 +++ src/sys/arch/amd64/amd64/locore.S Sun Dec 15 02:58:21 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.194 2019/12/15 02:56:40 manu Exp $ */ +/* $NetBSD: locore.S,v 1.195 2019/12/15 02:58:21 manu Exp $ */ /* * Copyright-o-rama! @@ -544,7 +544,7 @@ next: pop %r8 mov $(KERNTEXTOFF - KERNBASE), %rdi /* dest */ mov %r8, %rsi sub $(start - kernel_text), %rsi /* src */ - mov $(__kernel_end - kernel_text), %rcx /* size *. + mov $(__kernel_end - kernel_text), %rcx /* size */ mov %rcx, %r12 movq %rdi, %r11 /* for misaligned check */
CVS commit: src/sys/arch/amd64
Module Name:src Committed By: manu Date: Sun Dec 15 02:56:40 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S src/sys/arch/amd64/conf: kern.ldscript Log Message: Restore multiboot 2 header in amd64 kernel The header must appear below 32k offset in the kernel file, but we have to make sure it does not load at low addresses, otherwise we break BIOS boot. .text section used to load at 0x20, we just load multiboot section there, and have .text loaded just after. To generate a diff of this commit: cvs rdiff -u -r1.193 -r1.194 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.29 -r1.30 src/sys/arch/amd64/conf/kern.ldscript Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.193 src/sys/arch/amd64/amd64/locore.S:1.194 --- src/sys/arch/amd64/amd64/locore.S:1.193 Tue Dec 10 02:06:07 2019 +++ src/sys/arch/amd64/amd64/locore.S Sun Dec 15 02:56:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.193 2019/12/10 02:06:07 manu Exp $ */ +/* $NetBSD: locore.S,v 1.194 2019/12/15 02:56:40 manu Exp $ */ /* * Copyright-o-rama! @@ -432,7 +432,7 @@ END(farjmp64) .space 512 tmpstk: -.section multiboot,"ax",@progbits +.section multiboot,"a" #if defined(MULTIBOOT) .align 8 .globl Multiboot2_Header Index: src/sys/arch/amd64/conf/kern.ldscript diff -u src/sys/arch/amd64/conf/kern.ldscript:1.29 src/sys/arch/amd64/conf/kern.ldscript:1.30 --- src/sys/arch/amd64/conf/kern.ldscript:1.29 Wed Dec 11 02:31:44 2019 +++ src/sys/arch/amd64/conf/kern.ldscript Sun Dec 15 02:56:40 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern.ldscript,v 1.29 2019/12/11 02:31:44 manu Exp $ */ +/* $NetBSD: kern.ldscript,v 1.30 2019/12/15 02:56:40 manu Exp $ */ #include "assym.h" @@ -13,7 +13,17 @@ __LARGE_PAGE_SIZE = 0x20 ; ENTRY(_start) SECTIONS { - .text : AT (ADDR(.text) & 0x0fff) + /* + * multiboot (file_offset) : AT (load_address) + * file_offset must be below 32k for multiboot 2 specification + * BIOS boot requires load_address above 0x20 + */ + multiboot 0x1000 : AT (0x20) + { + . = ALIGN(8); + KEEP(*(multiboot)); + } + .text : AT (0x20 + SIZEOF(multiboot)) { . = ALIGN(__PAGE_SIZE); __text_user_start = . ;
CVS commit: src/sys/arch/amd64/conf
Module Name:src Committed By: manu Date: Wed Dec 11 02:31:45 UTC 2019 Modified Files: src/sys/arch/amd64/conf: kern.ldscript Log Message: Rollback kernel link scrpt change for multiboot The multiboot section breaks BIOS boot. Rolling back the link script removes the section, which breaks multiboot but should restore BIOS boot. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/arch/amd64/conf/kern.ldscript Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/conf/kern.ldscript diff -u src/sys/arch/amd64/conf/kern.ldscript:1.28 src/sys/arch/amd64/conf/kern.ldscript:1.29 --- src/sys/arch/amd64/conf/kern.ldscript:1.28 Tue Dec 10 02:06:07 2019 +++ src/sys/arch/amd64/conf/kern.ldscript Wed Dec 11 02:31:44 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: kern.ldscript,v 1.28 2019/12/10 02:06:07 manu Exp $ */ +/* $NetBSD: kern.ldscript,v 1.29 2019/12/11 02:31:44 manu Exp $ */ #include "assym.h" @@ -13,13 +13,9 @@ __LARGE_PAGE_SIZE = 0x20 ; ENTRY(_start) SECTIONS { - multiboot 0x4000 : - { - KEEP(*(multiboot)); - } .text : AT (ADDR(.text) & 0x0fff) { - . = ALIGN(__LARGE_PAGE_SIZE); + . = ALIGN(__PAGE_SIZE); __text_user_start = . ; *(.text.user) . = ALIGN(__PAGE_SIZE);
CVS commit: src/sys/arch
Module Name:src Committed By: manu Date: Tue Dec 10 02:06:07 UTC 2019 Modified Files: src/sys/arch/amd64/amd64: locore.S machdep.c src/sys/arch/amd64/conf: GENERIC files.amd64 kern.ldscript src/sys/arch/x86/x86: efi.c multiboot2.c Log Message: Add multiboot 2 support to amd64 kernel To generate a diff of this commit: cvs rdiff -u -r1.192 -r1.193 src/sys/arch/amd64/amd64/locore.S cvs rdiff -u -r1.342 -r1.343 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.548 -r1.549 src/sys/arch/amd64/conf/GENERIC cvs rdiff -u -r1.113 -r1.114 src/sys/arch/amd64/conf/files.amd64 cvs rdiff -u -r1.27 -r1.28 src/sys/arch/amd64/conf/kern.ldscript cvs rdiff -u -r1.20 -r1.21 src/sys/arch/x86/x86/efi.c cvs rdiff -u -r1.2 -r1.3 src/sys/arch/x86/x86/multiboot2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/amd64/amd64/locore.S diff -u src/sys/arch/amd64/amd64/locore.S:1.192 src/sys/arch/amd64/amd64/locore.S:1.193 --- src/sys/arch/amd64/amd64/locore.S:1.192 Fri Nov 22 23:36:25 2019 +++ src/sys/arch/amd64/amd64/locore.S Tue Dec 10 02:06:07 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.S,v 1.192 2019/11/22 23:36:25 ad Exp $ */ +/* $NetBSD: locore.S,v 1.193 2019/12/10 02:06:07 manu Exp $ */ /* * Copyright-o-rama! @@ -158,6 +158,7 @@ #include "opt_compat_netbsd.h" #include "opt_compat_netbsd32.h" +#include "opt_multiboot.h" #include "opt_xen.h" #include "opt_svs.h" @@ -177,6 +178,13 @@ #include #include +#ifndef XENPV +#include +#endif + +#define CODE_SEGMENT 0x08 +#define DATA_SEGMENT 0x10 + #if NLAPIC > 0 #include #endif @@ -424,6 +432,50 @@ END(farjmp64) .space 512 tmpstk: +.section multiboot,"ax",@progbits +#if defined(MULTIBOOT) + .align 8 + .globl Multiboot2_Header +_C_LABEL(Multiboot2_Header): + .int MULTIBOOT2_HEADER_MAGIC + .int MULTIBOOT2_ARCHITECTURE_I386 + .int Multiboot2_Header_end - Multiboot2_Header + .int -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT2_ARCHITECTURE_I386 \ + + (Multiboot2_Header_end - Multiboot2_Header)) + + .int 1 /* MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST */ + .int 12 /* sizeof(multiboot_header_tag_information_request) */ + /* + sizeof(uint32_t) * requests */ + .int 4 /* MULTIBOOT_TAG_TYPE_BASIC_MEMINFO */ + .align 8 + + .int 3 /* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS */ + .int 16 /* sizeof(struct multiboot_tag_efi64) */ + .quad (multiboot2_entry - KERNBASE) + .align 8 + + .int 9 /* MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 */ + .int 16 /* sizeof(struct multiboot_tag_efi64) */ + .quad (multiboot2_entry - KERNBASE) + .align 8 + +#if notyet + /* + * Could be used to get an early console for debug, + * but this is broken. + */ + .int 7 /* MULTIBOOT_HEADER_TAG_EFI_BS */ + .int 8 /* sizeof(struct multiboot_tag) */ + .align 8 +#endif + + .int 0 /* MULTIBOOT_HEADER_TAG_END */ + .int 8 /* sizeof(struct multiboot_tag) */ + .align 8 + .globl Multiboot2_Header_end +_C_LABEL(Multiboot2_Header_end): +#endif /* MULTIBOOT */ + /* * Some hackage to deal with 64bit symbols in 32 bit mode. * This may not be needed if things are cleaned up a little. @@ -440,6 +492,700 @@ ENTRY(start) /* Warm boot */ movw $0x1234,0x472 +#if defined(MULTIBOOT) + jmp .Lnative_loader + + +multiboot2_entry: + .code64 + /* + * multiboot2 entry point. We are left here without + * stack and with no idea of where we were loaded in memory. + * The only inputs are + * %eax MULTIBOOT2_BOOTLOADER_MAGIC + * %ebx pointer to multiboot_info + * + * Here we will: + * - copy the kernel to 0x20 (KERNTEXTOFF - KERNBASE) + * as almost all the code in locore.S assume it is there. + * This is derived from + * src/sys/arch/i386/stand/efiboot/bootx64/startprog64.S + * - copy multiboot_info, as done in multiboot_pre_reloc() from + * src/sys/arch/x86/x86/multiboot2.c + * Unfortunately we cannot call that function as there is + * no simple way to build it as 32 bit code in a 64 bit kernel. + * - Copy ELF symbols, also as in multiboot_pre_reloc() + */ + + cli + + /* + * Discover our load address and use it to get start address + */ + mov $_RELOC(tmpstk),%rsp + call next +next: pop %r8 + sub $(next - start), %r8 + + /* + * Save multiboot_info for later. We cannot use + * temporary stack for that since we are going to + * overwrite it. + */ + movl %ebx, (multiboot2_info_ptr - start)(%r8) + + /* + * Get relocated multiboot2_loader entry point in %r9 + */ + mov $(KERNTEXTOFF - KERNBASE), %r9 + add $(multiboot2_loader - kernel_text), %r9 + + /* Copy kernel */ + mov $(KERNTEXTOFF - KERNBASE), %rdi /* dest */ + mov %r8, %rsi + sub $(start - kernel_text), %rsi /* src */ + mov $(__kernel_end - kernel_text), %rcx /* size *. + mov %rcx, %r12 + movq %rdi, %r11 /* for misaligned check */ + +#if !defined(NO_OVERLAP) + movq %rdi, %r13 + subq %rsi, %r13 +#endif + + shrq $3, %rcx /* count for copy by words */ + jz 8f /* j if less than 8 bytes */ + + lea
CVS commit: src/sys/arch/i386/stand
Module Name:src Committed By: manu Date: Tue Dec 10 02:02:48 UTC 2019 Modified Files: src/sys/arch/i386/stand/boot: devopen.c src/sys/arch/i386/stand/efiboot: devopen.c src/sys/arch/i386/stand/lib: biosdisk.c Log Message: In-RAID partitions with no name can be candidate for booting The code to select boot partition in RAID assumed thet had a name, which is true when there is a GPT inside the RAID, but not when there is a disklabel inside the RAID. This caused a regression from behavior of NetBSD 8.1. We fix this by allowing nameless partition to be boot candidates. This fixes misc/54748 While there, let raid device be used in the boot specification, like raid0a:/netbsd. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/boot/devopen.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/i386/stand/efiboot/devopen.c cvs rdiff -u -r1.52 -r1.53 src/sys/arch/i386/stand/lib/biosdisk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/i386/stand/boot/devopen.c diff -u src/sys/arch/i386/stand/boot/devopen.c:1.9 src/sys/arch/i386/stand/boot/devopen.c:1.10 --- src/sys/arch/i386/stand/boot/devopen.c:1.9 Sun Aug 18 02:18:24 2019 +++ src/sys/arch/i386/stand/boot/devopen.c Tue Dec 10 02:02:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: devopen.c,v 1.9 2019/08/18 02:18:24 manu Exp $ */ +/* $NetBSD: devopen.c,v 1.10 2019/12/10 02:02:47 manu Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ devopen(struct open_file *f, const char if (strstr(devname, "raid") == devname) { f->f_dev = [0]; /* must be biosdisk */ - return biosdisk_open_name(f, devname); + return biosdisk_open_name(f, fname); } #endif Index: src/sys/arch/i386/stand/efiboot/devopen.c diff -u src/sys/arch/i386/stand/efiboot/devopen.c:1.8 src/sys/arch/i386/stand/efiboot/devopen.c:1.9 --- src/sys/arch/i386/stand/efiboot/devopen.c:1.8 Thu Sep 26 12:21:03 2019 +++ src/sys/arch/i386/stand/efiboot/devopen.c Tue Dec 10 02:02:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: devopen.c,v 1.8 2019/09/26 12:21:03 nonaka Exp $ */ +/* $NetBSD: devopen.c,v 1.9 2019/12/10 02:02:47 manu Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -151,6 +151,7 @@ int devopen(struct open_file *f, const char *fname, char **file) { char *fsname, *devname; + const char *xname = NULL; int unit, partition; int biosdev; int i, error; @@ -172,8 +173,12 @@ devopen(struct open_file *f, const char nfsys = nfsys_disk; /* Search by GPT label or raidframe name */ - if ((strstr(devname, "NAME=") == devname) || - (strstr(devname, "raid") == devname)) { + if (strstr(devname, "NAME=") == devname) + xname = devname; + if (strstr(devname, "raid") == devname) + xname = fname; + + if (xname != NULL) { f->f_dev = [0]; /* must be biosdisk */ if (!kernel_loaded) { @@ -181,7 +186,7 @@ devopen(struct open_file *f, const char BI_ADD(, BTINFO_BOOTPATH, sizeof(bibp)); } - error = biosdisk_open_name(f, devname); + error = biosdisk_open_name(f, xname); return error; } Index: src/sys/arch/i386/stand/lib/biosdisk.c diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.52 src/sys/arch/i386/stand/lib/biosdisk.c:1.53 --- src/sys/arch/i386/stand/lib/biosdisk.c:1.52 Fri Sep 13 02:19:46 2019 +++ src/sys/arch/i386/stand/lib/biosdisk.c Tue Dec 10 02:02:47 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: biosdisk.c,v 1.52 2019/09/13 02:19:46 manu Exp $ */ +/* $NetBSD: biosdisk.c,v 1.53 2019/12/10 02:02:47 manu Exp $ */ /* * Copyright (c) 1996, 1998 @@ -1401,9 +1401,9 @@ next_disk: continue; if (d->part[part].fstype == FS_UNUSED) continue; - if (d->part[part].part_name == NULL) -continue; - if (strcmp(d->part[part].part_name, name) == 0) { + + if (d->part[part].part_name != NULL && + strcmp(d->part[part].part_name, name) == 0) { *biosdev = raidframe[i].biosdev; *offset = raidframe[i].offset + RF_PROTECTED_SECTORS
CVS commit: src/sbin
Module Name:src Committed By: manu Date: Mon Mar 25 02:13:01 UTC 2019 Modified Files: src/sbin/dump: dump.8 dump.h itime.c main.c src/sbin/dump_lfs: dump_lfs.8 Log Message: Add -U flag to dump(8) and dump_lfs(8) to specify dumpdates entry This address situations where dump(8) cannot figure out the device being dumped. It also allows tracking of subvolume dumps by using virtual device as dumpdates entry. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/sbin/dump/dump.8 cvs rdiff -u -r1.56 -r1.57 src/sbin/dump/dump.h cvs rdiff -u -r1.21 -r1.22 src/sbin/dump/itime.c cvs rdiff -u -r1.74 -r1.75 src/sbin/dump/main.c cvs rdiff -u -r1.17 -r1.18 src/sbin/dump_lfs/dump_lfs.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/dump/dump.8 diff -u src/sbin/dump/dump.8:1.69 src/sbin/dump/dump.8:1.70 --- src/sbin/dump/dump.8:1.69 Sun Jul 15 06:14:13 2018 +++ src/sbin/dump/dump.8 Mon Mar 25 02:13:01 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: dump.8,v 1.69 2018/07/15 06:14:13 dholland Exp $ +.\" $NetBSD: dump.8,v 1.70 2019/03/25 02:13:01 manu Exp $ .\" .\" Copyright (c) 1980, 1991, 1993 .\" Regents of the University of California. @@ -51,6 +51,7 @@ .Op Fl r Ar cachesize .Op Fl s Ar feet .Op Fl T Ar date +.Op Fl U Ar dumpdev .Op Fl x Ar snap-backup .Ar files-to-dump .Nm @@ -299,10 +300,22 @@ The file .Pa /etc/dumpdates may be edited to change any of the fields, if necessary. -If a list of files or subdirectories is being dumped +If the +.Fl T +option is used or if a list of files or subdirectories is being dumped (as opposed to an entire file system), then .Fl u is ignored. +.It Fl U Ar dumpdev +Same as +.Fl u +but specifies the device in +.Pa /etc/dumpdates +as +.Ar dumpdev . +This option can be used with subdir dumps and with the +.Fl T +option. .It Fl W .Nm tells the operator what file systems need to be dumped. Index: src/sbin/dump/dump.h diff -u src/sbin/dump/dump.h:1.56 src/sbin/dump/dump.h:1.57 --- src/sbin/dump/dump.h:1.56 Fri Mar 1 16:42:11 2019 +++ src/sbin/dump/dump.h Mon Mar 25 02:13:01 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dump.h,v 1.56 2019/03/01 16:42:11 christos Exp $ */ +/* $NetBSD: dump.h,v 1.57 2019/03/25 02:13:01 manu Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -115,6 +115,7 @@ const char *temp; /* name of the file fo char lastlevel; /* dump level of previous dump */ char level; /* dump level of this dump */ int uflag; /* update flag */ +const char *dumpdev; /* device name in dumpdates */ int eflag; /* eject flag */ int lflag; /* autoload flag */ int diskfd; /* disk file descriptor */ Index: src/sbin/dump/itime.c diff -u src/sbin/dump/itime.c:1.21 src/sbin/dump/itime.c:1.22 --- src/sbin/dump/itime.c:1.21 Fri Mar 1 16:42:11 2019 +++ src/sbin/dump/itime.c Mon Mar 25 02:13:01 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: itime.c,v 1.21 2019/03/01 16:42:11 christos Exp $ */ +/* $NetBSD: itime.c,v 1.22 2019/03/25 02:13:01 manu Exp $ */ /*- * Copyright (c) 1980, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)itime.c 8.1 (Berkeley) 6/5/93"; #else -__RCSID("$NetBSD: itime.c,v 1.21 2019/03/01 16:42:11 christos Exp $"); +__RCSID("$NetBSD: itime.c,v 1.22 2019/03/25 02:13:01 manu Exp $"); #endif #endif /* not lint */ @@ -129,9 +129,9 @@ getdumptime(void) { struct dumpdates *ddp; int i; - char *fname; + const char *fname; - fname = disk; + fname = dumpdev ? dumpdev : disk; #ifdef FDEBUG msg("Looking for name %s in dumpdates = %s for level = %c\n", fname, dumpdates, level); @@ -170,15 +170,15 @@ putdumptime(void) struct dumpdates *dtwalk, *dtfound; int i; int fd; - char *fname; + const char *fname; - if(uflag == 0) + if (uflag == 0 && dumpdev == NULL) return; if ((df = fopen(dumpdates, "r+")) == NULL) quite(errno, "cannot rewrite %s", dumpdates); fd = fileno(df); (void) flock(fd, LOCK_EX); - fname = disk; + fname = dumpdev ? dumpdev : disk; free((char *)ddatev); ddatev = 0; nddates = 0; Index: src/sbin/dump/main.c diff -u src/sbin/dump/main.c:1.74 src/sbin/dump/main.c:1.75 --- src/sbin/dump/main.c:1.74 Fri Mar 1 16:42:11 2019 +++ src/sbin/dump/main.c Mon Mar 25 02:13:01 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.74 2019/03/01 16:42:11 christos Exp $ */ +/* $NetBSD: main.c,v 1.75 2019/03/25 02:13:01 manu Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/1/95"; #else -__RCSID("$NetBSD: main.c,v 1.74 2019/03/01 16:42:11 christos Exp $"); +__RCSID("$NetBSD: main.c,v 1.75 2019/03/25 02:13:01 manu Exp $"); #endif #endif /* not lint */ @@ -133,7 +133,7 @@ main(int argc, char *argv[]) obsolete(, ); while ((ch = getopt(argc, argv, - "0123456789aB:b:cd:eFf:h:ik:l:L:nr:s:StT:uWwx:X")) != -1) + "0123456789aB:b:cd:eFf:h:ik:l:L:nr:s:StT:uU:Wwx:X")) != -1) switch
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Sat Feb 9 02:22:45 UTC 2019 Modified Files: src/lib/libperfuse: ops.c Log Message: Fix directory filehandle usage with libufse. Fix lookup count libfuse does not use filehandle the same way for directories and other objects. As a result, filehandles obtained by OPENDIR should not be sent on non-directory related operations like READ/WRITE/GETATTR... While there, fix the lookup count sent to the FORGET operation, which led to leaked nodes. To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.85 src/lib/libperfuse/ops.c:1.86 --- src/lib/libperfuse/ops.c:1.85 Fri Nov 16 02:39:02 2018 +++ src/lib/libperfuse/ops.c Sat Feb 9 02:22:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.85 2018/11/16 02:39:02 manu Exp $ */ +/* $NetBSD: ops.c,v 1.86 2019/02/09 02:22:45 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -105,6 +105,9 @@ const int vttoif_tab[9] = { #define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12]) #define VTTOIF(indx) (vttoif_tab[(int)(indx)]) +#define PN_ISDIR(opc) \ + (puffs_pn_getvap((struct puffs_node *)opc)->va_type == VDIR) + #if 0 static void print_node(const char *func, puffs_cookie_t opc) @@ -141,7 +144,7 @@ perfuse_node_close_common(struct puffs_u pn = (struct puffs_node *)opc; pnd = PERFUSE_NODE_DATA(pn); - if (puffs_pn_getvap(pn)->va_type == VDIR) { + if (PN_ISDIR(opc)) { op = FUSE_RELEASEDIR; mode = FREAD; } else { @@ -479,13 +482,14 @@ node_lookup_common(struct puffs_usermoun fuse_attr_to_vap(ps, >pn_va, >attr); pn->pn_va.va_gen = (u_long)(feo->generation); PERFUSE_NODE_DATA(pn)->pnd_fuse_nlookup++; + PERFUSE_NODE_DATA(pn)->pnd_puffs_nlookup++; *pnp = pn; #ifdef PERFUSE_DEBUG if (perfuse_diagflags & PDF_FILENAME) DPRINTF("%s: opc = %p, looked up opc = %p, " - "nodeid = 0x%"PRIx64" file = \"%s\"\n", __func__, + "nodeid = 0x%"PRIx64" file = \"%s\"\n", __func__, (void *)opc, pn, feo->nodeid, path); #endif @@ -533,6 +537,7 @@ node_mk_common(struct puffs_usermount *p pn = perfuse_new_pn(pu, pcn->pcn_name, opc); PERFUSE_NODE_DATA(pn)->pnd_nodeid = feo->nodeid; + PERFUSE_NODE_DATA(pn)->pnd_fuse_nlookup++; PERFUSE_NODE_DATA(pn)->pnd_puffs_nlookup++; perfuse_node_cache(ps, pn); @@ -1138,6 +1143,7 @@ perfuse_node_lookup(struct puffs_usermou break; } + PERFUSE_NODE_DATA(pn)->pnd_fuse_nlookup++; PERFUSE_NODE_DATA(pn)->pnd_puffs_nlookup++; error = 0; @@ -1247,6 +1253,7 @@ perfuse_node_create(struct puffs_usermou pn = perfuse_new_pn(pu, name, opc); perfuse_new_fh((puffs_cookie_t)pn, foo->fh, FWRITE); PERFUSE_NODE_DATA(pn)->pnd_nodeid = feo->nodeid; + PERFUSE_NODE_DATA(pn)->pnd_fuse_nlookup++; PERFUSE_NODE_DATA(pn)->pnd_puffs_nlookup++; perfuse_node_cache(ps, pn); @@ -1355,11 +1362,9 @@ perfuse_node_open2(struct puffs_usermoun int op; struct fuse_open_in *foi; struct fuse_open_out *foo; - struct puffs_node *pn; int error; ps = puffs_getspecific(pu); - pn = (struct puffs_node *)opc; pnd = PERFUSE_NODE_DATA(opc); error = 0; @@ -1368,7 +1373,7 @@ perfuse_node_open2(struct puffs_usermoun node_ref(opc); - if (puffs_pn_getvap(pn)->va_type == VDIR) + if (PN_ISDIR(opc)) op = FUSE_OPENDIR; else op = FUSE_OPEN; @@ -1592,9 +1597,9 @@ perfuse_node_getattr_ttl(struct puffs_us fgi = GET_INPAYLOAD(ps, pm, fuse_getattr_in); fgi->getattr_flags = 0; fgi->dummy = 0; - fgi->fh = 0; + fgi->fh = FUSE_UNKNOWN_FH; - if (PERFUSE_NODE_DATA(opc)->pnd_flags & PND_OPEN) { + if (!PN_ISDIR(opc) && PERFUSE_NODE_DATA(opc)->pnd_flags & PND_OPEN) { fgi->fh = perfuse_get_fh(opc, FREAD); fgi->getattr_flags |= FUSE_GETATTR_FH; } @@ -1728,7 +1733,7 @@ perfuse_node_setattr_ttl(struct puffs_us node_ref(opc); - if (pnd->pnd_flags & PND_WFH) + if (!PN_ISDIR(opc) && pnd->pnd_flags & PND_WFH) fh = perfuse_get_fh(opc, FWRITE); else fh = FUSE_UNKNOWN_FH; @@ -1954,7 +1959,7 @@ perfuse_node_poll(struct puffs_usermount */ pm = ps->ps_new_msg(pu, opc, FUSE_POLL, sizeof(*fpi), NULL); fpi = GET_INPAYLOAD(ps, pm, fuse_poll_in); - fpi->fh = perfuse_get_fh(opc, FREAD); + fpi->fh = PN_ISDIR(opc) ? FUSE_UNKNOWN_FH : perfuse_get_fh(opc, FREAD); fpi->kh = 0; fpi->flags = 0; @@ -2010,7 +2015,7 @@ perfuse_node_fsync(struct puffs_usermoun node_ref(opc); - if (puffs_pn_getvap((struct puffs_node *)opc)->va_type == VDIR) + if (PN_ISDIR(opc)) op = FUSE_FSYNCDIR; else /* VREG but also other types such as VLNK */
CVS commit: src/sys/kern
Module Name:src Committed By: manu Date: Thu Jan 31 02:27:06 UTC 2019 Modified Files: src/sys/kern: vfs_syscalls.c Log Message: Do not resolve fdat for openat(2) if path is absolute Opengroup says "The openat() function shall be equivalent to the open() function except in the case where path specifies a relative path", but says nothing about fdat usage when path is absolute; https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html We used to always reslove fdat, leading to error if it was invalid (e.g.: -1). That caused portability problem with other systems that just ignore it. See discussion in a pull request to work around that problem with MariaDB: https://github.com/MariaDB/server/pull/838 We fix the problem by ignoring fdat when path is absolute. To generate a diff of this commit: cvs rdiff -u -r1.520 -r1.521 src/sys/kern/vfs_syscalls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_syscalls.c diff -u src/sys/kern/vfs_syscalls.c:1.520 src/sys/kern/vfs_syscalls.c:1.521 --- src/sys/kern/vfs_syscalls.c:1.520 Tue Jan 29 09:28:50 2019 +++ src/sys/kern/vfs_syscalls.c Thu Jan 31 02:27:06 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls.c,v 1.520 2019/01/29 09:28:50 pgoyette Exp $ */ +/* $NetBSD: vfs_syscalls.c,v 1.521 2019/01/31 02:27:06 manu Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.520 2019/01/29 09:28:50 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.521 2019/01/31 02:27:06 manu Exp $"); #ifdef _KERNEL_OPT #include "opt_fileassoc.h" @@ -1631,6 +1631,7 @@ do_sys_openat(lwp_t *l, int fdat, const file_t *dfp = NULL; struct vnode *dvp = NULL; struct pathbuf *pb; + const char *pathstring = NULL; int error; if (path == NULL) { @@ -1643,7 +1644,14 @@ do_sys_openat(lwp_t *l, int fdat, const return error; } - if (fdat != AT_FDCWD) { + pathstring = pathbuf_stringcopy_get(pb); + + /* + * fdat is ignored if: + * 1) if fdat is AT_FDCWD, which means use current directory as base. + * 2) if path is absolute, then fdat is useless. + */ + if (fdat != AT_FDCWD && pathstring[0] != '/') { /* fd_getvnode() will use the descriptor for us */ if ((error = fd_getvnode(fdat, )) != 0) goto out; @@ -1656,6 +1664,7 @@ do_sys_openat(lwp_t *l, int fdat, const if (dfp != NULL) fd_putfile(fdat); out: + pathbuf_stringcopy_put(pb, pathstring); pathbuf_destroy(pb); return error; }
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Fri Nov 16 02:39:02 UTC 2018 Modified Files: src/lib/libperfuse: debug.c ops.c perfuse.c perfuse_priv.h Log Message: Use reclaim2 to fix reclaim/lookup race conditions The PUFFS reclaim operation had a race condition with lookups: we could be asked to lookup a node, then to reclaim it before lookup completion. At lookup completion, we would then create a leaked node. Enter the PUFFS reclaim2 operation, which features a nlookup argument. That let us count how many lookups are pending and avoid the above described scenario. It also makes the codes simplier. To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/lib/libperfuse/debug.c cvs rdiff -u -r1.84 -r1.85 src/lib/libperfuse/ops.c cvs rdiff -u -r1.40 -r1.41 src/lib/libperfuse/perfuse.c cvs rdiff -u -r1.36 -r1.37 src/lib/libperfuse/perfuse_priv.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/debug.c diff -u src/lib/libperfuse/debug.c:1.12 src/lib/libperfuse/debug.c:1.13 --- src/lib/libperfuse/debug.c:1.12 Sat Jul 21 05:49:42 2012 +++ src/lib/libperfuse/debug.c Fri Nov 16 02:39:02 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.12 2012/07/21 05:49:42 manu Exp $ */ +/* $NetBSD: debug.c,v 1.13 2018/11/16 02:39:02 manu Exp $ */ /*- * Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved. @@ -270,7 +270,6 @@ perfuse_trace_dump(struct puffs_usermoun fprintf(fp, "\n\nGlobal statistics\n"); fprintf(fp, "Nodes: %d\n", ps->ps_nodecount); fprintf(fp, "Exchanges: %d\n", ps->ps_xchgcount); - fprintf(fp, "Nodes possibly leaked: %d\n", ps->ps_nodeleakcount); (void)fflush(fp); return; Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.84 src/lib/libperfuse/ops.c:1.85 --- src/lib/libperfuse/ops.c:1.84 Wed Jun 3 14:07:05 2015 +++ src/lib/libperfuse/ops.c Fri Nov 16 02:39:02 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.84 2015/06/03 14:07:05 manu Exp $ */ +/* $NetBSD: ops.c,v 1.85 2018/11/16 02:39:02 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -500,11 +500,6 @@ node_lookup_common(struct puffs_usermoun puffs_newinfo_setrdev(pni, pn->pn_va.va_rdev); } - if (PERFUSE_NODE_DATA(pn)->pnd_flags & PND_NODELEAK) { - PERFUSE_NODE_DATA(pn)->pnd_flags &= ~PND_NODELEAK; - ps->ps_nodeleakcount--; - } - ps->ps_destroy_msg(pm); return 0; @@ -672,7 +667,7 @@ fuse_to_dirent(struct puffs_usermount *p "failed: %d", name, error); } else { fd->ino = pn->pn_va.va_fileid; - (void)perfuse_node_reclaim(pu, pn); + (void)perfuse_node_reclaim2(pu, pn, 1); } } } @@ -1135,7 +1130,7 @@ perfuse_node_lookup(struct puffs_usermou case NAMEI_RENAME: error = sticky_access(opc, pn, pcn->pcn_cred); if (error != 0) { - (void)perfuse_node_reclaim(pu, pn); + (void)perfuse_node_reclaim2(pu, pn, 1); goto out; } break; @@ -1182,7 +1177,7 @@ perfuse_node_create(struct puffs_usermou error = node_lookup_common(pu, opc, NULL, pcn->pcn_name, pcn->pcn_cred, ); if (error == 0) { - (void)perfuse_node_reclaim(pu, pn); + (void)perfuse_node_reclaim2(pu, pn, 1); error = EEXIST; goto out; } @@ -2682,17 +2677,22 @@ out: } int -perfuse_node_reclaim(struct puffs_usermount *pu, puffs_cookie_t opc) +perfuse_node_reclaim2(struct puffs_usermount *pu, + puffs_cookie_t opc, int nlookup) { struct perfuse_state *ps; perfuse_msg_t *pm; struct perfuse_node_data *pnd; struct fuse_forget_in *ffi; - int nlookup; - struct timespec now; - if (opc == 0) +#ifdef PERFUSE_DEBUG + if (perfuse_diagflags & PDF_RECLAIM) + DPRINTF("%s called with opc = %p, nlookup = %d\n", +__func__, (void *)opc, nlookup); +#endif + if (opc == 0 || nlookup == 0) { return 0; + } ps = puffs_getspecific(pu); pnd = PERFUSE_NODE_DATA(opc); @@ -2703,43 +2703,23 @@ perfuse_node_reclaim(struct puffs_usermo if (pnd->pnd_nodeid == FUSE_ROOT_ID) return 0; +#ifdef PERFUSE_DEBUG + if (perfuse_diagflags & PDF_RECLAIM) + DPRINTF("%s (nodeid %"PRId64") reclaimed, nlookup = %d/%d\n", + perfuse_node_path(ps, opc), pnd->pnd_nodeid, + nlookup, pnd->pnd_puffs_nlookup); +#endif /* - * There is a race condition between reclaim and lookup. - * When looking up an already known node, the kernel cannot - * hold a reference on the result until it gets the PUFFS - * reply. It mayy therefore reclaim the node after the - * userland looked it up, and before it gets the reply. - * On rely, the kernel re-creates the node, but at that - * time the node has been reclaimed in userland. - * - * In order to avoid this, we refuse reclaiming nodes that - * are too young since the last lookup - and tha
CVS commit: src/sys/dev/usb
Module Name:src Committed By: manu Date: Fri Nov 16 00:34:51 UTC 2018 Modified Files: src/sys/dev/usb: usbdi.c Log Message: Build fix >From David H. Gutteridge To generate a diff of this commit: cvs rdiff -u -r1.179 -r1.180 src/sys/dev/usb/usbdi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbdi.c diff -u src/sys/dev/usb/usbdi.c:1.179 src/sys/dev/usb/usbdi.c:1.180 --- src/sys/dev/usb/usbdi.c:1.179 Thu Nov 15 02:35:23 2018 +++ src/sys/dev/usb/usbdi.c Fri Nov 16 00:34:50 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.c,v 1.179 2018/11/15 02:35:23 manu Exp $ */ +/* $NetBSD: usbdi.c,v 1.180 2018/11/16 00:34:50 manu Exp $ */ /* * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.179 2018/11/15 02:35:23 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.180 2018/11/16 00:34:50 manu Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -924,7 +924,7 @@ usb_transfer_complete(struct usbd_xfer * !usbd_xfer_isread(xfer)) { USBHIST_LOG(usbdebug, "Possible output ack miss for xfer %#jx: " "hiding write timeout to %d.%s for %d bytes written", - xfer, curlwp->l_proc->p_pid, curlwp->l_lid, + (uintptr_t)xfer, curlwp->l_proc->p_pid, curlwp->l_lid, xfer->ux_length); xfer->ux_status = USBD_NORMAL_COMPLETION;
CVS commit: src/sys/dev/usb
Module Name:src Committed By: manu Date: Thu Nov 15 02:35:23 UTC 2018 Modified Files: src/sys/dev/usb: usb_quirks.c usb_quirks.h usbdi.c Log Message: Workaround NBP PN533 USB toggle bit bugs The PN533 is known to mishandle the USB toggle bit, causing replies to be filtered out by the host controller. As a result, the kernel sees a timed out operation. Vendor errata suggests that userland applications should detect the situation on read timeout, and write a dumy frame to resync the toggle bit. NFC Tools's libnfc does just that, but in order to succeed, the dummy frame write must not be reported as timed out. We therefore introduce a new USB quirk for devices known to miss output acks. When that occur, we pretend that the operation succeeded, leaving userland the duty to check that everything went okay. This workaround lets libnfc recover from interrupted communications without the need te reboot the system. To generate a diff of this commit: cvs rdiff -u -r1.89 -r1.90 src/sys/dev/usb/usb_quirks.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/usb/usb_quirks.h cvs rdiff -u -r1.178 -r1.179 src/sys/dev/usb/usbdi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usb_quirks.c diff -u src/sys/dev/usb/usb_quirks.c:1.89 src/sys/dev/usb/usb_quirks.c:1.90 --- src/sys/dev/usb/usb_quirks.c:1.89 Thu Nov 8 09:00:24 2018 +++ src/sys/dev/usb/usb_quirks.c Thu Nov 15 02:35:23 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_quirks.c,v 1.89 2018/11/08 09:00:24 martin Exp $ */ +/* $NetBSD: usb_quirks.c,v 1.90 2018/11/15 02:35:23 manu Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.30 2003/01/02 04:15:55 imp Exp $ */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.89 2018/11/08 09:00:24 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.90 2018/11/15 02:35:23 manu Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -310,13 +310,24 @@ Static const struct usbd_quirk_entry { { USB_VENDOR_ZOOM, USB_PRODUCT_ZOOM_3095, ANY, { UQ_LOST_CS_DESC, NULL }}, - /* NXP PN533 corrupts its USB configuration descriptors */ + /* + * NXP PN533 bugs + * + * 1. It corrupts its USB descriptors. The quirk is to provide hardcoded + *descriptors instead of getting them from the device. + * 2. It mishandles the USB toggle bit. This causes some replies to be + *filered out by the USB host controller and be reported as timed out. + *NFC tool's libnfc workaround this bug by sending a dummy frame to + *resync the toggle bit, but in order to succeed, that operation must + *not be reported as failed. The quirk is therefore to pretend to + *userland that output timeouts are successes. + */ { USB_VENDOR_PHILIPSSEMI, USB_PRODUCT_PHILIPSSEMI_PN533, ANY, - { UQ_DESC_CORRUPT, desc_pn533 }}, + { UQ_DESC_CORRUPT | UQ_MISS_OUT_ACK, desc_pn533 }}, { USB_VENDOR_SHUTTLE, USB_PRODUCT_SHUTTLE_SCL3711, ANY, - { UQ_DESC_CORRUPT, desc_pn533 }}, + { UQ_DESC_CORRUPT | UQ_MISS_OUT_ACK, desc_pn533 }}, { USB_VENDOR_SHUTTLE, USB_PRODUCT_SHUTTLE_SCL3712, ANY, - { UQ_DESC_CORRUPT, desc_pn533 }}, + { UQ_DESC_CORRUPT | UQ_MISS_OUT_ACK, desc_pn533 }}, { 0, 0, 0, { 0, NULL } } }; Index: src/sys/dev/usb/usb_quirks.h diff -u src/sys/dev/usb/usb_quirks.h:1.28 src/sys/dev/usb/usb_quirks.h:1.29 --- src/sys/dev/usb/usb_quirks.h:1.28 Thu Nov 8 02:11:54 2018 +++ src/sys/dev/usb/usb_quirks.h Thu Nov 15 02:35:23 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_quirks.h,v 1.28 2018/11/08 02:11:54 manu Exp $ */ +/* $NetBSD: usb_quirks.h,v 1.29 2018/11/15 02:35:23 manu Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_quirks.h,v 1.9 1999/11/12 23:31:03 n_hibma Exp $ */ /* @@ -50,6 +50,7 @@ struct usbd_quirks { #define UQ_LOST_CS_DESC 0x1 /* look everywhere for the CS descriptors */ #define UQ_APPLE_ISO 0x2 /* force ISO layout on Apple keyboards */ #define UQ_DESC_CORRUPT 0x4 /* may corrupt its config descriptors */ +#define UQ_MISS_OUT_ACK 0x8 /* may fail to ack output */ const usb_descriptor_t **desc; /* Replacement for UQ_DESC_CORRUPT */ }; Index: src/sys/dev/usb/usbdi.c diff -u src/sys/dev/usb/usbdi.c:1.178 src/sys/dev/usb/usbdi.c:1.179 --- src/sys/dev/usb/usbdi.c:1.178 Sun Sep 16 20:21:56 2018 +++ src/sys/dev/usb/usbdi.c Thu Nov 15 02:35:23 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: usbdi.c,v 1.178 2018/09/16 20:21:56 mrg Exp $ */ +/* $NetBSD: usbdi.c,v 1.179 2018/11/15 02:35:23 manu Exp $ */ /* * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.178 2018/09/16 20:21:56 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.179 2018/11/15 02:35:23 manu Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -898,9 +898,7 @@ usb_transfer_complete(struct usbd_xfer * struct usbd_pipe *pipe = xfer->ux_pipe; struct usbd_bus *bus = pipe->up_dev->ud_bus; int sync =
CVS commit: src/sys/dev/usb
Module Name:src Committed By: manu Date: Thu Nov 8 02:11:54 UTC 2018 Modified Files: src/sys/dev/usb: usb_quirks.c usb_quirks.h usbdi_util.c usbdi_util.h Log Message: Workaround PN533 USB descriptor corruption During normal operation, the PN533 chip may corrupt its USB configuration, interface and endpoint descriptors. The device descriptor remains unaffected. Since the descriptors are documented to be immutable, we can work around the problem by providing hard-coded descriptors instead of pulling them from the device. Userland implementation such as NFC tools' libnfc use the same approach, but this kernel quirk is still necessary so that the device can be attached on reboot, after its USB descriptors got corrupted. To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/sys/dev/usb/usb_quirks.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/usb/usb_quirks.h cvs rdiff -u -r1.71 -r1.72 src/sys/dev/usb/usbdi_util.c cvs rdiff -u -r1.47 -r1.48 src/sys/dev/usb/usbdi_util.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usb_quirks.c diff -u src/sys/dev/usb/usb_quirks.c:1.87 src/sys/dev/usb/usb_quirks.c:1.88 --- src/sys/dev/usb/usb_quirks.c:1.87 Tue Jul 24 08:15:57 2018 +++ src/sys/dev/usb/usb_quirks.c Thu Nov 8 02:11:54 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_quirks.c,v 1.87 2018/07/24 08:15:57 msaitoh Exp $ */ +/* $NetBSD: usb_quirks.c,v 1.88 2018/11/08 02:11:54 manu Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.30 2003/01/02 04:15:55 imp Exp $ */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.87 2018/07/24 08:15:57 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_quirks.c,v 1.88 2018/11/08 02:11:54 manu Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -43,13 +43,137 @@ __KERNEL_RCSID(0, "$NetBSD: usb_quirks.c #include #include +#include +#include +#include #include #ifdef USB_DEBUG extern int usbdebug; #endif +#define DPRINTF(FMT,A,B,C,D)USBHIST_LOG(usbdebug,FMT,A,B,C,D) + #define ANY 0x +#define _USETW(w) { (w) & 0x00ff, ((w) & 0xff00) >> 8 } + +/* + * NXP PN533 NFC chip descriptors + */ +static const usb_endpoint_descriptor_t desc_ep_pn533_in = { + /* bLength */ sizeof(desc_ep_pn533_in), + /* bDescriptorType */ UDESC_ENDPOINT, + /* bEndpointAddress */ UE_DIR_IN | 0x04, + /* bmAttributes */ UE_BULK, + /* wMaxPacketSize */ _USETW(0x0040), + /* bInterval */ 0x04, /* 255ms */ +}; + +static const usb_endpoint_descriptor_t desc_ep_pn533_out = { + /* bLength */ sizeof(desc_ep_pn533_in), + /* bDescriptorType */ UDESC_ENDPOINT, + /* bEndpointAddress */ UE_DIR_OUT | 0x04, + /* bmAttributes */ UE_BULK, + /* wMaxPacketSize */ _USETW(0x0040), + /* bInterval */ 0x04, /* 255ms */ +}; + +static const usb_interface_descriptor_t desc_iface_pn533 = { + /* bLength */ sizeof(desc_iface_pn533), + /* bDescriptorType */ UDESC_INTERFACE, + /* bInterfaceNumber */ 0, + /* bAlternateSetting */ 0, + /* bNumEndpoints */ 2, + /* bInterfaceClass */ 0xff, + /* bInterfaceSubClass */ 0xff, + /* bInterfaceProtocol */ 0xff, + /* iInterface */ 0, +}; + +static const usb_config_descriptor_t desc_conf_pn533 = { + /* bLength */ sizeof(desc_conf_pn533), + /* bDescriptorType */ UDESC_CONFIG, + /* wTotalLength */ _USETW(sizeof(desc_conf_pn533) + + sizeof(desc_iface_pn533) + + sizeof(desc_ep_pn533_in) + + sizeof(desc_ep_pn533_out) + ), + /* bNumInterfac */ 1, + /* bConfigurationValue */1, + /* iConfiguration */ 0, + /* bmAttributes */ UC_ATTR_MBO, + /* bMaxPower */ 0x32, /* 100mA */ +}; + +static const usb_descriptor_t *desc_pn533[] = { + (const usb_descriptor_t *)_conf_pn533, + (const usb_descriptor_t *)_iface_pn533, + (const usb_descriptor_t *)_ep_pn533_out, + (const usb_descriptor_t *)_ep_pn533_in, + NULL +}; + + +usbd_status +usbd_get_desc_fake(struct usbd_device *dev, int type, int index, + int len, void *desc) +{ + USBHIST_FUNC(); USBHIST_CALLED(usbdebug); +#ifdef USB_DEBUG + const usb_device_descriptor_t *dd = usbd_get_device_descriptor(dev); +#endif + const usb_descriptor_t *ub; + int i = 0; + int j = 0; + usbd_status err = USBD_INVAL; + + if (dev->ud_quirks == NULL || dev->ud_quirks->desc == NULL) { + DPRINTF("%04x/%04x: no fake descriptors", + UGETW(dd->idVendor), UGETW(dd->idProduct), 0, 0); + goto out; + } + + for (j = 0; dev->ud_quirks->desc[j]; j++) { + ub = dev->ud_quirks->desc[j]; + if (ub->bDescriptorType == type && i++ == index) + break; + } + + if (dev->ud_quirks->desc[j] == NULL) { + DPRINTF("%04x/%04x: no fake descriptor type = %d, len = %d", + UGETW(dd->idVendor), UGETW(dd->idProduct), type, len); + goto out; + } + + do { + ub = dev->ud_quirks->desc[j]; + + if (ub->bLength > len) { + DPRINTF("%04x/%04x: short buf len = %d, bLength = %d", + UGETW(dd->idVendor), UGETW(dd->idProduct), + type, ub->bLength); + goto out; +
CVS commit: src/sys/dev/usb
Module Name:src Committed By: manu Date: Thu Nov 8 02:03:37 UTC 2018 Modified Files: src/sys/dev/usb: usbdevs.h usbdevs_data.h Log Message: regen To generate a diff of this commit: cvs rdiff -u -r1.752 -r1.753 src/sys/dev/usb/usbdevs.h \ src/sys/dev/usb/usbdevs_data.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbdevs.h diff -u src/sys/dev/usb/usbdevs.h:1.752 src/sys/dev/usb/usbdevs.h:1.753 --- src/sys/dev/usb/usbdevs.h:1.752 Wed Oct 3 10:00:29 2018 +++ src/sys/dev/usb/usbdevs.h Thu Nov 8 02:03:37 2018 @@ -1,10 +1,10 @@ -/* $NetBSD: usbdevs.h,v 1.752 2018/10/03 10:00:29 martin Exp $ */ +/* $NetBSD: usbdevs.h,v 1.753 2018/11/08 02:03:37 manu Exp $ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: usbdevs,v 1.759 2018/10/03 09:59:34 martin Exp + * NetBSD: usbdevs,v 1.760 2018/11/08 02:01:28 manu Exp */ /*- @@ -2645,6 +2645,7 @@ /* Philips Semiconductor products */ #define USB_PRODUCT_PHILIPSSEMI_HUB1122 0x1122 /* hub */ +#define USB_PRODUCT_PHILIPSSEMT_PN533 0x2533 /* NFC PN533 */ /* P.I. Engineering products */ #define USB_PRODUCT_PIENGINEERING_PS2USB 0x020b /* PS2 to Mac USB Adapter */ @@ -2987,6 +2988,8 @@ #define USB_PRODUCT_SHUTTLE_CDRW 0x0101 /* CD-RW Device */ #define USB_PRODUCT_SHUTTLE_ORCA 0x0325 /* eUSB ORCA Quad Reader */ #define USB_PRODUCT_SHUTTLE_SCM 0x1010 /* SCM Micro */ +#define USB_PRODUCT_SHUTTLE_SCL3711 0x5591 /* SCM Micro SCL3711-NFC */ +#define USB_PRODUCT_SHUTTLE_SCL3712 0x5594 /* SCM Micro SCL3712-NFC */ /* Siemens products */ #define USB_PRODUCT_SIEMENS_SPEEDSTREAM 0x1001 /* SpeedStream USB */ Index: src/sys/dev/usb/usbdevs_data.h diff -u src/sys/dev/usb/usbdevs_data.h:1.752 src/sys/dev/usb/usbdevs_data.h:1.753 --- src/sys/dev/usb/usbdevs_data.h:1.752 Wed Oct 3 10:00:29 2018 +++ src/sys/dev/usb/usbdevs_data.h Thu Nov 8 02:03:37 2018 @@ -1,10 +1,10 @@ -/* $NetBSD: usbdevs_data.h,v 1.752 2018/10/03 10:00:29 martin Exp $ */ +/* $NetBSD: usbdevs_data.h,v 1.753 2018/11/08 02:03:37 manu Exp $ */ /* * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * NetBSD: usbdevs,v 1.759 2018/10/03 09:59:34 martin Exp + * NetBSD: usbdevs,v 1.760 2018/11/08 02:01:28 manu Exp */ /*- @@ -3550,88 +3550,90 @@ static const uint16_t usb_products[] = { 5064, 0, USB_VENDOR_PHILIPSSEMI, USB_PRODUCT_PHILIPSSEMI_HUB1122, 6980, 0, + USB_VENDOR_PHILIPSSEMT, USB_PRODUCT_PHILIPSSEMT_PN533, + 15884, 15888, 0, USB_VENDOR_PIENGINEERING, USB_PRODUCT_PIENGINEERING_PS2USB, 8126, 5651, 9700, 4871, 4885, 0, USB_VENDOR_PIENGINEERING, USB_PRODUCT_PIENGINEERING_XKEYS58, - 15884, 15890, 5854, 15903, 15907, 0, + 15894, 15900, 5854, 15913, 15917, 0, USB_VENDOR_PIENGINEERING, USB_PRODUCT_PIENGINEERING_XKEYS, - 15884, 15890, 5854, 0, + 15894, 15900, 5854, 0, USB_VENDOR_PILOTECH, USB_PRODUCT_PILOTECH_CRW600, - 15913, 14761, 10438, 0, + 15923, 14761, 10438, 0, USB_VENDOR_PINNACLE, USB_PRODUCT_PINNACLE_PCTV800E, - 15921, 15926, 0, + 15931, 15936, 0, USB_VENDOR_PINNACLE, USB_PRODUCT_PINNACLE_PCTVDVBTFLASH, - 4575, 15921, 6785, 11487, 0, + 4575, 15931, 6785, 11487, 0, USB_VENDOR_PINNACLE, USB_PRODUCT_PINNACLE_PCTV72E, - 4575, 15921, 15931, 0, + 4575, 15931, 15941, 0, USB_VENDOR_PINNACLE, USB_PRODUCT_PINNACLE_PCTV73E, - 4575, 15921, 15935, 0, + 4575, 15931, 15945, 0, USB_VENDOR_PLANEX, USB_PRODUCT_PLANEX_GW_US11H, - 15939, 5278, 0, + 15949, 5278, 0, USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_RTL8188CUS, 7344, 0, USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_GW_US11S, - 15948, 5278, 0, + 15958, 5278, 0, USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_RTL8188CU_3, 5205, 0, USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_GWUSFANG300, - 15957, 0, + 15967, 0, USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_GWUS54GXS, - 15970, 0, + 15980, 0, USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_GW_US300, - 15981, 0, + 15991, 0, USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_GWUS54HP, - 15990, 0, - USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_GWUS300MINIS, 16000, 0, + USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_GWUS300MINIS, + 16010, 0, USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_RT3070, 5071, 0, USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_GWUSNANO, - 16014, 0, - USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_GWUSMICRO300, 16024, 0, + USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_GWUSMICRO300, + 16034, 0, USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_RTL8188CU_1, - 16038, 0, + 16048, 0, USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_RTL8192CU, - 16049, 0, + 16059, 0, USB_VENDOR_PLANEX2, USB_PRODUCT_PLANEX2_RTL8188CU_4,
CVS commit: src/sys/dev/usb
Module Name:src Committed By: manu Date: Thu Nov 8 02:01:28 UTC 2018 Modified Files: src/sys/dev/usb: usbdevs Log Message: Add PN533 based NFC devices To generate a diff of this commit: cvs rdiff -u -r1.759 -r1.760 src/sys/dev/usb/usbdevs Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/usbdevs diff -u src/sys/dev/usb/usbdevs:1.759 src/sys/dev/usb/usbdevs:1.760 --- src/sys/dev/usb/usbdevs:1.759 Wed Oct 3 09:59:34 2018 +++ src/sys/dev/usb/usbdevs Thu Nov 8 02:01:28 2018 @@ -1,4 +1,4 @@ -$NetBSD: usbdevs,v 1.759 2018/10/03 09:59:34 martin Exp $ +$NetBSD: usbdevs,v 1.760 2018/11/08 02:01:28 manu Exp $ /*- * Copyright (c) 1998-2004 The NetBSD Foundation, Inc. @@ -2638,6 +2638,7 @@ product PHILIPS RT2870 0x200f RT2870 /* Philips Semiconductor products */ product PHILIPSSEMI HUB1122 0x1122 hub +product PHILIPSSEMT PN533 0x2533 NFC PN533 /* P.I. Engineering products */ product PIENGINEERING PS2USB 0x020b PS2 to Mac USB Adapter @@ -2980,6 +2981,8 @@ product SHUTTLE EUSCSI_C 0x000c eUSCSI B product SHUTTLE CDRW 0x0101 CD-RW Device product SHUTTLE ORCA 0x0325 eUSB ORCA Quad Reader product SHUTTLE SCM 0x1010 SCM Micro +product SHUTTLE SCL3711 0x5591 SCM Micro SCL3711-NFC +product SHUTTLE SCL3712 0x5594 SCM Micro SCL3712-NFC /* Siemens products */ product SIEMENS SPEEDSTREAM 0x1001 SpeedStream USB
CVS commit: src/sys/dev/usb
Module Name:src Committed By: manu Date: Thu Nov 8 01:59:53 UTC 2018 Modified Files: src/sys/dev/usb: ugen.c Log Message: Enfore USB timeout on ugen(4) write operations To generate a diff of this commit: cvs rdiff -u -r1.140 -r1.141 src/sys/dev/usb/ugen.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/ugen.c diff -u src/sys/dev/usb/ugen.c:1.140 src/sys/dev/usb/ugen.c:1.141 --- src/sys/dev/usb/ugen.c:1.140 Mon Sep 3 16:29:34 2018 +++ src/sys/dev/usb/ugen.c Thu Nov 8 01:59:53 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ugen.c,v 1.140 2018/09/03 16:29:34 riastradh Exp $ */ +/* $NetBSD: ugen.c,v 1.141 2018/11/08 01:59:53 manu Exp $ */ /* * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.140 2018/09/03 16:29:34 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ugen.c,v 1.141 2018/11/08 01:59:53 manu Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -1456,6 +1456,7 @@ ugen_do_ioctl(struct ugen_softc *sc, int uint8_t conf, alt; int cdesclen; int error; + int dir; DPRINTFN(5, ("ugenioctl: cmd=%08lx\n", cmd)); if (sc->sc_dying) @@ -1478,14 +1479,13 @@ ugen_do_ioctl(struct ugen_softc *sc, int sce->state &= ~UGEN_SHORT_OK; return 0; case USB_SET_TIMEOUT: - sce = >sc_endpoints[endpt][IN]; - if (sce == NULL - /* XXX this shouldn't happen, but the distinction between - input and output pipes isn't clear enough. - || sce->pipeh == NULL */ - ) - return EINVAL; - sce->timeout = *(int *)addr; + for (dir = OUT; dir <= IN; dir++) { + sce = >sc_endpoints[endpt][dir]; + if (sce == NULL) +return EINVAL; + + sce->timeout = *(int *)addr; + } return 0; case USB_SET_BULK_RA: if (endpt == USB_CONTROL_ENDPOINT)
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Tue Nov 6 02:39:49 UTC 2018 Modified Files: src/sys/fs/puffs: puffs_vnops.c Log Message: Fix use after RECLAIM in PUFFS filesystems >From hannken@ When puffs_cookie2vnode() misses an entry and vrele() it operations puffs_vnop_reclaim() and puffs_vnop_fsync() get called with a VNON vnode. Do not notify the server in this case as the cookie is stale. To generate a diff of this commit: cvs rdiff -u -r1.212 -r1.213 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.212 src/sys/fs/puffs/puffs_vnops.c:1.213 --- src/sys/fs/puffs/puffs_vnops.c:1.212 Mon Nov 5 02:28:32 2018 +++ src/sys/fs/puffs/puffs_vnops.c Tue Nov 6 02:39:49 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.212 2018/11/05 02:28:32 manu Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.213 2018/11/06 02:39:49 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.212 2018/11/05 02:28:32 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.213 2018/11/06 02:39:49 manu Exp $"); #include #include @@ -1470,6 +1470,10 @@ puffs_vnop_reclaim(void *v) notifyserver = false; } + /* See the comment on top of puffs_vnop_inactive(). */ + if (vp->v_type == VNON) + notifyserver = false; + /* * purge info from kernel before issueing FAF, since we * don't really know when we'll get around to it after @@ -1723,6 +1727,11 @@ puffs_vnop_fsync(void *v) pn = VPTOPP(vp); KASSERT(pn != NULL); pmp = MPTOPUFFSMP(vp->v_mount); + + /* See the comment on top of puffs_vnop_inactive(). */ + if (vp->v_type == VNON) + return 0; + if (ap->a_flags & FSYNC_WAIT) { mutex_enter(>pn_sizemtx); } else {
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Mon Nov 5 02:28:32 UTC 2018 Modified Files: src/sys/fs/puffs: puffs_vnops.c Log Message: Add missing mutex pn->pn_sizemtx lock in puffs_vnop_open() puffs_vnop_open() calls flushvncache(), which calls dosetattr() if pn->pn_stat has PNODE_METACACHE_MASK. In that case, the lock on pn->pn_sizemtx is mandatory and asserted. To generate a diff of this commit: cvs rdiff -u -r1.211 -r1.212 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.211 src/sys/fs/puffs/puffs_vnops.c:1.212 --- src/sys/fs/puffs/puffs_vnops.c:1.211 Fri May 26 14:21:01 2017 +++ src/sys/fs/puffs/puffs_vnops.c Mon Nov 5 02:28:32 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.211 2017/05/26 14:21:01 riastradh Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.212 2018/11/05 02:28:32 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.211 2017/05/26 14:21:01 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.212 2018/11/05 02:28:32 manu Exp $"); #include #include @@ -913,7 +913,10 @@ puffs_vnop_open(void *v) * - we do not want to discard cached write by direct write * - read cache is now useless and should be freed */ + mutex_enter(>pn_sizemtx); flushvncache(vp, 0, 0, true); + mutex_exit(>pn_sizemtx); + if (mode & FREAD) pn->pn_stat |= PNODE_RDIRECT; if (mode & FWRITE)
CVS commit: src/sys/dev/usb
Module Name:src Committed By: manu Date: Tue Oct 23 01:49:37 UTC 2018 Modified Files: src/sys/dev/usb: uhub.c usb_subr.c Log Message: Make USB port iteration code consistent, always startint at port #1 This complements change in revision 1.140 To generate a diff of this commit: cvs rdiff -u -r1.140 -r1.141 src/sys/dev/usb/uhub.c cvs rdiff -u -r1.227 -r1.228 src/sys/dev/usb/usb_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/uhub.c diff -u src/sys/dev/usb/uhub.c:1.140 src/sys/dev/usb/uhub.c:1.141 --- src/sys/dev/usb/uhub.c:1.140 Fri Oct 19 00:33:27 2018 +++ src/sys/dev/usb/uhub.c Tue Oct 23 01:49:37 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: uhub.c,v 1.140 2018/10/19 00:33:27 manu Exp $ */ +/* $NetBSD: uhub.c,v 1.141 2018/10/23 01:49:37 manu Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */ /* $OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */ @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.140 2018/10/19 00:33:27 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.141 2018/10/23 01:49:37 manu Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -413,11 +413,11 @@ uhub_attach(device_t parent, device_t se sizeof(struct usbd_tt), KM_SLEEP); } /* Set up data structures */ - for (p = 0; p < nports; p++) { - struct usbd_port *up = >uh_ports[p]; + for (p = 1; p <= nports; p++) { + struct usbd_port *up = >uh_ports[p - 1]; up->up_dev = NULL; up->up_parent = dev; - up->up_portno = p + 1; + up->up_portno = p; if (dev->ud_selfpowered) /* Self powered hub, give ports maximum current. */ up->up_power = USB_MAX_POWER; @@ -426,7 +426,7 @@ uhub_attach(device_t parent, device_t se up->up_restartcnt = 0; up->up_reattach = 0; if (UHUB_IS_HIGH_SPEED(sc)) { - up->up_tt = [UHUB_IS_SINGLE_TT(sc) ? 0 : p]; + up->up_tt = [UHUB_IS_SINGLE_TT(sc) ? 0 : p - 1]; up->up_tt->utt_hub = hub; } else { up->up_tt = NULL; Index: src/sys/dev/usb/usb_subr.c diff -u src/sys/dev/usb/usb_subr.c:1.227 src/sys/dev/usb/usb_subr.c:1.228 --- src/sys/dev/usb/usb_subr.c:1.227 Tue Sep 18 01:36:44 2018 +++ src/sys/dev/usb/usb_subr.c Tue Oct 23 01:49:37 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: usb_subr.c,v 1.227 2018/09/18 01:36:44 mrg Exp $ */ +/* $NetBSD: usb_subr.c,v 1.228 2018/10/23 01:49:37 manu Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ /* @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.227 2018/09/18 01:36:44 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.228 2018/10/23 01:49:37 manu Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -1230,9 +1230,10 @@ usbd_new_device(device_t parent, struct adev = hub, hub = hub->ud_myhub) ; if (hub) { - for (p = 0; p < hub->ud_hub->uh_hubdesc.bNbrPorts; p++) { - if (hub->ud_hub->uh_ports[p].up_dev == adev) { -dev->ud_myhsport = >ud_hub->uh_ports[p]; + for (p = 1; p <= hub->ud_hub->uh_hubdesc.bNbrPorts; p++) { + if (hub->ud_hub->uh_ports[p - 1].up_dev == adev) { +dev->ud_myhsport = +>ud_hub->uh_ports[p - 1]; goto found; } } @@ -1558,8 +1559,8 @@ usbd_fill_deviceinfo(struct usbd_device } const int nports = dev->ud_hub->uh_hubdesc.bNbrPorts; - for (i = 0; i < __arraycount(di->udi_ports) && i < nports; i++) { - p = >ud_hub->uh_ports[i]; + for (i = 1; i <= __arraycount(di->udi_ports) && i <= nports; i++) { + p = >ud_hub->uh_ports[i - 1]; if (p->up_dev) err = p->up_dev->ud_addr; else { @@ -1581,7 +1582,7 @@ usbd_fill_deviceinfo(struct usbd_device else err = USB_PORT_DISABLED; } - di->udi_ports[i] = err; + di->udi_ports[i - 1] = err; } di->udi_nports = nports; } @@ -1633,9 +1634,9 @@ usbd_fill_deviceinfo_old(struct usbd_dev } const int nports = dev->ud_hub->uh_hubdesc.bNbrPorts; - for (i = 0; i < __arraycount(di->udi_ports) && i < nports; + for (i = 1; i <= __arraycount(di->udi_ports) && i <= nports; i++) { - p = >ud_hub->uh_ports[i]; + p = >ud_hub->uh_ports[i - 1]; if (p->up_dev) err = p->up_dev->ud_addr; else { @@ -1649,7 +1650,7 @@ usbd_fill_deviceinfo_old(struct usbd_dev else err = USB_PORT_DISABLED; } - di->udi_ports[i] = err; + di->udi_ports[i - 1] = err; } di->udi_nports = nports; }
CVS commit: src/sys/dev/usb
Module Name:src Committed By: manu Date: Fri Oct 19 00:33:27 UTC 2018 Modified Files: src/sys/dev/usb: uhub.c Log Message: Make USB port numbers display consistent Make sure USB ports numbers are displayed with the first one as number one and not number zero when rescanning bus. The change makes the display consistent with the display at boot time USB discovery. While we are there, make port iteration consistent everywhere in the code, always starting at one instead of zero. To generate a diff of this commit: cvs rdiff -u -r1.139 -r1.140 src/sys/dev/usb/uhub.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/usb/uhub.c diff -u src/sys/dev/usb/uhub.c:1.139 src/sys/dev/usb/uhub.c:1.140 --- src/sys/dev/usb/uhub.c:1.139 Tue Sep 18 01:36:44 2018 +++ src/sys/dev/usb/uhub.c Fri Oct 19 00:33:27 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: uhub.c,v 1.139 2018/09/18 01:36:44 mrg Exp $ */ +/* $NetBSD: uhub.c,v 1.140 2018/10/19 00:33:27 manu Exp $ */ /* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */ /* $OpenBSD: uhub.c,v 1.86 2015/06/29 18:27:40 mpi Exp $ */ @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.139 2018/09/18 01:36:44 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.140 2018/10/19 00:33:27 manu Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -823,8 +823,8 @@ uhub_detach(device_t self, int flags) KERNEL_LOCK(1, curlwp); nports = hub->uh_hubdesc.bNbrPorts; - for (port = 0; port < nports; port++) { - rup = >uh_ports[port]; + for (port = 1; port <= nports; port++) { + rup = >uh_ports[port - 1]; if (rup->up_dev == NULL) continue; if ((rc = usb_disconnect_port(rup, self, flags)) != 0) { @@ -871,8 +871,8 @@ uhub_rescan(device_t self, const char *i struct usbd_device *dev; int port; - for (port = 0; port < hub->uh_hubdesc.bNbrPorts; port++) { - dev = hub->uh_ports[port].up_dev; + for (port = 1; port <= hub->uh_hubdesc.bNbrPorts; port++) { + dev = hub->uh_ports[port - 1].up_dev; if (dev == NULL) continue; usbd_reattach_device(sc->sc_dev, dev, port, locators); @@ -896,8 +896,8 @@ uhub_childdet(device_t self, device_t ch panic("hub not fully initialised, but child deleted?"); nports = devhub->ud_hub->uh_hubdesc.bNbrPorts; - for (port = 0; port < nports; port++) { - dev = devhub->ud_hub->uh_ports[port].up_dev; + for (port = 1; port <= nports; port++) { + dev = devhub->ud_hub->uh_ports[port - 1].up_dev; if (!dev || dev->ud_subdevlen == 0) continue; for (i = 0; i < dev->ud_subdevlen; i++) {
CVS commit: src/sys/kern
Module Name:src Committed By: manu Date: Fri Oct 5 01:25:38 UTC 2018 Modified Files: src/sys/kern: vfs_trans.c Log Message: Back out sftchg/fstcnt deadlock workaround The change did prevent some system freeze, but caused spurious unmount failures reporter by bouyer@. hannken@ is working on the right fix, see kern/53624 To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/kern/vfs_trans.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_trans.c diff -u src/sys/kern/vfs_trans.c:1.49 src/sys/kern/vfs_trans.c:1.50 --- src/sys/kern/vfs_trans.c:1.49 Thu Sep 27 01:03:40 2018 +++ src/sys/kern/vfs_trans.c Fri Oct 5 01:25:38 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_trans.c,v 1.49 2018/09/27 01:03:40 manu Exp $ */ +/* $NetBSD: vfs_trans.c,v 1.50 2018/10/05 01:25:38 manu Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.49 2018/09/27 01:03:40 manu Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.50 2018/10/05 01:25:38 manu Exp $"); /* * File system transaction operations. @@ -42,7 +42,6 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_trans.c, #include #include -#include #include #include #include @@ -533,14 +532,10 @@ fstrans_setstate(struct mount *mp, enum /* * All threads see the new state now. * Wait for transactions invalid at this state to leave. - * We cannot wait forever because many processes would - * get stuck waiting for fstcnt in fstrans_start(). This - * is acute when suspending the root filesystem. */ error = 0; while (! state_change_done(mp)) { - error = cv_timedwait_sig(_count_cv, - _lock, hz / 4); + error = cv_wait_sig(_count_cv, _lock); if (error) { new_state = fmi->fmi_state = FSTRANS_NORMAL; break;
CVS commit: src/sys/dev/hdaudio
Module Name:src Committed By: manu Date: Thu Sep 27 01:18:11 UTC 2018 Modified Files: src/sys/dev/hdaudio: hdafg.c Log Message: Fix hdaudio device configuration When disabling unassociated devices, we have a special handling for pins of type COP_AWCAP_TYPE_PIN_COMPLEX, but it came after code that may disable any pins, including the ones that should be handled as COP_AWCAP_TYPE_PIN_COMPLEX. The result was that hdaudio could fail to detect some devices. We fix the situation by making sure that COP_AWCAP_TYPE_PIN_COMPLEX pins always get their specific handling. The change makes the built-in speaker work on Dell OptiPlex 5060 To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/dev/hdaudio/hdafg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hdaudio/hdafg.c diff -u src/sys/dev/hdaudio/hdafg.c:1.15 src/sys/dev/hdaudio/hdafg.c:1.16 --- src/sys/dev/hdaudio/hdafg.c:1.15 Wed Feb 14 18:28:43 2018 +++ src/sys/dev/hdaudio/hdafg.c Thu Sep 27 01:18:11 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: hdafg.c,v 1.15 2018/02/14 18:28:43 maya Exp $ */ +/* $NetBSD: hdafg.c,v 1.16 2018/09/27 01:18:11 manu Exp $ */ /* * Copyright (c) 2009 Precedence Technologies Ltd @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.15 2018/02/14 18:28:43 maya Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hdafg.c,v 1.16 2018/09/27 01:18:11 manu Exp $"); #include #include @@ -2102,25 +2102,25 @@ hdafg_disable_unassoc(struct hdafg_softc struct hdaudio_control *ctl; int i, j, k; - /* Disable unassociated widgets */ for (i = sc->sc_startnode; i < sc->sc_endnode; i++) { w = hdafg_widget_lookup(sc, i); if (w == NULL || w->w_enable == false) continue; - if (w->w_bindas == -1) { - w->w_enable = 0; - hda_trace(sc, "disable %02X [unassociated]\n", - w->w_nid); + + /* Disable unassociated widgets */ + if (w->w_type != COP_AWCAP_TYPE_PIN_COMPLEX) { + if (w->w_bindas == -1) { +w->w_enable = 0; +hda_trace(sc, "disable %02X [unassociated]\n", +w->w_nid); + } + continue; } - } - /* Disable input connections on input pin and output on output */ - for (i = sc->sc_startnode; i < sc->sc_endnode; i++) { - w = hdafg_widget_lookup(sc, i); - if (w == NULL || w->w_enable == false) - continue; - if (w->w_type != COP_AWCAP_TYPE_PIN_COMPLEX) - continue; + /* + * Disable input connections on input pin + * and output on output pin + */ if (w->w_bindas < 0) continue; if (as[w->w_bindas].as_dir == HDAUDIO_PINDIR_IN) {
CVS commit: src/sys/kern
Module Name:src Committed By: manu Date: Thu Sep 27 01:03:40 UTC 2018 Modified Files: src/sys/kern: vfs_trans.c Log Message: Work around deadlock between fstchg and fstcnt When suspending a filesystem in fstrans_setstate(), we wait on fstcnt for threads to finish transactions. While we do this, any thread trying to start a filesystem transaction will wait on fstchg in fstrans_start(), a situation which can deadlock. The wait for fstcnt in fstrans_setstate() can be interrupted by a signal, but the wait for fstchg in fstrans_start() cannot. Once most processes are stuck in fstchg, it is impossible to send a signal to the thread that waits on fstcnt, because no process respond anymore to user input. We fix that by adding a timeout to the wait on fstcnt in fstrans_setstate(). This means suspending a filesystem may fail, but it was already the case when the sleep was interupted by a signal, hence calling function must already handle a possible failure. Fixes kern/53624 To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/kern/vfs_trans.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_trans.c diff -u src/sys/kern/vfs_trans.c:1.48 src/sys/kern/vfs_trans.c:1.49 --- src/sys/kern/vfs_trans.c:1.48 Sun Jun 18 14:00:17 2017 +++ src/sys/kern/vfs_trans.c Thu Sep 27 01:03:40 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_trans.c,v 1.48 2017/06/18 14:00:17 hannken Exp $ */ +/* $NetBSD: vfs_trans.c,v 1.49 2018/09/27 01:03:40 manu Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.48 2017/06/18 14:00:17 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.49 2018/09/27 01:03:40 manu Exp $"); /* * File system transaction operations. @@ -42,6 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_trans.c, #include #include +#include #include #include #include @@ -532,10 +533,14 @@ fstrans_setstate(struct mount *mp, enum /* * All threads see the new state now. * Wait for transactions invalid at this state to leave. + * We cannot wait forever because many processes would + * get stuck waiting for fstcnt in fstrans_start(). This + * is acute when suspending the root filesystem. */ error = 0; while (! state_change_done(mp)) { - error = cv_wait_sig(_count_cv, _lock); + error = cv_timedwait_sig(_count_cv, + _lock, hz / 4); if (error) { new_state = fmi->fmi_state = FSTRANS_NORMAL; break;
CVS commit: src/sys/kern
Module Name:src Committed By: manu Date: Wed Feb 7 15:51:35 UTC 2018 Modified Files: src/sys/kern: subr_tftproot.c Log Message: Fix md(4) double attachment in TFTPROOT option The mdattach() call in tftproot_dhcpboot() has probably always been useless, but it seems it became harmful, as it causes 7.1.1 to deadlock during boot. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/kern/subr_tftproot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_tftproot.c diff -u src/sys/kern/subr_tftproot.c:1.19 src/sys/kern/subr_tftproot.c:1.20 --- src/sys/kern/subr_tftproot.c:1.19 Mon Oct 31 15:27:24 2016 +++ src/sys/kern/subr_tftproot.c Wed Feb 7 15:51:35 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_tftproot.c,v 1.19 2016/10/31 15:27:24 maxv Exp $ */ +/* $NetBSD: subr_tftproot.c,v 1.20 2018/02/07 15:51:35 manu Exp $ */ /*- * Copyright (c) 2007 Emmanuel Dreyfus, all rights reserved. @@ -39,7 +39,7 @@ #include "opt_md.h" #include -__KERNEL_RCSID(0, "$NetBSD: subr_tftproot.c,v 1.19 2016/10/31 15:27:24 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_tftproot.c,v 1.20 2018/02/07 15:51:35 manu Exp $"); #include #include @@ -65,8 +65,6 @@ __KERNEL_RCSID(0, "$NetBSD: subr_tftproo #include #include -extern void mdattach(int); - /* * Copied from */ @@ -333,7 +331,6 @@ tftproot_getfile(struct tftproot_handle DPRINTF(("%s():%d RAMdisk loaded: %ld@%p\n", __func__, __LINE__, trh->trh_len, trh->trh_base)); md_root_setconf(trh->trh_base, trh->trh_len); - mdattach(0); error = 0; out:
CVS commit: src/sbin/route
Module Name:src Committed By: manu Date: Thu Jul 13 08:26:29 UTC 2017 Modified Files: src/sbin/route: rtutil.c Log Message: Fix route and netstat -r output when built with -DSMALL A missing \n caused the routing table to be printed all in one line if -DSMALL was used. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sbin/route/rtutil.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/route/rtutil.c diff -u src/sbin/route/rtutil.c:1.9 src/sbin/route/rtutil.c:1.10 --- src/sbin/route/rtutil.c:1.9 Wed Jun 28 04:14:53 2017 +++ src/sbin/route/rtutil.c Thu Jul 13 08:26:29 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: rtutil.c,v 1.9 2017/06/28 04:14:53 ozaki-r Exp $ */ +/* $NetBSD: rtutil.c,v 1.10 2017/07/13 08:26:29 manu Exp $ */ /* $OpenBSD: show.c,v 1.1 2006/05/27 19:16:37 claudio Exp $ */ /* @@ -304,6 +304,8 @@ p_rtentry(struct rt_msghdr *rtm, int fla putchar('\n'); if (flags & RT_VFLAG) p_rtrmx(>rtm_rmx); +#else + putchar('\n'); #endif }
CVS commit: src/external/bsd/dhcp/dist
Module Name:src Committed By: manu Date: Wed Jun 28 02:46:31 UTC 2017 Modified Files: src/external/bsd/dhcp/dist/client: dhclient.c src/external/bsd/dhcp/dist/common: bpf.c comapi.c discover.c dispatch.c dlpi.c execute.c lpf.c nit.c options.c packet.c parse.c raw.c socket.c tr.c tree.c upf.c src/external/bsd/dhcp/dist/dhcpctl: cltest.c omshell.c src/external/bsd/dhcp/dist/includes: dhcpd.h src/external/bsd/dhcp/dist/relay: dhcrelay.c src/external/bsd/dhcp/dist/server: dhcpd.c src/external/bsd/dhcp/dist/tests: t_api.c Log Message: Make DHCP programs compatible with crunchgen(1) DHCP programs are incompatible with crunchgen(1) so far, because libdhcp uses callbacks with the same function names for dhclient, dhcrelay, dhcpd, and omshell. As a result, it is impossible to link correctly in a single binary. The offending symbols are classify, check_collection, dhcp, dhcpv6, bootp, find_class, parse_allow_deny, and dhcp_set_control_state, and the local_port and remote_port variables. This change make each program register an array of callbacks at main() start. libdhcp then uses callbacks through registered function and variable pointers, and DHCP programs can now go trough crunchgen(1). Submitted upstream as ISC-Bugs #45330 with a patch against latest ISC git. The soon to be released 4.3.6 will not include the change, but it is likely to be included in 4.3.7 To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/external/bsd/dhcp/dist/client/dhclient.c cvs rdiff -u -r1.4 -r1.5 src/external/bsd/dhcp/dist/common/bpf.c \ src/external/bsd/dhcp/dist/common/dispatch.c cvs rdiff -u -r1.1.1.3 -r1.2 src/external/bsd/dhcp/dist/common/comapi.c \ src/external/bsd/dhcp/dist/common/nit.c \ src/external/bsd/dhcp/dist/common/tr.c \ src/external/bsd/dhcp/dist/common/upf.c cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcp/dist/common/discover.c cvs rdiff -u -r1.1.1.4 -r1.2 src/external/bsd/dhcp/dist/common/dlpi.c \ src/external/bsd/dhcp/dist/common/execute.c \ src/external/bsd/dhcp/dist/common/options.c \ src/external/bsd/dhcp/dist/common/parse.c \ src/external/bsd/dhcp/dist/common/socket.c \ src/external/bsd/dhcp/dist/common/tree.c cvs rdiff -u -r1.1.1.5 -r1.2 src/external/bsd/dhcp/dist/common/lpf.c cvs rdiff -u -r1.3 -r1.4 src/external/bsd/dhcp/dist/common/packet.c cvs rdiff -u -r1.1.1.2 -r1.2 src/external/bsd/dhcp/dist/common/raw.c cvs rdiff -u -r1.1.1.3 -r1.2 src/external/bsd/dhcp/dist/dhcpctl/cltest.c \ src/external/bsd/dhcp/dist/dhcpctl/omshell.c cvs rdiff -u -r1.8 -r1.9 src/external/bsd/dhcp/dist/includes/dhcpd.h cvs rdiff -u -r1.7 -r1.8 src/external/bsd/dhcp/dist/relay/dhcrelay.c cvs rdiff -u -r1.5 -r1.6 src/external/bsd/dhcp/dist/server/dhcpd.c cvs rdiff -u -r1.1.1.3 -r1.2 src/external/bsd/dhcp/dist/tests/t_api.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcp/dist/client/dhclient.c diff -u src/external/bsd/dhcp/dist/client/dhclient.c:1.10 src/external/bsd/dhcp/dist/client/dhclient.c:1.11 --- src/external/bsd/dhcp/dist/client/dhclient.c:1.10 Sun Jan 10 20:10:44 2016 +++ src/external/bsd/dhcp/dist/client/dhclient.c Wed Jun 28 02:46:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: dhclient.c,v 1.10 2016/01/10 20:10:44 christos Exp $ */ +/* $NetBSD: dhclient.c,v 1.11 2017/06/28 02:46:30 manu Exp $ */ /* dhclient.c DHCP Client. */ @@ -32,7 +32,7 @@ */ #include -__RCSID("$NetBSD: dhclient.c,v 1.10 2016/01/10 20:10:44 christos Exp $"); +__RCSID("$NetBSD: dhclient.c,v 1.11 2017/06/28 02:46:30 manu Exp $"); #include "dhcpd.h" #include @@ -95,6 +95,21 @@ int wanted_ia_ta = 0; int wanted_ia_pd = 0; char *mockup_relay = NULL; +libdhcp_callbacks_t dhclient_callbacks = { + _port, + _port, + classify, + check_collection, + dhcp, +#ifdef DHCPv6 + dhcpv6, +#endif /* DHCPv6 */ + bootp, + find_class, + parse_allow_deny, + dhcp_set_control_state, +}; + void run_stateless(int exit_mode); static void usage(void); @@ -183,6 +198,8 @@ main(int argc, char **argv) { char *s; char **ifaces; + libdhcp_callbacks_register(_callbacks); + /* Initialize client globals. */ memset(_duid, 0, sizeof(default_duid)); @@ -942,7 +959,7 @@ int find_subnet (struct subnet **sp, */ #include -__RCSID("$NetBSD: dhclient.c,v 1.10 2016/01/10 20:10:44 christos Exp $"); +__RCSID("$NetBSD: dhclient.c,v 1.11 2017/06/28 02:46:30 manu Exp $"); void state_reboot (cpp) void *cpp; Index: src/external/bsd/dhcp/dist/common/bpf.c diff -u src/external/bsd/dhcp/dist/common/bpf.c:1.4 src/external/bsd/dhcp/dist/common/bpf.c:1.5 --- src/external/bsd/dhcp/dist/common/bpf.c:1.4 Sun Jan 10 20:10:44 2016 +++ src/external/bsd/dhcp/dist/common/bpf.c Wed Jun 28 02:46:30 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: bpf.c,v 1.4 2016/01/10 20:10:44 christos Exp $ */ +/* $NetBSD: bpf.c,v 1.5 2017/06/28 02:46:30
CVS commit: src/lib/libc/net
Module Name:src Committed By: manu Date: Sun Jun 18 04:03:44 UTC 2017 Modified Files: src/lib/libc/net: Makefile.inc Log Message: Include IPv6 global variable in USE_INET6=no libc This ensures a binary built with USE_INET6=yes libc can still link at runtime with a USE_INET6=no libc. Of course IPv6 functionnality is not available, but dynamic linking is not killed by missing symbols such as in6addr_any. To generate a diff of this commit: cvs rdiff -u -r1.86 -r1.87 src/lib/libc/net/Makefile.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/net/Makefile.inc diff -u src/lib/libc/net/Makefile.inc:1.86 src/lib/libc/net/Makefile.inc:1.87 --- src/lib/libc/net/Makefile.inc:1.86 Wed Apr 15 19:13:46 2015 +++ src/lib/libc/net/Makefile.inc Sun Jun 18 04:03:44 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.86 2015/04/15 19:13:46 mrg Exp $ +# $NetBSD: Makefile.inc,v 1.87 2017/06/18 04:03:44 manu Exp $ # @(#)Makefile.inc 8.2 (Berkeley) 9/5/93 # net sources @@ -21,8 +21,9 @@ SRCS+= hesiod.c SRCS+= getaddrinfo.c getnameinfo.c .if (${USE_INET6} != "no") -SRCS+= ip6opt.c rthdr.c vars6.c inet6_scopeid.c +SRCS+= ip6opt.c rthdr.c inet6_scopeid.c .endif +SRCS+= vars6.c SRCS+= if_indextoname.c if_nameindex.c if_nametoindex.c LPREFIX=_nsyy
CVS commit: src
Module Name:src Committed By: manu Date: Sun Jun 18 03:56:39 UTC 2017 Modified Files: src/distrib/utils/libhack: Makefile Makefile.inc src/lib/libc/gen: getcap.c Log Message: Make shared -DSMALL libc buildable without breaking libhack We used -DSMALL to exclude code from libc in order to build libhack. Introduce -DLIBHACK to do this without so that -DSMALL does not remove code necessary for building a shared libc To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/distrib/utils/libhack/Makefile cvs rdiff -u -r1.26 -r1.27 src/distrib/utils/libhack/Makefile.inc cvs rdiff -u -r1.56 -r1.57 src/lib/libc/gen/getcap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/utils/libhack/Makefile diff -u src/distrib/utils/libhack/Makefile:1.24 src/distrib/utils/libhack/Makefile:1.25 --- src/distrib/utils/libhack/Makefile:1.24 Tue Aug 27 09:53:33 2013 +++ src/distrib/utils/libhack/Makefile Sun Jun 18 03:56:39 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.24 2013/08/27 09:53:33 christos Exp $ +# $NetBSD: Makefile,v 1.25 2017/06/18 03:56:39 manu Exp $ # # Stubs to kill off some things from libc: # This save space on a boot system. @@ -10,6 +10,7 @@ HACKSRC?=${.CURDIR} HACKOBJ?=${.OBJDIR} CPPFLAGS+= -DSMALL +CPPFLAGS+= -DLIBHACK CPPFLAGS.runetable.c+= -I${HACKSRC}/../../../lib/libc/citrus \ -DALL_80_TO_FF_SW1 CPPFLAGS.syslog.c+= -I${HACKSRC}/../../../lib/libc/include Index: src/distrib/utils/libhack/Makefile.inc diff -u src/distrib/utils/libhack/Makefile.inc:1.26 src/distrib/utils/libhack/Makefile.inc:1.27 --- src/distrib/utils/libhack/Makefile.inc:1.26 Mon Aug 25 14:11:51 2014 +++ src/distrib/utils/libhack/Makefile.inc Sun Jun 18 03:56:39 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.26 2014/08/25 14:11:51 christos Exp $ +# $NetBSD: Makefile.inc,v 1.27 2017/06/18 03:56:39 manu Exp $ # # Include this fragment to build libhack.o # It is .o and not .a to make sure these are the @@ -17,6 +17,7 @@ # CPPFLAGS+= -DSMALL +CPPFLAGS+= -DLIBHACK HACKOBJS+= getcap.o getgrent.o getnet.o getnetgr.o getpwent.o \ localeconv.o multibyte.o perror.o runetable.o setlocale.o \ strerror.o strsignal.o syslog.o utmp.o yplib.o Index: src/lib/libc/gen/getcap.c diff -u src/lib/libc/gen/getcap.c:1.56 src/lib/libc/gen/getcap.c:1.57 --- src/lib/libc/gen/getcap.c:1.56 Wed Sep 24 13:18:52 2014 +++ src/lib/libc/gen/getcap.c Sun Jun 18 03:56:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: getcap.c,v 1.56 2014/09/24 13:18:52 christos Exp $ */ +/* $NetBSD: getcap.c,v 1.57 2017/06/18 03:56:39 manu Exp $ */ /*- * Copyright (c) 1992, 1993 @@ -41,11 +41,11 @@ #if 0 static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94"; #else -__RCSID("$NetBSD: getcap.c,v 1.56 2014/09/24 13:18:52 christos Exp $"); +__RCSID("$NetBSD: getcap.c,v 1.57 2017/06/18 03:56:39 manu Exp $"); #endif #endif /* LIBC_SCCS and not lint */ -#ifndef SMALL +#ifndef LIBHACK #include "namespace.h" #endif #include @@ -65,7 +65,7 @@ __RCSID("$NetBSD: getcap.c,v 1.56 2014/0 #include #include -#if defined(__weak_alias) && !defined(SMALL) +#if defined(__weak_alias) && !defined(LIBHACK) __weak_alias(cgetcap,_cgetcap) __weak_alias(cgetclose,_cgetclose) __weak_alias(cgetent,_cgetent)
CVS commit: src/sys/dev/hpc
Module Name:src Committed By: manu Date: Mon Jun 12 09:23:39 UTC 2017 Modified Files: src/sys/dev/hpc: hpckbd.c Log Message: Restore wscons keymaps feature on hpcarm hpc ports need to alter keydesc data at runtime in order to load alternate keymaps. But since keydesc is const initialized data, it is mapped read only and the operation should fail. It seems older compiler failed to enforce the read-only mapping and this is why it used to work, but on recent NetBSD releases, the feature is broken. We fix it by duplicating the keydesc data once into a malloc'ed area that can be modified. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/dev/hpc/hpckbd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/hpc/hpckbd.c diff -u src/sys/dev/hpc/hpckbd.c:1.30 src/sys/dev/hpc/hpckbd.c:1.31 --- src/sys/dev/hpc/hpckbd.c:1.30 Sat Oct 27 17:18:17 2012 +++ src/sys/dev/hpc/hpckbd.c Mon Jun 12 09:23:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: hpckbd.c,v 1.30 2012/10/27 17:18:17 chs Exp $ */ +/* $NetBSD: hpckbd.c,v 1.31 2017/06/12 09:23:39 manu Exp $ */ /*- * Copyright (c) 1999-2001 The NetBSD Foundation, Inc. @@ -30,11 +30,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.30 2012/10/27 17:18:17 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.31 2017/06/12 09:23:39 manu Exp $"); #include #include #include +#include #include @@ -264,22 +265,30 @@ hpckbd_keymap_setup(struct hpckbd_core * const keysym_t *map, int mapsize) { int i; - struct wscons_keydesc *desc; + const struct wscons_keydesc *desc; + static struct wscons_keydesc *ndesc = NULL; - /* fix keydesc table */ /* - * XXX The way this is done is really wrong. The __UNCONST() - * is a hint as to what is wrong. This actually ends up modifying - * initialized data which is marked "const". - * The reason we get away with it here is apparently that text - * and read-only data gets mapped read/write on the platforms - * using this code. + * fix keydesc table. Since it is const data, we must + * copy it once before changingg it. */ - desc = (struct wscons_keydesc *)__UNCONST(hpckbd_keymapdata.keydesc); + + if (ndesc == NULL) { + size_t sz; + + for (sz = 0; hpckbd_keymapdata.keydesc[sz].name != 0; sz++); + + ndesc = malloc(sz * sizeof(*ndesc), M_DEVBUF, M_WAITOK); + memcpy(ndesc, hpckbd_keymapdata.keydesc, sz * sizeof(*ndesc)); + + hpckbd_keymapdata.keydesc = ndesc; + } + + desc = hpckbd_keymapdata.keydesc; for (i = 0; desc[i].name != 0; i++) { if ((desc[i].name & KB_MACHDEP) && desc[i].map == NULL) { - desc[i].map = map; - desc[i].map_size = mapsize; + ndesc[i].map = map; + ndesc[i].map_size = mapsize; } }
CVS commit: src/external/bsd/dhcp/dist/relay
Module Name:src Committed By: manu Date: Mon Jun 5 07:35:23 UTC 2017 Modified Files: src/external/bsd/dhcp/dist/relay: dhcrelay.c Log Message: Fix buggy dhcrelay(8) requirement to stay in foreground This version of dhcrelay(8) needed to stay inforeground with -d flag in order to service requests. Running inbackground turned it deaf to DHCP requests. This was caused by wrong kqueue(2) usage, where kevent(2) was used with a file descriptor obtained by a kqueue(2) call done before fork(2). kqueue(2) man page says "The queue is not inherited by a child created with fork(2)". As a result, kevent(2) calls always got EBADF. The fix is to reorder function calls in dhcrelay(8) main() function. dhcp_context_create(), which causes kqueue(2) to be invoked, is moved with its dependencies after fork(2). This matches the code layout of dhclient(8) and dhcpd(8), which do not have the bug. The fix was not submitted upstream since latest ISC DHCP code was refactored and does not have the bug anymore. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/external/bsd/dhcp/dist/relay/dhcrelay.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/dhcp/dist/relay/dhcrelay.c diff -u src/external/bsd/dhcp/dist/relay/dhcrelay.c:1.6 src/external/bsd/dhcp/dist/relay/dhcrelay.c:1.7 --- src/external/bsd/dhcp/dist/relay/dhcrelay.c:1.6 Sun Jan 10 20:10:45 2016 +++ src/external/bsd/dhcp/dist/relay/dhcrelay.c Mon Jun 5 07:35:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: dhcrelay.c,v 1.6 2016/01/10 20:10:45 christos Exp $ */ +/* $NetBSD: dhcrelay.c,v 1.7 2017/06/05 07:35:23 manu Exp $ */ /* dhcrelay.c DHCP/BOOTP Relay Agent. */ @@ -28,7 +28,7 @@ */ #include -__RCSID("$NetBSD: dhcrelay.c,v 1.6 2016/01/10 20:10:45 christos Exp $"); +__RCSID("$NetBSD: dhcrelay.c,v 1.7 2017/06/05 07:35:23 manu Exp $"); #include "dhcpd.h" #include @@ -207,13 +207,6 @@ main(int argc, char **argv) { setlogmask(LOG_UPTO(LOG_INFO)); #endif - /* Set up the isc and dns library managers */ - status = dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB, - NULL, NULL); - if (status != ISC_R_SUCCESS) - log_fatal("Can't initialize context: %s", - isc_result_totext(status)); - /* Set up the OMAPI. */ status = omapi_init(); if (status != ISC_R_SUCCESS) @@ -536,17 +529,6 @@ main(int argc, char **argv) { } #endif - /* Get the current time... */ - gettimeofday(_tv, NULL); - - /* Discover all the network interfaces. */ - discover_interfaces(DISCOVER_RELAY); - -#ifdef DHCPv6 - if (local_family == AF_INET6) - setup_streams(); -#endif - /* Become a daemon... */ if (!no_daemon) { int pid; @@ -587,6 +569,24 @@ main(int argc, char **argv) { IGNORE_RET (chdir("/")); } + /* Set up the isc and dns library managers */ + status = dhcp_context_create(DHCP_CONTEXT_PRE_DB | DHCP_CONTEXT_POST_DB, + NULL, NULL); + if (status != ISC_R_SUCCESS) + log_fatal("Can't initialize context: %s", + isc_result_totext(status)); + + /* Get the current time... */ + gettimeofday(_tv, NULL); + + /* Discover all the network interfaces. */ + discover_interfaces(DISCOVER_RELAY); + +#ifdef DHCPv6 + if (local_family == AF_INET6) + setup_streams(); +#endif + /* Set up the packet handler... */ if (local_family == AF_INET) bootp_packet_handler = do_relay4; @@ -948,7 +948,7 @@ find_interface_by_agent_option(struct dh */ #include -__RCSID("$NetBSD: dhcrelay.c,v 1.6 2016/01/10 20:10:45 christos Exp $"); +__RCSID("$NetBSD: dhcrelay.c,v 1.7 2017/06/05 07:35:23 manu Exp $"); static int add_relay_agent_options(struct interface_info *ip, struct dhcp_packet *packet, unsigned length, struct in_addr giaddr) {
CVS commit: src/external/bsd/bind/lib/libdns
Module Name:src Committed By: manu Date: Mon May 15 13:38:34 UTC 2017 Modified Files: src/external/bsd/bind/lib/libdns: Makefile Log Message: Allow building with MKKERBEROS=no To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/external/bsd/bind/lib/libdns/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/bsd/bind/lib/libdns/Makefile diff -u src/external/bsd/bind/lib/libdns/Makefile:1.13 src/external/bsd/bind/lib/libdns/Makefile:1.14 --- src/external/bsd/bind/lib/libdns/Makefile:1.13 Sat Mar 1 03:24:41 2014 +++ src/external/bsd/bind/lib/libdns/Makefile Mon May 15 13:38:34 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.13 2014/03/01 03:24:41 christos Exp $ +# $NetBSD: Makefile,v 1.14 2017/05/15 13:38:34 manu Exp $ LIB=dns #USE_SHLIBDIR= yes @@ -24,9 +24,13 @@ COPTS.${f}.c+= -Wno-pointer-sign -fno-s .endfor DNSSEC_SRCS= dst_api.c dst_lib.c dst_parse.c dst_result.c \ - gssapi_link.c gssapictx.c hmac_link.c key.c openssl_link.c \ + gssapictx.c hmac_link.c key.c openssl_link.c \ openssldh_link.c openssldsa_link.c opensslrsa_link.c \ - opensslecdsa_link.c opensslgost_link.c spnego.c + opensslecdsa_link.c opensslgost_link.c +.if ${MKKERBEROS} != "no" +DNSSEC_SRCS+= gssapi_link.c spnego.c +.endif + SRCS= acl.c acache.c adb.c byaddr.c cache.c callbacks.c clientinfo.c \ compress.c client.c tsec.c ecdb.c \
CVS commit: src/sys/compat/linux
Module Name:src Committed By: manu Date: Mon Jan 2 16:32:10 UTC 2017 Modified Files: src/sys/compat/linux/arch/alpha: syscalls.master src/sys/compat/linux/arch/amd64: syscalls.master src/sys/compat/linux/arch/arm: syscalls.master src/sys/compat/linux/arch/i386: syscalls.master src/sys/compat/linux/arch/m68k: syscalls.master src/sys/compat/linux/arch/mips: syscalls.master src/sys/compat/linux/arch/powerpc: syscalls.master src/sys/compat/linux/common: linux_misc.c linux_signal.h Log Message: Add pselect6 Linux system call. This lets Matlab R2016A run on NetBSD/amd64 To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 src/sys/compat/linux/arch/alpha/syscalls.master cvs rdiff -u -r1.57 -r1.58 src/sys/compat/linux/arch/amd64/syscalls.master cvs rdiff -u -r1.64 -r1.65 src/sys/compat/linux/arch/arm/syscalls.master cvs rdiff -u -r1.121 -r1.122 src/sys/compat/linux/arch/i386/syscalls.master cvs rdiff -u -r1.90 -r1.91 src/sys/compat/linux/arch/m68k/syscalls.master cvs rdiff -u -r1.60 -r1.61 src/sys/compat/linux/arch/mips/syscalls.master cvs rdiff -u -r1.69 -r1.70 src/sys/compat/linux/arch/powerpc/syscalls.master cvs rdiff -u -r1.233 -r1.234 src/sys/compat/linux/common/linux_misc.c cvs rdiff -u -r1.30 -r1.31 src/sys/compat/linux/common/linux_signal.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/linux/arch/alpha/syscalls.master diff -u src/sys/compat/linux/arch/alpha/syscalls.master:1.91 src/sys/compat/linux/arch/alpha/syscalls.master:1.92 --- src/sys/compat/linux/arch/alpha/syscalls.master:1.91 Sun Jul 24 13:22:01 2016 +++ src/sys/compat/linux/arch/alpha/syscalls.master Mon Jan 2 16:32:09 2017 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.91 2016/07/24 13:22:01 njoly Exp $ + $NetBSD: syscalls.master,v 1.92 2017/01/02 16:32:09 manu Exp $ ; ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -731,7 +731,10 @@ linux_umode_t mode); } 462 STD { int|linux_sys||faccessat(int fd, const char *path, \ int amode); } -463 UNIMPL pselect6 +463 STD { int|linux_sys||pselect6(int nfds, fd_set *readfds, \ + fd_set *writefds, fd_set *exceptfds, \ + struct linux_timespec *timeout, \ + linux_sized_sigset_t *ss); } 464 STD { int|linux_sys||ppoll(struct pollfd *fds, u_int nfds, \ struct linux_timespec *timeout, \ linux_sigset_t *sigset); } Index: src/sys/compat/linux/arch/amd64/syscalls.master diff -u src/sys/compat/linux/arch/amd64/syscalls.master:1.57 src/sys/compat/linux/arch/amd64/syscalls.master:1.58 --- src/sys/compat/linux/arch/amd64/syscalls.master:1.57 Sun Jul 24 13:22:01 2016 +++ src/sys/compat/linux/arch/amd64/syscalls.master Mon Jan 2 16:32:09 2017 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.57 2016/07/24 13:22:01 njoly Exp $ + $NetBSD: syscalls.master,v 1.58 2017/01/02 16:32:09 manu Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -489,7 +489,10 @@ linux_umode_t mode); } 269 STD { int|linux_sys||faccessat(int fd, const char *path, \ int amode); } -270 UNIMPL pselect6 +270 STD { int|linux_sys||pselect6(int nfds, fd_set *readfds, \ + fd_set *writefds, fd_set *exceptfds, \ + struct linux_timespec *timeout, \ + linux_sized_sigset_t *ss); } 271 STD { int|linux_sys||ppoll(struct pollfd *fds, u_int nfds, \ struct linux_timespec *timeout, \ linux_sigset_t *sigset); } Index: src/sys/compat/linux/arch/arm/syscalls.master diff -u src/sys/compat/linux/arch/arm/syscalls.master:1.64 src/sys/compat/linux/arch/arm/syscalls.master:1.65 --- src/sys/compat/linux/arch/arm/syscalls.master:1.64 Sun Jul 24 13:22:01 2016 +++ src/sys/compat/linux/arch/arm/syscalls.master Mon Jan 2 16:32:09 2017 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.64 2016/07/24 13:22:01 njoly Exp $ + $NetBSD: syscalls.master,v 1.65 2017/01/02 16:32:09 manu Exp $ ; Derived from sys/compat/linux/arch/*/syscalls.master ; and from Linux 2.4.12 arch/arm/kernel/calls.S @@ -530,7 +530,10 @@ linux_umode_t mode); } 334 STD { int|linux_sys||faccessat(int fd, const char *path, \ int amode); } -335 UNIMPL pselect6 +335 STD { int|linux_sys||pselect6(int nfds, fd_set *readfds, \ + fd_set *writefds, fd_set *exceptfds, \ + struct linux_timespec *timeout, \ + linux_sized_sigset_t *ss); } 336 STD { int|linux_sys||ppoll(struct pollfd *fds, u_int nfds, \ struct linux_timespec *timeout, \ linux_sigset_t *sigset); } Index: src/sys/compat/linux/arch/i386/syscalls.master diff -u src/sys/compat/linux/arch/i386/syscalls.master:1.121 src/sys/compat/linux/arch/i386/syscalls.master:1.122 --- src/sys/compat/linux/arch/i386/syscalls.master:1.121 Sun Jul 24 13:22:01 2016 +++ src/sys/compat/linux/arch/i386/syscalls.master Mon Jan 2 16:32:09 2017 @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.121 2016/07/24 13:22:01 njoly Exp $
CVS commit: src
Module Name:src Committed By: manu Date: Tue Oct 18 15:06:17 UTC 2016 Modified Files: src/lib/libperfuse: libperfuse.3 perfuse.c src/usr.sbin/perfused: msg.c perfused.8 Log Message: Make FUSE socket buffer tunable When dealing with high I/O throughput, we could run out of buffer space if the filesystem was not consuming requests fast enough. Here we slightly raise the buffer size, and we make it tunable through the PERFUSE_BUFSIZE environment variable so that we can cope with higher requirement later. While there, document PERFUSE_OPTIONS environment variable. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/lib/libperfuse/libperfuse.3 cvs rdiff -u -r1.37 -r1.38 src/lib/libperfuse/perfuse.c cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/perfused/msg.c cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/perfused/perfused.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/libperfuse.3 diff -u src/lib/libperfuse/libperfuse.3:1.3 src/lib/libperfuse/libperfuse.3:1.4 --- src/lib/libperfuse/libperfuse.3:1.3 Tue May 10 12:14:37 2011 +++ src/lib/libperfuse/libperfuse.3 Tue Oct 18 15:06:17 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: libperfuse.3,v 1.3 2011/05/10 12:14:37 njoly Exp $ +.\" $NetBSD: libperfuse.3,v 1.4 2016/10/18 15:06:17 manu Exp $ .\" .\" Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved. .\" @@ -100,6 +100,21 @@ is different than .Fn perfuse_open handles control to the regular .Xr open 2 . +.Sh ENVIRONMENT +.Bl -tag -width Er +.It Ev PERFUSE_OPTIONS +Comma-separated values controlling the usage of some FUSE methods. Allowed +values are +.Li enable_access , +.Li disable_access , +.Li enable_creat , +.Li disable_creat . +.It Ev PERFUSE_BUFSIZE +Set the socket buffer sizes used for communication with the filesystem. +This should be raised as operation throughput requires it. Default is +.Li 2162688 +bytes, which is enough to queue 16 FUSE packets of maximum 132 kB length. +.El .Sh RETURN VALUES .Fn perfuse_mount returns a file descriptor to the Index: src/lib/libperfuse/perfuse.c diff -u src/lib/libperfuse/perfuse.c:1.37 src/lib/libperfuse/perfuse.c:1.38 --- src/lib/libperfuse/perfuse.c:1.37 Fri Jun 19 17:33:20 2015 +++ src/lib/libperfuse/perfuse.c Tue Oct 18 15:06:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: perfuse.c,v 1.37 2015/06/19 17:33:20 christos Exp $ */ +/* $NetBSD: perfuse.c,v 1.38 2016/10/18 15:06:17 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -51,6 +51,7 @@ extern char **environ; static struct perfuse_state *init_state(void); static int get_fd(const char *); +static uint32_t bufvar_from_env(const char *, const uint32_t); static struct perfuse_state * @@ -146,6 +147,35 @@ get_fd(const char *data) } +static uint32_t +bufvar_from_env(name, defval) + const char *name; + const uint32_t defval; +{ + char valstr[1024]; + uint32_t retval = defval; + + if (getenv_r(name, valstr, sizeof(valstr)) != -1) { + long int val; + char *ep; + + errno = 0; + val = (int)strtol(valstr, , 10); + if (*valstr == '\0' || *ep != '\0') + DWARNX("bad %s value \"%s\"", name, valstr); + else if (errno != 0) + DWARN("bad %s value \"%s\"", name, valstr); + else if (val <= 0L || + (unsigned long int)val > (unsigned long int)UINT32_MAX) + DWARNX("%s value %ld out of " + "uint32_t bounds", name, val); + else + retval = val; + } + + return retval; +} + int perfuse_open(const char *path, int flags, mode_t mode) { @@ -180,10 +210,10 @@ perfuse_open(const char *path, int flags } /* - * Set a buffer lentgh large enough so that any FUSE packet + * Set a buffer lentgh large enough so that enough FUSE packets * will fit. */ - opt = (uint32_t)FUSE_BUFSIZE; + opt = bufvar_from_env("PERFUSE_BUFSIZE", 16 * FUSE_BUFSIZE); optlen = sizeof(opt); if (setsockopt(sv[0], SOL_SOCKET, SO_SNDBUF, , optlen) != 0) DWARN("%s: setsockopt SO_SNDBUF to %d failed", __func__, opt); @@ -211,10 +241,10 @@ perfuse_open(const char *path, int flags } /* - * Set a buffer lentgh large enough so that any FUSE packet + * Set a buffer lentgh large enough so that enough FUSE packets * will fit. */ - opt = (uint32_t)(4 * FUSE_BUFSIZE); + opt = bufvar_from_env("PERFUSE_BUFSIZE", 16 * FUSE_BUFSIZE); optlen = sizeof(opt); if (setsockopt(sv[0], SOL_SOCKET, SO_SNDBUF, , optlen) != 0) DWARN("%s: setsockopt SO_SNDBUF to %d failed", __func__, opt); Index: src/usr.sbin/perfused/msg.c diff -u src/usr.sbin/perfused/msg.c:1.22 src/usr.sbin/perfused/msg.c:1.23 --- src/usr.sbin/perfused/msg.c:1.22 Sat Aug 16 16:32:04 2014 +++ src/usr.sbin/perfused/msg.c Tue Oct 18 15:06:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: msg.c,v 1.22 2014/08/16 16:32:04 manu Exp $ */ +/* $NetBSD: ms
CVS commit: src/sys/kern
Module Name:src Committed By: manu Date: Sun Aug 2 03:29:22 UTC 2015 Modified Files: src/sys/kern: vfs_mount.c Log Message: Do not VFS_SYNC before VFS_UNMOUNT on force unmount VFS_SYNC does not consider whether we are performing a force unmount or not, and therefore it can wait for a while if the filesytstem is misbehaving. Removing VFS_SYNC before VFS_UNMOUNT on forced unmount fixes the problem. This should not cause harm as the VFS_SYNC seems just useless. As noted by Chuck Silvers in http://mail-index.netbsd.org/tech-kern/2015/07/13/msg019156.html - Nothing seems to prevent vnodes from getting dirty again after VFS_SYNC call. - Filesystems do flush data through vflush() in VFS_UNMOUNT anyway. As a consequence, the VFS_SYNC call in do_unmount() could probably be completely removed. But since such a change is quite dangerous, we just remove it in the case of forced unmounts, which are situations where the risk of data loss is known to the operator. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/kern/vfs_mount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.35 src/sys/kern/vfs_mount.c:1.36 --- src/sys/kern/vfs_mount.c:1.35 Wed May 6 15:57:08 2015 +++ src/sys/kern/vfs_mount.c Sun Aug 2 03:29:22 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.35 2015/05/06 15:57:08 hannken Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.36 2015/08/02 03:29:22 manu Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_mount.c,v 1.35 2015/05/06 15:57:08 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_mount.c,v 1.36 2015/08/02 03:29:22 manu Exp $); #define _VFS_VNODE_PRIVATE @@ -824,7 +824,7 @@ dounmount(struct mount *mp, int flags, s if (used_syncer) vfs_syncer_remove_from_worklist(mp); error = 0; - if ((mp-mnt_flag MNT_RDONLY) == 0) { + if (((mp-mnt_flag MNT_RDONLY) == 0) ((flags MNT_FORCE) == 0)) { error = VFS_SYNC(mp, MNT_WAIT, l-l_cred); } if (error == 0 || (flags MNT_FORCE)) {
CVS commit: src/sys/nfs
Module Name:src Committed By: manu Date: Wed Jul 15 03:28:55 UTC 2015 Modified Files: src/sys/nfs: nfs_bio.c nfs_clntsocket.c nfs_iod.c nfs_socket.c nfs_var.h nfs_vfsops.c nfsmount.h Log Message: Fix soft NFS force unmount For many reasons, forcibly unmounting a soft NFS mount could hang forever. Here are the fixes: - Introduce decents timeouts in operation that awaited NFS server reply. - On timeout, fails operations on soft mounts with EIO. - Introduce NFSMNT_DISMNTFORCE to let the filesystem know that a force unmount is ongoing. This causes timeouts to be reduced and prevents the NFS client to attempt reconnecting to the NFS server. Also fix a race condition where some asynchronous I/O could reference destroyed mount structures. We fix this by awaiting asynchronous I/O to drain before proceeding. Reviewed by Chuck Silvers. To generate a diff of this commit: cvs rdiff -u -r1.190 -r1.191 src/sys/nfs/nfs_bio.c cvs rdiff -u -r1.2 -r1.3 src/sys/nfs/nfs_clntsocket.c cvs rdiff -u -r1.6 -r1.7 src/sys/nfs/nfs_iod.c cvs rdiff -u -r1.196 -r1.197 src/sys/nfs/nfs_socket.c cvs rdiff -u -r1.93 -r1.94 src/sys/nfs/nfs_var.h cvs rdiff -u -r1.229 -r1.230 src/sys/nfs/nfs_vfsops.c cvs rdiff -u -r1.52 -r1.53 src/sys/nfs/nfsmount.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/nfs/nfs_bio.c diff -u src/sys/nfs/nfs_bio.c:1.190 src/sys/nfs/nfs_bio.c:1.191 --- src/sys/nfs/nfs_bio.c:1.190 Fri Sep 5 05:34:57 2014 +++ src/sys/nfs/nfs_bio.c Wed Jul 15 03:28:55 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_bio.c,v 1.190 2014/09/05 05:34:57 matt Exp $ */ +/* $NetBSD: nfs_bio.c,v 1.191 2015/07/15 03:28:55 manu Exp $ */ /* * Copyright (c) 1989, 1993 @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.190 2014/09/05 05:34:57 matt Exp $); +__KERNEL_RCSID(0, $NetBSD: nfs_bio.c,v 1.191 2015/07/15 03:28:55 manu Exp $); #ifdef _KERNEL_OPT #include opt_nfs.h @@ -624,7 +624,10 @@ nfs_vinvalbuf(struct vnode *vp, int flag slptimeo = 2 * hz; } else { catch_p = false; - slptimeo = 0; + if (nmp-nm_flag NFSMNT_SOFT) + slptimeo = nmp-nm_retry * nmp-nm_timeo; + else + slptimeo = 0; } /* * First wait for any other process doing a flush to complete. @@ -743,6 +746,13 @@ nfs_asyncio(struct buf *bp) return (EIO); nmp = VFSTONFS(bp-b_vp-v_mount); + + if (nmp-nm_flag NFSMNT_SOFT) + slptimeo = nmp-nm_retry * nmp-nm_timeo; + + if (nmp-nm_iflag NFSMNT_DISMNTFORCE) + slptimeo = hz; + again: if (nmp-nm_flag NFSMNT_INT) catch_p = true; @@ -804,6 +814,13 @@ again: nmp-nm_lock, slptimeo); } if (error) { +if (error == EWOULDBLOCK +nmp-nm_flag NFSMNT_SOFT) { + mutex_exit(nmp-nm_lock); + bp-b_error = EIO; + return (EIO); +} + if (nfs_sigintr(nmp, NULL, curlwp)) { mutex_exit(nmp-nm_lock); return (EINTR); Index: src/sys/nfs/nfs_clntsocket.c diff -u src/sys/nfs/nfs_clntsocket.c:1.2 src/sys/nfs/nfs_clntsocket.c:1.3 --- src/sys/nfs/nfs_clntsocket.c:1.2 Fri Sep 5 05:34:57 2014 +++ src/sys/nfs/nfs_clntsocket.c Wed Jul 15 03:28:55 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_clntsocket.c,v 1.2 2014/09/05 05:34:57 matt Exp $ */ +/* $NetBSD: nfs_clntsocket.c,v 1.3 2015/07/15 03:28:55 manu Exp $ */ /* * Copyright (c) 1989, 1991, 1993, 1995 @@ -39,7 +39,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: nfs_clntsocket.c,v 1.2 2014/09/05 05:34:57 matt Exp $); +__KERNEL_RCSID(0, $NetBSD: nfs_clntsocket.c,v 1.3 2015/07/15 03:28:55 manu Exp $); #ifdef _KERNEL_OPT #include opt_nfs.h @@ -967,6 +967,12 @@ nfs_sndlock(struct nfsmount *nmp, struct bool catch_p = false; int error = 0; + if (nmp-nm_flag NFSMNT_SOFT) + timeo = nmp-nm_retry * nmp-nm_timeo; + + if (nmp-nm_iflag NFSMNT_DISMNTFORCE) + timeo = hz; + if (rep) { l = rep-r_lwp; if (rep-r_nmp-nm_flag NFSMNT_INT) @@ -980,9 +986,20 @@ nfs_sndlock(struct nfsmount *nmp, struct goto quit; } if (catch_p) { - cv_timedwait_sig(nmp-nm_sndcv, nmp-nm_lock, timeo); + error = cv_timedwait_sig(nmp-nm_sndcv, + nmp-nm_lock, timeo); } else { - cv_timedwait(nmp-nm_sndcv, nmp-nm_lock, timeo); + error = cv_timedwait(nmp-nm_sndcv, + nmp-nm_lock, timeo); + } + + if (error) { + if ((error == EWOULDBLOCK) + (nmp-nm_flag NFSMNT_SOFT)) { +error = EIO; +goto quit; + } + error = 0; } if (catch_p) { catch_p = false; Index: src/sys/nfs/nfs_iod.c diff -u src/sys/nfs/nfs_iod.c:1.6 src/sys/nfs/nfs_iod.c:1.7 --- src/sys/nfs/nfs_iod.c:1.6 Fri Oct 25 16:01:56 2013 +++ src/sys/nfs/nfs_iod.c Wed Jul 15 03:28:55 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: nfs_iod.c,v 1.6 2013/10/25 16:01:56 martin Exp $ */ +/* $NetBSD: nfs_iod.c,v 1.7 2015/07/15 03:28:55 manu Exp $ */ /* * Copyright (c) 1989, 1993 @@ -35,7 +35,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: nfs_iod.c,v 1.6
CVS commit: src/sbin/umount
Module Name:src Committed By: manu Date: Sat Jun 27 08:29:56 UTC 2015 Modified Files: src/sbin/umount: umount.c Log Message: Remove useless and harmful sync(2) call in umount(8) Remove sync(2) call before unmount(2) in umount(8). This sync(2) is useless since unmount(2) will perform a VFS_SYNC anyway. But moreover, this sync(2) may be harmful, as there are some situation where it cannot return (unreachable NFS server, for instance), causing umount -f to be uneffective. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/sbin/umount/umount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/umount/umount.c diff -u src/sbin/umount/umount.c:1.47 src/sbin/umount/umount.c:1.48 --- src/sbin/umount/umount.c:1.47 Tue Jul 2 01:39:17 2013 +++ src/sbin/umount/umount.c Sat Jun 27 08:29:56 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: umount.c,v 1.47 2013/07/02 01:39:17 christos Exp $ */ +/* $NetBSD: umount.c,v 1.48 2015/06/27 08:29:56 manu Exp $ */ /*- * Copyright (c) 1980, 1989, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = @(#)umount.c 8.8 (Berkeley) 5/8/95; #else -__RCSID($NetBSD: umount.c,v 1.47 2013/07/02 01:39:17 christos Exp $); +__RCSID($NetBSD: umount.c,v 1.48 2015/06/27 08:29:56 manu Exp $); #endif #endif /* not lint */ @@ -96,9 +96,6 @@ main(int argc, char *argv[]) #endif /* SMALL */ const char **typelist = NULL; - /* Start disks transferring immediately. */ - sync(); - #ifdef SMALL #define OPTS fR #else
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Wed Jun 3 14:07:06 UTC 2015 Modified Files: src/lib/libperfuse: ops.c Log Message: Fix dot-lookup when readdir does not provide inodes Some filesystems do not provide inode numbers through readdir (FUSE mounts without -o use_ino). We therefore have to lookup each directory entry to get the missing numbers. dot and double-dot are exceptions, as we already know the values. Moreover, the lookup code does not expect to get requests for dot and will abort perfused(8) when it gets some. In order to fix that, we just check for dot and double-dot special case and use the known values instead of sending a lookup. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.83 src/lib/libperfuse/ops.c:1.84 --- src/lib/libperfuse/ops.c:1.83 Sun Feb 15 20:21:29 2015 +++ src/lib/libperfuse/ops.c Wed Jun 3 14:07:05 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.83 2015/02/15 20:21:29 manu Exp $ */ +/* $NetBSD: ops.c,v 1.84 2015/06/03 14:07:05 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -651,13 +651,17 @@ fuse_to_dirent(struct puffs_usermount *p struct puffs_node *pn; struct perfuse_node_data *pnd = PERFUSE_NODE_DATA(opc); - /* - * Avoid breaking out of fs - * by lookup to .. on root - */ - if ((strcmp(name, ..) == 0) - (pnd-pnd_nodeid == FUSE_ROOT_ID)) { -fd-ino = FUSE_ROOT_ID; + if (strcmp(name, ..) == 0) { +/* + * Avoid breaking out of fs + * by lookup to .. on root + */ +if (pnd-pnd_nodeid == FUSE_ROOT_ID) + fd-ino = FUSE_ROOT_ID; +else + fd-ino = pnd-pnd_parent_nodeid; + } else if (strcmp(name, .) == 0 ) { +fd-ino = pnd-pnd_nodeid; } else { int error;
CVS commit: src
Module Name:src Committed By: manu Date: Fri May 29 07:37:32 UTC 2015 Modified Files: src/include: limits.h src/lib/libpthread: pthread.c pthread_int.h pthread_key_create.3 pthread_tsd.c src/lib/libpthread_dbg: pthread_dbg.c Log Message: Make PTHREAD_KEYS_MAX dynamically adjustable NetBSD's PTHREAD_KEYS_MAX is set to 256, which is low compared to other systems like Linux (1024) or MacOS X (512). As a result some setups tested on Linux will exhibit problems on NetBSD because of pthread_keys usage beyond the limit. This happens for instance on Apache with various module loaded, and in this case no particular developper can be blamed for going beyond the limit, since several modules from different sources contribute to the problem. This patch makes the limit conigurable through the PTHREAD_KEYS_MAX environement variable. If undefined, the default remains unchanged (256). In any case, the value cannot be lowered below POSIX-mandated _POSIX_THREAD_KEYS_MAX (128). While there: - use EXIT_FAILURE instead of 1 when calling err(3) in libpthread. - Reset _POSIX_THREAD_KEYS_MAX to POSIX mandated 128, instead of 256. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/include/limits.h cvs rdiff -u -r1.145 -r1.146 src/lib/libpthread/pthread.c cvs rdiff -u -r1.90 -r1.91 src/lib/libpthread/pthread_int.h cvs rdiff -u -r1.6 -r1.7 src/lib/libpthread/pthread_key_create.3 cvs rdiff -u -r1.11 -r1.12 src/lib/libpthread/pthread_tsd.c cvs rdiff -u -r1.42 -r1.43 src/lib/libpthread_dbg/pthread_dbg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/include/limits.h diff -u src/include/limits.h:1.33 src/include/limits.h:1.34 --- src/include/limits.h:1.33 Sun Nov 18 17:41:53 2012 +++ src/include/limits.h Fri May 29 07:37:31 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: limits.h,v 1.33 2012/11/18 17:41:53 manu Exp $ */ +/* $NetBSD: limits.h,v 1.34 2015/05/29 07:37:31 manu Exp $ */ /* * Copyright (c) 1988, 1993 @@ -75,18 +75,20 @@ */ /* - * The following 3 are not part of the standard - * but left here for compatibility + * The following 3 are defined in + * Open Group Base Specifications Issue 7 */ #define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 -#define _POSIX_THREAD_KEYS_MAX 256 +#define _POSIX_THREAD_KEYS_MAX 128 #define _POSIX_THREAD_THREADS_MAX 64 /* * These are the correct names, defined in terms of the above + * except for PTHREAD_KEYS_MAX which is bigger than standard + * mandated minimum value _POSIX_THREAD_KEYS_MAX. */ #define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS -#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX +#define PTHREAD_KEYS_MAX 256 /* Not yet: PTHREAD_STACK_MIN */ #define PTHREAD_THREADS_MAX _POSIX_THREAD_THREADS_MAX Index: src/lib/libpthread/pthread.c diff -u src/lib/libpthread/pthread.c:1.145 src/lib/libpthread/pthread.c:1.146 --- src/lib/libpthread/pthread.c:1.145 Tue Dec 16 20:05:54 2014 +++ src/lib/libpthread/pthread.c Fri May 29 07:37:31 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: pthread.c,v 1.145 2014/12/16 20:05:54 pooka Exp $ */ +/* $NetBSD: pthread.c,v 1.146 2015/05/29 07:37:31 manu Exp $ */ /*- * Copyright (c) 2001, 2002, 2003, 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__RCSID($NetBSD: pthread.c,v 1.145 2014/12/16 20:05:54 pooka Exp $); +__RCSID($NetBSD: pthread.c,v 1.146 2015/05/29 07:37:31 manu Exp $); #define __EXPOSE_STACK 1 @@ -116,7 +116,8 @@ int pthread__dbg; /* set by libpthread_d */ size_t pthread__stacksize; size_t pthread__pagesize; -static struct __pthread_st pthread__main; +static struct __pthread_st *pthread__main; +static size_t __pthread_st_size; int _sys___sigprocmask14(int, const sigset_t *, sigset_t *); @@ -165,6 +166,22 @@ pthread__init(void) int i; extern int __isthreaded; + /* + * Allocate pthread_keys descriptors before + * reseting __uselibcstub because otherwise + * malloc() will call pthread_keys_create() + * while pthread_keys descriptors are not + * yet allocated. + */ + if (pthread_tsd_init() != 0) + err(EXIT_FAILURE, Cannot allocate pthread_keys descriptors); + + __pthread_st_size = sizeof(*pthread__main) + + pthread_keys_max * sizeof(pthread__main-pt_specific[0]); + + if ((pthread__main = calloc(1, __pthread_st_size)) == NULL) + err(EXIT_FAILURE, Cannot allocate pthread__specific); + __uselibcstub = 0; pthread__pagesize = (size_t)sysconf(_SC_PAGESIZE); @@ -179,7 +196,7 @@ pthread__init(void) /* Fetch parameters. */ i = (int)_lwp_unpark_all(NULL, 0, NULL); if (i == -1) - err(1, _lwp_unpark_all); + err(EXIT_FAILURE, _lwp_unpark_all); if (i pthread__unpark_max) pthread__unpark_max = i; @@ -200,7 +217,7 @@ pthread__init(void) (void)rb_tree_insert_node(pthread__alltree, first); if (_lwp_ctl(LWPCTL_FEATURE_CURCPU, first-pt_lwpctl) != 0) { - err(1, _lwp_ctl); +
CVS commit: src/sbin/raidctl
Module Name:src Committed By: manu Date: Wed May 27 15:31:15 UTC 2015 Modified Files: src/sbin/raidctl: raidctl.c Log Message: Better sanity check numbers given to raidctl(8) Replace atoi(3) by strtol(3), and check that numbers are valid, positive, and in int32_t range. The previous lack of check could silently lead to the same serial being set to all RAID volumes for instance because given numbers were bigger than INT_MAX. The consequence is in an awful mess when RAIDframe would mix volumes... To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/sbin/raidctl/raidctl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/raidctl/raidctl.c diff -u src/sbin/raidctl/raidctl.c:1.57 src/sbin/raidctl/raidctl.c:1.58 --- src/sbin/raidctl/raidctl.c:1.57 Thu Apr 3 18:54:10 2014 +++ src/sbin/raidctl/raidctl.c Wed May 27 15:31:15 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: raidctl.c,v 1.57 2014/04/03 18:54:10 christos Exp $ */ +/* $NetBSD: raidctl.c,v 1.58 2015/05/27 15:31:15 manu Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ #include sys/cdefs.h #ifndef lint -__RCSID($NetBSD: raidctl.c,v 1.57 2014/04/03 18:54:10 christos Exp $); +__RCSID($NetBSD: raidctl.c,v 1.58 2015/05/27 15:31:15 manu Exp $); #endif @@ -85,6 +85,7 @@ static void get_bar(char *, double, int static void get_time_string(char *, int); static void rf_output_pmstat(int, int); static void rf_pm_configure(int, int, char *, int[]); +static unsigned int _strtoud(char *); int verbose; @@ -183,7 +184,7 @@ main(int argc,char *argv[]) break; case 'I': action = RAIDFRAME_INIT_LABELS; - serial_number = atoi(optarg); + serial_number = _strtoud(optarg); num_options++; break; case 'm': @@ -195,11 +196,11 @@ main(int argc,char *argv[]) action = RAIDFRAME_PARITYMAP_SET_DISABLE; parityconf = strdup(optarg); num_options++; - /* XXXjld: should rf_pm_configure do the atoi()s? */ + /* XXXjld: should rf_pm_configure do the strtol()s? */ i = 0; while (i 3 optind argc isdigit((int)argv[optind][0])) -parityparams[i++] = atoi(argv[optind++]); +parityparams[i++] = _strtoud(argv[optind++]); while (i 3) parityparams[i++] = 0; break; @@ -1158,3 +1159,26 @@ usage(void) exit(1); /* NOTREACHED */ } + +static unsigned int +_strtoud(char *str) +{ + long num; + char *ep; + + errno = 0; + num = strtol(str, ep, 10); + if (str[0] == '\0' || *ep != '\0') + errx(1, Not a number: %s, str); + + if (errno) + err(1, Inavlid number %s, str); + + if (num 0) + errx(1, Negative number: %s, str); + + if (num INT_MAX) + errx(1, Number too large: %s, str); + + return (unsigned int)num; +}
CVS commit: src/usr.bin/make
Module Name:src Committed By: manu Date: Mon May 25 09:01:06 UTC 2015 Modified Files: src/usr.bin/make: targ.c Log Message: Fix warning about uninitialized variable This warning gets fatal when including make(1) as a crunchgen(1) binary. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/usr.bin/make/targ.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/targ.c diff -u src/usr.bin/make/targ.c:1.59 src/usr.bin/make/targ.c:1.60 --- src/usr.bin/make/targ.c:1.59 Sun Sep 7 20:55:34 2014 +++ src/usr.bin/make/targ.c Mon May 25 09:01:06 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: targ.c,v 1.59 2014/09/07 20:55:34 joerg Exp $ */ +/* $NetBSD: targ.c,v 1.60 2015/05/25 09:01:06 manu Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = $NetBSD: targ.c,v 1.59 2014/09/07 20:55:34 joerg Exp $; +static char rcsid[] = $NetBSD: targ.c,v 1.60 2015/05/25 09:01:06 manu Exp $; #else #include sys/cdefs.h #ifndef lint #if 0 static char sccsid[] = @(#)targ.c 8.2 (Berkeley) 3/19/94; #else -__RCSID($NetBSD: targ.c,v 1.59 2014/09/07 20:55:34 joerg Exp $); +__RCSID($NetBSD: targ.c,v 1.60 2015/05/25 09:01:06 manu Exp $); #endif #endif /* not lint */ #endif @@ -334,7 +334,7 @@ GNode * Targ_FindNode(const char *name, int flags) { GNode *gn; /* node in that element */ -Hash_Entry *he; /* New or used hash entry for node */ +Hash_Entry *he = NULL; /* New or used hash entry for node */ Boolean isNew; /* Set TRUE if Hash_CreateEntry had to create */ /* an entry for the node */
CVS commit: src/usr.bin/netstat
Module Name:src Committed By: manu Date: Mon May 25 03:56:20 UTC 2015 Modified Files: src/usr.bin/netstat: route.c Log Message: Make sure netstat builds with -DSMALL src/usr.bin/netstat relies on code from src/sbin/route. WHen building with -DSMALL, some functions such as mpls_ntoa() or p_rtrmx() are not built in src/sbin/route. We therefore have to make sure they are not used in src/usr.bin/netstat. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/usr.bin/netstat/route.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/netstat/route.c diff -u src/usr.bin/netstat/route.c:1.83 src/usr.bin/netstat/route.c:1.84 --- src/usr.bin/netstat/route.c:1.83 Thu Nov 6 21:30:09 2014 +++ src/usr.bin/netstat/route.c Mon May 25 03:56:20 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: route.c,v 1.83 2014/11/06 21:30:09 christos Exp $ */ +/* $NetBSD: route.c,v 1.84 2015/05/25 03:56:20 manu Exp $ */ /* * Copyright (c) 1983, 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = from: @(#)route.c 8.3 (Berkeley) 3/9/94; #else -__RCSID($NetBSD: route.c,v 1.83 2014/11/06 21:30:09 christos Exp $); +__RCSID($NetBSD: route.c,v 1.84 2015/05/25 03:56:20 manu Exp $); #endif #endif /* not lint */ @@ -262,6 +262,7 @@ p_krtentry(struct rtentry *rt) printf(%6s, -); putchar((rt-rt_rmx.rmx_locks RTV_MTU) ? 'L' : ' '); if (tagflag == 1) { +#ifndef SMALL if (rt-rt_tag != NULL) { const struct sockaddr *tagsa = kgetsa(rt-rt_tag); char *tagstr; @@ -276,6 +277,7 @@ p_krtentry(struct rtentry *rt) else printf(%7s, -); } else +#endif printf(%7s, -); } if (rt-rt_ifp) { @@ -287,8 +289,10 @@ p_krtentry(struct rtentry *rt) rt-rt_nodes[0].rn_dupedkey ? = : ); } putchar('\n'); +#ifndef SMALL if (vflag) p_rtrmx(rt-rt_rmx); +#endif } /*
CVS commit: src/bin/dd
Module Name:src Committed By: manu Date: Wed Mar 18 13:23:49 UTC 2015 Modified Files: src/bin/dd: Makefile args.c dd.1 dd.c dd.h extern.h Log Message: Add iflag and oflag operands to dd(1) Like GNU dd(1) similar operands, iflag and oflag allow specifying the O_* flags given to open(2) for the input and the output file. The values are comma-sepratated, lower-case, O_ prefix-stripped constants documented in open(2). Since iflag and oflag override default values, specifying oflag means O_CREATE is not set by default and must be specified explicitely. Some values do not make sense (e.g.: iflag=directory) but are still used and will raise a warning. For oflag, values rdonly, rdwr and wronly are filtered out with a warning (dd(1) attempts open(2) with O_RDWR and then O_WRONLY on failure). Specifying oflag=trunc along with (seek, oseek or conv=notrunc) is contradictory and will raise an error. iflag and oflag are disabled if building with -DMALLPROG To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/bin/dd/Makefile cvs rdiff -u -r1.38 -r1.39 src/bin/dd/args.c cvs rdiff -u -r1.25 -r1.26 src/bin/dd/dd.1 cvs rdiff -u -r1.49 -r1.50 src/bin/dd/dd.c cvs rdiff -u -r1.15 -r1.16 src/bin/dd/dd.h cvs rdiff -u -r1.22 -r1.23 src/bin/dd/extern.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/dd/Makefile diff -u src/bin/dd/Makefile:1.17 src/bin/dd/Makefile:1.18 --- src/bin/dd/Makefile:1.17 Wed Aug 8 14:09:14 2012 +++ src/bin/dd/Makefile Wed Mar 18 13:23:49 2015 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.17 2012/08/08 14:09:14 christos Exp $ +# $NetBSD: Makefile,v 1.18 2015/03/18 13:23:49 manu Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 .include bsd.own.mk @@ -10,8 +10,9 @@ DPADD+= ${LIBUTIL} LDADD+= -lutil .ifdef SMALLPROG -CPPFLAGS+= -DNO_CONV -DNO_MSGFMT -DSMALL +CPPFLAGS+= -DNO_CONV -DNO_MSGFMT -DNO_IOFLAG -DSMALL .else +CPPFLAGS+= -D_NETBSD_SOURCE -D_INCOMPLETE_XOPEN_C063 SRCS+= conv_tab.c .ifdef CRUNCHEDPROG CPPFLAGS+= -DSMALL Index: src/bin/dd/args.c diff -u src/bin/dd/args.c:1.38 src/bin/dd/args.c:1.39 --- src/bin/dd/args.c:1.38 Wed Jul 17 12:55:48 2013 +++ src/bin/dd/args.c Wed Mar 18 13:23:49 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: args.c,v 1.38 2013/07/17 12:55:48 christos Exp $ */ +/* $NetBSD: args.c,v 1.39 2015/03/18 13:23:49 manu Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -38,13 +38,16 @@ #if 0 static char sccsid[] = @(#)args.c 8.3 (Berkeley) 4/2/94; #else -__RCSID($NetBSD: args.c,v 1.38 2013/07/17 12:55:48 christos Exp $); +__RCSID($NetBSD: args.c,v 1.39 2015/03/18 13:23:49 manu Exp $); #endif #endif /* not lint */ #include sys/types.h #include sys/time.h +#ifndef NO_IOFLAG +#include fcntl.h +#endif /* NO_IOFLAG */ #include err.h #include errno.h #include limits.h @@ -70,6 +73,16 @@ static void f_conv(char *); static int c_conv(const void *, const void *); #endif /* NO_CONV */ +#ifdef NO_IOFLAG +static void f_iflag(char *) __dead; +static void f_oflag(char *) __dead; +#else +static void f_iflag(char *); +static void f_oflag(char *); +static u_int f_ioflag(char *, u_int); +static int c_ioflag(const void *, const void *); +#endif /* NO_IOFLAG */ + static void f_bs(char *); static void f_cbs(char *); static void f_count(char *); @@ -96,10 +109,12 @@ static const struct arg { { files, f_files, C_FILES, C_FILES }, { ibs, f_ibs, C_IBS, C_BS|C_IBS }, { if, f_if, C_IF, C_IF }, + { iflag, f_iflag, C_IFLAG, C_IFLAG }, { iseek, f_skip, C_SKIP, C_SKIP }, { msgfmt, f_msgfmt, 0, 0 }, { obs, f_obs, C_OBS, C_BS|C_OBS }, { of, f_of, C_OF, C_OF }, + { oflag, f_oflag, C_OFLAG, C_OFLAG }, { oseek, f_seek, C_SEEK, C_SEEK }, { progress, f_progress, 0, 0 }, { seek, f_seek, C_SEEK, C_SEEK }, @@ -389,3 +404,102 @@ c_conv(const void *a, const void *b) } #endif /* NO_CONV */ + +static void +f_iflag(char *arg) +{ +/* Build a small version (i.e. for a ramdisk root) */ +#ifdef NO_IOFLAG + errx(EXIT_FAILURE, iflag option disabled); + /* NOTREACHED */ +#else + iflag = f_ioflag(arg, C_IFLAG); + return; +#endif +} + +static void +f_oflag(char *arg) +{ +/* Build a small version (i.e. for a ramdisk root) */ +#ifdef NO_IOFLAG + errx(EXIT_FAILURE, oflag option disabled); + /* NOTREACHED */ +#else + oflag = f_ioflag(arg, C_OFLAG); + return; +#endif +} + +#ifndef NO_IOFLAG +static const struct ioflag { + const char *name; + u_int set; + u_int allowed; +} olist[] = { + /* the array needs to be sorted by the first column so + bsearch() can be used to find commands quickly */ + { alt_io, O_ALT_IO, C_IFLAG|C_OFLAG }, + { append, O_APPEND, C_OFLAG }, + { async, O_ASYNC, C_IFLAG|C_OFLAG }, + { cloexec, O_CLOEXEC, C_IFLAG|C_OFLAG }, + { creat, O_CREAT, C_OFLAG }, + { direct, O_DIRECT, C_IFLAG|C_OFLAG }, + { directory, O_DIRECTORY, C_NONE }, + { dsync, O_DSYNC, C_OFLAG }, + { excl, O_EXCL, C_IFLAG|C_OFLAG }, + { exlock,
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Wed Feb 25 14:08:45 UTC 2015 Modified Files: src/sys/fs/puffs: puffs_vnops.c Log Message: Update file size after write without metadata flush If we do not use metadata flush, we must make sure the size is updated in the filesystem after a write, otherwise the next GETATTR will get us a stale value and the file will be truncated. To generate a diff of this commit: cvs rdiff -u -r1.200 -r1.201 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.200 src/sys/fs/puffs/puffs_vnops.c:1.201 --- src/sys/fs/puffs/puffs_vnops.c:1.200 Sun Feb 15 20:21:29 2015 +++ src/sys/fs/puffs/puffs_vnops.c Wed Feb 25 14:08:45 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.200 2015/02/15 20:21:29 manu Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.201 2015/02/25 14:08:45 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.200 2015/02/15 20:21:29 manu Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.201 2015/02/25 14:08:45 manu Exp $); #include sys/param.h #include sys/buf.h @@ -2551,6 +2551,23 @@ puffs_vnop_write(void *v) uflags |= PUFFS_UPDATEMTIME; puffs_updatenode(VPTOPP(vp), uflags, vp-v_size); + /* + * If we do not use meta flush, we need to update the + * filesystem now, otherwise we will get a stale value + * on the next GETATTR + */ + if (!PUFFS_USE_METAFLUSH(pmp) (uflags PUFFS_UPDATESIZE)) { + struct vattr va; + int ret; + + vattr_null(va); + va.va_size = vp-v_size; + ret = dosetattr(vp, va, FSCRED, 0); + if (ret) { + DPRINTF((dosetattr set size to %lld failed: %d\n, + vp-v_size, ret)); + } + } mutex_exit(pn-pn_sizemtx); return error; }
CVS commit: src
Module Name:src Committed By: manu Date: Sun Feb 15 20:21:29 UTC 2015 Modified Files: src/lib/libperfuse: ops.c perfuse.c src/lib/libpuffs: puffs.3 src/sys/fs/puffs: puffs_msgif.h puffs_sys.h puffs_vfsops.c puffs_vnops.c Log Message: Add PUFFS_KFLAG_NOFLUSH_META to prevent sending metadata flush to FUSE FUSE filesystems do not expect to get metadata updates for [amc]time and size, they updates the value on their own after operations. The PUFFS PUFFS_KFLAG_NOFLUSH_META option prevents regular metadata cache flushes to the filesystem , and libperfuse uses it to match Linux FUSE behavior. While there, fix a bug in SETATTR: do not update kernel metadata cache from SETATTR reply when the request is asynchronous, as we do not have the reply yet. To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/lib/libperfuse/ops.c cvs rdiff -u -r1.35 -r1.36 src/lib/libperfuse/perfuse.c cvs rdiff -u -r1.59 -r1.60 src/lib/libpuffs/puffs.3 cvs rdiff -u -r1.83 -r1.84 src/sys/fs/puffs/puffs_msgif.h cvs rdiff -u -r1.88 -r1.89 src/sys/fs/puffs/puffs_sys.h cvs rdiff -u -r1.115 -r1.116 src/sys/fs/puffs/puffs_vfsops.c cvs rdiff -u -r1.199 -r1.200 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.82 src/lib/libperfuse/ops.c:1.83 --- src/lib/libperfuse/ops.c:1.82 Tue Jan 13 16:51:30 2015 +++ src/lib/libperfuse/ops.c Sun Feb 15 20:21:29 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.82 2015/01/13 16:51:30 manu Exp $ */ +/* $NetBSD: ops.c,v 1.83 2015/02/15 20:21:29 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -1828,6 +1828,7 @@ perfuse_node_setattr_ttl(struct puffs_us fsi-valid |= FUSE_FATTR_LOCKOWNER; } +#ifndef PUFFS_KFLAG_NOFLUSH_META /* * ftruncate() sends only va_size, and metadata cache * flush adds va_atime and va_mtime. Some FUSE @@ -1856,6 +1857,7 @@ perfuse_node_setattr_ttl(struct puffs_us */ if (fsi-valid == FUSE_FATTR_ATIME) fsi-valid = ~FUSE_FATTR_ATIME; +#endif /* PUFFS_KFLAG_NOFLUSH_META */ /* * If nothing remain, discard the operation. Index: src/lib/libperfuse/perfuse.c diff -u src/lib/libperfuse/perfuse.c:1.35 src/lib/libperfuse/perfuse.c:1.36 --- src/lib/libperfuse/perfuse.c:1.35 Fri Oct 31 15:12:15 2014 +++ src/lib/libperfuse/perfuse.c Sun Feb 15 20:21:29 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: perfuse.c,v 1.35 2014/10/31 15:12:15 manu Exp $ */ +/* $NetBSD: perfuse.c,v 1.36 2015/02/15 20:21:29 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -539,6 +539,15 @@ perfuse_init(struct perfuse_callbacks *p puffs_flags |= PUFFS_FLAG_IAONDEMAND; #endif + /* + * FUSE filesystem do not expect [amc]time and size + * updates to be sent by the kernel, they do the + * updates on their own after other operations. + */ +#ifdef PUFFS_KFLAG_NOFLUSH_META + puffs_flags |= PUFFS_KFLAG_NOFLUSH_META; +#endif + if (perfuse_diagflags PDF_PUFFS) puffs_flags |= PUFFS_FLAG_OPDUMP; Index: src/lib/libpuffs/puffs.3 diff -u src/lib/libpuffs/puffs.3:1.59 src/lib/libpuffs/puffs.3:1.60 --- src/lib/libpuffs/puffs.3:1.59 Tue Mar 18 18:20:38 2014 +++ src/lib/libpuffs/puffs.3 Sun Feb 15 20:21:29 2015 @@ -1,4 +1,4 @@ -.\ $NetBSD: puffs.3,v 1.59 2014/03/18 18:20:38 riastradh Exp $ +.\ $NetBSD: puffs.3,v 1.60 2015/02/15 20:21:29 manu Exp $ .\ .\ Copyright (c) 2006, 2007, 2008 Antti Kantee. All rights reserved. .\ @@ -263,6 +263,9 @@ Never send lookups for .Dq .. to the filesystem. Parent vnodes are all kept active until their children are reclaimed. +.It Dv PUFFS_KFLAG_NOFLUSH_META +Do not send metadata cache flushes for time and size to the filesystem, +which should take care of updating the values on its own. .It Dv PUFFS_FLAG_OPDUMP This option makes the framework dump a textual representation of each operation before executing it. Index: src/sys/fs/puffs/puffs_msgif.h diff -u src/sys/fs/puffs/puffs_msgif.h:1.83 src/sys/fs/puffs/puffs_msgif.h:1.84 --- src/sys/fs/puffs/puffs_msgif.h:1.83 Fri Oct 31 14:20:54 2014 +++ src/sys/fs/puffs/puffs_msgif.h Sun Feb 15 20:21:29 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_msgif.h,v 1.83 2014/10/31 14:20:54 manu Exp $ */ +/* $NetBSD: puffs_msgif.h,v 1.84 2015/02/15 20:21:29 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -163,7 +163,8 @@ struct puffs_kargs { #define PUFFS_KFLAG_NOCACHE_ATTR 0x040 /* no attrib cache (unused) */ #define PUFFS_KFLAG_CACHE_FS_TTL 0x080 /* cache use TTL from FS*/ #define PUFFS_KFLAG_CACHE_DOTDOT 0x100 /* don't send lookup for .. */ -#define PUFFS_KFLAG_MASK 0x1bf +#define PUFFS_KFLAG_NOFLUSH_META 0x200 /* don't flush metadata cache*/ +#define PUFFS_KFLAG_MASK 0x3bf #define PUFFS_FHFLAG_DYNAMIC 0x01 #define PUFFS_FHFLAG_NFSV2 0x02 Index: src
CVS commit: src/lib/libc/gen
Module Name:src Committed By: manu Date: Thu Jan 29 15:55:22 UTC 2015 Modified Files: src/lib/libc/gen: fts.c Log Message: Fix double free in fts_read()/fts_close() When fts_read() gets an error on fchdir(), it exited with sp-fts_cur set to a freed structure. fts_close() would later attempt to free it again, crashing the program. To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/lib/libc/gen/fts.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/gen/fts.c diff -u src/lib/libc/gen/fts.c:1.47 src/lib/libc/gen/fts.c:1.48 --- src/lib/libc/gen/fts.c:1.47 Thu Sep 18 13:58:20 2014 +++ src/lib/libc/gen/fts.c Thu Jan 29 15:55:21 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: fts.c,v 1.47 2014/09/18 13:58:20 christos Exp $ */ +/* $NetBSD: fts.c,v 1.48 2015/01/29 15:55:21 manu Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = @(#)fts.c 8.6 (Berkeley) 8/14/94; #else -__RCSID($NetBSD: fts.c,v 1.47 2014/09/18 13:58:20 christos Exp $); +__RCSID($NetBSD: fts.c,v 1.48 2015/01/29 15:55:21 manu Exp $); #endif #endif /* LIBC_SCCS and not lint */ @@ -430,8 +430,19 @@ fts_read(FTS *sp) goto name; } +next: /* Move to the next node on this level. */ -next: tmp = p; + tmp = p; + + /* + * We are going to free sp-fts_cur, set it to NULL so + * that fts_close() does not attempt to free it again + * if we exit without setting it to a new value because + * FCHDIR() failed below. + */ + assert(tmp == sp-fts_cur); + sp-fts_cur = NULL; + if ((p = p-fts_link) != NULL) { fts_free(tmp);
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Tue Jan 13 16:39:51 UTC 2015 Modified Files: src/sys/fs/puffs: puffs_vnops.c Log Message: Make sure reads on empty files reach PUFFS filesystems Sending a read through the page cache will get the operation short-circuited. This is a problem with some filesystems that expect to receive the read operation in order to update atime. We fix that by bypassing the page cache when reading a file wich a size known to be zero. To generate a diff of this commit: cvs rdiff -u -r1.198 -r1.199 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.198 src/sys/fs/puffs/puffs_vnops.c:1.199 --- src/sys/fs/puffs/puffs_vnops.c:1.198 Tue Nov 4 09:14:42 2014 +++ src/sys/fs/puffs/puffs_vnops.c Tue Jan 13 16:39:51 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.198 2014/11/04 09:14:42 manu Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.199 2015/01/13 16:39:51 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.198 2014/11/04 09:14:42 manu Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.199 2015/01/13 16:39:51 manu Exp $); #include sys/param.h #include sys/buf.h @@ -2279,9 +2279,17 @@ puffs_vnop_read(void *v) if (uio-uio_offset 0) return EFBIG; + /* + * On the case of reading empty files and (vp-v_size != 0) below: + * some filesystems (hint: FUSE and distributed filesystems) still + * expect to get the READ in order to update atime. Reading through + * the case filters empty files, therefore we prefer to bypass the + * cache here. + */ if (vp-v_type == VREG PUFFS_USE_PAGECACHE(pmp) - !(pn-pn_stat PNODE_RDIRECT)) { + !(pn-pn_stat PNODE_RDIRECT) + (vp-v_size != 0)) { const int advice = IO_ADV_DECODE(ap-a_ioflag); while (uio-uio_resid 0) {
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Tue Jan 13 16:51:30 UTC 2015 Modified Files: src/lib/libperfuse: ops.c Log Message: Fix atime update FUSE filesystems assume that SETATTR with atime is the result of utiimes() being called. As a result, atime and mtime will be updated. This happens with MooseFS and glusterFS. atime is supposed to be updated by the filesystem itself when it gets read operations. We fix the problem in SETATTR operations by 1) do not create a mtime update when we have an atime update (and vice versa), just fill the fields to avoid the filesystem restting the missing field to Epoch, but do not pretend we want to update it. 2) If the change is limited to atime, iscard it, as updates should be done by READ operations 3) Kernel part of PUFFS has been fixed to make sure reads on empty file are sent to the filesystem: http://mail-index.netbsd.org/source-changes/2015/01/13/msg062364.html Thanks to Tom Ivar Helbekkmo for reporting this issue. To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.81 src/lib/libperfuse/ops.c:1.82 --- src/lib/libperfuse/ops.c:1.81 Wed Nov 12 05:08:43 2014 +++ src/lib/libperfuse/ops.c Tue Jan 13 16:51:30 2015 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.81 2014/11/12 05:08:43 manu Exp $ */ +/* $NetBSD: ops.c,v 1.82 2015/01/13 16:51:30 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -1785,30 +1785,27 @@ perfuse_node_setattr_ttl(struct puffs_us } /* - * Setting mtime without atime or vice versa leads to - * dates being reset to Epoch on glusterfs. If one - * is missing, use the old value. + * When not sending a time field, still fill with + * current value, as the filesystem may just reset + * the field to Epoch even if fsi-valid bit is + * not set (GlusterFS does that). */ - if ((vap-va_mtime.tv_sec != (time_t)PUFFS_VNOVAL) || - (vap-va_atime.tv_sec != (time_t)PUFFS_VNOVAL)) { - - if (vap-va_atime.tv_sec != (time_t)PUFFS_VNOVAL) { - fsi-atime = vap-va_atime.tv_sec; - fsi-atimensec = (uint32_t)vap-va_atime.tv_nsec; - } else { - fsi-atime = old_va-va_atime.tv_sec; - fsi-atimensec = (uint32_t)old_va-va_atime.tv_nsec; - } - - if (vap-va_mtime.tv_sec != (time_t)PUFFS_VNOVAL) { - fsi-mtime = vap-va_mtime.tv_sec; - fsi-mtimensec = (uint32_t)vap-va_mtime.tv_nsec; - } else { - fsi-mtime = old_va-va_mtime.tv_sec; - fsi-mtimensec = (uint32_t)old_va-va_mtime.tv_nsec; - } + if (vap-va_atime.tv_sec != (time_t)PUFFS_VNOVAL) { + fsi-atime = vap-va_atime.tv_sec; + fsi-atimensec = (uint32_t)vap-va_atime.tv_nsec; + fsi-valid |= FUSE_FATTR_ATIME; + } else { + fsi-atime = old_va-va_atime.tv_sec; + fsi-atimensec = (uint32_t)old_va-va_atime.tv_nsec; + } - fsi-valid |= (FUSE_FATTR_MTIME|FUSE_FATTR_ATIME); + if (vap-va_mtime.tv_sec != (time_t)PUFFS_VNOVAL) { + fsi-mtime = vap-va_mtime.tv_sec; + fsi-mtimensec = (uint32_t)vap-va_mtime.tv_nsec; + fsi-valid |= FUSE_FATTR_MTIME; + } else { + fsi-mtime = old_va-va_mtime.tv_sec; + fsi-mtimensec = (uint32_t)old_va-va_mtime.tv_nsec; } if (vap-va_mode != (mode_t)PUFFS_VNOVAL) { @@ -1851,6 +1848,14 @@ perfuse_node_setattr_ttl(struct puffs_us fsi-mtimensec = 0; fsi-valid = ~(FUSE_FATTR_ATIME|FUSE_FATTR_MTIME); } + + /* + * If only atime is changed, discard the operation: it + * happens after read, and in that case the filesystem + * already updaed atime. NB: utimes() also change mtime. + */ + if (fsi-valid == FUSE_FATTR_ATIME) + fsi-valid = ~FUSE_FATTR_ATIME; /* * If nothing remain, discard the operation.
CVS commit: src/lib/libpuffs
Module Name:src Committed By: manu Date: Mon Dec 22 08:16:21 UTC 2014 Modified Files: src/lib/libpuffs: puffs.c Log Message: Do not warn about relative path because of trailing slash libpuffs calls realpath() to obtain an absolute path to use for mounting. If the obtained path is different from the one given by the caller, a warning is issued. This included the situation where the path passed by the caller just have trailing slashes, a situation where we just want them to be striped without a warning. To generate a diff of this commit: cvs rdiff -u -r1.118 -r1.119 src/lib/libpuffs/puffs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpuffs/puffs.c diff -u src/lib/libpuffs/puffs.c:1.118 src/lib/libpuffs/puffs.c:1.119 --- src/lib/libpuffs/puffs.c:1.118 Fri Oct 31 13:56:04 2014 +++ src/lib/libpuffs/puffs.c Mon Dec 22 08:16:21 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs.c,v 1.118 2014/10/31 13:56:04 manu Exp $ */ +/* $NetBSD: puffs.c,v 1.119 2014/12/22 08:16:21 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -31,7 +31,7 @@ #include sys/cdefs.h #if !defined(lint) -__RCSID($NetBSD: puffs.c,v 1.118 2014/10/31 13:56:04 manu Exp $); +__RCSID($NetBSD: puffs.c,v 1.119 2014/12/22 08:16:21 manu Exp $); #endif /* !lint */ #include sys/param.h @@ -574,13 +574,17 @@ do { \ rv = 0; } else { char rp[MAXPATHLEN]; + size_t rplen,dirlen; if (realpath(dir, rp) == NULL) { rv = -1; goto out; } - if (strcmp(dir, rp) != 0) { + rplen = strlen(rp); + dirlen = strlen(dir); + if (strncmp(dir, rp, rplen) != 0 || + strspn(dir + rplen, /) != dirlen - rplen) { warnx(puffs_mount: \%s\ is a relative path., dir); warnx(puffs_mount: using \%s\ instead., rp); }
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: manu Date: Fri Dec 19 10:59:21 UTC 2014 Modified Files: src/sys/ufs/ufs: extattr.h Log Message: Bump UFS1 extended attribute max name length to 256 For extended attribute name max length, kernel filesystem-independant code use either EXTATTR_MAXNAMELEN (BSD API) or XATTR_NAME_MAX (Linux API), which are both defined as KERNEL_NAME_MAX and fits Linux limit of 255 without training \0. UFS1 code had a lower limit that broke Linux compatibility. We can bump the limit without sacrifying backward compatibility, because: 1) There is no API exposing this limit outside the kernel. Upper kernel layers have a larger limit handle the increase without a hitch 2) Each attribute has its own backing store in the fileystem, the name of the backing store matching the attribute name. A newer kernel can create/read/write backing store for longer attribute names and will have no problem with existing shorter names. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/ufs/ufs/extattr.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ufs/extattr.h diff -u src/sys/ufs/ufs/extattr.h:1.10 src/sys/ufs/ufs/extattr.h:1.11 --- src/sys/ufs/ufs/extattr.h:1.10 Sun Oct 9 21:15:34 2011 +++ src/sys/ufs/ufs/extattr.h Fri Dec 19 10:59:21 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: extattr.h,v 1.10 2011/10/09 21:15:34 chs Exp $ */ +/* $NetBSD: extattr.h,v 1.11 2014/12/19 10:59:21 manu Exp $ */ /*- * Copyright (c) 1999-2001 Robert N. M. Watson @@ -43,7 +43,7 @@ #define UFS_EXTATTR_FSROOTSUBDIR .attribute #define UFS_EXTATTR_SUBDIR_SYSTEM system #define UFS_EXTATTR_SUBDIR_USER user -#define UFS_EXTATTR_MAXEXTATTRNAME 65 /* including null */ +#define UFS_EXTATTR_MAXEXTATTRNAME 256 /* including null */ #define UFS_EXTATTR_ATTR_FLAG_INUSE 0x0001 /* attr has been set */ #define UFS_EXTATTR_PERM_KERNEL 0x
CVS commit: src/usr.sbin/perfused
Module Name:src Committed By: manu Date: Fri Dec 12 09:58:39 UTC 2014 Modified Files: src/usr.sbin/perfused: perfused.c Log Message: Survive if filesystem installs a signal handler We tested for signal(3) to return 0 for success, which is incorrect: signal(3) returns the previous handler. Success should be tested as != SIG_ERR, otherwise we fail when a signal handler was previously installed by perfused(8) parrent process, which happens to be the FUSE filesystem. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/usr.sbin/perfused/perfused.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/perfused/perfused.c diff -u src/usr.sbin/perfused/perfused.c:1.24 src/usr.sbin/perfused/perfused.c:1.25 --- src/usr.sbin/perfused/perfused.c:1.24 Sat Jul 21 05:49:42 2012 +++ src/usr.sbin/perfused/perfused.c Fri Dec 12 09:58:39 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: perfused.c,v 1.24 2012/07/21 05:49:42 manu Exp $ */ +/* $NetBSD: perfused.c,v 1.25 2014/12/12 09:58:39 manu Exp $ */ /*- * Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved. @@ -298,7 +298,7 @@ new_mount(int fd, int pmnt_flags) could not open \%s\, _PATH_VAR_RUN_PERFUSE_TRACE); - if (signal(SIGUSR1, sigusr1_handler) != 0) + if (signal(SIGUSR1, sigusr1_handler) == SIG_ERR) DERR(EX_OSERR, signal failed); /* @@ -399,7 +399,7 @@ parse_options(int argc, char **argv) perfuse_diagflags |= parse_debug(optarg); break; case 's': - if (signal(SIGINFO, siginfo_handler) != 0) + if (signal(SIGINFO, siginfo_handler) == SIG_ERR) DERR(EX_OSERR, signal failed); break; case 'f':
CVS commit: src/sys/kern
Module Name:src Committed By: manu Date: Wed Nov 26 10:50:36 UTC 2014 Modified Files: src/sys/kern: vfs_syscalls.c Log Message: Do not follow symlinks in sys_unmount() There are situations where the underlying filesystem is unreachable (e.g: NFS) causing symlink resolution to hang. Such a situation should be avoided by using umount -f -R (force and raw), but while -R causes the symlink resolution to be skipped in umount(8), the kernel was still doing it in sys_unmount(). This changes fixes that. When the -R flag is not given, umount(8) does symlinks resolution through realpath(3) before calling unmount(2), hence not doing it in the kernel would not change behavior. To generate a diff of this commit: cvs rdiff -u -r1.491 -r1.492 src/sys/kern/vfs_syscalls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_syscalls.c diff -u src/sys/kern/vfs_syscalls.c:1.491 src/sys/kern/vfs_syscalls.c:1.492 --- src/sys/kern/vfs_syscalls.c:1.491 Fri Sep 5 09:20:59 2014 +++ src/sys/kern/vfs_syscalls.c Wed Nov 26 10:50:36 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls.c,v 1.491 2014/09/05 09:20:59 matt Exp $ */ +/* $NetBSD: vfs_syscalls.c,v 1.492 2014/11/26 10:50:36 manu Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.491 2014/09/05 09:20:59 matt Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_syscalls.c,v 1.492 2014/11/26 10:50:36 manu Exp $); #ifdef _KERNEL_OPT #include opt_fileassoc.h @@ -574,7 +574,7 @@ sys_unmount(struct lwp *l, const struct return error; } - NDINIT(nd, LOOKUP, FOLLOW | LOCKLEAF | TRYEMULROOT, pb); + NDINIT(nd, LOOKUP, LOCKLEAF | TRYEMULROOT, pb); if ((error = namei(nd)) != 0) { pathbuf_destroy(pb); return error;
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: manu Date: Wed Nov 19 16:26:47 UTC 2014 Modified Files: src/sys/ufs/ufs: ufs_extattr.c Log Message: Fix uninitialized mutex usage We use extended attribute mount mutex before testing if it had been initialized, and as reported by Christos, this caused panic with LOCKDEBUG. Fix it by testing before using. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/ufs/ufs_extattr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ufs/ufs_extattr.c diff -u src/sys/ufs/ufs/ufs_extattr.c:1.45 src/sys/ufs/ufs/ufs_extattr.c:1.46 --- src/sys/ufs/ufs/ufs_extattr.c:1.45 Sat Nov 15 05:03:55 2014 +++ src/sys/ufs/ufs/ufs_extattr.c Wed Nov 19 16:26:47 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_extattr.c,v 1.45 2014/11/15 05:03:55 manu Exp $ */ +/* $NetBSD: ufs_extattr.c,v 1.46 2014/11/19 16:26:47 manu Exp $ */ /*- * Copyright (c) 1999-2002 Robert N. M. Watson @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.45 2014/11/15 05:03:55 manu Exp $); +__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.46 2014/11/19 16:26:47 manu Exp $); #ifdef _KERNEL_OPT #include opt_ffs.h @@ -1103,6 +1103,9 @@ vop_getextattr { struct ufsmount *ump = VFSTOUFS(mp); int error; + if (!(ump-um_extattr.uepm_flags UFS_EXTATTR_UEPM_STARTED)) + return (EOPNOTSUPP); + ufs_extattr_uepm_lock(ump); error = ufs_extattr_get(ap-a_vp, ap-a_attrnamespace, ap-a_name, @@ -1129,9 +1132,6 @@ ufs_extattr_get(struct vnode *vp, int at size_t len, old_len; int error = 0; - if (!(ump-um_extattr.uepm_flags UFS_EXTATTR_UEPM_STARTED)) - return (EOPNOTSUPP); - if (strlen(name) == 0) return (EINVAL); @@ -1221,6 +1221,9 @@ vop_listextattr { struct ufsmount *ump = VFSTOUFS(mp); int error; + if (!(ump-um_extattr.uepm_flags UFS_EXTATTR_UEPM_STARTED)) + return (EOPNOTSUPP); + ufs_extattr_uepm_lock(ump); error = ufs_extattr_list(ap-a_vp, ap-a_attrnamespace, @@ -1247,9 +1250,6 @@ ufs_extattr_list(struct vnode *vp, int a size_t listsize = 0; int error = 0; - if (!(ump-um_extattr.uepm_flags UFS_EXTATTR_UEPM_STARTED)) - return (EOPNOTSUPP); - /* * XXX: We can move this inside the loop and iterate on individual * attributes. @@ -1348,6 +1348,9 @@ vop_deleteextattr { struct ufsmount *ump = VFSTOUFS(mp); int error; + if (!(ump-um_extattr.uepm_flags UFS_EXTATTR_UEPM_STARTED)) + return (EOPNOTSUPP); + ufs_extattr_uepm_lock(ump); error = ufs_extattr_rm(ap-a_vp, ap-a_attrnamespace, ap-a_name, @@ -1377,6 +1380,9 @@ vop_setextattr { struct ufsmount *ump = VFSTOUFS(mp); int error; + if (!(ump-um_extattr.uepm_flags UFS_EXTATTR_UEPM_STARTED)) + return (EOPNOTSUPP); + ufs_extattr_uepm_lock(ump); /* @@ -1415,8 +1421,7 @@ ufs_extattr_set(struct vnode *vp, int at if (vp-v_mount-mnt_flag MNT_RDONLY) return (EROFS); - if (!(ump-um_extattr.uepm_flags UFS_EXTATTR_UEPM_STARTED)) - return (EOPNOTSUPP); + if (!ufs_extattr_valid_attrname(attrnamespace, name)) return (EINVAL); @@ -1535,8 +1540,7 @@ ufs_extattr_rm(struct vnode *vp, int att if (vp-v_mount-mnt_flag MNT_RDONLY) return (EROFS); - if (!(ump-um_extattr.uepm_flags UFS_EXTATTR_UEPM_STARTED)) - return (EOPNOTSUPP); + if (!ufs_extattr_valid_attrname(attrnamespace, name)) return (EINVAL); @@ -1609,12 +1613,10 @@ ufs_extattr_vnode_inactive(struct vnode if (!(ump-um_extattr.uepm_flags UFS_EXTATTR_UEPM_INITIALIZED)) return; - ufs_extattr_uepm_lock(ump); - - if (!(ump-um_extattr.uepm_flags UFS_EXTATTR_UEPM_STARTED)) { - ufs_extattr_uepm_unlock(ump); + if (!(ump-um_extattr.uepm_flags UFS_EXTATTR_UEPM_STARTED)) return; - } + + ufs_extattr_uepm_lock(ump); LIST_FOREACH(uele, ump-um_extattr.uepm_list, uele_entries) ufs_extattr_rm(vp, uele-uele_attrnamespace,
CVS commit: src/sys
Module Name:src Committed By: manu Date: Sun Nov 16 16:01:43 UTC 2014 Modified Files: src/sys/arch/acorn26/conf: GENERIC src/sys/arch/acorn32/conf: GENERIC src/sys/arch/alpha/conf: GENERIC src/sys/arch/amd64/conf: ALL GENERIC XEN3_DOM0 XEN3_DOMU src/sys/arch/amiga/conf: GENERIC GENERIC.in src/sys/arch/amigappc/conf: GENERIC src/sys/arch/arc/conf: GENERIC src/sys/arch/bebox/conf: GENERIC src/sys/arch/cats/conf: GENERIC src/sys/arch/cesfic/conf: GENERIC src/sys/arch/cobalt/conf: GENERIC src/sys/arch/dreamcast/conf: GENERIC src/sys/arch/emips/conf: GENERIC src/sys/arch/epoc32/conf: GENERIC src/sys/arch/ews4800mips/conf: GENERIC src/sys/arch/hp300/conf: GENERIC src/sys/arch/hpcmips/conf: GENERIC src/sys/arch/hpcsh/conf: GENERIC src/sys/arch/hppa/conf: GENERIC src/sys/arch/i386/conf: ALL GENERIC XEN3_DOM0 XEN3_DOMU src/sys/arch/ibmnws/conf: GENERIC src/sys/arch/iyonix/conf: GENERIC src/sys/arch/landisk/conf: GENERIC src/sys/arch/luna68k/conf: GENERIC src/sys/arch/mac68k/conf: GENERIC src/sys/arch/macppc/conf: GENERIC MAMBO POWERMAC_G5 src/sys/arch/mipsco/conf: GENERIC src/sys/arch/mmeye/conf: GENERIC src/sys/arch/mvme68k/conf: GENERIC src/sys/arch/mvmeppc/conf: GENERIC src/sys/arch/netwinder/conf: GENERIC src/sys/arch/news68k/conf: GENERIC src/sys/arch/newsmips/conf: GENERIC src/sys/arch/next68k/conf: GENERIC src/sys/arch/ofppc/conf: GENERIC src/sys/arch/pmax/conf: GENERIC GENERIC64 src/sys/arch/prep/conf: GENERIC src/sys/arch/rs6000/conf: GENERIC src/sys/arch/sandpoint/conf: GENERIC src/sys/arch/sbmips/conf: GENERIC src/sys/arch/sgimips/conf: GENERIC32_IP12 GENERIC32_IP2x GENERIC32_IP3x src/sys/arch/shark/conf: GENERIC src/sys/arch/sparc/conf: GENERIC TADPOLE3GX src/sys/arch/sparc64/conf: GENERIC NONPLUS64 src/sys/arch/sun2/conf: GENERIC src/sys/arch/sun3/conf: GENERIC src/sys/arch/vax/conf: GENERIC VAX780 src/sys/arch/x68k/conf: GENERIC src/sys/arch/zaurus/conf: GENERIC src/sys/ufs: files.ufs Log Message: Remove unused extended attributes kernel options As Masao Uebayashi pointed to me, UFS_EXTATTR_AUTOSTART, LFS_EXTATTR_AUTOSTART and UFS_EXTATTR_AUTOCREATE are not used anywhere in the code. Remove them as they have been obsolete for a long time: UFS_EXTATTR_AUTOSTART was replaced by mount -o extattr LFS_EXTATTR_AUTOSTART was created to match obsolete UFS_EXTATTR_AUTOSTART UFS_EXTATTR_AUTOCREATE was replaced by sysctl vfs.ffs.extattr_autocreate To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/sys/arch/acorn26/conf/GENERIC cvs rdiff -u -r1.115 -r1.116 src/sys/arch/acorn32/conf/GENERIC cvs rdiff -u -r1.361 -r1.362 src/sys/arch/alpha/conf/GENERIC cvs rdiff -u -r1.22 -r1.23 src/sys/arch/amd64/conf/ALL cvs rdiff -u -r1.403 -r1.404 src/sys/arch/amd64/conf/GENERIC cvs rdiff -u -r1.111 -r1.112 src/sys/arch/amd64/conf/XEN3_DOM0 cvs rdiff -u -r1.59 -r1.60 src/sys/arch/amd64/conf/XEN3_DOMU cvs rdiff -u -r1.310 -r1.311 src/sys/arch/amiga/conf/GENERIC cvs rdiff -u -r1.128 -r1.129 src/sys/arch/amiga/conf/GENERIC.in cvs rdiff -u -r1.23 -r1.24 src/sys/arch/amigappc/conf/GENERIC cvs rdiff -u -r1.183 -r1.184 src/sys/arch/arc/conf/GENERIC cvs rdiff -u -r1.144 -r1.145 src/sys/arch/bebox/conf/GENERIC cvs rdiff -u -r1.154 -r1.155 src/sys/arch/cats/conf/GENERIC cvs rdiff -u -r1.64 -r1.65 src/sys/arch/cesfic/conf/GENERIC cvs rdiff -u -r1.146 -r1.147 src/sys/arch/cobalt/conf/GENERIC cvs rdiff -u -r1.120 -r1.121 src/sys/arch/dreamcast/conf/GENERIC cvs rdiff -u -r1.14 -r1.15 src/sys/arch/emips/conf/GENERIC cvs rdiff -u -r1.7 -r1.8 src/sys/arch/epoc32/conf/GENERIC cvs rdiff -u -r1.50 -r1.51 src/sys/arch/ews4800mips/conf/GENERIC cvs rdiff -u -r1.189 -r1.190 src/sys/arch/hp300/conf/GENERIC cvs rdiff -u -r1.228 -r1.229 src/sys/arch/hpcmips/conf/GENERIC cvs rdiff -u -r1.105 -r1.106 src/sys/arch/hpcsh/conf/GENERIC cvs rdiff -u -r1.5 -r1.6 src/sys/arch/hppa/conf/GENERIC cvs rdiff -u -r1.388 -r1.389 src/sys/arch/i386/conf/ALL cvs rdiff -u -r1.1117 -r1.1118 src/sys/arch/i386/conf/GENERIC cvs rdiff -u -r1.92 -r1.93 src/sys/arch/i386/conf/XEN3_DOM0 cvs rdiff -u -r1.64 -r1.65 src/sys/arch/i386/conf/XEN3_DOMU cvs rdiff -u -r1.45 -r1.46 src/sys/arch/ibmnws/conf/GENERIC cvs rdiff -u -r1.87 -r1.88 src/sys/arch/iyonix/conf/GENERIC cvs rdiff -u -r1.44 -r1.45 src/sys/arch/landisk/conf/GENERIC cvs rdiff -u -r1.118 -r1.119 src/sys/arch/luna68k/conf/GENERIC cvs rdiff -u -r1.219 -r1.220 src/sys/arch/mac68k/conf/GENERIC cvs rdiff -u -r1.319 -r1.320 src/sys/arch/macppc/conf/GENERIC cvs rdiff -u -r1.23 -r1.24 src/sys/arch/macppc/conf/MAMBO cvs rdiff -u -r1.24 -r1.25 src/sys/arch/macppc/conf/POWERMAC_G5 cvs rdiff -u -r1.87 -r1.88
CVS commit: src/sys
Module Name:src Committed By: manu Date: Fri Nov 14 10:09:50 UTC 2014 Modified Files: src/sys/kern: vfs_mount.c src/sys/ufs/ffs: ffs_vfsops.c src/sys/ufs/ufs: ufs_extattr.c Log Message: Fix use-after-free on failed unmount with extended attribute enabled When unmount failed, for instance because the mount is still busy, UFS1 extended attributes structures were left freed while the kernel assumes extended attributes were still enabled. This led to using UFS1 extended attributes structures after free. With LOCKDEBUG, with quickly triggers a panic. The problem is fixed by: 1) clear MNT_EXTATTR flag after extended attributes structures are freed 2) attempt to restart extended attributes after failed unmount 2) set MNT_EXTATTR correctly after extended attributes restart As a side effect, extended attribute structures are now only initialized when extended attributes are started for the filesystem. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.301 -r1.302 src/sys/ufs/ffs/ffs_vfsops.c cvs rdiff -u -r1.43 -r1.44 src/sys/ufs/ufs/ufs_extattr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.30 src/sys/kern/vfs_mount.c:1.31 --- src/sys/kern/vfs_mount.c:1.30 Fri May 30 08:46:00 2014 +++ src/sys/kern/vfs_mount.c Fri Nov 14 10:09:50 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.30 2014/05/30 08:46:00 hannken Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.31 2014/11/14 10:09:50 manu Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: vfs_mount.c,v 1.30 2014/05/30 08:46:00 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: vfs_mount.c,v 1.31 2014/11/14 10:09:50 manu Exp $); #define _VFS_VNODE_PRIVATE @@ -616,6 +616,22 @@ mount_checkdirs(vnode_t *olddp) vput(newdp); } +/* + * Start extended attributes + */ +static int +start_extattr(struct mount *mp) +{ + int error; + + error = VFS_EXTATTRCTL(mp, EXTATTR_CMD_START, NULL, 0, NULL); + if (error) + printf(%s: failed to start extattr: error = %d\n, + mp-mnt_stat.f_mntonname, error); + + return error; +} + int mount_domount(struct lwp *l, vnode_t **vpp, struct vfsops *vfsops, const char *path, int flags, void *data, size_t *data_len) @@ -721,13 +737,9 @@ mount_domount(struct lwp *l, vnode_t **v error = VFS_START(mp, 0); if (error) { vrele(vp); - } else if (flags MNT_EXTATTR) { - error = VFS_EXTATTRCTL(vp-v_mountedhere, - EXTATTR_CMD_START, NULL, 0, NULL); - if (error) - printf(%s: failed to start extattr: error = %d\n, - vp-v_mountedhere-mnt_stat.f_mntonname, error); - } + } else if (flags MNT_EXTATTR) { + (void)start_extattr(mp); + } /* Drop reference held for VFS_START(). */ vfs_destroy(mp); *vpp = NULL; @@ -762,7 +774,7 @@ int dounmount(struct mount *mp, int flags, struct lwp *l) { vnode_t *coveredvp; - int error, async, used_syncer; + int error, async, used_syncer, used_extattr; #if NVERIEXEC 0 error = veriexec_unmountchk(mp); @@ -796,6 +808,7 @@ dounmount(struct mount *mp, int flags, s } used_syncer = (mp-mnt_syncer != NULL); + used_extattr = mp-mnt_flag MNT_EXTATTR; /* * XXX Syncer must be frozen when we get here. This should really @@ -835,6 +848,12 @@ dounmount(struct mount *mp, int flags, s mutex_exit(mp-mnt_updating); if (used_syncer) mutex_exit(syncer_mutex); + if (used_extattr) { + if (start_extattr(mp) != 0) +mp-mnt_flag = ~MNT_EXTATTR; + else +mp-mnt_flag |= MNT_EXTATTR; + } return (error); } mutex_exit(mp-mnt_updating); Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.301 src/sys/ufs/ffs/ffs_vfsops.c:1.302 --- src/sys/ufs/ffs/ffs_vfsops.c:1.301 Thu Oct 30 17:13:41 2014 +++ src/sys/ufs/ffs/ffs_vfsops.c Fri Nov 14 10:09:50 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.301 2014/10/30 17:13:41 maxv Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.302 2014/11/14 10:09:50 manu Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ffs_vfsops.c,v 1.301 2014/10/30 17:13:41 maxv Exp $); +__KERNEL_RCSID(0, $NetBSD: ffs_vfsops.c,v 1.302 2014/11/14 10:09:50 manu Exp $); #if defined(_KERNEL_OPT) #include opt_ffs.h @@ -1272,14 +1272,6 @@ ffs_mountfs(struct vnode *devvp, struct } #endif } -#ifdef UFS_EXTATTR - /* - * Initialize file-backed extended attributes on UFS1 file - * systems. - */ - if (ump-um_fstype == UFS1) - ufs_extattr_uepm_init(ump-um_extattr); -#endif /* UFS_EXTATTR */ if (mp-mnt_flag MNT_DISCARD) ump-um_discarddata = ffs_discard_init(devvp, fs); @@ -1527,6 +1519,7 @@ ffs_flushfiles(struct mount *mp, int fla ufs_extattr_stop(mp, l); if
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: manu Date: Sat Nov 15 05:03:55 UTC 2014 Modified Files: src/sys/ufs/ufs: ufs_extattr.c Log Message: Fix UFS1 extended attribute backend autocreation deadlock UFS1 extended attribute backend autocration goes through a vn_open() to create the backend file, and this forces us to release the lock on the target node, in case the target is within the parents of the backend file. That created a window within which another thread could acquire a lock on the target vnode and deadlock awaiting for the mount extended attribute lock. We fix the problem by also releasing the mount extended attribute lock when calling vn_open(), but that lets another thread race us for backend creation. We just detect this using O_EXCL for vn_open() and by checking for EEXIST return code. If we are raced, we fail backend creation but this is not a problem since another thread succeeded on it: we just have to use the result. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/ufs/ufs/ufs_extattr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ufs/ufs_extattr.c diff -u src/sys/ufs/ufs/ufs_extattr.c:1.44 src/sys/ufs/ufs/ufs_extattr.c:1.45 --- src/sys/ufs/ufs/ufs_extattr.c:1.44 Fri Nov 14 10:09:50 2014 +++ src/sys/ufs/ufs/ufs_extattr.c Sat Nov 15 05:03:55 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_extattr.c,v 1.44 2014/11/14 10:09:50 manu Exp $ */ +/* $NetBSD: ufs_extattr.c,v 1.45 2014/11/15 05:03:55 manu Exp $ */ /*- * Copyright (c) 1999-2002 Robert N. M. Watson @@ -48,7 +48,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.44 2014/11/14 10:09:50 manu Exp $); +__KERNEL_RCSID(0, $NetBSD: ufs_extattr.c,v 1.45 2014/11/15 05:03:55 manu Exp $); #ifdef _KERNEL_OPT #include opt_ffs.h @@ -210,9 +210,9 @@ ufs_extattr_valid_attrname(int attrnames /* * Autocreate an attribute storage */ -static struct ufs_extattr_list_entry * +static int ufs_extattr_autocreate_attr(struct vnode *vp, int attrnamespace, -const char *attrname, struct lwp *l) +const char *attrname, struct lwp *l, struct ufs_extattr_list_entry **uelep) { struct mount *mp = vp-v_mount; struct ufsmount *ump = VFSTOUFS(mp); @@ -246,11 +246,21 @@ ufs_extattr_autocreate_attr(struct vnode break; default: PNBUF_PUT(path); - return NULL; + *uelep = NULL; + return EINVAL; break; } /* + * Release extended attribute mount lock, otherwise + * we can deadlock with another thread that would lock + * vp after we unlock it below, and call + * ufs_extattr_uepm_lock(ump), for instance + * in ufs_getextattr(). + */ + ufs_extattr_uepm_unlock(ump); + + /* * XXX unlock/lock should only be done when setting extattr * on backing store or one of its parent directory * including root, but we always do it for now. @@ -261,7 +271,12 @@ ufs_extattr_autocreate_attr(struct vnode pb = pathbuf_create(path); NDINIT(nd, CREATE, LOCKPARENT, pb); - error = vn_open(nd, O_CREAT|O_RDWR, 0600); + /* + * Since we do not hold ufs_extattr_uepm_lock anymore, + * another thread may race with us for backend creation, + * but only one can succeed here thanks to O_EXCL + */ + error = vn_open(nd, O_CREAT|O_EXCL|O_RDWR, 0600); /* * Reacquire the lock on the vnode @@ -269,10 +284,13 @@ ufs_extattr_autocreate_attr(struct vnode KASSERT(VOP_ISLOCKED(vp) == 0); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + ufs_extattr_uepm_lock(ump); + if (error != 0) { pathbuf_destroy(pb); PNBUF_PUT(path); - return NULL; + *uelep = NULL; + return error; } KASSERT(nd.ni_vp != NULL); @@ -300,7 +318,8 @@ ufs_extattr_autocreate_attr(struct vnode printf(%s: write uef header failed for %s, error = %d\n, __func__, attrname, error); vn_close(backing_vp, FREAD|FWRITE, l-l_cred); - return NULL; + *uelep = NULL; + return error; } /* @@ -313,7 +332,8 @@ ufs_extattr_autocreate_attr(struct vnode printf(%s: enable %s failed, error %d\n, __func__, attrname, error); vn_close(backing_vp, FREAD|FWRITE, l-l_cred); - return NULL; + *uelep = NULL; + return error; } uele = ufs_extattr_find_attr(ump, attrnamespace, attrname); @@ -321,13 +341,15 @@ ufs_extattr_autocreate_attr(struct vnode printf(%s: atttribute %s created but not found!\n, __func__, attrname); vn_close(backing_vp, FREAD|FWRITE, l-l_cred); - return NULL; + *uelep = NULL; + return ESRCH; /* really internal error */ } printf(%s: EA backing store autocreated for %s\n, mp-mnt_stat.f_mntonname, attrname); - return uele; + *uelep = uele; + return 0; } /* @@ -1405,10 +1427,17 @@ ufs_extattr_set(struct vnode *vp, int at attribute = ufs_extattr_find_attr(ump, attrnamespace, name); if (!attribute) { - attribute = ufs_extattr_autocreate_attr(vp, attrnamespace, - name, l); - if (!attribute) - return (ENODATA); + error
CVS commit: src/sys/arch
Module Name:src Committed By: manu Date: Wed Nov 12 10:47:24 UTC 2014 Modified Files: src/sys/arch/acorn26/conf: GENERIC src/sys/arch/acorn32/conf: GENERIC src/sys/arch/alpha/conf: GENERIC src/sys/arch/amd64/conf: GENERIC XEN3_DOM0 XEN3_DOMU src/sys/arch/amiga/conf: GENERIC GENERIC.in src/sys/arch/amigappc/conf: GENERIC src/sys/arch/arc/conf: GENERIC src/sys/arch/bebox/conf: GENERIC src/sys/arch/cats/conf: GENERIC src/sys/arch/cesfic/conf: GENERIC src/sys/arch/cobalt/conf: GENERIC src/sys/arch/dreamcast/conf: GENERIC src/sys/arch/emips/conf: GENERIC src/sys/arch/epoc32/conf: GENERIC src/sys/arch/ews4800mips/conf: GENERIC src/sys/arch/hp300/conf: GENERIC src/sys/arch/hpcmips/conf: GENERIC src/sys/arch/hpcsh/conf: GENERIC src/sys/arch/hppa/conf: GENERIC src/sys/arch/i386/conf: GENERIC XEN3_DOM0 XEN3_DOMU src/sys/arch/ibmnws/conf: GENERIC src/sys/arch/iyonix/conf: GENERIC src/sys/arch/landisk/conf: GENERIC src/sys/arch/luna68k/conf: GENERIC src/sys/arch/mac68k/conf: GENERIC src/sys/arch/macppc/conf: GENERIC MAMBO POWERMAC_G5 src/sys/arch/mipsco/conf: GENERIC src/sys/arch/mmeye/conf: GENERIC src/sys/arch/mvme68k/conf: GENERIC src/sys/arch/mvmeppc/conf: GENERIC src/sys/arch/netwinder/conf: GENERIC src/sys/arch/news68k/conf: GENERIC src/sys/arch/newsmips/conf: GENERIC src/sys/arch/next68k/conf: GENERIC src/sys/arch/ofppc/conf: GENERIC src/sys/arch/pmax/conf: GENERIC GENERIC64 src/sys/arch/prep/conf: GENERIC src/sys/arch/rs6000/conf: GENERIC src/sys/arch/sandpoint/conf: GENERIC src/sys/arch/sbmips/conf: GENERIC src/sys/arch/sgimips/conf: GENERIC32_IP12 GENERIC32_IP2x GENERIC32_IP3x src/sys/arch/shark/conf: GENERIC src/sys/arch/sparc/conf: GENERIC TADPOLE3GX src/sys/arch/sparc64/conf: GENERIC NONPLUS64 src/sys/arch/sun2/conf: GENERIC src/sys/arch/sun3/conf: GENERIC src/sys/arch/vax/conf: GENERIC VAX780 src/sys/arch/x68k/conf: GENERIC src/sys/arch/zaurus/conf: GENERIC Log Message: Support for UFS1 extended attributes in GENERIC and GENERIC-like kernels This change just brings UFS1 extended attribute *support* in the kernel, extended attributes are not enabled unless three conditions are met: 1) filesystem is UFS1 (newfs -O1) 2) .attribute/system and .attribute/user directories are created at fs root 3) filesystem is mounted with -o extattr Some GENERIC kernels are obviously memory constrained, the extended attributes options were not enabled for them, but just added commented out. (kernel were considered memory constrained if QUOTA option was disabled) To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/arch/acorn26/conf/GENERIC cvs rdiff -u -r1.114 -r1.115 src/sys/arch/acorn32/conf/GENERIC cvs rdiff -u -r1.360 -r1.361 src/sys/arch/alpha/conf/GENERIC cvs rdiff -u -r1.402 -r1.403 src/sys/arch/amd64/conf/GENERIC cvs rdiff -u -r1.110 -r1.111 src/sys/arch/amd64/conf/XEN3_DOM0 cvs rdiff -u -r1.58 -r1.59 src/sys/arch/amd64/conf/XEN3_DOMU cvs rdiff -u -r1.309 -r1.310 src/sys/arch/amiga/conf/GENERIC cvs rdiff -u -r1.127 -r1.128 src/sys/arch/amiga/conf/GENERIC.in cvs rdiff -u -r1.22 -r1.23 src/sys/arch/amigappc/conf/GENERIC cvs rdiff -u -r1.182 -r1.183 src/sys/arch/arc/conf/GENERIC cvs rdiff -u -r1.143 -r1.144 src/sys/arch/bebox/conf/GENERIC cvs rdiff -u -r1.153 -r1.154 src/sys/arch/cats/conf/GENERIC cvs rdiff -u -r1.63 -r1.64 src/sys/arch/cesfic/conf/GENERIC cvs rdiff -u -r1.145 -r1.146 src/sys/arch/cobalt/conf/GENERIC cvs rdiff -u -r1.119 -r1.120 src/sys/arch/dreamcast/conf/GENERIC cvs rdiff -u -r1.13 -r1.14 src/sys/arch/emips/conf/GENERIC cvs rdiff -u -r1.6 -r1.7 src/sys/arch/epoc32/conf/GENERIC cvs rdiff -u -r1.49 -r1.50 src/sys/arch/ews4800mips/conf/GENERIC cvs rdiff -u -r1.188 -r1.189 src/sys/arch/hp300/conf/GENERIC cvs rdiff -u -r1.227 -r1.228 src/sys/arch/hpcmips/conf/GENERIC cvs rdiff -u -r1.104 -r1.105 src/sys/arch/hpcsh/conf/GENERIC cvs rdiff -u -r1.4 -r1.5 src/sys/arch/hppa/conf/GENERIC cvs rdiff -u -r1.1116 -r1.1117 src/sys/arch/i386/conf/GENERIC cvs rdiff -u -r1.91 -r1.92 src/sys/arch/i386/conf/XEN3_DOM0 cvs rdiff -u -r1.63 -r1.64 src/sys/arch/i386/conf/XEN3_DOMU cvs rdiff -u -r1.44 -r1.45 src/sys/arch/ibmnws/conf/GENERIC cvs rdiff -u -r1.86 -r1.87 src/sys/arch/iyonix/conf/GENERIC cvs rdiff -u -r1.43 -r1.44 src/sys/arch/landisk/conf/GENERIC cvs rdiff -u -r1.117 -r1.118 src/sys/arch/luna68k/conf/GENERIC cvs rdiff -u -r1.218 -r1.219 src/sys/arch/mac68k/conf/GENERIC cvs rdiff -u -r1.318 -r1.319 src/sys/arch/macppc/conf/GENERIC cvs rdiff -u -r1.22 -r1.23 src/sys/arch/macppc/conf/MAMBO cvs rdiff -u -r1.23 -r1.24 src/sys/arch/macppc/conf/POWERMAC_G5 cvs rdiff -u -r1.86 -r1.87
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Wed Nov 12 05:08:44 UTC 2014 Modified Files: src/lib/libperfuse: ops.c Log Message: Allow setxattr to be called with a NULL value, instead of crashing. To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.80 src/lib/libperfuse/ops.c:1.81 --- src/lib/libperfuse/ops.c:1.80 Tue Nov 4 09:17:31 2014 +++ src/lib/libperfuse/ops.c Wed Nov 12 05:08:43 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.80 2014/11/04 09:17:31 manu Exp $ */ +/* $NetBSD: ops.c,v 1.81 2014/11/12 05:08:43 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -3460,6 +3460,7 @@ perfuse_node_setextattr(struct puffs_use perfuse_msg_t *pm; struct fuse_setxattr_in *fsi; size_t attrnamelen; + size_t datalen; size_t len; char *np; int error; @@ -3472,23 +3473,27 @@ perfuse_node_setextattr(struct puffs_use ps = puffs_getspecific(pu); attrname = perfuse_native_ns(attrns, attrname, fuse_attrname); attrnamelen = strlen(attrname) + 1; - len = sizeof(*fsi) + attrnamelen + *resid; + + datalen = (resid != NULL) ? *resid : 0; + len = sizeof(*fsi) + attrnamelen + datalen; pm = ps-ps_new_msg(pu, opc, FUSE_SETXATTR, len, pcr); fsi = GET_INPAYLOAD(ps, pm, fuse_setxattr_in); - fsi-size = (unsigned int)*resid; + fsi-size = (unsigned int)datalen; fsi-flags = 0; np = (char *)(void *)(fsi + 1); (void)strlcpy(np, attrname, attrnamelen); np += attrnamelen; - (void)memcpy(np, (char *)attr, *resid); + if (datalen) + (void)memcpy(np, (char *)attr, datalen); if ((error = xchg_msg(pu, opc, pm, NO_PAYLOAD_REPLY_LEN, wait_reply)) != 0) goto out; ps-ps_destroy_msg(pm); - *resid = 0; + if (resid) + *resid = 0; error = 0; out:
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Tue Nov 4 09:10:37 UTC 2014 Modified Files: src/sys/fs/puffs: puffs_node.c puffs_vnops.c Log Message: Fix PUFFS node use-after-reclaim When puffs_cookie2vnode() misses an entry, vcache_get() creates a new node (puffs_vfsop_loadvnode being called to initialize the PUFFS part), then it discovers it is VNON, and tries to vrele() it. vrele() calls VOP_INACTIVE(), which led us in puffs_vnop_inactive() where we sent a request to the filesystem for a node that already had been reclaimed. The fix is to check for VNON nodes in puffs_vnop_inactive() and to return without doing anyting. This is suboptimal, but a better workaround would probably need to modify vcache API, with an impact on other filesystems. Let us keep it simple. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/fs/puffs/puffs_node.c cvs rdiff -u -r1.196 -r1.197 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_node.c diff -u src/sys/fs/puffs/puffs_node.c:1.34 src/sys/fs/puffs/puffs_node.c:1.35 --- src/sys/fs/puffs/puffs_node.c:1.34 Tue Sep 30 10:15:03 2014 +++ src/sys/fs/puffs/puffs_node.c Tue Nov 4 09:10:37 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_node.c,v 1.34 2014/09/30 10:15:03 hannken Exp $ */ +/* $NetBSD: puffs_node.c,v 1.35 2014/11/04 09:10:37 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_node.c,v 1.34 2014/09/30 10:15:03 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_node.c,v 1.35 2014/11/04 09:10:37 manu Exp $); #include sys/param.h #include sys/hash.h @@ -266,6 +266,7 @@ puffs_cookie2vnode(struct puffs_mount *p mutex_enter((*vpp)-v_interlock); if ((*vpp)-v_type == VNON) { mutex_exit((*vpp)-v_interlock); + /* XXX vrele() calls VOP_INACTIVE() with VNON node */ vrele(*vpp); *vpp = NULL; return PUFFS_NOSUCHCOOKIE; Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.196 src/sys/fs/puffs/puffs_vnops.c:1.197 --- src/sys/fs/puffs/puffs_vnops.c:1.196 Fri Oct 31 13:52:41 2014 +++ src/sys/fs/puffs/puffs_vnops.c Tue Nov 4 09:10:37 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.196 2014/10/31 13:52:41 manu Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.197 2014/11/04 09:10:37 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.196 2014/10/31 13:52:41 manu Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.197 2014/11/04 09:10:37 manu Exp $); #include sys/param.h #include sys/buf.h @@ -1330,6 +1330,18 @@ puffs_vnop_inactive(void *v) struct puffs_node *pnode; bool recycle = false; + /* + * When puffs_cookie2vnode() misses an entry, vcache_get() + * creates a new node (puffs_vfsop_loadvnode being called to + * initialize the PUFFS part), then it discovers it is VNON, + * and tries to vrele() it. This leads us there, while the + * cookie was stall and the node likely already reclaimed. + */ + if (vp-v_type == VNON) { + VOP_UNLOCK(vp); + return 0; + } + pnode = vp-v_data; mutex_enter(pnode-pn_sizemtx);
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Tue Nov 4 09:14:42 UTC 2014 Modified Files: src/sys/fs/puffs: puffs_vnops.c Log Message: PUFFS direct I/O cache fix There are a few situations where we must take care of the cache if direct I/O was enabled: - if we do direct I/O for write but not for read, then any write must invalidate the cache so that a reader gets the written data and not the not-updated cache. - if we used a vnode without direct I/O and it is enabled for writing, we must flush the cache before compeling the open operation, so that the cachec write are not lost. And at inactive time, we wipe direct I/O flags so that a new open without direct I/O does not inherit direct I/O. To generate a diff of this commit: cvs rdiff -u -r1.197 -r1.198 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.197 src/sys/fs/puffs/puffs_vnops.c:1.198 --- src/sys/fs/puffs/puffs_vnops.c:1.197 Tue Nov 4 09:10:37 2014 +++ src/sys/fs/puffs/puffs_vnops.c Tue Nov 4 09:14:42 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.197 2014/11/04 09:10:37 manu Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.198 2014/11/04 09:14:42 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.197 2014/11/04 09:10:37 manu Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.198 2014/11/04 09:14:42 manu Exp $); #include sys/param.h #include sys/buf.h @@ -908,6 +908,12 @@ puffs_vnop_open(void *v) error = checkerr(pmp, error, __func__); if (open_msg-pvnr_oflags PUFFS_OPEN_IO_DIRECT) { + /* + * Flush cache: + * - we do not want to discard cached write by direct write + * - read cache is now useless and should be freed + */ + flushvncache(vp, 0, 0, true); if (mode FREAD) pn-pn_stat |= PNODE_RDIRECT; if (mode FWRITE) @@ -1416,6 +1422,11 @@ puffs_vnop_inactive(void *v) } } + /* + * Wipe direct I/O flags + */ + pnode-pn_stat = ~(PNODE_RDIRECT|PNODE_WDIRECT); + *ap-a_recycle = recycle; mutex_exit(pnode-pn_sizemtx); @@ -2381,19 +2392,20 @@ puffs_vnop_write(void *v) mutex_enter(pn-pn_sizemtx); + /* + * userspace *should* be allowed to control this, + * but with UBC it's a bit unclear how to handle it + */ + if (ap-a_ioflag IO_APPEND) + uio-uio_offset = vp-v_size; + + origoff = uio-uio_offset; + if (vp-v_type == VREG PUFFS_USE_PAGECACHE(pmp) !(pn-pn_stat PNODE_WDIRECT)) { ubcflags = UBC_WRITE | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp); - /* - * userspace *should* be allowed to control this, - * but with UBC it's a bit unclear how to handle it - */ - if (ap-a_ioflag IO_APPEND) - uio-uio_offset = vp-v_size; - - origoff = uio-uio_offset; while (uio-uio_resid 0) { oldoff = uio-uio_offset; bytelen = uio-uio_resid; @@ -2500,6 +2512,22 @@ puffs_vnop_write(void *v) } } puffs_msgmem_release(park_write); + + /* + * Direct I/O on write but not on read: we must + * invlidate the written pages so that we read + * the written data and not the stalled cache. + */ + if ((error == 0) + (vp-v_type == VREG) PUFFS_USE_PAGECACHE(pmp) + (pn-pn_stat PNODE_WDIRECT) + !(pn-pn_stat PNODE_RDIRECT)) { + voff_t off_lo = trunc_page(origoff); + voff_t off_hi = round_page(uio-uio_offset); + + mutex_enter(vp-v_uobj.vmobjlock); + error = VOP_PUTPAGES(vp, off_lo, off_hi, PGO_FREE); + } } if (vp-v_mount-mnt_flag MNT_RELATIME)
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Tue Nov 4 09:17:32 UTC 2014 Modified Files: src/lib/libperfuse: ops.c Log Message: Restore build with -DDEBUG, and avoid a spurious diagnostic error with -DDEBUG To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.79 src/lib/libperfuse/ops.c:1.80 --- src/lib/libperfuse/ops.c:1.79 Fri Oct 31 15:20:08 2014 +++ src/lib/libperfuse/ops.c Tue Nov 4 09:17:31 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.79 2014/10/31 15:20:08 manu Exp $ */ +/* $NetBSD: ops.c,v 1.80 2014/11/04 09:17:31 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -813,11 +813,6 @@ requeue_request(struct puffs_usermount * { struct perfuse_cc_queue pcq; struct perfuse_node_data *pnd; -#ifdef PERFUSE_DEBUG - struct perfuse_state *ps; - - ps = perfuse_getspecific(pu); -#endif pnd = PERFUSE_NODE_DATA(opc); pcq.pcq_type = type; @@ -2821,11 +2816,11 @@ perfuse_node_inactive(struct puffs_userm if (opc == 0) return 0; - node_ref(opc); pnd = PERFUSE_NODE_DATA(opc); - if (!(pnd-pnd_flags (PND_OPEN|PND_REMOVED))) - goto out; + return 0; + + node_ref(opc); /* * Make sure all operation are finished
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Fri Oct 31 13:52:41 UTC 2014 Modified Files: src/sys/fs/puffs: puffs_msgif.h puffs_vnops.c Log Message: Add PUFFS support for fallocate and fdiscard operations To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/sys/fs/puffs/puffs_msgif.h cvs rdiff -u -r1.195 -r1.196 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_msgif.h diff -u src/sys/fs/puffs/puffs_msgif.h:1.81 src/sys/fs/puffs/puffs_msgif.h:1.82 --- src/sys/fs/puffs/puffs_msgif.h:1.81 Sat Aug 16 16:19:41 2014 +++ src/sys/fs/puffs/puffs_msgif.h Fri Oct 31 13:52:41 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_msgif.h,v 1.81 2014/08/16 16:19:41 manu Exp $ */ +/* $NetBSD: puffs_msgif.h,v 1.82 2014/10/31 13:52:41 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -86,11 +86,12 @@ enum { PUFFS_VN_ADVLOCK, PUFFS_VN_LEASE, PUFFS_VN_WHITEOUT, PUFFS_VN_GETPAGES, PUFFS_VN_PUTPAGES, PUFFS_VN_GETEXTATTR, PUFFS_VN_LISTEXTATTR, PUFFS_VN_OPENEXTATTR, PUFFS_VN_DELETEEXTATTR, - PUFFS_VN_SETEXTATTR, PUFFS_VN_CLOSEEXTATTR + PUFFS_VN_SETEXTATTR, PUFFS_VN_CLOSEEXTATTR, PUFFS_VN_FALLOCATE, + PUFFS_VN_FDISCARD, /* NOTE: If you add an op, decrement PUFFS_VN_SPARE accordingly */ }; -#define PUFFS_VN_MAX PUFFS_VN_CLOSEEXTATTR -#define PUFFS_VN_SPARE 32 +#define PUFFS_VN_MAX PUFFS_VN_FDISCARD +#define PUFFS_VN_SPARE 30 /* * These signal invalid parameters the file system returned. @@ -666,6 +667,18 @@ struct puffs_vnmsg_deleteextattr { struct puffs_kcred pvnr_cred; /* OUT */ }; +struct puffs_vnmsg_fallocate { + struct puffs_req pvn_pr; + off_t pvnr_off; /* OUT*/ + off_t pvnr_len; /* OUT*/ +}; + +struct puffs_vnmsg_fdiscard { + struct puffs_req pvn_pr; + off_t pvnr_off; /* OUT*/ + off_t pvnr_len; /* OUT*/ +}; + /* * For cache reports. Everything is always out-out-out, no replies */ Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.195 src/sys/fs/puffs/puffs_vnops.c:1.196 --- src/sys/fs/puffs/puffs_vnops.c:1.195 Fri Oct 31 13:51:33 2014 +++ src/sys/fs/puffs/puffs_vnops.c Fri Oct 31 13:52:41 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.195 2014/10/31 13:51:33 manu Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.196 2014/10/31 13:52:41 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.195 2014/10/31 13:51:33 manu Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.196 2014/10/31 13:52:41 manu Exp $); #include sys/param.h #include sys/buf.h @@ -73,6 +73,8 @@ int puffs_vnop_symlink(void *); int puffs_vnop_rename(void *); int puffs_vnop_read(void *); int puffs_vnop_write(void *); +int puffs_vnop_fallocate(void *); +int puffs_vnop_fdiscard(void *); int puffs_vnop_fcntl(void *); int puffs_vnop_ioctl(void *); int puffs_vnop_inactive(void *); @@ -113,8 +115,8 @@ const struct vnodeopv_entry_desc puffs_v { vop_setattr_desc, puffs_vnop_checkop }, /* setattr */ { vop_read_desc, puffs_vnop_checkop }, /* read */ { vop_write_desc, puffs_vnop_checkop }, /* write */ - { vop_fallocate_desc, genfs_eopnotsupp }, /* fallocate */ - { vop_fdiscard_desc, genfs_eopnotsupp }, /* fdiscard */ + { vop_fallocate_desc, puffs_vnop_fallocate }, /* fallocate */ + { vop_fdiscard_desc, puffs_vnop_fdiscard }, /* fdiscard */ { vop_fsync_desc, puffs_vnop_fsync }, /* REAL fsync */ { vop_seek_desc, puffs_vnop_checkop }, /* seek */ { vop_remove_desc, puffs_vnop_checkop }, /* remove */ @@ -2499,6 +2501,80 @@ puffs_vnop_write(void *v) } int +puffs_vnop_fallocate(void *v) +{ + struct vop_fallocate_args /* { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + off_t a_pos; + off_t a_len; + } */ *ap = v; + struct vnode *vp = ap-a_vp; + struct puffs_node *pn = VPTOPP(vp); + struct puffs_mount *pmp = MPTOPUFFSMP(vp-v_mount); + PUFFS_MSG_VARS(vn, fallocate); + int error; + + mutex_enter(pn-pn_sizemtx); + + PUFFS_MSG_ALLOC(vn, fallocate); + fallocate_msg-pvnr_off = ap-a_pos; + fallocate_msg-pvnr_len = ap-a_len; + puffs_msg_setinfo(park_fallocate, PUFFSOP_VN, + PUFFS_VN_FALLOCATE, VPTOPNC(vp)); + + PUFFS_MSG_ENQUEUEWAIT2(pmp, park_fallocate, vp-v_data, NULL, error); + error = checkerr(pmp, error, __func__); + PUFFS_MSG_RELEASE(fallocate); + + switch (error) { + case 0: + break; + case EAGAIN: + error = EIO; + /* FALLTHROUGH */ + default: + goto out; + } + + if (ap-a_pos + ap-a_len vp-v_size) { + uvm_vnp_setsize(vp, ap-a_pos + ap-a_len); + puffs_updatenode(pn, PUFFS_UPDATESIZE, vp-v_size); + } +out: + mutex_exit(pn-pn_sizemtx); + + return error; +} + +int +puffs_vnop_fdiscard(void *v) +{ + struct vop_fdiscard_args /* { + const struct vnodeop_desc *a_desc;
CVS commit: src/lib/libpuffs
Module Name:src Committed By: manu Date: Fri Oct 31 13:56:04 UTC 2014 Modified Files: src/lib/libpuffs: dispatcher.c opdump.c puffs.c puffs.h puffs_ops.3 Log Message: libpuffs support for fallocate and fdiscard operations To generate a diff of this commit: cvs rdiff -u -r1.47 -r1.48 src/lib/libpuffs/dispatcher.c cvs rdiff -u -r1.36 -r1.37 src/lib/libpuffs/opdump.c cvs rdiff -u -r1.117 -r1.118 src/lib/libpuffs/puffs.c cvs rdiff -u -r1.125 -r1.126 src/lib/libpuffs/puffs.h cvs rdiff -u -r1.39 -r1.40 src/lib/libpuffs/puffs_ops.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpuffs/dispatcher.c diff -u src/lib/libpuffs/dispatcher.c:1.47 src/lib/libpuffs/dispatcher.c:1.48 --- src/lib/libpuffs/dispatcher.c:1.47 Sat Aug 16 16:25:44 2014 +++ src/lib/libpuffs/dispatcher.c Fri Oct 31 13:56:04 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: dispatcher.c,v 1.47 2014/08/16 16:25:44 manu Exp $ */ +/* $NetBSD: dispatcher.c,v 1.48 2014/10/31 13:56:04 manu Exp $ */ /* * Copyright (c) 2006, 2007, 2008 Antti Kantee. All Rights Reserved. @@ -31,7 +31,7 @@ #include sys/cdefs.h #if !defined(lint) -__RCSID($NetBSD: dispatcher.c,v 1.47 2014/08/16 16:25:44 manu Exp $); +__RCSID($NetBSD: dispatcher.c,v 1.48 2014/10/31 13:56:04 manu Exp $); #endif /* !lint */ #include sys/types.h @@ -1140,6 +1140,34 @@ dispatch(struct puffs_cc *pcc) break; } + case PUFFS_VN_FALLOCATE: + { + struct puffs_vnmsg_fallocate *auxt = auxbuf; + + if (pops-puffs_node_fallocate == NULL) { +error = EOPNOTSUPP; +break; + } + + error = pops-puffs_node_fallocate(pu, + opcookie, auxt-pvnr_off, auxt-pvnr_len); + break; + } + + case PUFFS_VN_FDISCARD: + { + struct puffs_vnmsg_fdiscard *auxt = auxbuf; + + if (pops-puffs_node_fdiscard == NULL) { +error = EOPNOTSUPP; +break; + } + + error = pops-puffs_node_fdiscard(pu, + opcookie, auxt-pvnr_off, auxt-pvnr_len); + break; + } + default: printf(inval op %d\n, preq-preq_optype); error = EINVAL; Index: src/lib/libpuffs/opdump.c diff -u src/lib/libpuffs/opdump.c:1.36 src/lib/libpuffs/opdump.c:1.37 --- src/lib/libpuffs/opdump.c:1.36 Thu Mar 15 02:02:21 2012 +++ src/lib/libpuffs/opdump.c Fri Oct 31 13:56:04 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: opdump.c,v 1.36 2012/03/15 02:02:21 joerg Exp $ */ +/* $NetBSD: opdump.c,v 1.37 2014/10/31 13:56:04 manu Exp $ */ /* * Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved. @@ -35,7 +35,7 @@ #include sys/cdefs.h #if !defined(lint) -__RCSID($NetBSD: opdump.c,v 1.36 2012/03/15 02:02:21 joerg Exp $); +__RCSID($NetBSD: opdump.c,v 1.37 2014/10/31 13:56:04 manu Exp $); #endif /* !lint */ #include sys/types.h @@ -117,6 +117,8 @@ const char *puffsdump_vnop_revmap[] = { PUFFS_VN_DELETEEXTATTR, PUFFS_VN_SETEXTATTR, PUFFS_VN_CLOSEEXTATTR, + PUFFS_VN_FALLOCATE, + PUFFS_VN_FDISCARD, }; size_t puffsdump_vnop_count = __arraycount(puffsdump_vnop_revmap); Index: src/lib/libpuffs/puffs.c diff -u src/lib/libpuffs/puffs.c:1.117 src/lib/libpuffs/puffs.c:1.118 --- src/lib/libpuffs/puffs.c:1.117 Mon Nov 14 01:27:42 2011 +++ src/lib/libpuffs/puffs.c Fri Oct 31 13:56:04 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs.c,v 1.117 2011/11/14 01:27:42 chs Exp $ */ +/* $NetBSD: puffs.c,v 1.118 2014/10/31 13:56:04 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -31,7 +31,7 @@ #include sys/cdefs.h #if !defined(lint) -__RCSID($NetBSD: puffs.c,v 1.117 2011/11/14 01:27:42 chs Exp $); +__RCSID($NetBSD: puffs.c,v 1.118 2014/10/31 13:56:04 manu Exp $); #endif /* !lint */ #include sys/param.h @@ -106,6 +106,8 @@ fillvnopmask(struct puffs_ops *pops, str FILLOP(setextattr, SETEXTATTR); FILLOP(listextattr, LISTEXTATTR); FILLOP(deleteextattr, DELETEEXTATTR); + FILLOP(fallocate, FALLOCATE); + FILLOP(fdiscard, FDISCARD); } #undef FILLOP Index: src/lib/libpuffs/puffs.h diff -u src/lib/libpuffs/puffs.h:1.125 src/lib/libpuffs/puffs.h:1.126 --- src/lib/libpuffs/puffs.h:1.125 Sat Aug 16 16:25:44 2014 +++ src/lib/libpuffs/puffs.h Fri Oct 31 13:56:04 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs.h,v 1.125 2014/08/16 16:25:44 manu Exp $ */ +/* $NetBSD: puffs.h,v 1.126 2014/10/31 13:56:04 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -252,8 +252,12 @@ struct puffs_ops { puffs_cookie_t, int); int (*puffs_node_open2)(struct puffs_usermount *, puffs_cookie_t, int, const struct puffs_cred *, int *); + int (*puffs_node_fallocate)(struct puffs_usermount *, + puffs_cookie_t, off_t, off_t); + int (*puffs_node_fdiscard)(struct puffs_usermount *, + puffs_cookie_t, off_t, off_t); - void *puffs_ops_spare[28]; + void *puffs_ops_spare[26]; }; typedef int (*pu_pathbuild_fn)(struct puffs_usermount *, @@ -414,7 +418,11 @@ enum { int fsname##_node_reclaim2(struct puffs_usermount *, \
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Fri Oct 31 14:20:54 UTC 2014 Modified Files: src/sys/fs/puffs: puffs_msgif.h Log Message: Add PUFFS_HAVE_FALLOCATE in puffs_msgif.h so that filesystem can decide at build time wether fallocate is usable To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/sys/fs/puffs/puffs_msgif.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_msgif.h diff -u src/sys/fs/puffs/puffs_msgif.h:1.82 src/sys/fs/puffs/puffs_msgif.h:1.83 --- src/sys/fs/puffs/puffs_msgif.h:1.82 Fri Oct 31 13:52:41 2014 +++ src/sys/fs/puffs/puffs_msgif.h Fri Oct 31 14:20:54 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_msgif.h,v 1.82 2014/10/31 13:52:41 manu Exp $ */ +/* $NetBSD: puffs_msgif.h,v 1.83 2014/10/31 14:20:54 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -667,6 +667,7 @@ struct puffs_vnmsg_deleteextattr { struct puffs_kcred pvnr_cred; /* OUT */ }; +#define PUFFS_HAVE_FALLOCATE 1 struct puffs_vnmsg_fallocate { struct puffs_req pvn_pr; off_t pvnr_off; /* OUT*/
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Fri Oct 31 15:12:15 UTC 2014 Modified Files: src/lib/libperfuse: fuse.h ops.c perfuse.c perfuse_priv.h Log Message: FUSE fallocate support There seems to be no fdiscard FUSE operation at the moment, hence that one is left unused. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/lib/libperfuse/fuse.h cvs rdiff -u -r1.77 -r1.78 src/lib/libperfuse/ops.c cvs rdiff -u -r1.34 -r1.35 src/lib/libperfuse/perfuse.c cvs rdiff -u -r1.35 -r1.36 src/lib/libperfuse/perfuse_priv.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/fuse.h diff -u src/lib/libperfuse/fuse.h:1.5 src/lib/libperfuse/fuse.h:1.6 --- src/lib/libperfuse/fuse.h:1.5 Wed Dec 28 17:33:53 2011 +++ src/lib/libperfuse/fuse.h Fri Oct 31 15:12:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: fuse.h,v 1.5 2011/12/28 17:33:53 manu Exp $ */ +/* $NetBSD: fuse.h,v 1.6 2014/10/31 15:12:15 manu Exp $ */ /*- * Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved. @@ -169,6 +169,9 @@ enum fuse_opcode { FUSE_DESTROY = 38, FUSE_IOCTL = 39, FUSE_POLL = 40, + FUSE_NOTIFY_REPLY = 41, + FUSE_BATCH_FORGET = 42, + FUSE_FALLOCATE = 43, FUSE_OPCODE_MAX, FUSE_CUSE_INIT = 4096 @@ -441,6 +444,14 @@ struct fuse_notify_poll_wakeup_out { uint64_t kh; }; +struct fuse_fallocate_in { + uint64_t fh; + uint64_t offset; + uint64_t length; + uint32_t mode; + uint32_t padding; +}; + #if 0 /* Duplicated in perfuse.h to avoid making fuse.h public */ /* Send from kernel to proces */ struct fuse_in_header { Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.77 src/lib/libperfuse/ops.c:1.78 --- src/lib/libperfuse/ops.c:1.77 Tue Oct 28 16:54:11 2014 +++ src/lib/libperfuse/ops.c Fri Oct 31 15:12:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.77 2014/10/28 16:54:11 manu Exp $ */ +/* $NetBSD: ops.c,v 1.78 2014/10/31 15:12:15 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -3635,8 +3635,47 @@ perfuse_node_deleteextattr(struct puffs_ error = xchg_msg(pu, opc, pm, NO_PAYLOAD_REPLY_LEN, wait_reply); if (error != 0) goto out; + + ps-ps_destroy_msg(pm); + +out: + node_rele(opc); + return error; +} + +int +perfuse_node_fallocate(struct puffs_usermount *pu, puffs_cookie_t opc, + off_t off, off_t len) +{ + struct perfuse_state *ps; + perfuse_msg_t *pm; + struct fuse_fallocate_in *fai; + int error; + ps = puffs_getspecific(pu); + if (ps-ps_flags PS_NO_FALLOCATE) + return EOPNOTSUPP; + + node_ref(opc); + + pm = ps-ps_new_msg(pu, opc, FUSE_FALLOCATE, sizeof(*fai), NULL); + + fai = GET_INPAYLOAD(ps, pm, fuse_fallocate_in); + fai-fh = perfuse_get_fh(opc, FWRITE); + fai-offset = off; + fai-length = len; + fai-mode = 0; + + error = xchg_msg(pu, opc, pm, NO_PAYLOAD_REPLY_LEN, wait_reply); + if (error == EOPNOTSUPP || error == ENOSYS) { + ps-ps_flags |= PS_NO_FALLOCATE; + error = EOPNOTSUPP; + } + if (error != 0) + goto out; + ps-ps_destroy_msg(pm); + out: node_rele(opc); return error; Index: src/lib/libperfuse/perfuse.c diff -u src/lib/libperfuse/perfuse.c:1.34 src/lib/libperfuse/perfuse.c:1.35 --- src/lib/libperfuse/perfuse.c:1.34 Wed Sep 3 16:01:45 2014 +++ src/lib/libperfuse/perfuse.c Fri Oct 31 15:12:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: perfuse.c,v 1.34 2014/09/03 16:01:45 manu Exp $ */ +/* $NetBSD: perfuse.c,v 1.35 2014/10/31 15:12:15 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -503,6 +503,9 @@ perfuse_init(struct perfuse_callbacks *p #ifdef PUFFS_OPEN_IO_DIRECT PUFFSOP_SET(pops, perfuse, node, open2); #endif /* PUFFS_OPEN_IO_DIRECT */ +#ifdef PUFFS_HAVE_FALLOCATE + PUFFSOP_SET(pops, perfuse, node, fallocate); +#endif /* PUFFS_HAVE_FALLOCATE */ /* * PUFFS_KFLAG_NOCACHE_NAME is required so that we can see changes Index: src/lib/libperfuse/perfuse_priv.h diff -u src/lib/libperfuse/perfuse_priv.h:1.35 src/lib/libperfuse/perfuse_priv.h:1.36 --- src/lib/libperfuse/perfuse_priv.h:1.35 Wed Sep 3 23:59:58 2014 +++ src/lib/libperfuse/perfuse_priv.h Fri Oct 31 15:12:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: perfuse_priv.h,v 1.35 2014/09/03 23:59:58 enami Exp $ */ +/* $NetBSD: perfuse_priv.h,v 1.36 2014/10/31 15:12:15 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -67,6 +67,7 @@ struct perfuse_state { #define PS_NO_ACCESS 0x0001 /* access is unimplemented; */ #define PS_NO_CREAT 0x0004 /* create is unimplemented */ #define PS_INLOOP 0x0008 /* puffs mainloop started */ +#define PS_NO_FALLOCATE 0x0010 /* fallocate is unimplemented */ uint64_t ps_fsid; uint32_t ps_max_readahead; uint32_t ps_max_write; @@ -277,6 +278,8 @@ int perfuse_node_getattr_ttl(struct puff int perfuse_node_setattr_ttl(struct puffs_usermount *, puffs_cookie_t, struct vattr *, const struct puffs_cred
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Fri Oct 31 15:20:08 UTC 2014 Modified Files: src/lib/libperfuse: ops.c Log Message: Avoid deadlocks on write errors On write errors, we failed to dequeue some operations, leading to rare but unpleasant deadlocks To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.78 src/lib/libperfuse/ops.c:1.79 --- src/lib/libperfuse/ops.c:1.78 Fri Oct 31 15:12:15 2014 +++ src/lib/libperfuse/ops.c Fri Oct 31 15:20:08 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.78 2014/10/31 15:12:15 manu Exp $ */ +/* $NetBSD: ops.c,v 1.79 2014/10/31 15:20:08 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -3299,6 +3299,7 @@ perfuse_node_write2(struct puffs_usermou if (*resid != 0) error = EFBIG; +out: #ifdef PERFUSE_DEBUG if (perfuse_diagflags PDF_RESIZE) { if (offset (off_t)vap-va_size) @@ -3315,16 +3316,6 @@ perfuse_node_write2(struct puffs_usermou if (offset (off_t)vap-va_size) vap-va_size = offset; - if (inresize) { -#ifdef PERFUSE_DEBUG - if (!(pnd-pnd_flags PND_INRESIZE)) - DERRX(EX_SOFTWARE, file write grow without resize); -#endif - pnd-pnd_flags = ~PND_INRESIZE; - (void)dequeue_requests(opc, PCQ_RESIZE, DEQUEUE_ALL); - } - - /* * Statistics */ @@ -3344,7 +3335,15 @@ perfuse_node_write2(struct puffs_usermou __func__, (void*)opc, perfuse_node_path(ps, opc)); #endif -out: + if (inresize) { +#ifdef PERFUSE_DEBUG + if (!(pnd-pnd_flags PND_INRESIZE)) + DERRX(EX_SOFTWARE, file write grow without resize); +#endif + pnd-pnd_flags = ~PND_INRESIZE; + (void)dequeue_requests(opc, PCQ_RESIZE, DEQUEUE_ALL); + } + /* * VOP_PUTPAGE causes FAF write where kernel does not * check operation result. At least warn if it failed.
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Tue Oct 28 16:54:11 UTC 2014 Modified Files: src/lib/libperfuse: ops.c Log Message: Fix invalid free in deletextattr FUSE handler Do not free FUSE message on error as it was not allocated. To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.76 src/lib/libperfuse/ops.c:1.77 --- src/lib/libperfuse/ops.c:1.76 Sat Oct 11 04:19:38 2014 +++ src/lib/libperfuse/ops.c Tue Oct 28 16:54:11 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.76 2014/10/11 04:19:38 manu Exp $ */ +/* $NetBSD: ops.c,v 1.77 2014/10/28 16:54:11 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -3633,9 +3633,11 @@ perfuse_node_deleteextattr(struct puffs_ (void)strlcpy(np, attrname, attrnamelen); error = xchg_msg(pu, opc, pm, NO_PAYLOAD_REPLY_LEN, wait_reply); + if (error != 0) + goto out; ps-ps_destroy_msg(pm); - +out: node_rele(opc); return error; }
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Sat Oct 11 04:19:38 UTC 2014 Modified Files: src/lib/libperfuse: ops.c Log Message: Report allocated bytes on FS correctly, instead of using file size (which is wrong for sparse files) To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.75 src/lib/libperfuse/ops.c:1.76 --- src/lib/libperfuse/ops.c:1.75 Tue Sep 30 00:06:19 2014 +++ src/lib/libperfuse/ops.c Sat Oct 11 04:19:38 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.75 2014/09/30 00:06:19 manu Exp $ */ +/* $NetBSD: ops.c,v 1.76 2014/10/11 04:19:38 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -321,7 +321,7 @@ fuse_attr_to_vap(struct perfuse_state *p vap-va_gen = 0; vap-va_flags = 0; vap-va_rdev = fa-rdev; - vap-va_bytes = fa-size; + vap-va_bytes = fa-blocks * S_BLKSIZE; vap-va_filerev = (u_quad_t)PUFFS_VNOVAL; vap-va_vaflags = 0;
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Mon Oct 6 09:05:55 UTC 2014 Modified Files: src/sys/fs/puffs: puffs_vnops.c Log Message: Retore LP64 fix that was removed by mistake To generate a diff of this commit: cvs rdiff -u -r1.190 -r1.191 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.190 src/sys/fs/puffs/puffs_vnops.c:1.191 --- src/sys/fs/puffs/puffs_vnops.c:1.190 Mon Oct 6 04:41:59 2014 +++ src/sys/fs/puffs/puffs_vnops.c Mon Oct 6 09:05:55 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.190 2014/10/06 04:41:59 manu Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.191 2014/10/06 09:05:55 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.190 2014/10/06 04:41:59 manu Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.191 2014/10/06 09:05:55 manu Exp $); #include sys/param.h #include sys/buf.h @@ -1160,7 +1160,8 @@ zerofill_lastpage(struct vnode *vp, voff error = ubc_uiomove(vp-v_uobj, uio, len, UVM_ADV_SEQUENTIAL, UBC_WRITE|UBC_UNMAP_FLAG(vp)); if (error) - DPRINTF((zero-fill 0x%lx@0x%llx = %d\n, len, off, error)); + DPRINTF((zero-fill 0x%lx@0x% PRIx64 failed: error = %d\n, + len, off, error)); return; }
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Sun Oct 5 07:53:22 UTC 2014 Modified Files: src/sys/fs/puffs: puffs_vnops.c Log Message: If we truncate the file, make sure we zero-fill the end of the last page, otherwise if the file is later truncated to a larger size (creating a hole), that area will not return zeroes as it should. To generate a diff of this commit: cvs rdiff -u -r1.187 -r1.188 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.187 src/sys/fs/puffs/puffs_vnops.c:1.188 --- src/sys/fs/puffs/puffs_vnops.c:1.187 Tue Sep 30 10:15:03 2014 +++ src/sys/fs/puffs/puffs_vnops.c Sun Oct 5 07:53:22 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.187 2014/09/30 10:15:03 hannken Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.188 2014/10/05 07:53:22 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.187 2014/09/30 10:15:03 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.188 2014/10/05 07:53:22 manu Exp $); #include sys/param.h #include sys/buf.h @@ -1130,6 +1130,38 @@ puffs_vnop_getattr(void *v) return error; } +static void +zerofill_lastpage(struct vnode *vp, voff_t off) +{ + char zbuf[PAGE_SIZE]; + struct iovec iov; + struct uio uio; + vsize_t len; + int error; + + if (trunc_page(off) == off) + return; + + len = round_page(off) - off; + memset(zbuf, 0, len); + + iov.iov_base = zbuf; + iov.iov_len = len; + UIO_SETUP_SYSSPACE(uio); + uio.uio_iov = iov; + uio.uio_iovcnt = 1; + uio.uio_offset = off; + uio.uio_resid = len; + uio.uio_rw = UIO_WRITE; + + error = ubc_uiomove(vp-v_uobj, uio, len, + UVM_ADV_SEQUENTIAL, UBC_WRITE|UBC_UNMAP_FLAG(vp)); + if (error) + DPRINTF((zero-fill 0x%lx@0x%llx = %d\n, len, off, error)); + + return; +} + static int dosetattr(struct vnode *vp, struct vattr *vap, kauth_cred_t cred, int flags) { @@ -1191,6 +1223,17 @@ dosetattr(struct vnode *vp, struct vattr if ((flags SETATTR_ASYNC) == 0) error = puffs_msg_wait2(pmp, park_setattr, vp-v_data, NULL); + /* + * If we truncate the file, make sure we zero-fill + * the end of the last page, otherwise if the file + * is later truncated to a larger size (creating a + * a hole), that area will not return zeroes as it + * should. + */ + if ((error == 0) (flags SETATTR_CHSIZE) + (vap-va_size != VNOVAL) (vap-va_size vp-v_size)) + zerofill_lastpage(vp, vap-va_size); + if ((error == 0) PUFFS_USE_FS_TTL(pmp)) { struct timespec *va_ttl = setattr_msg-pvnr_va_ttl; struct vattr *rvap = setattr_msg-pvnr_va;
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Mon Oct 6 04:41:59 UTC 2014 Modified Files: src/sys/fs/puffs: puffs_vnops.c Log Message: Improve zero-fill of last page after shrink fix: 1) do it only if the file is open for writing, otherwise we send write requests to the FS on a file that has never been open. 2) do it inside existing if (vap-va_size != VNOVAL) block To generate a diff of this commit: cvs rdiff -u -r1.189 -r1.190 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.189 src/sys/fs/puffs/puffs_vnops.c:1.190 --- src/sys/fs/puffs/puffs_vnops.c:1.189 Sun Oct 5 09:28:24 2014 +++ src/sys/fs/puffs/puffs_vnops.c Mon Oct 6 04:41:59 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.189 2014/10/05 09:28:24 justin Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.190 2014/10/06 04:41:59 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.189 2014/10/05 09:28:24 justin Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.190 2014/10/06 04:41:59 manu Exp $); #include sys/param.h #include sys/buf.h @@ -1141,6 +1141,9 @@ zerofill_lastpage(struct vnode *vp, voff if (trunc_page(off) == off) return; + + if (vp-v_writecount == 0) + return; len = round_page(off) - off; memset(zbuf, 0, len); @@ -1157,7 +1160,7 @@ zerofill_lastpage(struct vnode *vp, voff error = ubc_uiomove(vp-v_uobj, uio, len, UVM_ADV_SEQUENTIAL, UBC_WRITE|UBC_UNMAP_FLAG(vp)); if (error) - DPRINTF((zero-fill 0x%lx@0x% PRIx64 = %d\n, len, off, error)); + DPRINTF((zero-fill 0x%lx@0x%llx = %d\n, len, off, error)); return; } @@ -1168,6 +1171,7 @@ dosetattr(struct vnode *vp, struct vattr PUFFS_MSG_VARS(vn, setattr); struct puffs_mount *pmp = MPTOPUFFSMP(vp-v_mount); struct puffs_node *pn = vp-v_data; + vsize_t oldsize = vp-v_size; int error = 0; KASSERT(!(flags SETATTR_CHSIZE) || mutex_owned(pn-pn_sizemtx)); @@ -1223,17 +1227,6 @@ dosetattr(struct vnode *vp, struct vattr if ((flags SETATTR_ASYNC) == 0) error = puffs_msg_wait2(pmp, park_setattr, vp-v_data, NULL); - /* - * If we truncate the file, make sure we zero-fill - * the end of the last page, otherwise if the file - * is later truncated to a larger size (creating a - * a hole), that area will not return zeroes as it - * should. - */ - if ((error == 0) (flags SETATTR_CHSIZE) - (vap-va_size != VNOVAL) (vap-va_size vp-v_size)) - zerofill_lastpage(vp, vap-va_size); - if ((error == 0) PUFFS_USE_FS_TTL(pmp)) { struct timespec *va_ttl = setattr_msg-pvnr_va_ttl; struct vattr *rvap = setattr_msg-pvnr_va; @@ -1251,6 +1244,17 @@ dosetattr(struct vnode *vp, struct vattr } if (vap-va_size != VNOVAL) { + /* + * If we truncated the file, make sure the data beyond + * EOF in last page does not remain in cache, otherwise + * if the file is later truncated to a larger size (creating + * a hole), that area will not return zeroes as it + * should. + */ + if ((flags SETATTR_CHSIZE) PUFFS_USE_PAGECACHE(pmp) + (vap-va_size oldsize)) + zerofill_lastpage(vp, vap-va_size); + pn-pn_serversize = vap-va_size; if (flags SETATTR_CHSIZE) uvm_vnp_setsize(vp, vap-va_size);
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Tue Sep 30 00:06:19 UTC 2014 Modified Files: src/lib/libperfuse: ops.c Log Message: Do not trust the filesystem's readdir to give us nul-terminated file names To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.74 src/lib/libperfuse/ops.c:1.75 --- src/lib/libperfuse/ops.c:1.74 Thu Sep 11 04:05:52 2014 +++ src/lib/libperfuse/ops.c Tue Sep 30 00:06:19 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.74 2014/09/11 04:05:52 manu Exp $ */ +/* $NetBSD: ops.c,v 1.75 2014/09/30 00:06:19 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -607,6 +607,7 @@ fuse_to_dirent(struct puffs_usermount *p do { char *ndp; size_t reclen; + char name[MAXPATHLEN]; reclen = _DIRENT_RECLEN(dents, fd-namelen); @@ -639,6 +640,9 @@ fuse_to_dirent(struct puffs_usermount *p dents = (struct dirent *)(void *)ndp; } + strncpy(name, fd-name, fd-namelen); + name[fd-namelen] = '\0'; + /* * Filesystem was mounted without -o use_ino * Perform a lookup to find it. @@ -651,13 +655,17 @@ fuse_to_dirent(struct puffs_usermount *p * Avoid breaking out of fs * by lookup to .. on root */ - if ((strcmp(fd-name, ..) == 0) + if ((strcmp(name, ..) == 0) (pnd-pnd_nodeid == FUSE_ROOT_ID)) { fd-ino = FUSE_ROOT_ID; } else { -if (node_lookup_common(pu, opc, NULL, fd-name, - NULL, pn) != 0) { - DWARNX(node_lookup_common failed); +int error; + +error = node_lookup_common(pu, opc, NULL, + name, NULL, pn); +if (error != 0) { + DWARNX(node_lookup_common %s + failed: %d, name, error); } else { fd-ino = pn-pn_va.va_fileid; (void)perfuse_node_reclaim(pu, pn); @@ -669,7 +677,7 @@ fuse_to_dirent(struct puffs_usermount *p dents-d_reclen = (unsigned short)reclen; dents-d_namlen = fd-namelen; dents-d_type = fd-type; - strlcpy(dents-d_name, fd-name, fd-namelen + 1); + strlcpy(dents-d_name, name, fd-namelen + 1); #ifdef PERFUSE_DEBUG if (perfuse_diagflags PDF_READDIR) @@ -720,7 +728,7 @@ fuse_to_dirent(struct puffs_usermount *p */ if (written != -1) PERFUSE_NODE_DATA(opc)-pnd_dirent_len = written; - + return written; }
CVS commit: src/lib/libc
Module Name:src Committed By: manu Date: Thu Sep 25 15:08:29 UTC 2014 Modified Files: src/lib/libc/include: namespace.h src/lib/libc/sys: Makefile.inc Added Files: src/lib/libc/sys: fdiscard.c posix_fallocate.c Log Message: Fix argument paddiing for posix_fallocate and fdiscard with gcc 1.x To generate a diff of this commit: cvs rdiff -u -r1.174 -r1.175 src/lib/libc/include/namespace.h cvs rdiff -u -r1.224 -r1.225 src/lib/libc/sys/Makefile.inc cvs rdiff -u -r0 -r1.1 src/lib/libc/sys/fdiscard.c \ src/lib/libc/sys/posix_fallocate.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libc/include/namespace.h diff -u src/lib/libc/include/namespace.h:1.174 src/lib/libc/include/namespace.h:1.175 --- src/lib/libc/include/namespace.h:1.174 Fri Jun 13 15:45:05 2014 +++ src/lib/libc/include/namespace.h Thu Sep 25 15:08:29 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: namespace.h,v 1.174 2014/06/13 15:45:05 joerg Exp $ */ +/* $NetBSD: namespace.h,v 1.175 2014/09/25 15:08:29 manu Exp $ */ /*- * Copyright (c) 1997-2004 The NetBSD Foundation, Inc. @@ -281,6 +281,7 @@ #define execv _execv #define execvp _execvp #define explicit_memset _explicit_memset +#define fdiscard _fdiscard #define fdopen _fdopen #define fgetln _fgetln #define fgetwln _fgetwln @@ -520,6 +521,7 @@ #define pread _pread #define printf_l _printf_l #define pselect _pselect +#define posix_fallocate _posix_fallocate #define psignal _psignal #define pthread_atfork _pthread_atfork #define ptree_init ptree_init Index: src/lib/libc/sys/Makefile.inc diff -u src/lib/libc/sys/Makefile.inc:1.224 src/lib/libc/sys/Makefile.inc:1.225 --- src/lib/libc/sys/Makefile.inc:1.224 Fri Jul 25 08:30:47 2014 +++ src/lib/libc/sys/Makefile.inc Thu Sep 25 15:08:29 2014 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.inc,v 1.224 2014/07/25 08:30:47 dholland Exp $ +# $NetBSD: Makefile.inc,v 1.225 2014/09/25 15:08:29 manu Exp $ # @(#)Makefile.inc 8.3 (Berkeley) 10/24/94 # sys sources @@ -30,8 +30,9 @@ SRCS+= posix_fadvise.c posix_madvise.c s # glue to provide compatibility between GCC 1.X and 2.X and for compat # with old syscall interfaces. -GLUE+= ftruncate.c lseek.c mmap.c pread.c preadv.c pwrite.c \ - pwritev.c truncate.c ntp_adjtime.c mknodat.c +GLUE+= fdiscard.c ftruncate.c lseek.c mmap.c posix_fallocate.c \ + pread.c preadv.c pwrite.c pwritev.c truncate.c ntp_adjtime.c \ + mknodat.c GLUE50+= adjtime.c clock_settime.c settimeofday.c @@ -147,11 +148,11 @@ ASM_MD= _lwp_getprivate.S mremap.S .endfor WEAKASM= accept.S __aio_suspend50.S close.S connect.S execve.S \ - fcntl.S fdatasync.S fdiscard.S fsync.S \ + fcntl.S fdatasync.S fsync.S \ fsync_range.S __kevent50.S \ kill.S mq_receive.S mq_send.S __mq_timedreceive50.S __mq_timedsend50.S \ msgrcv.S msgsnd.S __msync13.S __nanosleep50.S open.S poll.S \ - __pollts50.S posix_fallocate.S __pselect50.S read.S readlink.S \ + __pollts50.S __pselect50.S read.S readlink.S \ readv.S _sched_setparam.S _sched_getparam.S _sched_setaffinity.S \ _sched_getaffinity.S sched_yield.S \ __select50.S setcontext.S __sigprocmask14.S __sigsuspend14.S sysarch.S \ Added files: Index: src/lib/libc/sys/fdiscard.c diff -u /dev/null src/lib/libc/sys/fdiscard.c:1.1 --- /dev/null Thu Sep 25 15:08:29 2014 +++ src/lib/libc/sys/fdiscard.c Thu Sep 25 15:08:29 2014 @@ -0,0 +1,52 @@ +/* $NetBSD: fdiscard.c,v 1.1 2014/09/25 15:08:29 manu Exp $ */ + +/* + * Copyright (c) 2014 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Emmanuel Dreyfus. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + *derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Thu Sep 11 07:59:14 UTC 2014 Modified Files: src/sys/fs/puffs: puffs_vnops.c Log Message: PUFFS fixes for size update ater write plus read/write sanity checks - Always update kernel metadata cache for size when writing This fixes situation where size update after appending to a file lagged - Make read/write nilpotent when called with null size, as FFS does - Return EFBIG instead of EINVAL for negative offsets, as FFS does To generate a diff of this commit: cvs rdiff -u -r1.185 -r1.186 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.185 src/sys/fs/puffs/puffs_vnops.c:1.186 --- src/sys/fs/puffs/puffs_vnops.c:1.185 Fri Sep 5 15:39:18 2014 +++ src/sys/fs/puffs/puffs_vnops.c Thu Sep 11 07:59:14 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.185 2014/09/05 15:39:18 manu Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.186 2014/09/11 07:59:14 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.185 2014/09/05 15:39:18 manu Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.186 2014/09/11 07:59:14 manu Exp $); #include sys/param.h #include sys/buf.h @@ -2203,7 +2203,7 @@ puffs_vnop_read(void *v) if (uio-uio_resid == 0) return 0; if (uio-uio_offset 0) - return EINVAL; + return EFBIG; if (vp-v_type == VREG PUFFS_USE_PAGECACHE(pmp) @@ -2310,6 +2310,12 @@ puffs_vnop_write(void *v) error = uflags = 0; write_msg = NULL; + /* std sanity */ + if (uio-uio_resid == 0) + return 0; + if (uio-uio_offset 0) + return EFBIG; + mutex_enter(pn-pn_sizemtx); if (vp-v_type == VREG @@ -2326,10 +2332,6 @@ puffs_vnop_write(void *v) origoff = uio-uio_offset; while (uio-uio_resid 0) { - if (vp-v_mount-mnt_flag MNT_RELATIME) -uflags |= PUFFS_UPDATEATIME; - uflags |= PUFFS_UPDATECTIME; - uflags |= PUFFS_UPDATEMTIME; oldoff = uio-uio_offset; bytelen = uio-uio_resid; @@ -2390,8 +2392,6 @@ puffs_vnop_write(void *v) error = VOP_PUTPAGES(vp, trunc_page(origoff), round_page(uio-uio_offset), PGO_CLEANIT); } - - puffs_updatenode(VPTOPP(vp), uflags, vp-v_size); } else { /* tomove is non-increasing */ tomove = PUFFS_TOMOVE(uio-uio_resid, pmp); @@ -2425,8 +2425,10 @@ puffs_vnop_write(void *v) } /* adjust file size */ - if (vp-v_size uio-uio_offset) + if (vp-v_size uio-uio_offset) { +uflags |= PUFFS_UPDATESIZE; uvm_vnp_setsize(vp, uio-uio_offset); + } /* didn't move everything? bad userspace. bail */ if (write_msg-pvnr_resid != 0) { @@ -2437,6 +2439,12 @@ puffs_vnop_write(void *v) puffs_msgmem_release(park_write); } + if (vp-v_mount-mnt_flag MNT_RELATIME) + uflags |= PUFFS_UPDATEATIME; + uflags |= PUFFS_UPDATECTIME; + uflags |= PUFFS_UPDATEMTIME; + puffs_updatenode(VPTOPP(vp), uflags, vp-v_size); + mutex_exit(pn-pn_sizemtx); return error; }
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Thu Sep 11 04:05:52 UTC 2014 Modified Files: src/lib/libperfuse: ops.c Log Message: Avoid a file resize serialization deadlock when writing with PUFFS_IO_APPEND flag. The symptom was a hang when appending to a file with a null size. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.73 src/lib/libperfuse/ops.c:1.74 --- src/lib/libperfuse/ops.c:1.73 Fri Sep 5 15:20:16 2014 +++ src/lib/libperfuse/ops.c Thu Sep 11 04:05:52 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.73 2014/09/05 15:20:16 manu Exp $ */ +/* $NetBSD: ops.c,v 1.74 2014/09/11 04:05:52 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -3198,16 +3198,6 @@ perfuse_node_write2(struct puffs_usermou requeue_request(pu, opc, PCQ_WRITE); pnd-pnd_flags |= PND_INWRITE; - /* - * Serialize size access, see comment in perfuse_node_setattr(). - */ - if ((u_quad_t)offset + *resid vap-va_size) { - while (pnd-pnd_flags PND_INRESIZE) - requeue_request(pu, opc, PCQ_RESIZE); - pnd-pnd_flags |= PND_INRESIZE; - inresize = 1; - } - /* * append flag: re-read the file size so that * we get the latest value. @@ -3219,6 +3209,16 @@ perfuse_node_write2(struct puffs_usermou offset = vap-va_size; } + /* + * Serialize size access, see comment in perfuse_node_setattr(). + */ + if ((u_quad_t)offset + *resid vap-va_size) { + while (pnd-pnd_flags PND_INRESIZE) + requeue_request(pu, opc, PCQ_RESIZE); + pnd-pnd_flags |= PND_INRESIZE; + inresize = 1; + } + #ifdef PERFUSE_DEBUG if (perfuse_diagflags PDF_RESIZE) DPRINTF( %s %p % PRIu64 \n, __func__,
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Fri Sep 5 15:20:17 UTC 2014 Modified Files: src/lib/libperfuse: ops.c Log Message: rmdir dir/.. must return an error. Use ENOTEMPRY like FFS does. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.72 src/lib/libperfuse/ops.c:1.73 --- src/lib/libperfuse/ops.c:1.72 Wed Sep 3 23:59:58 2014 +++ src/lib/libperfuse/ops.c Fri Sep 5 15:20:16 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.72 2014/09/03 23:59:58 enami Exp $ */ +/* $NetBSD: ops.c,v 1.73 2014/09/05 15:20:16 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -2352,6 +2352,12 @@ perfuse_node_rmdir(struct puffs_usermoun (PERFUSE_NODE_DATA(targ)-pnd_flags PND_REMOVED)) return ENOENT; + /* + * Attempt to rmdir dir/.. shoud raise ENOTEMPTY + */ + if (PERFUSE_NODE_DATA(targ)-pnd_nodeid == pnd-pnd_parent_nodeid) + return ENOTEMPTY; + node_ref(opc); node_ref(targ);
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Fri Sep 5 15:39:19 UTC 2014 Modified Files: src/sys/fs/puffs: puffs_node.c puffs_vnops.c Log Message: When changing a directory content, update the ctime/mtime in kernel cache, otherwise the updated ctime/mtime appears after the cached entry expire. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sys/fs/puffs/puffs_node.c cvs rdiff -u -r1.184 -r1.185 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_node.c diff -u src/sys/fs/puffs/puffs_node.c:1.32 src/sys/fs/puffs/puffs_node.c:1.33 --- src/sys/fs/puffs/puffs_node.c:1.32 Thu Aug 28 08:29:50 2014 +++ src/sys/fs/puffs/puffs_node.c Fri Sep 5 15:39:18 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_node.c,v 1.32 2014/08/28 08:29:50 hannken Exp $ */ +/* $NetBSD: puffs_node.c,v 1.33 2014/09/05 15:39:18 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_node.c,v 1.32 2014/08/28 08:29:50 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_node.c,v 1.33 2014/09/05 15:39:18 manu Exp $); #include sys/param.h #include sys/hash.h @@ -180,6 +180,8 @@ puffs_newnode(struct mount *mp, struct v cache_enter(dvp, *vpp, cnp-cn_nameptr, cnp-cn_namelen, cnp-cn_flags); + puffs_updatenode(VPTOPP(dvp), PUFFS_UPDATECTIME|PUFFS_UPDATEMTIME, 0); + return 0; } Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.184 src/sys/fs/puffs/puffs_vnops.c:1.185 --- src/sys/fs/puffs/puffs_vnops.c:1.184 Thu Aug 28 08:29:50 2014 +++ src/sys/fs/puffs/puffs_vnops.c Fri Sep 5 15:39:18 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.184 2014/08/28 08:29:50 hannken Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.185 2014/09/05 15:39:18 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.184 2014/08/28 08:29:50 hannken Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.185 2014/09/05 15:39:18 manu Exp $); #include sys/param.h #include sys/buf.h @@ -1805,6 +1805,8 @@ puffs_vnop_remove(void *v) PUFFS_MSG_RELEASE(remove); + puffs_updatenode(VPTOPP(dvp), PUFFS_UPDATECTIME|PUFFS_UPDATEMTIME, 0); + RELEPN_AND_VP(dvp, dpn); RELEPN_AND_VP(vp, pn); @@ -1922,6 +1924,8 @@ puffs_vnop_rmdir(void *v) PUFFS_MSG_RELEASE(rmdir); + puffs_updatenode(VPTOPP(dvp), PUFFS_UPDATECTIME|PUFFS_UPDATEMTIME, 0); + /* XXX: some call cache_purge() *for both vnodes* here, investigate */ RELEPN_AND_VP(dvp, dpn); RELEPN_AND_VP(vp, pn); @@ -1967,8 +1971,11 @@ puffs_vnop_link(void *v) * XXX: stay in touch with the cache. I don't like this, but * don't have a better solution either. See also puffs_rename(). */ - if (error == 0) + if (error == 0) { puffs_updatenode(pn, PUFFS_UPDATECTIME, 0); + puffs_updatenode(VPTOPP(dvp), + PUFFS_UPDATECTIME|PUFFS_UPDATEMTIME, 0); + } RELEPN_AND_VP(dvp, dpn); puffs_releasenode(pn); @@ -2133,6 +2140,12 @@ puffs_vnop_rename(void *v) */ if (error == 0) { puffs_updatenode(fpn, PUFFS_UPDATECTIME, 0); + puffs_updatenode(VPTOPP(fdvp), + PUFFS_UPDATECTIME|PUFFS_UPDATEMTIME, 0); + if (fdvp != tdvp) + puffs_updatenode(VPTOPP(tdvp), + PUFFS_UPDATECTIME|PUFFS_UPDATEMTIME, + 0); if (PUFFS_USE_DOTDOTCACHE(pmp) (VPTOPP(fvp)-pn_parent != tdvp))
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Wed Sep 3 16:01:45 UTC 2014 Modified Files: src/lib/libperfuse: ops.c perfuse.c Log Message: Improve POSIX compliance of FUSE filesystems through PERUSE - access denied is EPERM and not EACCES - access to file owned by someone else in a sticy-bit directory should be allowed for the sticy-bit directory owner - setting sticky-bit on a non directory should produce EFTYPE - implement PATHCONF method as much as we can. To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/lib/libperfuse/ops.c cvs rdiff -u -r1.33 -r1.34 src/lib/libperfuse/perfuse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.70 src/lib/libperfuse/ops.c:1.71 --- src/lib/libperfuse/ops.c:1.70 Fri Aug 29 04:58:40 2014 +++ src/lib/libperfuse/ops.c Wed Sep 3 16:01:45 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.70 2014/08/29 04:58:40 manu Exp $ */ +/* $NetBSD: ops.c,v 1.71 2014/09/03 16:01:45 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -269,7 +269,7 @@ sticky_access(puffs_cookie_t opc, struct const struct puffs_cred *pcr) { uid_t uid; - int sticky, owner; + int sticky, owner, parent_owner; /* * This covers the case where the kernel requests a DELETE @@ -288,9 +288,10 @@ sticky_access(puffs_cookie_t opc, struct sticky = puffs_pn_getvap(opc)-va_mode S_ISTXT; owner = puffs_pn_getvap(targ)-va_uid == uid; + parent_owner = puffs_pn_getvap(opc)-va_uid == uid; - if (sticky !owner) - return EACCES; + if (sticky !owner !parent_owner) + return EPERM; return 0; } @@ -1305,7 +1306,7 @@ perfuse_node_mknod(struct puffs_usermoun break; default: /* VNON, VBLK, VCHR, VBAD */ if (!puffs_cred_isjuggernaut(pcn-pcn_cred)) { - error = EACCES; + error = EPERM; goto out; } break; @@ -1696,7 +1697,7 @@ perfuse_node_setattr_ttl(struct puffs_us (vap-va_mtime.tv_sec != (time_t)PUFFS_VNOVAL)) (puffs_access_times(old_va-va_uid, old_va-va_gid, old_va-va_mode, 0, pcr) != 0)) - return EACCES; + return EPERM; /* * Check for permission to change owner and group @@ -1705,7 +1706,15 @@ perfuse_node_setattr_ttl(struct puffs_us (vap-va_gid != (gid_t)PUFFS_VNOVAL)) (puffs_access_chown(old_va-va_uid, old_va-va_gid, vap-va_uid, vap-va_gid, pcr)) != 0) - return EACCES; + return EPERM; + + /* + * Check for sticky bit on non-directory by non root user + */ + if ((vap-va_mode != (mode_t)PUFFS_VNOVAL) + (vap-va_mode S_ISTXT) (old_va-va_type != VDIR) + !puffs_cred_isjuggernaut(pcr)) + return EFTYPE; /* * Check for permission to change permissions @@ -1713,7 +1722,7 @@ perfuse_node_setattr_ttl(struct puffs_us if ((vap-va_mode != (mode_t)PUFFS_VNOVAL) (puffs_access_chmod(old_va-va_uid, old_va-va_gid, old_va-va_type, vap-va_mode, pcr)) != 0) - return EACCES; + return EPERM; node_ref(opc); @@ -2877,13 +2886,68 @@ perfuse_node_print(struct puffs_usermoun return 0; } -/* ARGSUSED0 */ int perfuse_node_pathconf(struct puffs_usermount *pu, puffs_cookie_t opc, int name, int *retval) { - DERRX(EX_SOFTWARE, %s: UNIMPLEMENTED (FATAL), __func__); - return 0; + perfuse_msg_t *pm; + struct perfuse_state *ps; + struct fuse_statfs_out *fso; + int error = 0; + + /* + * Static values copied from UFS + * in src/sys/ufs/ufs/ufs_vnops.c + */ + switch (name) { + case _PC_LINK_MAX: + *retval = LINK_MAX; + break; + case _PC_PATH_MAX: + *retval = PATH_MAX; + break; + case _PC_PIPE_BUF: + *retval = PIPE_BUF; + break; + case _PC_CHOWN_RESTRICTED: + *retval = 1; + break; + case _PC_NO_TRUNC: + *retval = 1; + break; + case _PC_SYNC_IO: + *retval = 1; + break; + case _PC_FILESIZEBITS: + *retval = 42; + break; + case _PC_SYMLINK_MAX: + *retval = MAXPATHLEN; + break; + case _PC_2_SYMLINKS: + *retval = 1; + break; + case _PC_NAME_MAX: + ps = puffs_getspecific(pu); + pm = ps-ps_new_msg(pu, opc, FUSE_STATFS, 0, NULL); + + error = xchg_msg(pu, opc, pm, sizeof(*fso), wait_reply); + if (error != 0) + return error; + + fso = GET_OUTPAYLOAD(ps, pm, fuse_statfs_out); + *retval = fso-st.namelen; + + ps-ps_destroy_msg(pm); + + break; + default: + DWARN(Unimplemented pathconf for name = %d, name); + error = ENOSYS; + break; + } + + return error; } int Index: src/lib/libperfuse/perfuse.c diff -u src/lib/libperfuse/perfuse.c:1.33 src/lib/libperfuse/perfuse.c:1.34 --- src/lib/libperfuse/perfuse.c:1.33 Sat Aug 16 16:31:15 2014 +++ src/lib/libperfuse/perfuse.c Wed Sep 3 16:01:45 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: perfuse.c,v 1.33 2014/08/16 16:31:15 manu Exp $ */ +/* $NetBSD: perfuse.c,v 1.34 2014/09/03 16:01:45 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -483,6 +483,7 @@ perfuse_init(struct perfuse_callbacks *p
CVS commit: src/usr.sbin/pcictl
Module Name:src Committed By: manu Date: Mon Sep 1 07:11:19 UTC 2014 Modified Files: src/usr.sbin/pcictl: pcictl.8 pcictl.c Log Message: read and write commands for pcictl, from riastradh@ and wiz@ http://mail-index.netbsd.org/tech-kern/2014/08/26/msg017572.html To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/pcictl/pcictl.8 cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/pcictl/pcictl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/pcictl/pcictl.8 diff -u src/usr.sbin/pcictl/pcictl.8:1.13 src/usr.sbin/pcictl/pcictl.8:1.14 --- src/usr.sbin/pcictl/pcictl.8:1.13 Sun Aug 31 09:59:08 2014 +++ src/usr.sbin/pcictl/pcictl.8 Mon Sep 1 07:11:19 2014 @@ -1,4 +1,4 @@ -.\ $NetBSD: pcictl.8,v 1.13 2014/08/31 09:59:08 wiz Exp $ +.\ $NetBSD: pcictl.8,v 1.14 2014/09/01 07:11:19 manu Exp $ .\ .\ Copyright 2001 Wasabi Systems, Inc. .\ All rights reserved. @@ -83,6 +83,31 @@ at the specified bus, device, and functi If the bus is not specified, it defaults to the bus number of the PCI bus specified on the command line. If the function is not specified, it defaults to 0. +.Pp +.Nm read +.Op Fl b Ar bus +.Fl d Ar device +.Op Fl f Ar function +.Ar reg +.Pp +Read the specified 32-bit aligned PCI configuration register and print +it in hexadecimal to standard output. +If the bus is not specified, it defaults to the bus number of the +PCI bus specified on the command line. +If the function is not specified, it defaults to 0. +.Pp +.Nm write +.Op Fl b Ar bus +.Fl d Ar device +.Op Fl f Ar function +.Ar reg +.Ar value +.Pp +Write the specified value to the specified 32-bit aligned PCI +configuration register. +If the bus is not specified, it defaults to the bus number of the +PCI bus specified on the command line. +If the function is not specified, it defaults to 0. .Sh FILES .Pa /dev/pci* - PCI bus device nodes Index: src/usr.sbin/pcictl/pcictl.c diff -u src/usr.sbin/pcictl/pcictl.c:1.20 src/usr.sbin/pcictl/pcictl.c:1.21 --- src/usr.sbin/pcictl/pcictl.c:1.20 Sun Aug 31 09:59:08 2014 +++ src/usr.sbin/pcictl/pcictl.c Mon Sep 1 07:11:19 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: pcictl.c,v 1.20 2014/08/31 09:59:08 wiz Exp $ */ +/* $NetBSD: pcictl.c,v 1.21 2014/09/01 07:11:19 manu Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -77,6 +77,8 @@ static int print_names = 0; static void cmd_list(int, char *[]); static void cmd_dump(int, char *[]); +static void cmd_read(int, char *[]); +static void cmd_write(int, char *[]); static const struct command commands[] = { { list, @@ -89,10 +91,21 @@ static const struct command commands[] = cmd_dump, O_RDONLY }, + { read, + [-b bus] -d device [-f function] reg, + cmd_read, + O_RDONLY }, + + { write, + [-b bus] -d device [-f function] reg value, + cmd_write, + O_WRONLY }, + { 0, 0, 0, 0 }, }; static int parse_bdf(const char *); +static u_int parse_reg(const char *); static void scan_pci(int, int, int, void (*)(u_int, u_int, u_int)); @@ -234,6 +247,87 @@ cmd_dump(int argc, char *argv[]) scan_pci(bus, dev, func, scan_pci_dump); } +static void +cmd_read(int argc, char *argv[]) +{ + int bus, dev, func; + u_int reg; + pcireg_t value; + int ch; + + bus = pci_businfo.busno; + func = 0; + dev = -1; + + while ((ch = getopt(argc, argv, b:d:f:)) != -1) { + switch (ch) { + case 'b': + bus = parse_bdf(optarg); + break; + case 'd': + dev = parse_bdf(optarg); + break; + case 'f': + func = parse_bdf(optarg); + break; + default: + usage(); + } + } + argv += optind; + argc -= optind; + + if (argc != 1) + usage(); + reg = parse_reg(argv[0]); + if (pcibus_conf_read(pcifd, bus, dev, func, reg, value) == -1) + err(EXIT_FAILURE, pcibus_conf_read + (bus %d dev %d func %d reg %u), bus, dev, func, reg); + if (printf(%08x\n, value) 0) + err(EXIT_FAILURE, printf); +} + +static void +cmd_write(int argc, char *argv[]) +{ + int bus, dev, func; + u_int reg; + pcireg_t value; + int ch; + + bus = pci_businfo.busno; + func = 0; + dev = -1; + + while ((ch = getopt(argc, argv, b:d:f:)) != -1) { + switch (ch) { + case 'b': + bus = parse_bdf(optarg); + break; + case 'd': + dev = parse_bdf(optarg); + break; + case 'f': + func = parse_bdf(optarg); + break; + default: + usage(); + } + } + argv += optind; + argc -= optind; + + if (argc != 2) + usage(); + reg = parse_reg(argv[0]); + __CTASSERT(sizeof(value) == sizeof(u_int)); + value = parse_reg(argv[1]); + if (pcibus_conf_write(pcifd, bus, dev, func, reg, value) == -1) + err(EXIT_FAILURE, pcibus_conf_write + (bus %d dev %d func %d reg %u value 0x%x), + bus, dev, func, reg, value); +} + static int parse_bdf(const char *str) { @@ -244,9 +338,32 @@ parse_bdf(const char *str) strcmp(str, any) == 0) return (-1); + errno = 0; value = strtol(str, end, 0); - if (*end != '\0') + if ((str[0] == '\0') || (*end !=
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Fri Aug 29 04:58:40 UTC 2014 Modified Files: src/lib/libperfuse: ops.c Log Message: We used to remove the trailing zeros in FUSE readlink replies, but it seems it does not always happen. Just remove them if present. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.69 src/lib/libperfuse/ops.c:1.70 --- src/lib/libperfuse/ops.c:1.69 Tue Aug 19 15:29:14 2014 +++ src/lib/libperfuse/ops.c Fri Aug 29 04:58:40 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.69 2014/08/19 15:29:14 manu Exp $ */ +/* $NetBSD: ops.c,v 1.70 2014/08/29 04:58:40 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -2633,12 +2633,16 @@ perfuse_node_readlink(struct puffs_userm if (len == 0) DERRX(EX_PROTOCOL, path len = %zd too short, len); + (void)memcpy(linkname, _GET_OUTPAYLOAD(ps, pm, char *), len); + /* * FUSE filesystems return a NUL terminated string, we - * do not want to trailing \0 + * do not want the trailing \0 */ - *linklen = len - 1; - (void)memcpy(linkname, _GET_OUTPAYLOAD(ps, pm, char *), len); + while (len 0 linkname[len - 1] == '\0') + len--; + + *linklen = len; ps-ps_destroy_msg(pm); error = 0;
CVS commit: src/sys/kern
Module Name:src Committed By: manu Date: Tue Aug 26 09:38:54 UTC 2014 Modified Files: src/sys/kern: subr_tftproot.c Log Message: Fix build with TFTPROOT option enabled To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/kern/subr_tftproot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/subr_tftproot.c diff -u src/sys/kern/subr_tftproot.c:1.12 src/sys/kern/subr_tftproot.c:1.13 --- src/sys/kern/subr_tftproot.c:1.12 Sat Dec 1 11:41:50 2012 +++ src/sys/kern/subr_tftproot.c Tue Aug 26 09:38:54 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_tftproot.c,v 1.12 2012/12/01 11:41:50 mbalmer Exp $ */ +/* $NetBSD: subr_tftproot.c,v 1.13 2014/08/26 09:38:54 manu Exp $ */ /*- * Copyright (c) 2007 Emmanuel Dreyfus, all rights reserved. @@ -39,10 +39,11 @@ #include opt_md.h #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: subr_tftproot.c,v 1.12 2012/12/01 11:41:50 mbalmer Exp $); +__KERNEL_RCSID(0, $NetBSD: subr_tftproot.c,v 1.13 2014/08/26 09:38:54 manu Exp $); #include sys/param.h #include sys/types.h +#include sys/vnode.h #include sys/mount.h #include sys/lwp.h #include sys/kmem.h
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Tue Aug 19 15:29:14 UTC 2014 Modified Files: src/lib/libperfuse: ops.c Log Message: Remove usless warning that happens often with direct IO To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.68 src/lib/libperfuse/ops.c:1.69 --- src/lib/libperfuse/ops.c:1.68 Sat Aug 16 16:31:15 2014 +++ src/lib/libperfuse/ops.c Tue Aug 19 15:29:14 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.68 2014/08/16 16:31:15 manu Exp $ */ +/* $NetBSD: ops.c,v 1.69 2014/08/19 15:29:14 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -3139,8 +3139,6 @@ perfuse_node_write2(struct puffs_usermou * we get the latest value. */ if (ioflag PUFFS_IO_APPEND) { - DWARNX(%s: PUFFS_IO_APPEND set, untested code, __func__); - if ((error = perfuse_node_getattr(pu, opc, vap, pcr)) != 0) goto out;
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: manu Date: Sat Aug 16 16:19:41 UTC 2014 Modified Files: src/sys/fs/puffs: puffs_msgif.h puffs_sys.h puffs_vnops.c Log Message: Add a oflags input field to open requests so that the filesystem can pass back information about the file. Implement PUFFS_OPEN_IO_DIRECT, which will force direct IO (bypassing page cache) for the file. To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/sys/fs/puffs/puffs_msgif.h cvs rdiff -u -r1.84 -r1.85 src/sys/fs/puffs/puffs_sys.h cvs rdiff -u -r1.182 -r1.183 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_msgif.h diff -u src/sys/fs/puffs/puffs_msgif.h:1.80 src/sys/fs/puffs/puffs_msgif.h:1.81 --- src/sys/fs/puffs/puffs_msgif.h:1.80 Fri Aug 10 16:49:35 2012 +++ src/sys/fs/puffs/puffs_msgif.h Sat Aug 16 16:19:41 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_msgif.h,v 1.80 2012/08/10 16:49:35 manu Exp $ */ +/* $NetBSD: puffs_msgif.h,v 1.81 2014/08/16 16:19:41 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -339,6 +339,9 @@ struct puffs_vfsmsg_suspend { #define PUFFS_EXTATTRCTL_HASNODE 0x01 #define PUFFS_EXTATTRCTL_HASATTRNAME 0x02 + +#define PUFFS_OPEN_IO_DIRECT 0x01 + struct puffs_vfsmsg_extattrctl { struct puffs_req pvfsr_pr; @@ -399,6 +402,7 @@ struct puffs_vnmsg_open { struct puffs_kcred pvnr_cred; /* OUT */ int pvnr_mode; /* OUT */ + int pvnr_oflags; /* IN */ }; struct puffs_vnmsg_close { Index: src/sys/fs/puffs/puffs_sys.h diff -u src/sys/fs/puffs/puffs_sys.h:1.84 src/sys/fs/puffs/puffs_sys.h:1.85 --- src/sys/fs/puffs/puffs_sys.h:1.84 Thu Oct 17 21:03:27 2013 +++ src/sys/fs/puffs/puffs_sys.h Sat Aug 16 16:19:41 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_sys.h,v 1.84 2013/10/17 21:03:27 christos Exp $ */ +/* $NetBSD: puffs_sys.h,v 1.85 2014/08/16 16:19:41 manu Exp $ */ /* * Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved. @@ -197,6 +197,8 @@ struct puffs_mount { #define PNODE_FAF 0x004 /* issue all operations as FAF */ #define PNODE_DOINACT 0x008 /* if inactive-on-demand, call inactive */ #define PNODE_SOPEXP 0x100 /* Node reclaim postponed in sop thread */ +#define PNODE_RDIRECT 0x200 /* bypass page cache on read */ +#define PNODE_WDIRECT 0x400 /* bypass page cache on write */ #define PNODE_METACACHE_ATIME 0x10 /* cache atime metadata */ #define PNODE_METACACHE_CTIME 0x20 /* cache atime metadata */ Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.182 src/sys/fs/puffs/puffs_vnops.c:1.183 --- src/sys/fs/puffs/puffs_vnops.c:1.182 Fri Jul 25 08:20:52 2014 +++ src/sys/fs/puffs/puffs_vnops.c Sat Aug 16 16:19:41 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.182 2014/07/25 08:20:52 dholland Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.183 2014/08/16 16:19:41 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include sys/cdefs.h -__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.182 2014/07/25 08:20:52 dholland Exp $); +__KERNEL_RCSID(0, $NetBSD: puffs_vnops.c,v 1.183 2014/08/16 16:19:41 manu Exp $); #include sys/param.h #include sys/buf.h @@ -893,6 +893,7 @@ puffs_vnop_open(void *v) PUFFS_MSG_VARS(vn, open); struct vnode *vp = ap-a_vp; struct puffs_mount *pmp = MPTOPUFFSMP(vp-v_mount); + struct puffs_node *pn = VPTOPP(vp); int mode = ap-a_mode; int error; @@ -913,6 +914,12 @@ puffs_vnop_open(void *v) PUFFS_MSG_ENQUEUEWAIT2(pmp, park_open, vp-v_data, NULL, error); error = checkerr(pmp, error, __func__); + if (open_msg-pvnr_oflags PUFFS_OPEN_IO_DIRECT) { + if (mode FREAD) + pn-pn_stat |= PNODE_RDIRECT; + if (mode FWRITE) + pn-pn_stat |= PNODE_WDIRECT; + } out: DPRINTF((puffs_open: returning %d\n, error)); PUFFS_MSG_RELEASE(open); @@ -2181,6 +2188,7 @@ puffs_vnop_read(void *v) } */ *ap = v; PUFFS_MSG_VARS(vn, read); struct vnode *vp = ap-a_vp; + struct puffs_node *pn = VPTOPP(vp); struct puffs_mount *pmp = MPTOPUFFSMP(vp-v_mount); struct uio *uio = ap-a_uio; size_t tomove, argsize; @@ -2196,7 +2204,9 @@ puffs_vnop_read(void *v) if (uio-uio_offset 0) return EINVAL; - if (vp-v_type == VREG PUFFS_USE_PAGECACHE(pmp)) { + if (vp-v_type == VREG + PUFFS_USE_PAGECACHE(pmp) + !(pn-pn_stat PNODE_RDIRECT)) { const int advice = IO_ADV_DECODE(ap-a_ioflag); while (uio-uio_resid 0) { @@ -2301,7 +2311,9 @@ puffs_vnop_write(void *v) mutex_enter(pn-pn_sizemtx); - if (vp-v_type == VREG PUFFS_USE_PAGECACHE(pmp)) { + if (vp-v_type == VREG + PUFFS_USE_PAGECACHE(pmp) + !(pn-pn_stat PNODE_WDIRECT)) { ubcflags = UBC_WRITE | UBC_PARTIALOK | UBC_UNMAP_FLAG(vp); /*
CVS commit: src/lib/libpuffs
Module Name:src Committed By: manu Date: Sat Aug 16 16:25:44 UTC 2014 Modified Files: src/lib/libpuffs: dispatcher.c puffs.h puffs_ops.3 Log Message: Add an open2 method, like open but with an additionnal oflags used by the filesystem to send back information about the file. This is used to implement PUFFS_OPEN_IO_DIRECT by which the filesystem tells the kernel that read/write should bypass the page cache. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/lib/libpuffs/dispatcher.c cvs rdiff -u -r1.124 -r1.125 src/lib/libpuffs/puffs.h cvs rdiff -u -r1.36 -r1.37 src/lib/libpuffs/puffs_ops.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libpuffs/dispatcher.c diff -u src/lib/libpuffs/dispatcher.c:1.46 src/lib/libpuffs/dispatcher.c:1.47 --- src/lib/libpuffs/dispatcher.c:1.46 Wed Nov 6 19:56:38 2013 +++ src/lib/libpuffs/dispatcher.c Sat Aug 16 16:25:44 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: dispatcher.c,v 1.46 2013/11/06 19:56:38 christos Exp $ */ +/* $NetBSD: dispatcher.c,v 1.47 2014/08/16 16:25:44 manu Exp $ */ /* * Copyright (c) 2006, 2007, 2008 Antti Kantee. All Rights Reserved. @@ -31,7 +31,7 @@ #include sys/cdefs.h #if !defined(lint) -__RCSID($NetBSD: dispatcher.c,v 1.46 2013/11/06 19:56:38 christos Exp $); +__RCSID($NetBSD: dispatcher.c,v 1.47 2014/08/16 16:25:44 manu Exp $); #endif /* !lint */ #include sys/types.h @@ -412,6 +412,14 @@ dispatch(struct puffs_cc *pcc) struct puffs_vnmsg_open *auxt = auxbuf; PUFFS_MAKECRED(pcr, auxt-pvnr_cred); + if (pops-puffs_node_open2 != NULL) { +error = pops-puffs_node_open2(pu, +opcookie, auxt-pvnr_mode, pcr, +auxt-pvnr_oflags); + +break; + } + if (pops-puffs_node_open == NULL) { error = 0; break; Index: src/lib/libpuffs/puffs.h diff -u src/lib/libpuffs/puffs.h:1.124 src/lib/libpuffs/puffs.h:1.125 --- src/lib/libpuffs/puffs.h:1.124 Thu Aug 16 09:25:44 2012 +++ src/lib/libpuffs/puffs.h Sat Aug 16 16:25:44 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs.h,v 1.124 2012/08/16 09:25:44 manu Exp $ */ +/* $NetBSD: puffs.h,v 1.125 2014/08/16 16:25:44 manu Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -250,6 +250,8 @@ struct puffs_ops { uint8_t *, off_t, size_t *, const struct puffs_cred *, int, int); int (*puffs_node_reclaim2)(struct puffs_usermount *, puffs_cookie_t, int); + int (*puffs_node_open2)(struct puffs_usermount *, + puffs_cookie_t, int, const struct puffs_cred *, int *); void *puffs_ops_spare[28]; }; @@ -410,7 +412,9 @@ enum { puffs_cookie_t, uint8_t *, off_t, size_t *, \ const struct puffs_cred *, int, int); \ int fsname##_node_reclaim2(struct puffs_usermount *, \ - puffs_cookie_t, int); + puffs_cookie_t, int); \ + int fsname##_node_open2(struct puffs_usermount *, \ + puffs_cookie_t, int, const struct puffs_cred *, int *); #define PUFFSOP_INIT(ops) \ Index: src/lib/libpuffs/puffs_ops.3 diff -u src/lib/libpuffs/puffs_ops.3:1.36 src/lib/libpuffs/puffs_ops.3:1.37 --- src/lib/libpuffs/puffs_ops.3:1.36 Thu Aug 16 11:28:38 2012 +++ src/lib/libpuffs/puffs_ops.3 Sat Aug 16 16:25:44 2014 @@ -1,4 +1,4 @@ -.\ $NetBSD: puffs_ops.3,v 1.36 2012/08/16 11:28:38 wiz Exp $ +.\ $NetBSD: puffs_ops.3,v 1.37 2014/08/16 16:25:44 manu Exp $ .\ .\ Copyright (c) 2007 Antti Kantee. All rights reserved. .\ @@ -83,6 +83,11 @@ .Fa const struct puffs_cred *pcr .Fc .Ft int +.Fo puffs_node_open2 +.Fa struct puffs_usermount *pu puffs_cookie_t opc int modep +.Fa const struct puffs_cred *pcr int *oflags +.Fc +.Ft int .Fo puffs_node_close .Fa struct puffs_usermount *pu puffs_cookie_t opc int flags .Fa const struct puffs_cred *pcr @@ -481,6 +486,7 @@ file, directory and device special file, In case of mknod, the device identifier can be found in .Fa va-\*[Gt]va_rdev . .It Fn puffs_node_open pu opc mode pcr +.It Fn puffs_node_open2 pu opc mode pcr oflags Open the node denoted by the cookie .Fa opc . The parameter @@ -491,6 +497,12 @@ was called with, e.g. .Dv O_APPEND and .Dv O_NONBLOCK . +.Fn puffs_node_open2 +allows the filesystem to pass back information for the file in +.Fa oflags . +The only implemented flag for now is +.Dv PUFFS_OPEN_IO_DIRECT +that cause file read/write to bypass the page cache. .It Fn puffs_node_close pu opc flags pcr Close a node. The parameter
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Sat Aug 16 16:28:43 UTC 2014 Modified Files: src/lib/libperfuse: ops.c perfuse.c perfuse_priv.h Log Message: Use just introduced open2 PUFFS method and its PUFFS_OPEN_IO_DIRECT oflag to implement FUSE's OPEN_IO_DIRECT, by which the filesystem tells the kernel that read/write to the file should bypass the page cache. Remove a warning about read beyond EOF which will now normally appear when page cache is bypassed. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/lib/libperfuse/ops.c cvs rdiff -u -r1.31 -r1.32 src/lib/libperfuse/perfuse.c cvs rdiff -u -r1.32 -r1.33 src/lib/libperfuse/perfuse_priv.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.66 src/lib/libperfuse/ops.c:1.67 --- src/lib/libperfuse/ops.c:1.66 Sun Aug 10 03:22:33 2014 +++ src/lib/libperfuse/ops.c Sat Aug 16 16:28:43 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.66 2014/08/10 03:22:33 manu Exp $ */ +/* $NetBSD: ops.c,v 1.67 2014/08/16 16:28:43 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -1338,6 +1338,13 @@ int perfuse_node_open(struct puffs_usermount *pu, puffs_cookie_t opc, int mode, const struct puffs_cred *pcr) { + return perfuse_node_open2(pu, opc, mode, pcr, NULL); +} + +int +perfuse_node_open2(struct puffs_usermount *pu, puffs_cookie_t opc, int mode, + const struct puffs_cred *pcr, int *oflags) +{ struct perfuse_state *ps; struct perfuse_node_data *pnd; perfuse_msg_t *pm; @@ -1439,6 +1446,12 @@ perfuse_node_open(struct puffs_usermount */ perfuse_new_fh(opc, foo-fh, mode); + /* + * Set direct I/O if the filesystems forces it + */ + if ((foo-open_flags FUSE_FOPEN_DIRECT_IO) (oflags != NULL)) + *oflags |= PUFFS_OPEN_IO_DIRECT; + #ifdef PERFUSE_DEBUG if (perfuse_diagflags (PDF_FH|PDF_FILENAME)) DPRINTF(%s: opc = %p, file = \%s\, @@ -3031,11 +3044,6 @@ perfuse_node_read(struct puffs_usermount if (vap-va_type == VDIR) return EISDIR; - if ((u_quad_t)offset + *resid vap-va_size) - DWARNX(%s %p read %lld@%zu beyond EOF % PRIu64 \n, - __func__, (void *)opc, (long long)offset, - *resid, vap-va_size); - do { size_t max_read; Index: src/lib/libperfuse/perfuse.c diff -u src/lib/libperfuse/perfuse.c:1.31 src/lib/libperfuse/perfuse.c:1.32 --- src/lib/libperfuse/perfuse.c:1.31 Mon Sep 10 13:56:18 2012 +++ src/lib/libperfuse/perfuse.c Sat Aug 16 16:28:43 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: perfuse.c,v 1.31 2012/09/10 13:56:18 manu Exp $ */ +/* $NetBSD: perfuse.c,v 1.32 2014/08/16 16:28:43 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -503,6 +503,9 @@ perfuse_init(struct perfuse_callbacks *p #ifdef PUFFS_SETATTR_FAF PUFFSOP_SET(pops, perfuse, node, write2); #endif /* PUFFS_SETATTR_FAF */ +#ifdef PUFFS_OPEN_IO_DIRECT + PUFFSOP_SET(pops, perfuse, node, open2); +#endif /* PUFFS_OPEN_IO_DIRECT */ /* * PUFFS_KFLAG_NOCACHE_NAME is required so that we can see changes Index: src/lib/libperfuse/perfuse_priv.h diff -u src/lib/libperfuse/perfuse_priv.h:1.32 src/lib/libperfuse/perfuse_priv.h:1.33 --- src/lib/libperfuse/perfuse_priv.h:1.32 Sun Aug 10 03:22:33 2014 +++ src/lib/libperfuse/perfuse_priv.h Sat Aug 16 16:28:43 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: perfuse_priv.h,v 1.32 2014/08/10 03:22:33 manu Exp $ */ +/* $NetBSD: perfuse_priv.h,v 1.33 2014/08/16 16:28:43 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -262,6 +262,8 @@ int perfuse_node_write(struct puffs_user uint8_t *, off_t, size_t *, const struct puffs_cred *, int); int perfuse_node_write2(struct puffs_usermount *, puffs_cookie_t, uint8_t *, off_t, size_t *, const struct puffs_cred *, int, int); +int perfuse_node_open2(struct puffs_usermount *, +puffs_cookie_t, int, const struct puffs_cred *, int *); void perfuse_cache_write(struct puffs_usermount *, puffs_cookie_t, size_t, struct puffs_cacherun *); int perfuse_node_getextattr(struct puffs_usermount *, puffs_cookie_t,
CVS commit: src/usr.sbin/perfused
Module Name:src Committed By: manu Date: Sat Aug 16 16:32:04 UTC 2014 Modified Files: src/usr.sbin/perfused: msg.c Log Message: Remove a warning that happens when the filesystem cleanly exits. Just display a message when running in debug mode. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/perfused/msg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.sbin/perfused/msg.c diff -u src/usr.sbin/perfused/msg.c:1.21 src/usr.sbin/perfused/msg.c:1.22 --- src/usr.sbin/perfused/msg.c:1.21 Sat Jul 21 05:49:42 2012 +++ src/usr.sbin/perfused/msg.c Sat Aug 16 16:32:04 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: msg.c,v 1.21 2012/07/21 05:49:42 manu Exp $ */ +/* $NetBSD: msg.c,v 1.22 2014/08/16 16:32:04 manu Exp $ */ /*- * Copyright (c) 2010 Emmanuel Dreyfus. All rights reserved. @@ -493,7 +493,10 @@ perfused_readframe(struct puffs_usermoun switch (readen = recv(fd, data, len, MSG_NOSIGNAL|MSG_PEEK)) { case 0: - perfused_panic(); + DPRINTF(Filesystem exit\n); + /* NOTREACHED */ + exit(0); + break; case -1: if (errno == EAGAIN) return 0;
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Sat Aug 16 16:31:16 UTC 2014 Modified Files: src/lib/libperfuse: ops.c perfuse.c perfuse_priv.h Log Message: Removed unimplemented mmap and seek method. seek's declaration caused seek request to be passed backand forth between kernel and userland while we did nothing about them. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/lib/libperfuse/ops.c cvs rdiff -u -r1.32 -r1.33 src/lib/libperfuse/perfuse.c cvs rdiff -u -r1.33 -r1.34 src/lib/libperfuse/perfuse_priv.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.67 src/lib/libperfuse/ops.c:1.68 --- src/lib/libperfuse/ops.c:1.67 Sat Aug 16 16:28:43 2014 +++ src/lib/libperfuse/ops.c Sat Aug 16 16:31:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.67 2014/08/16 16:28:43 manu Exp $ */ +/* $NetBSD: ops.c,v 1.68 2014/08/16 16:31:15 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -1960,17 +1960,6 @@ out: return error; } -/* ARGSUSED0 */ -int -perfuse_node_mmap(struct puffs_usermount *pu, puffs_cookie_t opc, int flags, - const struct puffs_cred *pcr) -{ - /* - * Not implemented anymore in libfuse - */ - return ENOSYS; -} - /* ARGSUSED2 */ int perfuse_node_fsync(struct puffs_usermount *pu, puffs_cookie_t opc, @@ -2085,14 +2074,6 @@ out: return error; } -/* ARGSUSED0 */ -int -perfuse_node_seek(struct puffs_usermount *pu, puffs_cookie_t opc, - off_t oldoff, off_t newoff, const struct puffs_cred *pcr) -{ - return 0; -} - int perfuse_node_remove(struct puffs_usermount *pu, puffs_cookie_t opc, puffs_cookie_t targ, const struct puffs_cn *pcn) Index: src/lib/libperfuse/perfuse.c diff -u src/lib/libperfuse/perfuse.c:1.32 src/lib/libperfuse/perfuse.c:1.33 --- src/lib/libperfuse/perfuse.c:1.32 Sat Aug 16 16:28:43 2014 +++ src/lib/libperfuse/perfuse.c Sat Aug 16 16:31:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: perfuse.c,v 1.32 2014/08/16 16:28:43 manu Exp $ */ +/* $NetBSD: perfuse.c,v 1.33 2014/08/16 16:31:15 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -471,11 +471,7 @@ perfuse_init(struct perfuse_callbacks *p PUFFSOP_SET(pops, perfuse, node, getattr); PUFFSOP_SET(pops, perfuse, node, setattr); PUFFSOP_SET(pops, perfuse, node, poll); -#if 0 - PUFFSOP_SET(pops, perfuse, node, mmap); -#endif PUFFSOP_SET(pops, perfuse, node, fsync); - PUFFSOP_SET(pops, perfuse, node, seek); PUFFSOP_SET(pops, perfuse, node, remove); PUFFSOP_SET(pops, perfuse, node, link); PUFFSOP_SET(pops, perfuse, node, rename); Index: src/lib/libperfuse/perfuse_priv.h diff -u src/lib/libperfuse/perfuse_priv.h:1.33 src/lib/libperfuse/perfuse_priv.h:1.34 --- src/lib/libperfuse/perfuse_priv.h:1.33 Sat Aug 16 16:28:43 2014 +++ src/lib/libperfuse/perfuse_priv.h Sat Aug 16 16:31:15 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: perfuse_priv.h,v 1.33 2014/08/16 16:28:43 manu Exp $ */ +/* $NetBSD: perfuse_priv.h,v 1.34 2014/08/16 16:31:15 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -223,12 +223,8 @@ int perfuse_node_getattr(struct puffs_us int perfuse_node_setattr(struct puffs_usermount *, puffs_cookie_t, const struct vattr *, const struct puffs_cred *); int perfuse_node_poll(struct puffs_usermount *, puffs_cookie_t, int *); -int perfuse_node_mmap(struct puffs_usermount *, -puffs_cookie_t, vm_prot_t, const struct puffs_cred *); int perfuse_node_fsync(struct puffs_usermount *, puffs_cookie_t, const struct puffs_cred *, int, off_t, off_t); -int perfuse_node_seek(struct puffs_usermount *, -puffs_cookie_t, off_t, off_t, const struct puffs_cred *); int perfuse_node_remove(struct puffs_usermount *, puffs_cookie_t, puffs_cookie_t, const struct puffs_cn *); int perfuse_node_link(struct puffs_usermount *,
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Sat Aug 9 19:06:50 UTC 2014 Modified Files: src/lib/libperfuse: ops.c Log Message: getextattr: fix attribute length being reported to caller. If buffer is too small, return ENORANGE. Caught by glusterFS regression tests To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.64 src/lib/libperfuse/ops.c:1.65 --- src/lib/libperfuse/ops.c:1.64 Sat Aug 9 03:17:11 2014 +++ src/lib/libperfuse/ops.c Sat Aug 9 19:06:50 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.64 2014/08/09 03:17:11 manu Exp $ */ +/* $NetBSD: ops.c,v 1.65 2014/08/09 19:06:50 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -3359,9 +3359,17 @@ perfuse_node_getextattr(struct puffs_use */ foh = GET_OUTHDR(ps, pm); np = (char *)(void *)(foh + 1); + len = foh-len - sizeof(*foh); + + if (attrsize != NULL) + *attrsize = len; if (resid != NULL) { - len = MAX(foh-len - sizeof(*foh), *resid); + if (*resid len) { + error = ERANGE; + goto out; + } + (void)memcpy(attr, np, len); *resid -= len; }
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Sun Aug 10 03:22:33 UTC 2014 Modified Files: src/lib/libperfuse: ops.c perfuse_priv.h subr.c Log Message: - Make sure non root users cannot access system namespace attributes - honour namespace specification when listing attributes - Also fix message memory leak introduced by previous commit To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/lib/libperfuse/ops.c cvs rdiff -u -r1.31 -r1.32 src/lib/libperfuse/perfuse_priv.h cvs rdiff -u -r1.19 -r1.20 src/lib/libperfuse/subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.65 src/lib/libperfuse/ops.c:1.66 --- src/lib/libperfuse/ops.c:1.65 Sat Aug 9 19:06:50 2014 +++ src/lib/libperfuse/ops.c Sun Aug 10 03:22:33 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.65 2014/08/09 19:06:50 manu Exp $ */ +/* $NetBSD: ops.c,v 1.66 2014/08/10 03:22:33 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -3323,6 +3323,10 @@ perfuse_node_getextattr(struct puffs_use char *np; int error; + /* system namespace attrs are not accessible to non root users */ + if (attrns == EXTATTR_NAMESPACE_SYSTEM !puffs_cred_isjuggernaut(pcr)) + return EPERM; + node_ref(opc); ps = puffs_getspecific(pu); attrname = perfuse_native_ns(attrns, attrname, fuse_attrname); @@ -3367,6 +3371,7 @@ perfuse_node_getextattr(struct puffs_use if (resid != NULL) { if (*resid len) { error = ERANGE; + ps-ps_destroy_msg(pm); goto out; } @@ -3396,6 +3401,10 @@ perfuse_node_setextattr(struct puffs_use char *np; int error; + /* system namespace attrs are not accessible to non root users */ + if (attrns == EXTATTR_NAMESPACE_SYSTEM !puffs_cred_isjuggernaut(pcr)) + return EPERM; + node_ref(opc); ps = puffs_getspecific(pu); attrname = perfuse_native_ns(attrns, attrname, fuse_attrname); @@ -3436,9 +3445,13 @@ perfuse_node_listextattr(struct puffs_us struct fuse_getxattr_out *fgo; struct fuse_out_header *foh; char *np; - size_t len, puffs_len; + size_t len, puffs_len, i, attrlen, outlen; int error; + /* system namespace attrs are not accessible to non root users */ + if (attrns == EXTATTR_NAMESPACE_SYSTEM !puffs_cred_isjuggernaut(pcr)) + return EPERM; + node_ref(opc); ps = puffs_getspecific(pu); @@ -3478,28 +3491,44 @@ perfuse_node_listextattr(struct puffs_us np = (char *)(void *)(foh + 1); puffs_len = foh-len - sizeof(*foh); - if (attrs != NULL) { -#ifdef PUFFS_EXTATTR_LIST_LENPREFIX - /* - * Convert the FUSE reply to length prefixed strings - * if this is what the kernel wants. - */ - if (flag PUFFS_EXTATTR_LIST_LENPREFIX) { - size_t i, attrlen; + if (attrsize != NULL) + *attrsize = puffs_len; - for (i = 0; i puffs_len; i += attrlen + 1) { -attrlen = strlen(np + i); -(void)memmove(np + i + 1, np + i, attrlen); -*(np + i) = (uint8_t)attrlen; - } + if (attrs != NULL) { + if (*resid puffs_len) { + error = ERANGE; + ps-ps_destroy_msg(pm); + goto out; } + + outlen = 0; + + for (i = 0; i puffs_len; i += attrlen + 1) { + attrlen = strlen(np + i); + + /* + * Filter attributes per namespace + */ + if (!perfuse_ns_match(attrns, np + i)) +continue; + +#ifdef PUFFS_EXTATTR_LIST_LENPREFIX + /* + * Convert the FUSE reply to length prefixed strings + * if this is what the kernel wants. + */ + if (flag PUFFS_EXTATTR_LIST_LENPREFIX) { +(void)memcpy(attrs + outlen + 1, + np + i, attrlen); +*(attrs + outlen) = (uint8_t)attrlen; + } else #endif /* PUFFS_EXTATTR_LIST_LENPREFIX */ - (void)memcpy(attrs, np, puffs_len); - *resid -= puffs_len; - } + (void)memcpy(attrs + outlen, np + i, attrlen + 1); + outlen += attrlen + 1; + } - if (attrsize != NULL) - *attrsize = puffs_len; + *resid -= outlen; + } ps-ps_destroy_msg(pm); error = 0; @@ -3520,6 +3549,10 @@ perfuse_node_deleteextattr(struct puffs_ char *np; int error; + /* system namespace attrs are not accessible to non root users */ + if (attrns == EXTATTR_NAMESPACE_SYSTEM !puffs_cred_isjuggernaut(pcr)) + return EPERM; + node_ref(opc); ps = puffs_getspecific(pu); Index: src/lib/libperfuse/perfuse_priv.h diff -u src/lib/libperfuse/perfuse_priv.h:1.31 src/lib/libperfuse/perfuse_priv.h:1.32 --- src/lib/libperfuse/perfuse_priv.h:1.31 Sat Jul 21 05:49:42 2012 +++ src/lib/libperfuse/perfuse_priv.h Sun Aug 10 03:22:33 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: perfuse_priv.h,v 1.31 2012/07/21 05:49:42 manu Exp $ */ +/* $NetBSD: perfuse_priv.h,v 1.32 2014/08/10 03:22:33 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -186,6 +186,7 @@ uint64_t perfuse_get_fh(puffs_cookie_t, uint64_t perfuse_next_unique(struct puffs_usermount *); char *perfuse_node_path(struct perfuse_state *, puffs_cookie_t
CVS commit: src/lib/libperfuse
Module Name:src Committed By: manu Date: Sat Aug 9 03:17:11 UTC 2014 Modified Files: src/lib/libperfuse: ops.c Log Message: Send GETATTR to filesystem for removed but still-open files, as it is the expected behavior (bug caught by glusterFS regression tests) To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/lib/libperfuse/ops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/lib/libperfuse/ops.c diff -u src/lib/libperfuse/ops.c:1.63 src/lib/libperfuse/ops.c:1.64 --- src/lib/libperfuse/ops.c:1.63 Mon Jan 6 08:56:34 2014 +++ src/lib/libperfuse/ops.c Sat Aug 9 03:17:11 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ops.c,v 1.63 2014/01/06 08:56:34 manu Exp $ */ +/* $NetBSD: ops.c,v 1.64 2014/08/09 03:17:11 manu Exp $ */ /*- * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. @@ -1554,7 +1554,7 @@ perfuse_node_getattr_ttl(struct puffs_us struct fuse_attr_out *fao; int error = 0; - if (pnd-pnd_flags PND_REMOVED) + if ((pnd-pnd_flags PND_REMOVED) !(pnd-pnd_flags PND_OPEN)) return ENOENT; node_ref(opc);
CVS commit: src/usr.bin/extattr
Module Name:src Committed By: manu Date: Fri Jun 20 14:55:32 UTC 2014 Modified Files: src/usr.bin/extattr: getextattr.c Log Message: Do not record a trailing \0 From Thomas Schmitt scdbac...@gmx.net To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.bin/extattr/getextattr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/extattr/getextattr.c diff -u src/usr.bin/extattr/getextattr.c:1.10 src/usr.bin/extattr/getextattr.c:1.11 --- src/usr.bin/extattr/getextattr.c:1.10 Sun Jun 17 08:09:29 2012 +++ src/usr.bin/extattr/getextattr.c Fri Jun 20 14:55:31 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: getextattr.c,v 1.10 2012/06/17 08:09:29 manu Exp $ */ +/* $NetBSD: getextattr.c,v 1.11 2014/06/20 14:55:31 manu Exp $ */ /*- * Copyright (c) 2002, 2003 Networks Associates Technology, Inc. @@ -310,8 +310,8 @@ main(int argc, char *argv[]) (void)close(fd); } else { - val_len = strlen(argv[0]) + 1; - mkbuf(buf, buflen, val_len); + val_len = strlen(argv[0]); + mkbuf(buf, buflen, val_len + 1); strcpy(buf, argv[0]); /* safe */ argc--; argv++; }
CVS commit: src/usr.bin/extattr
Module Name:src Committed By: manu Date: Fri Jun 20 15:22:01 UTC 2014 Modified Files: src/usr.bin/extattr: getextattr.c Log Message: Use returned size and not buffer max length when displaying attribute From Thomas Schmitt scdbac...@gmx.net To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/extattr/getextattr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/extattr/getextattr.c diff -u src/usr.bin/extattr/getextattr.c:1.11 src/usr.bin/extattr/getextattr.c:1.12 --- src/usr.bin/extattr/getextattr.c:1.11 Fri Jun 20 14:55:31 2014 +++ src/usr.bin/extattr/getextattr.c Fri Jun 20 15:22:01 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: getextattr.c,v 1.11 2014/06/20 14:55:31 manu Exp $ */ +/* $NetBSD: getextattr.c,v 1.12 2014/06/20 15:22:01 manu Exp $ */ /*- * Copyright (c) 2002, 2003 Networks Associates Technology, Inc. @@ -406,7 +406,7 @@ main(int argc, char *argv[]) hexdump(buf, error); continue; } else { -fwrite(buf, buflen, 1, stdout); +fwrite(buf, error, 1, stdout); printf(\n); continue; }