tmpfs vs mfs
Hi @tech i've migrated one of our squid server to OpenBSD 5.5 and i tested tmpfs. It works like a charm, great work, but i noticed than the mfs is faster than tmpfs. My benchs (with dd) are showing that tmpfs is slower than mfs. (/tmp: tmpfs | /var/squid/cache: mfs), i've done many dd to test it, and i always have the same results Writing performance dd if=/dev/zero of=/tmp/test.img bs=1024 count=100 100+0 records in 100+0 records out 102400 bytes transferred in 8.706 secs (117614588 bytes/sec) dd if=/dev/zero of=/var/squid/cache/test.img bs=1024 count=100 100+0 records in 100+0 records out 102400 bytes transferred in 3.044 secs (336379694 bytes/sec) Reading performance dd if=/var/squid/cache/test.img of=/dev/null bs=1000 1024000+0 records in 1024000+0 records out 102400 bytes transferred in 2.767 secs (370015585 bytes/sec) dd if=/tmp/test.img of=/dev/null bs=1000 1024000+0 records in 1024000+0 records out 102400 bytes transferred in 3.553 secs (288178274 bytes/sec) Then, what is the goal of tmpfs ? Replace mfs ? Create a tmpfs structure for some special dirs (like /dev, /tmp, /var/run...) ? If yes, is this new tmpfs structure into fstab will be used in -current and next release ? Thanks in advance -- Best regards, Loïc BLOT, Engineering UNIX Systems, Security and Network Engineer http://www.unix-experience.fr
Re: tmpfs vs mfs
dd would perhaps not be the end goal for any memory filesystem, but the major point is that when you remove files, tmpfs will (try to) return the memory to the OS, where mfs will not. 2014-05-06 8:28 GMT+02:00 Loïc Blot loic.b...@unix-experience.fr: Hi @tech i've migrated one of our squid server to OpenBSD 5.5 and i tested tmpfs. It works like a charm, great work, but i noticed than the mfs is faster than tmpfs. My benchs (with dd) are showing that tmpfs is slower than mfs. (/tmp: tmpfs | /var/squid/cache: mfs), i've done many dd to test it, and i always have the same results Writing performance dd if=/dev/zero of=/tmp/test.img bs=1024 count=100 100+0 records in 100+0 records out 102400 bytes transferred in 8.706 secs (117614588 bytes/sec) dd if=/dev/zero of=/var/squid/cache/test.img bs=1024 count=100 100+0 records in 100+0 records out 102400 bytes transferred in 3.044 secs (336379694 bytes/sec) Reading performance dd if=/var/squid/cache/test.img of=/dev/null bs=1000 1024000+0 records in 1024000+0 records out 102400 bytes transferred in 2.767 secs (370015585 bytes/sec) dd if=/tmp/test.img of=/dev/null bs=1000 1024000+0 records in 1024000+0 records out 102400 bytes transferred in 3.553 secs (288178274 bytes/sec) Then, what is the goal of tmpfs ? Replace mfs ? Create a tmpfs structure for some special dirs (like /dev, /tmp, /var/run...) ? If yes, is this new tmpfs structure into fstab will be used in -current and next release ? Thanks in advance -- Best regards, Loïc BLOT, Engineering UNIX Systems, Security and Network Engineer http://www.unix-experience.fr -- May the most significant bit of your life be positive.
Re: tmpfs vs mfs
On 2014/05/06 09:28, Janne Johansson wrote: dd would perhaps not be the end goal for any memory filesystem, but the major point is that when you remove files, tmpfs will (try to) return the memory to the OS, where mfs will not. When used for things like port build directories or cvs /tmp, tmpfs performs better. On the other hand, at present mfs is more stable. 2014-05-06 8:28 GMT+02:00 Loïc Blot loic.b...@unix-experience.fr: My benchs (with dd) are showing that tmpfs is slower than mfs. (/tmp: tmpfs | /var/squid/cache: mfs), i've done many dd to test it, and i always have the same results I'm not sure I understand why you'd prefer to point squid at any type of memory filesystem rather than use its internal memory caching?
m-m_pkthdr.rcvif dereference
Diff below reduce the number of m-m_pkthdr.rcvif usage in icmp{,6} code. Should introduce no functional change but that will help me with upcoming pointer - index conversion. ok? Index: netinet/ip_icmp.c === RCS file: /home/ncvs/src/sys/netinet/ip_icmp.c,v retrieving revision 1.121 diff -u -p -r1.121 ip_icmp.c --- netinet/ip_icmp.c 21 Apr 2014 12:22:26 - 1.121 +++ netinet/ip_icmp.c 6 May 2014 09:23:11 - @@ -305,6 +305,7 @@ icmp_error(struct mbuf *n, int type, int void icmp_input(struct mbuf *m, ...) { + struct ifnet *ifp; struct icmp *icp; struct ip *ip = mtod(m, struct ip *); struct sockaddr_in sin; @@ -318,6 +319,8 @@ icmp_input(struct mbuf *m, ...) hlen = va_arg(ap, int); va_end(ap); + ifp = m-m_pkthdr.rcvif; + /* * Locate icmp structure in mbuf, and check * that not corrupted and of at least minimum length. @@ -480,7 +483,7 @@ icmp_input(struct mbuf *m, ...) sin.sin_len = sizeof(struct sockaddr_in); sin.sin_addr = icp-icmp_ip.ip_dst; #if NCARP 0 - if (m-m_pkthdr.rcvif-if_type == IFT_CARP + if (ifp-if_type == IFT_CARP carp_lsdrop(m, AF_INET, sin.sin_addr.s_addr, ip-ip_dst.s_addr)) goto freeit; @@ -545,10 +548,9 @@ icmp_input(struct mbuf *m, ...) sin.sin_addr = ip-ip_src; else sin.sin_addr = ip-ip_dst; - if (m-m_pkthdr.rcvif == NULL) + if (ifp == NULL) break; - ia = ifatoia(ifaof_ifpforaddr(sintosa(sin), - m-m_pkthdr.rcvif)); + ia = ifatoia(ifaof_ifpforaddr(sintosa(sin), ifp)); if (ia == 0) break; icp-icmp_type = ICMP_MASKREPLY; @@ -565,7 +567,7 @@ icmp_input(struct mbuf *m, ...) } reflect: #if NCARP 0 - if (m-m_pkthdr.rcvif-if_type == IFT_CARP + if (ifp-if_type == IFT_CARP carp_lsdrop(m, AF_INET, ip-ip_src.s_addr, ip-ip_dst.s_addr)) goto freeit; @@ -631,7 +633,7 @@ reflect: #endif #if NCARP 0 - if (m-m_pkthdr.rcvif-if_type == IFT_CARP + if (ifp-if_type == IFT_CARP carp_lsdrop(m, AF_INET, sdst.sin_addr.s_addr, ip-ip_dst.s_addr)) goto freeit; Index: netinet6/icmp6.c === RCS file: /home/ncvs/src/sys/netinet6/icmp6.c,v retrieving revision 1.143 diff -u -p -r1.143 icmp6.c --- netinet6/icmp6.c18 Apr 2014 10:48:30 - 1.143 +++ netinet6/icmp6.c6 May 2014 09:23:11 - @@ -385,6 +385,7 @@ icmp6_error(struct mbuf *m, int type, in int icmp6_input(struct mbuf **mp, int *offp, int proto) { + struct ifnet *ifp; struct mbuf *m = *mp, *n; struct ip6_hdr *ip6, *nip6; struct icmp6_hdr *icmp6, *nicmp6; @@ -393,7 +394,9 @@ icmp6_input(struct mbuf **mp, int *offp, int code, sum, noff; char src[INET6_ADDRSTRLEN], dst[INET6_ADDRSTRLEN]; - icmp6_ifstat_inc(m-m_pkthdr.rcvif, ifs6_in_msg); + ifp = m-m_pkthdr.rcvif; + + icmp6_ifstat_inc(ifp, ifs6_in_msg); /* * Locate icmp6 structure in mbuf, and check @@ -403,7 +406,7 @@ icmp6_input(struct mbuf **mp, int *offp, ip6 = mtod(m, struct ip6_hdr *); if (icmp6len sizeof(struct icmp6_hdr)) { icmp6stat.icp6s_tooshort++; - icmp6_ifstat_inc(m-m_pkthdr.rcvif, ifs6_in_error); + icmp6_ifstat_inc(ifp, ifs6_in_error); goto freeit; } @@ -423,7 +426,7 @@ icmp6_input(struct mbuf **mp, int *offp, icmp6-icmp6_type, sum, inet_ntop(AF_INET6, ip6-ip6_src, src, sizeof(src; icmp6stat.icp6s_checksum++; - icmp6_ifstat_inc(m-m_pkthdr.rcvif, ifs6_in_error); + icmp6_ifstat_inc(ifp, ifs6_in_error); goto freeit; } @@ -446,7 +449,7 @@ icmp6_input(struct mbuf **mp, int *offp, #endif /* NPF */ #if NCARP 0 - if (m-m_pkthdr.rcvif-if_type == IFT_CARP + if (ifp-if_type == IFT_CARP icmp6-icmp6_type == ICMP6_ECHO_REQUEST carp_lsdrop(m, AF_INET6, ip6-ip6_src.s6_addr32, ip6-ip6_dst.s6_addr32)) @@ -456,13 +459,13 @@ icmp6_input(struct mbuf **mp, int *offp, switch (icmp6-icmp6_type) { case ICMP6_DST_UNREACH: - icmp6_ifstat_inc(m-m_pkthdr.rcvif, ifs6_in_dstunreach); + icmp6_ifstat_inc(ifp, ifs6_in_dstunreach); switch (code) { case ICMP6_DST_UNREACH_NOROUTE: code = PRC_UNREACH_NET;
Kill {nd6_,}useloopback
Using the loopback interface for local traffic is not optional. I wonder if anybody using IPv6 ever turned this sysctl off. I'd be interested to hear from you and see your routing table if you did it. Otherwise, the diff below removes the global variable for IPv4 and the sysctl button for IPv6, ok? Index: sys/netinet/icmp6.h === RCS file: /home/ncvs/src/sys/netinet/icmp6.h,v retrieving revision 1.38 diff -u -p -r1.38 icmp6.h --- sys/netinet/icmp6.h 24 Oct 2013 11:20:16 - 1.38 +++ sys/netinet/icmp6.h 6 May 2014 09:53:40 - @@ -529,7 +529,6 @@ struct icmp6stat { #define ICMPV6CTL_ND6_DELAY8 #define ICMPV6CTL_ND6_UMAXTRIES9 #define ICMPV6CTL_ND6_MMAXTRIES10 -#define ICMPV6CTL_ND6_USELOOPBACK 11 #define ICMPV6CTL_NODEINFO 13 #define ICMPV6CTL_ERRPPSLIMIT 14 /* ICMPv6 error pps limitation */ #define ICMPV6CTL_ND6_MAXNUDHINT 15 @@ -552,7 +551,7 @@ struct icmp6stat { { nd6_delay, CTLTYPE_INT }, \ { nd6_umaxtries, CTLTYPE_INT }, \ { nd6_mmaxtries, CTLTYPE_INT }, \ - { nd6_useloopback, CTLTYPE_INT }, \ + { 0, 0 }, \ { 0, 0 }, \ { nodeinfo, CTLTYPE_INT }, \ { errppslimit, CTLTYPE_INT }, \ @@ -576,7 +575,7 @@ struct icmp6stat { nd6_delay, \ nd6_umaxtries, \ nd6_mmaxtries, \ - nd6_useloopback, \ + NULL, \ NULL, \ icmp6_nodeinfo, \ icmp6errppslim, \ Index: sys/netinet/if_ether.c === RCS file: /home/ncvs/src/sys/netinet/if_ether.c,v retrieving revision 1.126 diff -u -p -r1.126 if_ether.c --- sys/netinet/if_ether.c 5 May 2014 11:44:33 - 1.126 +++ sys/netinet/if_ether.c 6 May 2014 09:53:40 - @@ -90,7 +90,6 @@ LIST_HEAD(, llinfo_arp) llinfo_arp; struct ifqueue arpintrq; intarp_inuse, arp_allocated; intarp_maxtries = 5; -intuseloopback = 1;/* use loopback interface for local traffic */ intarpinit_done; intla_hold_total; @@ -233,23 +232,6 @@ arp_rtrequest(int req, struct rtentry *r break; } if (ifa) { - /* -* This test used to be -* if (lo0ifp-if_flags IFF_UP) -* It allowed local traffic to be forced through -* the hardware by configuring the loopback down. -* However, it causes problems during network -* configuration for boards that can't receive -* packets they send. It is now necessary to clear -* useloopback and remove the route to force -* traffic out to the hardware. -* -* In 4.4BSD, the above if statement checked -* rt-rt_ifa against rt_key(rt). It was changed -* to the current form so that we can provide a -* better support for multiple IPv4 addresses on a -* interface. -*/ rt-rt_expire = 0; SDL(gate)-sdl_alen = ETHER_ADDR_LEN; memcpy(LLADDR(SDL(gate)), @@ -260,8 +242,8 @@ arp_rtrequest(int req, struct rtentry *r * should not (ab)use it for any route related * to an interface of a different rdomain. */ - if (useloopback) - rt-rt_ifp = lo0ifp; + rt-rt_ifp = lo0ifp; + /* * make sure to set rt-rt_ifa to the interface * address we are using, otherwise we will have trouble Index: sbin/sysctl/sysctl.8 === RCS file: /home/ncvs/src/sbin/sysctl/sysctl.8,v retrieving revision 1.179 diff -u -p -r1.179 sysctl.8 --- sbin/sysctl/sysctl.84 May 2014 07:01:10 - 1.179 +++ sbin/sysctl/sysctl.86 May 2014 09:53:40 - @@ -317,7 +317,6 @@ and a few require a kernel compiled with .It net.inet6.icmp6.nd6_delay Ta integer Ta yes .It net.inet6.icmp6.nd6_umaxtries Ta integer Ta yes .It net.inet6.icmp6.nd6_mmaxtries Ta integer Ta yes -.It net.inet6.icmp6.nd6_useloopback Ta integer Ta yes .It net.inet6.icmp6.nodeinfo Ta integer Ta yes .It net.inet6.icmp6.errppslimit Ta integer Ta yes .It net.inet6.icmp6.nd6_maxnudhint Ta integer Ta yes Index: lib/libc/gen/sysctl.3 === RCS file: /home/ncvs/src/lib/libc/gen/sysctl.3,v retrieving revision 1.234 diff -u -p -r1.234 sysctl.3 --- lib/libc/gen/sysctl.3 4 May 2014 07:01:10 - 1.234 +++
Re: Kill {nd6_,}useloopback
On Tue, May 06, 2014 at 12:03:10PM +0200, Martin Pieuchot wrote: Using the loopback interface for local traffic is not optional. I wonder if anybody using IPv6 ever turned this sysctl off. I'd be interested to hear from you and see your routing table if you did it. Otherwise, the diff below removes the global variable for IPv4 and the sysctl button for IPv6, ok? Yes. I agree with removing this. I'd never turn on a knob that could make lo0 leak its traffic to the outside world... Index: sys/netinet/icmp6.h === RCS file: /home/ncvs/src/sys/netinet/icmp6.h,v retrieving revision 1.38 diff -u -p -r1.38 icmp6.h --- sys/netinet/icmp6.h 24 Oct 2013 11:20:16 - 1.38 +++ sys/netinet/icmp6.h 6 May 2014 09:53:40 - @@ -529,7 +529,6 @@ struct icmp6stat { #define ICMPV6CTL_ND6_DELAY 8 #define ICMPV6CTL_ND6_UMAXTRIES 9 #define ICMPV6CTL_ND6_MMAXTRIES 10 -#define ICMPV6CTL_ND6_USELOOPBACK11 #define ICMPV6CTL_NODEINFO 13 #define ICMPV6CTL_ERRPPSLIMIT14 /* ICMPv6 error pps limitation */ #define ICMPV6CTL_ND6_MAXNUDHINT 15 @@ -552,7 +551,7 @@ struct icmp6stat { { nd6_delay, CTLTYPE_INT }, \ { nd6_umaxtries, CTLTYPE_INT }, \ { nd6_mmaxtries, CTLTYPE_INT }, \ - { nd6_useloopback, CTLTYPE_INT }, \ + { 0, 0 }, \ { 0, 0 }, \ { nodeinfo, CTLTYPE_INT }, \ { errppslimit, CTLTYPE_INT }, \ @@ -576,7 +575,7 @@ struct icmp6stat { nd6_delay, \ nd6_umaxtries, \ nd6_mmaxtries, \ - nd6_useloopback, \ + NULL, \ NULL, \ icmp6_nodeinfo, \ icmp6errppslim, \ Index: sys/netinet/if_ether.c === RCS file: /home/ncvs/src/sys/netinet/if_ether.c,v retrieving revision 1.126 diff -u -p -r1.126 if_ether.c --- sys/netinet/if_ether.c5 May 2014 11:44:33 - 1.126 +++ sys/netinet/if_ether.c6 May 2014 09:53:40 - @@ -90,7 +90,6 @@ LIST_HEAD(, llinfo_arp) llinfo_arp; struct ifqueue arpintrq; int arp_inuse, arp_allocated; int arp_maxtries = 5; -int useloopback = 1;/* use loopback interface for local traffic */ int arpinit_done; int la_hold_total; @@ -233,23 +232,6 @@ arp_rtrequest(int req, struct rtentry *r break; } if (ifa) { - /* - * This test used to be - * if (lo0ifp-if_flags IFF_UP) - * It allowed local traffic to be forced through - * the hardware by configuring the loopback down. - * However, it causes problems during network - * configuration for boards that can't receive - * packets they send. It is now necessary to clear - * useloopback and remove the route to force - * traffic out to the hardware. - * - * In 4.4BSD, the above if statement checked - * rt-rt_ifa against rt_key(rt). It was changed - * to the current form so that we can provide a - * better support for multiple IPv4 addresses on a - * interface. - */ rt-rt_expire = 0; SDL(gate)-sdl_alen = ETHER_ADDR_LEN; memcpy(LLADDR(SDL(gate)), @@ -260,8 +242,8 @@ arp_rtrequest(int req, struct rtentry *r * should not (ab)use it for any route related * to an interface of a different rdomain. */ - if (useloopback) - rt-rt_ifp = lo0ifp; + rt-rt_ifp = lo0ifp; + /* * make sure to set rt-rt_ifa to the interface * address we are using, otherwise we will have trouble Index: sbin/sysctl/sysctl.8 === RCS file: /home/ncvs/src/sbin/sysctl/sysctl.8,v retrieving revision 1.179 diff -u -p -r1.179 sysctl.8 --- sbin/sysctl/sysctl.8 4 May 2014 07:01:10 - 1.179 +++ sbin/sysctl/sysctl.8 6 May 2014 09:53:40 - @@ -317,7 +317,6 @@ and a few require a kernel compiled with .It net.inet6.icmp6.nd6_delay Ta integer Ta yes .It net.inet6.icmp6.nd6_umaxtries Ta integer Ta yes .It net.inet6.icmp6.nd6_mmaxtries Ta integer Ta yes -.It net.inet6.icmp6.nd6_useloopback Ta integer Ta yes .It net.inet6.icmp6.nodeinfo Ta integer Ta yes .It net.inet6.icmp6.errppslimit Ta integer Ta yes .It net.inet6.icmp6.nd6_maxnudhint Ta integer Ta yes Index: lib/libc/gen/sysctl.3 ===
Fix the mtime for file creation on ext2+
Hello all. This fixes a bug with mtime not updated after file creation on ext2+ file systems. Try it yourself: # mount -t ext2fs /dev/sd0o /mnt # cp /tmp/qq /mnt # ls -l /mnt/qq -rw-r--r-- 1 root wheel 10 Jan 1 1970 qq # touch /mnt/qq -rw-r--r-- 1 root wheel 10 May 6 14:36 qq This probably does more than needed - I suspect that sometimes the updated mtime could be already there, but I don't see any real downside and it makes EX2FS_ITIMES() look more similar to ufs_itimies(). Opinions? Okays? -- WBR, Vadim Zhukov Index: inode.h === RCS file: /cvs/src/sys/ufs/ufs/inode.h,v retrieving revision 1.44 diff -u -p -r1.44 inode.h --- inode.h 14 Apr 2014 22:25:40 - 1.44 +++ inode.h 6 May 2014 10:36:59 - @@ -318,6 +318,8 @@ struct indir { (ip)-i_flag |= IN_MODIFIED;\ if ((ip)-i_flag IN_CHANGE) \ (ip)-i_e2fs_ctime = time_second; \ + if ((ip)-i_flag IN_UPDATE) \ + (ip)-i_e2fs_mtime = time_second; \ (ip)-i_flag = ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ } \ } while (0)
Re: ums(4) memory leak
On 06/05/14(Tue) 13:44, Jérémie Courrèges-Anglas wrote: Martin Pieuchot mpieuc...@nolizard.org writes: Plug a memory leak related to HID descriptor parsing, ok? I don't have any ums(4) device but this is obviously right, so ok. I've found this useless check during review: That's correct and ok mpi@, but could you please wait a bit before committing it, this will conflict with my HID parser diff. Index: hid.c === RCS file: /cvs/src/sys/dev/usb/hid.c,v retrieving revision 1.25 diff -u -p -p -u -r1.25 hid.c --- hid.c 5 Aug 2012 16:07:11 - 1.25 +++ hid.c 6 May 2014 11:43:07 - @@ -458,8 +458,6 @@ hid_is_collection(void *desc, int size, u_int32_t coll_usage = ~0; hd = hid_start_parse(desc, size, hid_none); - if (hd == NULL) - return (0); DPRINTFN(2,(hid_is_collection: id=%d usage=0x%x\n, id, usage)); while (hid_get_item(hd, hi)) { -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
USB sensors leak xfers
I don't have any of these devices so I appreciate if people can test this diff. It's basically the same pattern that has been copy/past'd in every driver. The rule is simple: if you uhidev_open() you need to uhidev_close() at some point. Ok? Index: ucycom.c === RCS file: /home/ncvs/src/sys/dev/usb/ucycom.c,v retrieving revision 1.26 diff -u -p -r1.26 ucycom.c --- ucycom.c15 Apr 2014 09:14:27 - 1.26 +++ ucycom.c6 May 2014 12:57:47 - @@ -582,6 +582,10 @@ ucycom_detach(struct device *self, int f config_detach(sc-sc_subdev, flags); sc-sc_subdev = NULL; } + + if (sc-sc_hdev.sc_state UHIDEV_OPEN) + uhidev_close(sc-sc_hdev); + return (0); } Index: uoaklux.c === RCS file: /home/ncvs/src/sys/dev/usb/uoaklux.c,v retrieving revision 1.7 diff -u -p -r1.7 uoaklux.c --- uoaklux.c 19 Mar 2014 08:59:37 - 1.7 +++ uoaklux.c 6 May 2014 12:57:47 - @@ -208,6 +208,9 @@ uoaklux_detach(struct device *self, int if (sc-sc_sensortask != NULL) sensor_task_unregister(sc-sc_sensortask); + if (sc-sc_hdev.sc_state UHIDEV_OPEN) + uhidev_close(sc-sc_hdev); + if (scc-sc_ibuf != NULL) { free(scc-sc_ibuf, M_USBDEV); scc-sc_ibuf = NULL; Index: uoakrh.c === RCS file: /home/ncvs/src/sys/dev/usb/uoakrh.c,v retrieving revision 1.8 diff -u -p -r1.8 uoakrh.c --- uoakrh.c19 Mar 2014 08:59:37 - 1.8 +++ uoakrh.c6 May 2014 12:57:47 - @@ -224,6 +224,9 @@ uoakrh_detach(struct device *self, int f if (sc-sc_sensortask != NULL) sensor_task_unregister(sc-sc_sensortask); + if (sc-sc_hdev.sc_state UHIDEV_OPEN) + uhidev_close(sc-sc_hdev); + if (scc-sc_ibuf != NULL) { free(scc-sc_ibuf, M_USBDEV); scc-sc_ibuf = NULL; Index: uoakv.c === RCS file: /home/ncvs/src/sys/dev/usb/uoakv.c,v retrieving revision 1.7 diff -u -p -r1.7 uoakv.c --- uoakv.c 19 Mar 2014 08:59:37 - 1.7 +++ uoakv.c 6 May 2014 12:57:47 - @@ -212,6 +212,9 @@ uoakv_detach(struct device *self, int fl if (sc-sc_sensortask != NULL) sensor_task_unregister(sc-sc_sensortask); + if (sc-sc_hdev.sc_state UHIDEV_OPEN) + uhidev_close(sc-sc_hdev); + if (scc-sc_ibuf != NULL) { free(scc-sc_ibuf, M_USBDEV); scc-sc_ibuf = NULL; Index: utrh.c === RCS file: /home/ncvs/src/sys/dev/usb/utrh.c,v retrieving revision 1.14 diff -u -p -r1.14 utrh.c --- utrh.c 15 Apr 2014 09:14:27 - 1.14 +++ utrh.c 6 May 2014 12:57:47 - @@ -175,6 +175,9 @@ utrh_detach(struct device *self, int fla sensor_task_unregister(sc-sc_sensortask); } + if (sc-sc_hdev.sc_state UHIDEV_OPEN) + uhidev_close(sc-sc_hdev); + if (sc-sc_ibuf != NULL) { free(sc-sc_ibuf, M_USBDEV); sc-sc_ibuf = NULL; Index: utwitch.c === RCS file: /home/ncvs/src/sys/dev/usb/utwitch.c,v retrieving revision 1.11 diff -u -p -r1.11 utwitch.c --- utwitch.c 15 Apr 2014 09:14:27 - 1.11 +++ utwitch.c 6 May 2014 12:57:47 - @@ -189,6 +189,9 @@ utwitch_detach(struct device *self, int if (sc-sc_sensortask != NULL) sensor_task_unregister(sc-sc_sensortask); + if (sc-sc_hdev.sc_state UHIDEV_OPEN) + uhidev_close(sc-sc_hdev); + if (sc-sc_ibuf != NULL) { free(sc-sc_ibuf, M_USBDEV); sc-sc_ibuf = NULL;
ftp(1) SSL_CTX memory leak(s)
Forgotten diff... For https connections which involve redirections, ftp(1) needlessly re-initializes libssl/libcrypto. It also creates, but doesn't free, a new SSL_CTX structure at each url_get() call. This diff makes ftp(1) perform this work lazily, and reuses the same SSL_CTX for subsequent HTTPS connections. I don't have the code anymore but using atexit(3) hooks to deallocate the libcrypto/libssl structures showed that indeed no leak was left there. Last hunk: as noticed by Mike Small and Maxime Villard, this patch adds a X509_free call for the server cert, in case the server hostname can't be validated. No functional change, just for consistency. Tests, comments and oks are welcome. Index: fetch.c === RCS file: /cvs/src/usr.bin/ftp/fetch.c,v retrieving revision 1.118 diff -u -p -p -u -r1.118 fetch.c --- fetch.c 9 Apr 2014 10:10:57 - 1.118 +++ fetch.c 22 Apr 2014 23:54:22 - @@ -87,6 +87,7 @@ int ssl_match_hostname(char *, char *); intssl_check_subject_altname(X509 *, char *); intssl_check_common_name(X509 *, char *); intssl_check_hostname(X509 *, char *); +SSL_CTX*ssl_get_ssl_ctx(void); #endif /* !SMALL */ #defineFTP_URL ftp://;/* ftp URL prefix */ @@ -329,6 +330,52 @@ ssl_check_hostname(X509 *cert, char *hos return ssl_check_common_name(cert, host); } + +SSL_CTX * +ssl_get_ssl_ctx(void) +{ + static SSL_CTX *ssl_ctx; + static int libssl_loaded; + + if (ssl_ctx != NULL) + return ssl_ctx; + + if (!libssl_loaded) { + SSL_library_init(); + SSL_load_error_strings(); + libssl_loaded = 1; + } + + ssl_ctx = SSL_CTX_new(SSLv23_client_method()); + if (ssl_ctx == NULL) + goto err; + + if (ssl_verify) { + if (ssl_ca_file == NULL ssl_ca_path == NULL) + ssl_ca_file = _PATH_SSL_CAFILE; + + if (SSL_CTX_load_verify_locations(ssl_ctx, + ssl_ca_file, ssl_ca_path) != 1) + goto err; + + SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, NULL); + if (ssl_verify_depth != -1) + SSL_CTX_set_verify_depth(ssl_ctx, + ssl_verify_depth); + } + + if (ssl_ciphers != NULL + SSL_CTX_set_cipher_list(ssl_ctx, ssl_ciphers) == -1) + goto err; + + return ssl_ctx; +err: + if (ssl_ctx != NULL) { + SSL_CTX_free(ssl_ctx); + ssl_ctx = NULL; + } + return NULL; +} #endif /* @@ -769,31 +816,11 @@ again: proxyurl = NULL; path = sslpath; } - SSL_library_init(); - SSL_load_error_strings(); - ssl_ctx = SSL_CTX_new(SSLv23_client_method()); + ssl_ctx = ssl_get_ssl_ctx(); if (ssl_ctx == NULL) { ERR_print_errors_fp(ttyout); goto cleanup_url_get; } - if (ssl_verify) { - if (ssl_ca_file == NULL ssl_ca_path == NULL) - ssl_ca_file = _PATH_SSL_CAFILE; - if (SSL_CTX_load_verify_locations(ssl_ctx, - ssl_ca_file, ssl_ca_path) != 1) { - ERR_print_errors_fp(ttyout); - goto cleanup_url_get; - } - SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, NULL); - if (ssl_verify_depth != -1) - SSL_CTX_set_verify_depth(ssl_ctx, - ssl_verify_depth); - } - if (ssl_ciphers != NULL - SSL_CTX_set_cipher_list(ssl_ctx, ssl_ciphers) == -1) { - ERR_print_errors_fp(ttyout); - goto cleanup_url_get; - } ssl = SSL_new(ssl_ctx); if (ssl == NULL) { ERR_print_errors_fp(ttyout); @@ -829,6 +856,7 @@ again: } if (ssl_check_hostname(cert, host) != 0) { + X509_free(cert); fprintf(ttyout, %s: host `%s' not present in server certificate\n, getprogname(), host); -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
Re: Fix the mtime for file creation on ext2+
On 6 May 2014 06:42, Vadim Zhukov persg...@gmail.com wrote: Hello all. This fixes a bug with mtime not updated after file creation on ext2+ file systems. Try it yourself: # mount -t ext2fs /dev/sd0o /mnt # cp /tmp/qq /mnt # ls -l /mnt/qq -rw-r--r-- 1 root wheel 10 Jan 1 1970 qq # touch /mnt/qq -rw-r--r-- 1 root wheel 10 May 6 14:36 qq This probably does more than needed - I suspect that sometimes the updated mtime could be already there, but I don't see any real downside and it makes EX2FS_ITIMES() look more similar to ufs_itimies(). Opinions? Okays? -- WBR, Vadim Zhukov Index: inode.h === RCS file: /cvs/src/sys/ufs/ufs/inode.h,v retrieving revision 1.44 diff -u -p -r1.44 inode.h --- inode.h 14 Apr 2014 22:25:40 - 1.44 +++ inode.h 6 May 2014 10:36:59 - @@ -318,6 +318,8 @@ struct indir { (ip)-i_flag |= IN_MODIFIED;\ if ((ip)-i_flag IN_CHANGE) \ (ip)-i_e2fs_ctime = time_second; \ + if ((ip)-i_flag IN_UPDATE) \ + (ip)-i_e2fs_mtime = time_second; \ (ip)-i_flag = ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ } \ } while (0) ok krw@ but it would be nice if a *real* filesystem guru opined too. :-) Ken
Re: Fix the mtime for file creation on ext2+
On Tue, 6 May 2014, Vadim Zhukov wrote: This fixes a bug with mtime not updated after file creation on ext2+ file systems. Try it yourself: # mount -t ext2fs /dev/sd0o /mnt # cp /tmp/qq /mnt # ls -l /mnt/qq -rw-r--r-- 1 root wheel 10 Jan 1 1970 qq # touch /mnt/qq -rw-r--r-- 1 root wheel 10 May 6 14:36 qq This probably does more than needed - I suspect that sometimes the updated mtime could be already there, but I don't see any real downside and it makes EX2FS_ITIMES() look more similar to ufs_itimies(). Opinions? Okays? As the person who broke this (sorry!), I think the diff should go a couple steps further and restore the IN_ACCESS handling too and mirror ufs_itimes() by bumping i_modrev on ctime change. Philip Index: ufs/ufs/inode.h === RCS file: /cvs/src/sys/ufs/ufs/inode.h,v retrieving revision 1.44 diff -u -p -r1.44 inode.h --- ufs/ufs/inode.h 14 Apr 2014 22:25:40 - 1.44 +++ ufs/ufs/inode.h 6 May 2014 15:31:24 - @@ -316,8 +316,14 @@ struct indir { #defineEXT2FS_ITIMES(ip) do { \ if ((ip)-i_flag (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ (ip)-i_flag |= IN_MODIFIED;\ - if ((ip)-i_flag IN_CHANGE) \ + if ((ip)-i_flag IN_ACCESS) \ + (ip)-i_e2fs_atime = time_second; \ + if ((ip)-i_flag IN_UPDATE) \ + (ip)-i_e2fs_mtime = time_second; \ + if ((ip)-i_flag IN_CHANGE) { \ (ip)-i_e2fs_ctime = time_second; \ + (ip)-i_modrev++; \ + } \ (ip)-i_flag = ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ } \ } while (0)
Re: Remove ln -F
Hi, if somebody wants to commit, ok schwarze@. Otherwise, i'm accepting OKs. See inline for a note on the history. Yours, Ingo Tristan Le Guern wrote on Mon, May 05, 2014 at 03:06:12PM +0200: This patch removes the undocumented ln flag -F, which forces the creation of a hard link for a directory. This option was present since before the first revision of NetBSD CVS, 21 years ago: http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/ln/ln.c I don't know where to dig for a more precise appearance date. A -f flag with the semantics of today's (well... for old values of today) -F first appeared in ATT Version 7 UNIX (1979). http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/ln.c Keith Bostic renamed -f to -F in September 1990, from the CSRG SCCS logs in bin/ln/SCCS/s.ln.c: s 00010/00010/00111 d D 4.13 90/06/19 14:10:53 bostic 16 15 c make -f option -F, S5 uses -f and POSIX is expected to. So 4.3BSD-Tahoe still called the flag -f, but since 4.3BSD-Reno, it is called -F. The problem is this option doesn't even work, the call to linkat(2) fails with EPERM. It's already removed in NetBSD and DragonFly. FreeBSD has an option with a similar name but a different meaning. Index: ln.c === RCS file: /home/tleguern/proj/perso/cvs/src/bin/ln/ln.c,v retrieving revision 1.19 diff -u -p -r1.19 ln.c --- ln.c12 Mar 2013 06:00:05 - 1.19 +++ ln.c5 May 2014 11:23:56 - @@ -42,7 +42,6 @@ #include string.h #include unistd.h -intdirflag;/* Undocumented directory flag. */ intfflag; /* Unlink existing files. */ inthflag; /* Check new name for symlink first. */ intPflag; /* Hard link to symlink. */ @@ -58,11 +57,8 @@ main(int argc, char *argv[]) int ch, exitval; char *sourcedir; - while ((ch = getopt(argc, argv, FfhLnPs)) != -1) + while ((ch = getopt(argc, argv, fhLnPs)) != -1) switch (ch) { - case 'F': - dirflag = 1;/* XXX: deliberately undocumented. */ - break; case 'f': fflag = 1; break; @@ -126,8 +122,8 @@ linkit(char *target, char *source, int i warn(%s, target); return (1); } - /* Only symbolic links to directories, unless -F option used. */ - if (!dirflag S_ISDIR(sb.st_mode)) { + /* Only symbolic links to directories. */ + if (S_ISDIR(sb.st_mode)) { errno = EISDIR; warn(%s, target); return (1);
Re: Remove ln -F
On 6 May 2014 11:45, Ingo Schwarze schwa...@usta.de wrote: Hi, if somebody wants to commit, ok schwarze@. Otherwise, i'm accepting OKs. See inline for a note on the history. Yours, Ingo Makes sense to me ok krw@, unless a history buff speaks up for it. Ken Tristan Le Guern wrote on Mon, May 05, 2014 at 03:06:12PM +0200: This patch removes the undocumented ln flag -F, which forces the creation of a hard link for a directory. This option was present since before the first revision of NetBSD CVS, 21 years ago: http://cvsweb.netbsd.org/bsdweb.cgi/src/bin/ln/ln.c I don't know where to dig for a more precise appearance date. A -f flag with the semantics of today's (well... for old values of today) -F first appeared in ATT Version 7 UNIX (1979). http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/ln.c Keith Bostic renamed -f to -F in September 1990, from the CSRG SCCS logs in bin/ln/SCCS/s.ln.c: s 00010/00010/00111 d D 4.13 90/06/19 14:10:53 bostic 16 15 c make -f option -F, S5 uses -f and POSIX is expected to. So 4.3BSD-Tahoe still called the flag -f, but since 4.3BSD-Reno, it is called -F. The problem is this option doesn't even work, the call to linkat(2) fails with EPERM. It's already removed in NetBSD and DragonFly. FreeBSD has an option with a similar name but a different meaning. Index: ln.c === RCS file: /home/tleguern/proj/perso/cvs/src/bin/ln/ln.c,v retrieving revision 1.19 diff -u -p -r1.19 ln.c --- ln.c12 Mar 2013 06:00:05 - 1.19 +++ ln.c5 May 2014 11:23:56 - @@ -42,7 +42,6 @@ #include string.h #include unistd.h -intdirflag;/* Undocumented directory flag. */ intfflag; /* Unlink existing files. */ inthflag; /* Check new name for symlink first. */ intPflag; /* Hard link to symlink. */ @@ -58,11 +57,8 @@ main(int argc, char *argv[]) int ch, exitval; char *sourcedir; - while ((ch = getopt(argc, argv, FfhLnPs)) != -1) + while ((ch = getopt(argc, argv, fhLnPs)) != -1) switch (ch) { - case 'F': - dirflag = 1;/* XXX: deliberately undocumented. */ - break; case 'f': fflag = 1; break; @@ -126,8 +122,8 @@ linkit(char *target, char *source, int i warn(%s, target); return (1); } - /* Only symbolic links to directories, unless -F option used. */ - if (!dirflag S_ISDIR(sb.st_mode)) { + /* Only symbolic links to directories. */ + if (S_ISDIR(sb.st_mode)) { errno = EISDIR; warn(%s, target); return (1);
Re: Remove ln -F
On Tue, May 6, 2014 at 9:18 AM, Kenneth Westerback kwesterb...@gmail.comwrote: On 6 May 2014 11:45, Ingo Schwarze schwa...@usta.de wrote: Hi, if somebody wants to commit, ok schwarze@. Otherwise, i'm accepting OKs. See inline for a note on the history. Yours, Ingo Makes sense to me ok krw@, unless a history buff speaks up for it. I agree. ok guenther@
sparc64: problem after trap table takeover under QEMU
Hi all, I'm currently working on a set of patches for OpenBIOS (the OF implementation for QEMU) in order to get the various *BSD kernels to boot under QEMU SPARC64 with some success, but I'm struggling with a privilege violation trap which occurs on the first window fill trap after OpenBSD takes over the trap table. This is with the latest OpenBSD 5.5 and with my current patchset the console output looks like this: Loading FCode image... Loaded 4829 bytes entry point is 0x4000 OpenBSD IEEE 1275 Bootblock 1.3 .. Jumping to entry point 0010 for type 0001... switching to new context: entry point 0x10 stack 0xffe8aa09 OpenBSD BOOT 1.6 Trying bsd... open /pci@1fe,0/pci-ata@5/ide1@600/cdrom@0:f/etc/random.seed: No such file or directory Booting /pci@1fe,0/pci-ata@5/ide1@600/cdrom@0:f/bsd 3901336@0x100+6248@0x13b8798+3261984@0x180+932320@0x1b1c620 symbols @ 0xffc5a300 119 start=0x100 Unexpected client interface exception: -1 panic: trap type 0x101 (breakpoint): pc=1010254 npc=1010258 pstate=99110414MG,PEF,PRIV halted EXIT I asked around on IRC and it was suggested that I post the information here in order to get some further input on this. My feeling is that QEMU SPARC64 may be doing something different to real hardware but I don't have any to play with and this is my first dig into OpenBSD, so I'd really appreciate some pointers from interested parties. The privilege violation trap I experience occurs just after OpenBSD invokes the OF SUNW,set-trap-table call and occurs in the epilogue of openfirmware() in locore.S at the final restore: ... rdpr%pstate, %l0 jmpl%i4, %o7 wrpr %g0, PSTATE_PROM|PSTATE_IE, %pstate wrpr%l0, %g0, %pstate mov %l1, %g1 mov %l2, %g2 mov %l3, %g3 mov %l4, %g4 mov %l5, %g5 mov %l6, %g6 mov %l7, %g7 wrpr%i2, 0, %pil ret restore%o0, %g0, %o0 What happens here is that when the final restore is executed in the delay slot, a fill_0_normal trap is generated which vectors into 0x1001800 here: (gdb) disas 0x1001800, 0x100185c Dump of assembler code from 0x1001800 to 0x100185c: = 0x01001800: wr %g0, 0x11, %asi 0x01001804: ldxa [ %sp + 0x7ff ] %asi, %l0 0x01001808: ldxa [ %sp + 0x807 ] %asi, %l1 0x0100180c: ldxa [ %sp + 0x80f ] %asi, %l2 0x01001810: ldxa [ %sp + 0x817 ] %asi, %l3 0x01001814: ldxa [ %sp + 0x81f ] %asi, %l4 0x01001818: ldxa [ %sp + 0x827 ] %asi, %l5 0x0100181c: ldxa [ %sp + 0x82f ] %asi, %l6 0x01001820: ldxa [ %sp + 0x837 ] %asi, %l7 0x01001824: ldxa [ %sp + 0x83f ] %asi, %i0 0x01001828: ldxa [ %sp + 0x847 ] %asi, %i1 0x0100182c: ldxa [ %sp + 0x84f ] %asi, %i2 0x01001830: ldxa [ %sp + 0x857 ] %asi, %i3 0x01001834: ldxa [ %sp + 0x85f ] %asi, %i4 0x01001838: ldxa [ %sp + 0x867 ] %asi, %i5 0x0100183c: ldxa [ %sp + 0x86f ] %asi, %fp 0x01001840: ldxa [ %sp + 0x877 ] %asi, %i7 0x01001844: nop 0x01001848: sethi %hi(0xe0018000), %g5 0x0100184c: ldx [ %g5 + 0x10 ], %g5! 0xe0018010 0x01001850: ldx [ %g5 + 0x28 ], %g5 0x01001854: xor %g5, %i7, %i7 0x01001858: restored End of assembler dump. (gdb) info regi sp sp 0x18006710x1800671 As soon as I step into address 0x1001804 then this is where things start to go wrong; the TLB (TTE) entry for 0x180 which is accessed by %sp is marked as privileged, but ASI 0x11 is user access only. QEMU's current behaviour for this is to generate a datafault for the page at 0x180 which seems to get all the way through to the retry at the end of winfixsave, but then hits the breakpoint trap above when executing the retry. Based on this I have a couple of questions about what is happening here: 1) Is the fill_0_normal (user-level) trap the correct one? Or does OpenBIOS need to do something with %otherwin to invoke a supervisor-level trap? 2) Is the QEMU SPARC64 behaviour of invoking a data_access_exception when accessing supervisor memory with a user ASI correct? FWIW I also tried some older OpenBSD ISOs and found that this behaviour was introduced between the 4.3 and 4.4 releases, and older releases don't exhibit this problem. Repeating the same test in 4.3, which is the last release that doesn't trap with the breakpoint error above, shows that the fill_0_normal trap is still invoked in the openfirmware() epilogue, however the stack pointer is now different: (gdb) info regi sp sp 0x1c096210x1c09621 And I can confirm that page 0x1c08000 exists in the TLB but compared to the current release above *isn't* marked as privileged, so no fault occurs
Re: Fix the mtime for file creation on ext2+
06.05.2014 19:36 пользователь Philip Guenther guent...@gmail.com написал: On Tue, 6 May 2014, Vadim Zhukov wrote: This fixes a bug with mtime not updated after file creation on ext2+ file systems. Try it yourself: # mount -t ext2fs /dev/sd0o /mnt # cp /tmp/qq /mnt # ls -l /mnt/qq -rw-r--r-- 1 root wheel 10 Jan 1 1970 qq # touch /mnt/qq -rw-r--r-- 1 root wheel 10 May 6 14:36 qq This probably does more than needed - I suspect that sometimes the updated mtime could be already there, but I don't see any real downside and it makes EX2FS_ITIMES() look more similar to ufs_itimies(). Opinions? Okays? As the person who broke this (sorry!), I think the diff should go a couple steps further and restore the IN_ACCESS handling too and mirror ufs_itimes() by bumping i_modrev on ctime change. Philip Index: ufs/ufs/inode.h === RCS file: /cvs/src/sys/ufs/ufs/inode.h,v retrieving revision 1.44 diff -u -p -r1.44 inode.h --- ufs/ufs/inode.h 14 Apr 2014 22:25:40 - 1.44 +++ ufs/ufs/inode.h 6 May 2014 15:31:24 - @@ -316,8 +316,14 @@ struct indir { #defineEXT2FS_ITIMES(ip) do { \ if ((ip)-i_flag (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ (ip)-i_flag |= IN_MODIFIED;\ - if ((ip)-i_flag IN_CHANGE) \ + if ((ip)-i_flag IN_ACCESS) \ + (ip)-i_e2fs_atime = time_second; \ + if ((ip)-i_flag IN_UPDATE) \ + (ip)-i_e2fs_mtime = time_second; \ + if ((ip)-i_flag IN_CHANGE) { \ (ip)-i_e2fs_ctime = time_second; \ + (ip)-i_modrev++; \ + } \ (ip)-i_flag = ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ } \ } while (0) Works for me here, on i386. The patch itself looks better too. Not that my opinion counts here but okay zhuk@. :)
Re: Fix the mtime for file creation on ext2+
On 6 May 2014 15:12, Vadim Zhukov persg...@gmail.com wrote: 06.05.2014 19:36 пользователь Philip Guenther guent...@gmail.com написал: On Tue, 6 May 2014, Vadim Zhukov wrote: This fixes a bug with mtime not updated after file creation on ext2+ file systems. Try it yourself: # mount -t ext2fs /dev/sd0o /mnt # cp /tmp/qq /mnt # ls -l /mnt/qq -rw-r--r-- 1 root wheel 10 Jan 1 1970 qq # touch /mnt/qq -rw-r--r-- 1 root wheel 10 May 6 14:36 qq This probably does more than needed - I suspect that sometimes the updated mtime could be already there, but I don't see any real downside and it makes EX2FS_ITIMES() look more similar to ufs_itimies(). Opinions? Okays? As the person who broke this (sorry!), I think the diff should go a couple steps further and restore the IN_ACCESS handling too and mirror ufs_itimes() by bumping i_modrev on ctime change. Philip Index: ufs/ufs/inode.h === RCS file: /cvs/src/sys/ufs/ufs/inode.h,v retrieving revision 1.44 diff -u -p -r1.44 inode.h --- ufs/ufs/inode.h 14 Apr 2014 22:25:40 - 1.44 +++ ufs/ufs/inode.h 6 May 2014 15:31:24 - @@ -316,8 +316,14 @@ struct indir { #defineEXT2FS_ITIMES(ip) do { \ if ((ip)-i_flag (IN_ACCESS | IN_CHANGE | IN_UPDATE)) { \ (ip)-i_flag |= IN_MODIFIED;\ - if ((ip)-i_flag IN_CHANGE) \ + if ((ip)-i_flag IN_ACCESS) \ + (ip)-i_e2fs_atime = time_second; \ + if ((ip)-i_flag IN_UPDATE) \ + (ip)-i_e2fs_mtime = time_second; \ + if ((ip)-i_flag IN_CHANGE) { \ (ip)-i_e2fs_ctime = time_second; \ + (ip)-i_modrev++; \ + } \ (ip)-i_flag = ~(IN_ACCESS | IN_CHANGE | IN_UPDATE); \ } \ } while (0) Works for me here, on i386. The patch itself looks better too. Not that my opinion counts here but okay zhuk@. :) ok krw@ Ken
Re: Fix the mtime for file creation on ext2+
On Tue, May 06, 2014 at 08:36, Philip Guenther wrote: As the person who broke this (sorry!), I think the diff should go a couple steps further and restore the IN_ACCESS handling too and mirror ufs_itimes() by bumping i_modrev on ctime change. As my commit message said, it may even work. I didn't make any promises. :)
[PATCH] rcs stored values never read
Hi tech, there are some never read values in rcs. fritjof Index: co.c === RCS file: /cvs/src/usr.bin/rcs/co.c,v retrieving revision 1.117 diff -u -p -r1.117 co.c --- co.c16 Apr 2013 20:24:45 - 1.117 +++ co.c6 May 2014 19:57:15 - @@ -56,7 +56,6 @@ checkout_main(int argc, char **argv) flags = ret = 0; kflag = RCS_KWEXP_ERR; - rev = RCS_HEAD_REV; rev_str = NULL; author = date = state = NULL; @@ -257,7 +256,7 @@ checkout_rev(RCSFILE *file, RCSNUM *frev time_t rcsdate, givendate; RCSNUM *rev; - rcsdate = givendate = -1; + givendate = -1; if (date != NULL (givendate = date_parse(date)) == -1) { warnx(invalid date: %s, date); return -1; Index: diff.c === RCS file: /cvs/src/usr.bin/rcs/diff.c,v retrieving revision 1.34 diff -u -p -r1.34 diff.c --- diff.c 16 May 2013 12:44:48 - 1.34 +++ diff.c 6 May 2014 20:00:43 - @@ -1302,7 +1302,7 @@ dump_unified_vec(FILE *f1, FILE *f2, int if (context_vec_start context_vec_ptr) return; - b = d = 0; /* gcc */ + d = 0; /* gcc */ lowa = MAX(1, cvp-a - diff_context); upb = MIN(len[0], context_vec_ptr-b + diff_context); lowc = MAX(1, cvp-c - diff_context); Index: merge.c === RCS file: /cvs/src/usr.bin/rcs/merge.c,v retrieving revision 1.7 diff -u -p -r1.7 merge.c --- merge.c 23 Jul 2010 21:46:05 - 1.7 +++ merge.c 6 May 2014 20:03:52 - @@ -40,7 +40,6 @@ merge_main(int argc, char **argv) BUF *bp; flags = labels = 0; - status = D_ERROR; /* * Using getopt(3) and not rcs_getopt() because merge(1) Index: rcs.c === RCS file: /cvs/src/usr.bin/rcs/rcs.c,v retrieving revision 1.80 diff -u -p -r1.80 rcs.c --- rcs.c 7 Jan 2014 14:08:16 - 1.80 +++ rcs.c 6 May 2014 20:06:00 - @@ -214,7 +214,6 @@ rcs_write(RCSFILE *rfp) int fd; fn = NULL; - fd = -1; if (rfp-rf_flags RCS_SYNCED) return; Index: rcsmerge.c === RCS file: /cvs/src/usr.bin/rcs/rcsmerge.c,v retrieving revision 1.52 diff -u -p -r1.52 rcsmerge.c --- rcsmerge.c 23 Jul 2010 21:46:05 - 1.52 +++ rcsmerge.c 6 May 2014 20:08:02 - @@ -44,7 +44,6 @@ rcsmerge_main(int argc, char **argv) BUF *bp; flags = 0; - kflag = RCS_KWEXP_ERR; status = D_ERROR; rev1 = rev2 = NULL; rev_str1 = rev_str2 = NULL; Index: rcsparse.c === RCS file: /cvs/src/usr.bin/rcs/rcsparse.c,v retrieving revision 1.9 diff -u -p -r1.9 rcsparse.c --- rcsparse.c 3 Jun 2013 17:04:35 - 1.9 +++ rcsparse.c 6 May 2014 20:10:23 - @@ -915,7 +915,6 @@ rcsparse_token(RCSFILE *rfp, int allowed } while (isspace(c)); pdp-rp_msglineno = pdp-rp_lineno; - type = 0; switch (c) { case '@': ret = rcsparse_string(rfp, allowed); @@ -1104,7 +1103,6 @@ rcsparse(RCSFILE *rfp, struct rcs_sectio int i, token; pdp = (struct rcs_pdata *)rfp-rf_pdata; - i = 0; token = 0; for (i = 0; sec[i].token != 0; i++) { Index: rcsutil.c === RCS file: /cvs/src/usr.bin/rcs/rcsutil.c,v retrieving revision 1.39 diff -u -p -r1.39 rcsutil.c --- rcsutil.c 16 Apr 2013 20:24:45 - 1.39 +++ rcsutil.c 6 May 2014 20:12:13 - @@ -157,8 +157,6 @@ rcs_choosefile(const char *filename, cha char *p, *ext, name[MAXPATHLEN], *next, *ptr, rcsdir[MAXPATHLEN], *suffixes, rcspath[MAXPATHLEN]; - fd = -1; - /* * If `filename' contains a directory, `rcspath' contains that * directory, including a trailing slash. Otherwise `rcspath' Index: rlog.c === RCS file: /cvs/src/usr.bin/rcs/rlog.c,v retrieving revision 1.67 diff -u -p -r1.67 rlog.c --- rlog.c 7 Jan 2014 14:08:16 - 1.67 +++ rlog.c 6 May 2014 20:14:50 - @@ -433,7 +433,7 @@ rlog_rev_print(struct rcs_delta *rdp) struct rcs_branch *rb; struct rcs_delta *nrdp; - i = found = 0; + found = 0; author = NULL; /* -l[lockers] */
Re: some more pqueue cleanup
Hi, Some more cleanup on top of my previous patch with e-mail subject libssl pqueue minor cleanup - no functional change intended. Applied, thanks! Miod
use reallocarray in pax
Don't rely on unchecked arithmetic. Index: options.c === RCS file: /cvs/src/bin/pax/options.c,v retrieving revision 1.84 diff -u -p -r1.84 options.c --- options.c 6 Feb 2014 20:51:55 - 1.84 +++ options.c 6 May 2014 20:56:22 - @@ -779,11 +779,9 @@ tar_options(int argc, char **argv) size_t n = nincfiles + 3; struct incfile *p; - p = realloc(incfiles, - sizeof(*incfiles) * n); + p = reallocarray(incfiles, n, + sizeof(*incfiles)); if (p == NULL) { - free(incfiles); - incfiles = NULL; paxwarn(0, Unable to allocate space for option list); exit(1); Index: tables.c === RCS file: /cvs/src/bin/pax/tables.c,v retrieving revision 1.30 diff -u -p -r1.30 tables.c --- tables.c8 Jan 2014 06:43:34 - 1.30 +++ tables.c6 May 2014 20:57:51 - @@ -1131,7 +1131,7 @@ add_dir(char *name, struct stat *psb, in name = rp; } if (dircnt == dirsize) { - dblk = realloc(dirp, 2 * dirsize * sizeof(DIRDATA)); + dblk = reallocarray(dirp, dirsize, 2 * sizeof(DIRDATA)); if (dblk == NULL) { paxwarn(1, Unable to store mode and times for created directory: %s, name);
[patch sbin/iked/pfkey.c] replacing select with poll
Hi there, Similar to the nfsd patch recently, replacing select() with poll() and removing some unecessary variables. ok? Index: pfkey.c === RCS file: /cvs/src/sbin/iked/pfkey.c,v retrieving revision 1.34 diff -u -p -u -r1.34 pfkey.c --- pfkey.c 6 May 2014 10:24:22 - 1.34 +++ pfkey.c 7 May 2014 00:20:06 - @@ -35,6 +35,7 @@ #include stdlib.h #include unistd.h #include event.h +#include poll.h #include iked.h #include ikev2.h @@ -43,7 +44,6 @@ #define IOV_CNT 20 #define PFKEYV2_CHUNK sizeof(u_int64_t) -#define PFKEY_REPLY_TIMEOUT 1000 static u_int32_t sadb_msg_seq = 0; static u_int sadb_decoupled = 0; @@ -1086,11 +1086,10 @@ pfkey_reply(int sd, u_int8_t **datap, ss { struct pfkey_message*pm; struct sadb_msg hdr; - struct timeval tv; + struct pollfdpfd; ssize_t len; u_int8_t*data; - fd_set *fds; - int n; + int ret, timeout; for (;;) { /* @@ -1100,24 +1099,17 @@ pfkey_reply(int sd, u_int8_t **datap, ss * and if it is not readable in that time, we fail * the read. */ - n = howmany(sd + 1, NFDBITS); - if ((fds = calloc(n, sizeof(fd_mask))) == NULL) { - log_warn(%s: calloc(%lu, %lu) failed, __func__, - (unsigned long) n, - (unsigned long) sizeof(fd_mask)); - return (-1); - } - FD_SET(sd, fds); - tv.tv_sec = 0; - tv.tv_usec = PFKEY_REPLY_TIMEOUT; - n = select(sd + 1, fds, 0, 0, tv); - free(fds); - if (n == -1) { - log_warn(%s: select(%d, fds, 0, 0, tv) failed, - __func__, sd + 1); + + timeout = 1; + pfd.fd = sd; + pfd.events = POLLIN; + ret = poll(pfd, 1, timeout); + + if (ret == -1) { + log_warn(%s: poll, __func__); return (-1); } - if (n == 0) { + if (ret == 0) { log_warnx(%s: no reply from PF_KEY, __func__); return (-1); } -- Peter Malone pe...@petermalone.org
[patch usr.bin/pkill/pkill.c malloc memset = calloc
Hi there, I thought I had sent in all of these, but this was in my drafts and I didn't see it after searching the list my sent items. ok? Index: pkill.c === RCS file: /cvs/src/usr.bin/pkill/pkill.c,v retrieving revision 1.34 diff -u -p -u -r1.34 pkill.c --- pkill.c 12 Nov 2013 13:54:51 - 1.34 +++ pkill.c 7 May 2014 01:08:45 - @@ -277,9 +277,8 @@ main(int argc, char **argv) * Allocate memory which will be used to keep track of the * selection. */ - if ((selected = malloc(nproc)) == NULL) + if ((selected = calloc(1, nproc)) == NULL) errx(STATUS_ERROR, memory allocation failure); - memset(selected, 0, nproc); /* * Refine the selection. -- Peter Malone pe...@petermalone.org
Re: [patch usr.bin/pkill/pkill.c malloc memset = calloc
On Tue, May 06, 2014 at 21:20, Peter Malone wrote: */ - if ((selected = malloc(nproc)) == NULL) + if ((selected = calloc(1, nproc)) == NULL) errx(STATUS_ERROR, memory allocation failure); selected is an array of nproc chars, so I made it calloc(nproc, 1). really, it doesn't matter, I just felt like being different this time.