head 1.184; access; symbols netbsd-10-0-RC6:1.183.4.1 netbsd-10-0-RC5:1.183.4.1 netbsd-10-0-RC4:1.183.4.1 netbsd-10-0-RC3:1.183.4.1 netbsd-10-0-RC2:1.183.4.1 thorpej-ifq:1.184.0.4 thorpej-ifq-base:1.184 thorpej-altq-separation:1.184.0.2 thorpej-altq-separation-base:1.184 netbsd-10-0-RC1:1.183.4.1 netbsd-10:1.183.0.4 netbsd-10-base:1.183 bouyer-sunxi-drm:1.183.0.2 bouyer-sunxi-drm-base:1.183 netbsd-9-3-RELEASE:1.177 thorpej-i2c-spi-conf2:1.181.0.16 thorpej-i2c-spi-conf2-base:1.181 thorpej-futex2:1.181.0.14 thorpej-futex2-base:1.181 thorpej-cfargs2:1.181.0.12 thorpej-cfargs2-base:1.181 cjep_sun2x-base1:1.181 cjep_sun2x:1.181.0.10 cjep_sun2x-base:1.181 cjep_staticlib_x-base1:1.181 netbsd-9-2-RELEASE:1.177 cjep_staticlib_x:1.181.0.8 cjep_staticlib_x-base:1.181 thorpej-i2c-spi-conf:1.181.0.6 thorpej-i2c-spi-conf-base:1.181 thorpej-cfargs:1.181.0.4 thorpej-cfargs-base:1.181 thorpej-futex:1.181.0.2 thorpej-futex-base:1.181 netbsd-9-1-RELEASE:1.177 bouyer-xenpvh-base2:1.180 phil-wifi-20200421:1.180 bouyer-xenpvh-base1:1.180 phil-wifi-20200411:1.180 bouyer-xenpvh:1.180.0.2 bouyer-xenpvh-base:1.180 is-mlppp:1.179.0.2 is-mlppp-base:1.179 phil-wifi-20200406:1.180 netbsd-8-2-RELEASE:1.173 ad-namecache-base3:1.179 netbsd-9-0-RELEASE:1.177 netbsd-9-0-RC2:1.177 ad-namecache-base2:1.179 ad-namecache-base1:1.179 ad-namecache:1.178.0.2 ad-namecache-base:1.178 netbsd-9-0-RC1:1.177 phil-wifi-20191119:1.177 netbsd-9:1.177.0.4 netbsd-9-base:1.177 phil-wifi-20190609:1.177 netbsd-8-1-RELEASE:1.173 netbsd-8-1-RC1:1.173 isaki-audio2:1.177.0.2 isaki-audio2-base:1.177 pgoyette-compat-merge-20190127:1.173.10.2 pgoyette-compat-20190127:1.175 pgoyette-compat-20190118:1.175 pgoyette-compat-1226:1.175 pgoyette-compat-1126:1.175 pgoyette-compat-1020:1.175 pgoyette-compat-0930:1.175 pgoyette-compat-0906:1.175 netbsd-7-2-RELEASE:1.170 pgoyette-compat-0728:1.174 netbsd-8-0-RELEASE:1.173 phil-wifi:1.174.0.2 phil-wifi-base:1.174 pgoyette-compat-0625:1.174 netbsd-8-0-RC2:1.173 pgoyette-compat-0521:1.174 pgoyette-compat-0502:1.173 pgoyette-compat-0422:1.173 netbsd-8-0-RC1:1.173 pgoyette-compat-0415:1.173 pgoyette-compat-0407:1.173 pgoyette-compat-0330:1.173 pgoyette-compat-0322:1.173 pgoyette-compat-0315:1.173 netbsd-7-1-2-RELEASE:1.170 pgoyette-compat:1.173.0.10 pgoyette-compat-base:1.173 netbsd-7-1-1-RELEASE:1.170 tls-maxphys-base-20171202:1.173 matt-nb8-mediatek:1.173.0.8 matt-nb8-mediatek-base:1.173 nick-nhusb-base-20170825:1.173 perseant-stdc-iso10646:1.173.0.6 perseant-stdc-iso10646-base:1.173 netbsd-8:1.173.0.4 netbsd-8-base:1.173 prg-localcount2-base3:1.173 prg-localcount2-base2:1.173 prg-localcount2-base1:1.173 prg-localcount2:1.173.0.2 prg-localcount2-base:1.173 pgoyette-localcount-20170426:1.172 bouyer-socketcan-base1:1.172 jdolecek-ncq:1.172.0.6 jdolecek-ncq-base:1.172 pgoyette-localcount-20170320:1.172 netbsd-7-1:1.170.0.12 netbsd-7-1-RELEASE:1.170 netbsd-7-1-RC2:1.170 nick-nhusb-base-20170204:1.172 netbsd-7-nhusb-base-20170116:1.170 bouyer-socketcan:1.172.0.4 bouyer-socketcan-base:1.172 pgoyette-localcount-20170107:1.172 netbsd-7-1-RC1:1.170 nick-nhusb-base-20161204:1.172 pgoyette-localcount-20161104:1.172 netbsd-7-0-2-RELEASE:1.170 nick-nhusb-base-20161004:1.172 localcount-20160914:1.172 netbsd-7-nhusb:1.170.0.10 netbsd-7-nhusb-base:1.170 pgoyette-localcount-20160806:1.172 pgoyette-localcount-20160726:1.172 pgoyette-localcount:1.172.0.2 pgoyette-localcount-base:1.172 nick-nhusb-base-20160907:1.172 nick-nhusb-base-20160529:1.172 netbsd-7-0-1-RELEASE:1.170 nick-nhusb-base-20160422:1.172 nick-nhusb-base-20160319:1.172 nick-nhusb-base-20151226:1.172 netbsd-7-0:1.170.0.8 netbsd-7-0-RELEASE:1.170 nick-nhusb-base-20150921:1.172 netbsd-7-0-RC3:1.170 netbsd-7-0-RC2:1.170 netbsd-7-0-RC1:1.170 nick-nhusb-base-20150606:1.172 nick-nhusb-base-20150406:1.170 nick-nhusb:1.170.0.6 nick-nhusb-base:1.170 netbsd-5-2-3-RELEASE:1.138.16.3 netbsd-5-1-5-RELEASE:1.138.16.2 netbsd-6-0-6-RELEASE:1.163.2.2 netbsd-6-1-5-RELEASE:1.163.2.2 netbsd-7:1.170.0.4 netbsd-7-base:1.170 yamt-pagecache-base9:1.170 yamt-pagecache-tag8:1.161.2.2 netbsd-6-1-4-RELEASE:1.163.2.2 netbsd-6-0-5-RELEASE:1.163.2.2 tls-earlyentropy:1.170.0.2 tls-earlyentropy-base:1.170 riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.170 riastradh-drm2-base3:1.170 netbsd-6-1-3-RELEASE:1.163.2.2 netbsd-6-0-4-RELEASE:1.163.2.2 netbsd-5-2-2-RELEASE:1.138.16.3 netbsd-5-1-4-RELEASE:1.138.16.2 netbsd-6-1-2-RELEASE:1.163.2.2 netbsd-6-0-3-RELEASE:1.163.2.2 netbsd-5-2-1-RELEASE:1.138.16.3 netbsd-5-1-3-RELEASE:1.138.16.2 rmind-smpnet-nbase:1.170 netbsd-6-1-1-RELEASE:1.163.2.2 riastradh-drm2-base2:1.165 riastradh-drm2-base1:1.165 riastradh-drm2:1.165.0.10 riastradh-drm2-base:1.165 rmind-smpnet:1.165.0.4 rmind-smpnet-base:1.170 netbsd-6-1:1.163.2.2.0.4 netbsd-6-0-2-RELEASE:1.163.2.2 netbsd-6-1-RELEASE:1.163.2.2 khorben-n900:1.165.0.8 netbsd-6-1-RC4:1.163.2.2 netbsd-6-1-RC3:1.163.2.2 agc-symver:1.165.0.6 agc-symver-base:1.165 netbsd-6-1-RC2:1.163.2.2 netbsd-6-1-RC1:1.163.2.2 yamt-pagecache-base8:1.165 netbsd-5-2:1.138.16.3.0.2 netbsd-6-0-1-RELEASE:1.163.2.2 yamt-pagecache-base7:1.165 netbsd-5-2-RELEASE:1.138.16.3 netbsd-5-2-RC1:1.138.16.3 matt-nb6-plus-nbase:1.163.2.2 yamt-pagecache-base6:1.165 netbsd-6-0:1.163.2.2.0.2 netbsd-6-0-RELEASE:1.163.2.2 netbsd-6-0-RC2:1.163.2.2 tls-maxphys:1.165.0.2 tls-maxphys-base:1.170 matt-nb6-plus:1.163.0.4 matt-nb6-plus-base:1.163.2.2 netbsd-6-0-RC1:1.163 jmcneill-usbmp-base10:1.163 yamt-pagecache-base5:1.163 jmcneill-usbmp-base9:1.163 yamt-pagecache-base4:1.163 jmcneill-usbmp-base8:1.163 jmcneill-usbmp-base7:1.163 jmcneill-usbmp-base6:1.163 jmcneill-usbmp-base5:1.163 jmcneill-usbmp-base4:1.163 jmcneill-usbmp-base3:1.163 jmcneill-usbmp-pre-base2:1.162 jmcneill-usbmp-base2:1.163 netbsd-6:1.163.0.2 netbsd-6-base:1.163 netbsd-5-1-2-RELEASE:1.138.16.2 netbsd-5-1-1-RELEASE:1.138.16.2 jmcneill-usbmp:1.162.0.2 jmcneill-usbmp-base:1.162 jmcneill-audiomp3:1.161.0.4 jmcneill-audiomp3-base:1.161 yamt-pagecache-base3:1.161 yamt-pagecache-base2:1.161 yamt-pagecache:1.161.0.2 yamt-pagecache-base:1.161 rmind-uvmplock-nbase:1.159 cherry-xenmp:1.159.0.2 cherry-xenmp-base:1.159 bouyer-quota2-nbase:1.156 bouyer-quota2:1.155.0.4 bouyer-quota2-base:1.156 jruoho-x86intr:1.155.0.2 jruoho-x86intr-base:1.155 matt-mips64-premerge-20101231:1.155 matt-nb5-mips64-premerge-20101231:1.138.16.1.4.1 matt-nb5-pq3:1.138.16.2.0.4 matt-nb5-pq3-base:1.138.16.2 netbsd-5-1:1.138.16.2.0.2 netbsd-5-1-RELEASE:1.138.16.2 uebayasi-xip-base4:1.151 uebayasi-xip-base3:1.151 yamt-nfs-mp-base11:1.151 netbsd-5-1-RC4:1.138.16.2 matt-nb5-mips64-k15:1.138.16.1.4.1 uebayasi-xip-base2:1.151 yamt-nfs-mp-base10:1.151 netbsd-5-1-RC3:1.138.16.2 netbsd-5-1-RC2:1.138.16.2 uebayasi-xip-base1:1.150 netbsd-5-1-RC1:1.138.16.2 rmind-uvmplock:1.150.0.4 rmind-uvmplock-base:1.159 yamt-nfs-mp-base9:1.150 uebayasi-xip:1.150.0.2 uebayasi-xip-base:1.150 netbsd-5-0-2-RELEASE:1.138.16.1 matt-nb5-mips64-premerge-20091211:1.138.16.1 matt-premerge-20091211:1.148 yamt-nfs-mp-base8:1.146 matt-nb5-mips64-u2-k2-k4-k7-k8-k9:1.138.16.1 matt-nb4-mips64-k7-u2a-k9b:1.138.16.1 matt-nb5-mips64-u1-k1-k5:1.138.16.1 yamt-nfs-mp-base7:1.146 matt-nb5-mips64:1.138.16.1.0.4 netbsd-5-0-1-RELEASE:1.138.16.1 jymxensuspend-base:1.146 yamt-nfs-mp-base6:1.146 yamt-nfs-mp-base5:1.146 yamt-nfs-mp-base4:1.144 jym-xensuspend-nbase:1.147 yamt-nfs-mp-base3:1.144 nick-hppapmap-base4:1.144 nick-hppapmap-base3:1.144 netbsd-5-0:1.138.16.1.0.2 netbsd-5-0-RELEASE:1.138.16.1 netbsd-5-0-RC4:1.138.16.1 netbsd-5-0-RC3:1.138 nick-hppapmap-base2:1.142 netbsd-5-0-RC2:1.138 jym-xensuspend:1.142.0.2 jym-xensuspend-base:1.144 netbsd-5-0-RC1:1.138 haad-dm-base2:1.141 haad-nbase2:1.141 ad-audiomp2:1.141.0.2 ad-audiomp2-base:1.141 christos-time_t-nbase:1.141 netbsd-5:1.138.0.16 netbsd-5-base:1.138 nick-hppapmap:1.138.0.14 nick-hppapmap-base:1.144 matt-mips64-base2:1.138 matt-mips64:1.129.0.10 haad-dm-base1:1.138 wrstuden-revivesa-base-4:1.138 netbsd-4-0-1-RELEASE:1.119.2.2 wrstuden-revivesa-base-3:1.138 wrstuden-revivesa-base-2:1.138 wrstuden-fixsa-newbase:1.119.2.2 nick-csl-alignment-base5:1.129 haad-dm:1.138.0.12 haad-dm-base:1.141 wrstuden-revivesa-base-1:1.138 simonb-wapbl-nbase:1.138 yamt-pf42-base4:1.138 simonb-wapbl:1.138.0.10 simonb-wapbl-base:1.138 yamt-pf42-base3:1.138 hpcarm-cleanup-nbase:1.138 yamt-pf42-baseX:1.138 yamt-pf42-base2:1.138 yamt-nfs-mp-base2:1.138 wrstuden-revivesa:1.138.0.8 wrstuden-revivesa-base:1.138 yamt-nfs-mp:1.138.0.6 yamt-nfs-mp-base:1.138 yamt-pf42:1.138.0.4 yamt-pf42-base:1.138 christos-time_t:1.138.0.2 christos-time_t-base:1.141 ad-socklock-base1:1.137 yamt-lazymbuf-base15:1.137 yamt-lazymbuf-base14:1.137 keiichi-mipv6-nbase:1.137 mjf-devfs2:1.135.0.6 mjf-devfs2-base:1.142 nick-net80211-sync:1.135.0.4 nick-net80211-sync-base:1.135 keiichi-mipv6:1.135.0.2 keiichi-mipv6-base:1.137 bouyer-xeni386-merge1:1.132.4.1 matt-armv6-prevmlocking:1.129.6.1 wrstuden-fixsa-base-1:1.119.2.2 vmlocking2-base3:1.133 netbsd-4-0:1.119.2.2.0.6 netbsd-4-0-RELEASE:1.119.2.2 bouyer-xeni386-nbase:1.133 yamt-kmem-base3:1.132 cube-autoconf:1.132.0.6 cube-autoconf-base:1.132 yamt-kmem-base2:1.132 bouyer-xeni386:1.132.0.4 bouyer-xeni386-base:1.133 yamt-kmem:1.132.0.2 yamt-kmem-base:1.132 vmlocking2-base2:1.132 reinoud-bufcleanup-nbase:1.132 vmlocking2:1.131.0.2 vmlocking2-base1:1.131 netbsd-4-0-RC5:1.119.2.2 matt-nb4-arm:1.119.2.2.0.4 matt-nb4-arm-base:1.119.2.2 matt-armv6-nbase:1.137 jmcneill-base:1.130 netbsd-4-0-RC4:1.119.2.2 mjf-devfs:1.130.0.4 mjf-devfs-base:1.134 bouyer-xenamd64-base2:1.130 vmlocking-nbase:1.131 yamt-x86pmap-base4:1.130 bouyer-xenamd64:1.130.0.2 bouyer-xenamd64-base:1.130 netbsd-4-0-RC3:1.119.2.2 yamt-x86pmap-base3:1.130 yamt-x86pmap-base2:1.129 netbsd-4-0-RC2:1.119.2.2 yamt-x86pmap:1.129.0.8 yamt-x86pmap-base:1.129 netbsd-4-0-RC1:1.119.2.2 matt-armv6:1.129.0.6 matt-armv6-base:1.133 matt-mips64-base:1.129 jmcneill-pm:1.129.0.4 jmcneill-pm-base:1.132 hpcarm-cleanup:1.129.0.2 hpcarm-cleanup-base:1.135 nick-csl-alignment:1.128.0.4 nick-csl-alignment-base:1.128 netbsd-3-1-1-RELEASE:1.94 netbsd-3-0-3-RELEASE:1.94 yamt-idlelwp-base8:1.128 wrstuden-fixsa:1.119.2.2.0.2 wrstuden-fixsa-base:1.119.2.2 thorpej-atomic:1.128.0.2 thorpej-atomic-base:1.128 reinoud-bufcleanup:1.127.0.6 reinoud-bufcleanup-base:1.132 mjf-ufs-trans:1.127.0.4 mjf-ufs-trans-base:1.128 vmlocking:1.127.0.2 vmlocking-base:1.130 ad-audiomp:1.125.0.2 ad-audiomp-base:1.125 yamt-idlelwp:1.123.0.2 post-newlock2-merge:1.123 newlock2-nbase:1.123 yamt-splraiseipl-base5:1.120 yamt-splraiseipl-base4:1.120 yamt-splraiseipl-base3:1.120 abandoned-netbsd-4-base:1.115 abandoned-netbsd-4:1.115.0.2 netbsd-3-1:1.94.0.6 netbsd-3-1-RELEASE:1.94 netbsd-3-0-2-RELEASE:1.94 yamt-splraiseipl-base2:1.118 netbsd-3-1-RC4:1.94 yamt-splraiseipl:1.117.0.4 yamt-splraiseipl-base:1.117 netbsd-3-1-RC3:1.94 yamt-pdpolicy-base9:1.117 newlock2:1.117.0.2 newlock2-base:1.123 yamt-pdpolicy-base8:1.117 netbsd-3-1-RC2:1.94 netbsd-3-1-RC1:1.94 yamt-pdpolicy-base7:1.115 netbsd-4:1.119.0.2 netbsd-4-base:1.119 yamt-pdpolicy-base6:1.112 chap-midi-nbase:1.112 netbsd-3-0-1-RELEASE:1.94 gdamore-uart:1.111.0.2 gdamore-uart-base:1.111 simonb-timcounters-final:1.100.4.3 yamt-pdpolicy-base5:1.109 chap-midi:1.109.0.2 chap-midi-base:1.112 yamt-pdpolicy-base4:1.102 yamt-pdpolicy-base3:1.102 peter-altq-base:1.101 peter-altq:1.101.0.6 yamt-pdpolicy-base2:1.101 elad-kernelauth-base:1.108 elad-kernelauth:1.101.0.4 yamt-pdpolicy:1.101.0.2 yamt-pdpolicy-base:1.101 yamt-uio_vmspace-base5:1.100 simonb-timecounters:1.100.0.4 simonb-timecounters-base:1.109 rpaulo-netinet-merge-pcb:1.100.0.2 rpaulo-netinet-merge-pcb-base:1.117 yamt-uio_vmspace:1.99.0.2 netbsd-3-0:1.94.0.4 netbsd-3-0-RELEASE:1.94 netbsd-3-0-RC6:1.94 yamt-readahead-base3:1.98 netbsd-3-0-RC5:1.94 netbsd-3-0-RC4:1.94 netbsd-3-0-RC3:1.94 yamt-readahead-base2:1.98 netbsd-3-0-RC2:1.94 yamt-readahead-pervnode:1.98.6.2 yamt-readahead-perfile:1.98.6.1 yamt-readahead:1.98.0.6 yamt-readahead-base:1.98 netbsd-3-0-RC1:1.94 yamt-vop-base3:1.98 netbsd-2-0-3-RELEASE:1.87.2.1 netbsd-2-1:1.87.2.1.0.4 yamt-vop-base2:1.98 thorpej-vnode-attr:1.98.0.4 thorpej-vnode-attr-base:1.98 netbsd-2-1-RELEASE:1.87.2.1 yamt-vop:1.98.0.2 yamt-vop-base:1.98 netbsd-2-1-RC6:1.87.2.1 netbsd-2-1-RC5:1.87.2.1 netbsd-2-1-RC4:1.87.2.1 netbsd-2-1-RC3:1.87.2.1 netbsd-2-1-RC2:1.87.2.1 netbsd-2-1-RC1:1.87.2.1 yamt-lazymbuf:1.95.0.2 yamt-km-base4:1.94 netbsd-2-0-2-RELEASE:1.87.2.1 yamt-km-base3:1.94 netbsd-3:1.94.0.2 netbsd-3-base:1.94 yamt-km-base2:1.93 yamt-km:1.93.0.4 yamt-km-base:1.93 kent-audio2:1.93.0.2 kent-audio2-base:1.94 netbsd-2-0-1-RELEASE:1.87.2.1 kent-audio1-beforemerge:1.93 netbsd-2:1.87.2.1.0.2 netbsd-2-base:1.87.2.1 kent-audio1:1.91.0.2 kent-audio1-base:1.91 netbsd-2-0-RELEASE:1.87.2.1 netbsd-2-0-RC5:1.87.2.1 netbsd-2-0-RC4:1.87.2.1 netbsd-2-0-RC3:1.87.2.1 netbsd-2-0-RC2:1.87.2.1 netbsd-2-0-RC1:1.87.2.1 netbsd-2-0:1.87.0.2 netbsd-2-0-base:1.87 netbsd-1-6-PATCH002-RELEASE:1.62.10.4 netbsd-1-6-PATCH002:1.62.10.4 netbsd-1-6-PATCH002-RC4:1.62.10.4 netbsd-1-6-PATCH002-RC3:1.62.10.4 netbsd-1-6-PATCH002-RC2:1.62.10.4 netbsd-1-6-PATCH002-RC1:1.62.10.4 ktrace-lwp:1.79.0.2 ktrace-lwp-base:1.98 netbsd-1-6-PATCH001:1.62.10.3 netbsd-1-6-PATCH001-RELEASE:1.62.10.3 netbsd-1-6-PATCH001-RC3:1.62.10.3 netbsd-1-6-PATCH001-RC2:1.62.10.3 netbsd-1-6-PATCH001-RC1:1.62.10.3 nathanw_sa_end:1.59.2.5 nathanw_sa_before_merge:1.66 fvdl_fs64_base:1.66 gmcgarry_ctxsw:1.66.0.4 gmcgarry_ctxsw_base:1.66 gmcgarry_ucred:1.66.0.2 gmcgarry_ucred_base:1.66 nathanw_sa_base:1.66 kqueue-aftermerge:1.65 kqueue-beforemerge:1.65 netbsd-1-6-RELEASE:1.62 netbsd-1-6-RC3:1.62 netbsd-1-6-RC2:1.62 netbsd-1-6-RC1:1.62 netbsd-1-6:1.62.0.10 netbsd-1-6-base:1.62 gehenna-devsw:1.62.0.8 gehenna-devsw-base:1.62 netbsd-1-5-PATCH003:1.54.4.1 eeh-devprop:1.62.0.6 eeh-devprop-base:1.62 newlock:1.62.0.4 newlock-base:1.62 ifpoll-base:1.62 thorpej-mips-cache:1.61.0.2 thorpej-mips-cache-base:1.62 thorpej-devvp-base3:1.61 thorpej-devvp-base2:1.61 post-chs-ubcperf:1.60 pre-chs-ubcperf:1.60 thorpej-devvp:1.60.0.2 thorpej-devvp-base:1.60 netbsd-1-5-PATCH002:1.54.4.1 kqueue:1.59.0.4 kqueue-base:1.65 netbsd-1-5-PATCH001:1.54.4.1 thorpej_scsipi_beforemerge:1.59 nathanw_sa:1.59.0.2 thorpej_scsipi_nbase:1.59 netbsd-1-5-RELEASE:1.54 netbsd-1-5-BETA2:1.54 netbsd-1-5-BETA:1.54 netbsd-1-4-PATCH003:1.50.2.2 netbsd-1-5-ALPHA2:1.54 netbsd-1-5:1.54.0.4 netbsd-1-5-base:1.54 minoura-xpg4dl-base:1.54 minoura-xpg4dl:1.54.0.2 netbsd-1-4-PATCH002:1.50.2.2 chs-ubc2-newbase:1.52 wrstuden-devbsize-19991221:1.52 wrstuden-devbsize:1.51.0.8 wrstuden-devbsize-base:1.52 kame_141_19991130:1.50.2.1 comdex-fall-1999:1.51.0.6 comdex-fall-1999-base:1.51 fvdl-softdep:1.51.0.4 fvdl-softdep-base:1.51 thorpej_scsipi:1.51.0.2 thorpej_scsipi_base:1.59 netbsd-1-4-PATCH001:1.50.2.1 kame_14_19990705:1.50.2.1 kame_14_19990628:1.50.2.1 kame:1.50.2.1.0.4 chs-ubc2:1.50.2.1.0.2 chs-ubc2-base:1.51 netbsd-1-4-RELEASE:1.50.2.1 netbsd-1-4:1.50.0.2 netbsd-1-4-base:1.50 netbsd-1-3-PATCH003:1.38.2.1 netbsd-1-3-PATCH003-CANDIDATE2:1.38.2.1 kenh-if-detach:1.45.0.4 kenh-if-detach-base:1.45 netbsd-1-3-PATCH003-CANDIDATE1:1.38.2.1 netbsd-1-3-PATCH003-CANDIDATE0:1.38.2.1 chs-ubc:1.45.0.2 chs-ubc-base:1.45 eeh-paddr_t:1.43.0.2 eeh-paddr_t-base:1.43 netbsd-1-3-PATCH002:1.38.2.1 post-lite-2:1.1.1.4 lite-2:1.1.1.3 lite-1:1.1.1.2 CSRG:1.1.1 netbsd-1-3-PATCH001:1.38.2.1 netbsd-1-3-RELEASE:1.38.2.1 netbsd-1-3-BETA:1.38 netbsd-1-3:1.38.0.2 netbsd-1-3-base:1.38 thorpej-signal:1.37.0.4 thorpej-signal-base:1.37 marc-pcmcia:1.37.0.2 marc-pcmcia-bp:1.37 marc-pcmcia-base:1.38 bouyer-scsipi:1.35.0.2 is-newarp-before-merge:1.31 netbsd-1-2-PATCH001:1.25.4.2 mrg-vm-swap:1.30.0.2 is-newarp:1.29.0.2 is-newarp-base:1.29 thorpej-setroot:1.27.0.2 netbsd-1-2-RELEASE:1.25 netbsd-1-2-BETA:1.25 netbsd-1-2:1.25.0.4 netbsd-1-2-base:1.25 date-03-may-96:1.1.1.2 netbsd-1-1-PATCH001:1.18 netbsd-1-1-RELEASE:1.18 netbsd-1-1:1.18.0.2 netbsd-1-1-base:1.18 netbsd-1-0-PATCH06:1.16 netbsd-1-0-PATCH05:1.16 netbsd-1-0-PATCH04:1.16 netbsd-1-0-PATCH03:1.16 netbsd-1-0-PATCH02:1.16 netbsd-1-0-PATCH1:1.16 netbsd-1-0-PATCH0:1.16 netbsd-1-0-RELEASE:1.16 netbsd-1-0:1.16.0.2 netbsd-1-0-base:1.16 magnum-base:1.8 magnum:1.8.0.2 netbsd-0-9-patch-001:1.6 netbsd-0-9-RELEASE:1.6 netbsd-0-9-BETA:1.6 netbsd-0-9-ALPHA2:1.6 netbsd-0-9-ALPHA:1.6 netbsd-0-9:1.6.0.2 netbsd-0-9-base:1.6 netbsd-alpha-1:1.3 patchkit-0-2-2:1.2 WFJ-386bsd-01:1.1.1.1 WFJ-920714:1.1.1; locks; strict; comment @ * @; 1.184 date 2023.03.23.19.53.01; author riastradh; state Exp; branches; next 1.183; commitid ccJqomfdOiWhLhiE; 1.183 date 2022.04.27.17.38.52; author hannken; state Exp; branches 1.183.4.1; next 1.182; commitid z0HnnF1rJ1JLCRBD; 1.182 date 2021.09.16.20.17.47; author andvar; state Exp; branches; next 1.181; commitid yla4Pet1A4O4Fd9D; 1.181 date 2020.09.05.16.30.12; author riastradh; state Exp; branches; next 1.180; commitid O3vHH3z2ci0RuSmC; 1.180 date 2020.04.04.07.07.20; author mlelstv; state Exp; branches; next 1.179; commitid O4fV7qaO8kJUg23C; 1.179 date 2020.01.17.20.08.09; author ad; state Exp; branches; next 1.178; commitid 9tZTPOWa6bUH95TB; 1.178 date 2020.01.02.15.42.27; author thorpej; state Exp; branches 1.178.2.1; next 1.177; commitid IVCsiaioR2iq98RB; 1.177 date 2019.02.20.10.05.20; author hannken; state Exp; branches 1.177.4.1; next 1.176; commitid qORSyqmkhXfXsucB; 1.176 date 2019.02.03.03.19.28; author mrg; state Exp; branches; next 1.175; commitid ZKxrBqDNbHMCKgaB; 1.175 date 2018.09.03.16.29.36; author riastradh; state Exp; branches; next 1.174; commitid BTC4S53hMH8f3GQA; 1.174 date 2018.05.03.07.28.43; author hannken; state Exp; branches 1.174.2.1; next 1.173; commitid fIF6s3waXPXe1PAA; 1.173 date 2017.04.26.03.02.49; author riastradh; state Exp; branches 1.173.4.1 1.173.10.1; next 1.172; 1.172 date 2015.04.21.03.19.03; author riastradh; state Exp; branches; next 1.171; 1.171 date 2015.04.20.23.03.09; author riastradh; state Exp; branches; next 1.170; 1.170 date 2014.01.23.10.13.57; author hannken; state Exp; branches 1.170.6.1; next 1.169; 1.169 date 2014.01.17.10.55.02; author hannken; state Exp; branches; next 1.168; 1.168 date 2013.12.14.22.04.03; author christos; state Exp; branches; next 1.167; 1.167 date 2013.12.14.16.19.28; author christos; state Exp; branches; next 1.166; 1.166 date 2013.09.14.22.29.08; author martin; state Exp; branches; next 1.165; 1.165 date 2012.08.29.14.00.22; author christos; state Exp; branches 1.165.2.1 1.165.4.1; next 1.164; 1.164 date 2012.08.27.11.35.13; author chs; state Exp; branches; next 1.163; 1.163 date 2012.02.01.02.27.24; author matt; state Exp; branches 1.163.2.1 1.163.4.1; next 1.162; 1.162 date 2011.11.21.09.07.59; author hannken; state Exp; branches 1.162.2.1; next 1.161; 1.161 date 2011.10.30.12.00.27; author hannken; state Exp; branches 1.161.2.1; next 1.160; 1.160 date 2011.08.08.16.04.07; author dholland; state Exp; branches; next 1.159; 1.159 date 2011.04.18.00.38.33; author dholland; state Exp; branches; next 1.158; 1.158 date 2011.04.11.01.33.05; author dholland; state Exp; branches; next 1.157; 1.157 date 2011.03.19.01.34.24; author dholland; state Exp; branches; next 1.156; 1.156 date 2011.02.05.13.35.11; author yamt; state Exp; branches; next 1.155; 1.155 date 2011.01.02.05.12.34; author dholland; state Exp; branches 1.155.2.1 1.155.4.1; next 1.154; 1.154 date 2011.01.02.05.09.31; author dholland; state Exp; branches; next 1.153; 1.153 date 2011.01.02.05.01.21; author dholland; state Exp; branches; next 1.152; 1.152 date 2010.11.30.10.30.03; author dholland; state Exp; branches; next 1.151; 1.151 date 2010.06.24.13.03.17; author hannken; state Exp; branches; next 1.150; 1.150 date 2010.01.08.11.35.11; author pooka; state Exp; branches 1.150.2.1 1.150.4.1; next 1.149; 1.149 date 2009.12.23.01.09.25; author pooka; state Exp; branches; next 1.148; 1.148 date 2009.11.07.07.27.49; author cegger; state Exp; branches; next 1.147; 1.147 date 2009.09.27.17.19.07; author dholland; state Exp; branches; next 1.146; 1.146 date 2009.05.23.15.31.21; author ad; state Exp; branches; next 1.145; 1.145 date 2009.05.23.14.45.18; author ad; state Exp; branches; next 1.144; 1.144 date 2009.04.10.18.58.50; author bouyer; state Exp; branches; next 1.143; 1.143 date 2009.03.14.15.36.24; author dsl; state Exp; branches; next 1.142; 1.142 date 2009.01.11.02.45.54; author christos; state Exp; branches 1.142.2.1; next 1.141; 1.141 date 2008.12.03.14.56.05; author pooka; state Exp; branches; next 1.140; 1.140 date 2008.11.27.14.04.58; author pooka; state Exp; branches; next 1.139; 1.139 date 2008.11.19.18.36.09; author ad; state Exp; branches; next 1.138; 1.138 date 2008.03.28.05.02.08; author dholland; state Exp; branches 1.138.2.1 1.138.6.1 1.138.12.1 1.138.14.1 1.138.16.1; next 1.137; 1.137 date 2008.03.08.08.03.46; author yamt; state Exp; branches; next 1.136; 1.136 date 2008.02.28.17.07.49; author elad; state Exp; branches; next 1.135; 1.135 date 2008.02.20.17.15.51; author matt; state Exp; branches 1.135.2.1 1.135.6.1; next 1.134; 1.134 date 2008.01.28.14.31.19; author dholland; state Exp; branches; next 1.133; 1.133 date 2007.12.22.03.31.15; author yamt; state Exp; branches; next 1.132; 1.132 date 2007.12.04.17.42.30; author yamt; state Exp; branches 1.132.4.1; next 1.131; 1.131 date 2007.11.26.19.02.20; author pooka; state Exp; branches 1.131.2.1; next 1.130; 1.130 date 2007.10.10.20.42.31; author ad; state Exp; branches 1.130.4.1; next 1.129; 1.129 date 2007.07.27.10.03.58; author yamt; state Exp; branches 1.129.4.1 1.129.6.1 1.129.8.1 1.129.10.1; next 1.128; 1.128 date 2007.04.06.14.28.28; author hannken; state Exp; branches 1.128.4.1; next 1.127; 1.127 date 2007.03.05.23.18.50; author yamt; state Exp; branches 1.127.2.1 1.127.4.1; next 1.126; 1.126 date 2007.03.04.06.03.37; author christos; state Exp; branches; next 1.125; 1.125 date 2007.02.22.06.14.28; author thorpej; state Exp; branches; next 1.124; 1.124 date 2007.02.20.16.27.21; author pooka; state Exp; branches; next 1.123; 1.123 date 2007.02.04.14.48.51; author chs; state Exp; branches 1.123.2.1; next 1.122; 1.122 date 2007.01.04.20.24.08; author elad; state Exp; branches; next 1.121; 1.121 date 2006.12.27.12.10.09; author yamt; state Exp; branches; next 1.120; 1.120 date 2006.12.09.16.11.52; author chs; state Exp; branches; next 1.119; 1.119 date 2006.11.09.09.53.57; author yamt; state Exp; branches 1.119.2.1; next 1.118; 1.118 date 2006.10.12.01.32.47; author christos; state Exp; branches; next 1.117; 1.117 date 2006.09.02.12.40.36; author yamt; state Exp; branches 1.117.2.1 1.117.4.1; next 1.116; 1.116 date 2006.09.02.07.26.47; author christos; state Exp; branches; next 1.115; 1.115 date 2006.07.20.15.12.23; author christos; state Exp; branches; next 1.114; 1.114 date 2006.07.13.12.00.26; author martin; state Exp; branches; next 1.113; 1.113 date 2006.06.30.09.56.03; author yamt; state Exp; branches; next 1.112; 1.112 date 2006.06.17.07.06.51; author yamt; state Exp; branches; next 1.111; 1.111 date 2006.06.09.21.41.14; author christos; state Exp; branches 1.111.2.1; next 1.110; 1.110 date 2006.06.07.22.34.17; author kardel; state Exp; branches; next 1.109; 1.109 date 2006.05.14.21.32.21; author elad; state Exp; branches 1.109.2.1; next 1.108; 1.108 date 2006.05.10.21.53.19; author mrg; state Exp; branches; next 1.107; 1.107 date 2006.04.15.01.58.44; author christos; state Exp; branches; next 1.106; 1.106 date 2006.04.15.01.54.46; author christos; state Exp; branches; next 1.105; 1.105 date 2006.04.15.01.39.15; author christos; state Exp; branches; next 1.104; 1.104 date 2006.04.15.01.37.46; author christos; state Exp; branches; next 1.103; 1.103 date 2006.04.15.00.44.18; author christos; state Exp; branches; next 1.102; 1.102 date 2006.03.27.20.20.46; author martin; state Exp; branches; next 1.101; 1.101 date 2006.03.01.12.38.32; author yamt; state Exp; branches 1.101.2.1 1.101.4.1 1.101.6.1; next 1.100; 1.100 date 2006.01.03.11.41.50; author yamt; state Exp; branches 1.100.2.1 1.100.4.1; next 1.99; 1.99 date 2005.12.11.12.25.16; author christos; state Exp; branches 1.99.2.1; next 1.98; 1.98 date 2005.10.06.10.23.01; author yamt; state Exp; branches 1.98.6.1; next 1.97; 1.97 date 2005.09.06.09.36.28; author jmmv; state Exp; branches; next 1.96; 1.96 date 2005.08.19.12.47.23; author yamt; state Exp; branches; next 1.95; 1.95 date 2005.05.18.12.57.34; author yamt; state Exp; branches 1.95.2.1; next 1.94; 1.94 date 2005.02.26.22.39.50; author perry; state Exp; branches; next 1.93; 1.93 date 2004.12.09.02.18.45; author yamt; state Exp; branches 1.93.2.1 1.93.4.1; next 1.92; 1.92 date 2004.12.09.01.48.22; author yamt; state Exp; branches; next 1.91; 1.91 date 2004.12.04.08.07.52; author yamt; state Exp; branches; next 1.90; 1.90 date 2004.09.17.14.11.25; author skrll; state Exp; branches; next 1.89; 1.89 date 2004.05.31.08.47.08; author yamt; state Exp; branches; next 1.88; 1.88 date 2004.04.21.01.05.42; author christos; state Exp; branches; next 1.87; 1.87 date 2004.01.07.12.17.10; author yamt; state Exp; branches 1.87.2.1; next 1.86; 1.86 date 2003.11.05.10.18.38; author hannken; state Exp; branches; next 1.85; 1.85 date 2003.10.29.21.28.37; author mycroft; state Exp; branches; next 1.84; 1.84 date 2003.10.28.02.01.46; author cl; state Exp; branches; next 1.83; 1.83 date 2003.10.20.13.53.47; author yamt; state Exp; branches; next 1.82; 1.82 date 2003.10.15.11.29.01; author hannken; state Exp; branches; next 1.81; 1.81 date 2003.08.07.16.33.51; author agc; state Exp; branches; next 1.80; 1.80 date 2003.07.09.21.16.12; author bouyer; state Exp; branches; next 1.79; 1.79 date 2003.06.29.22.32.16; author fvdl; state Exp; branches 1.79.2.1; next 1.78; 1.78 date 2003.06.29.18.43.36; author thorpej; state Exp; branches; next 1.77; 1.77 date 2003.06.28.14.22.17; author darrenr; state Exp; branches; next 1.76; 1.76 date 2003.06.09.13.10.31; author yamt; state Exp; branches; next 1.75; 1.75 date 2003.05.29.15.18.14; author yamt; state Exp; branches; next 1.74; 1.74 date 2003.05.07.13.10.44; author yamt; state Exp; branches; next 1.73; 1.73 date 2003.05.04.11.40.22; author yamt; state Exp; branches; next 1.72; 1.72 date 2003.05.03.18.36.26; author yamt; state Exp; branches; next 1.71; 1.71 date 2003.04.03.15.19.12; author yamt; state Exp; branches; next 1.70; 1.70 date 2003.04.02.15.14.20; author yamt; state Exp; branches; next 1.69; 1.69 date 2003.03.28.15.24.58; author yamt; state Exp; branches; next 1.68; 1.68 date 2003.03.28.13.05.47; author yamt; state Exp; branches; next 1.67; 1.67 date 2003.02.26.06.31.18; author matt; state Exp; branches; next 1.66; 1.66 date 2002.12.01.23.02.10; author matt; state Exp; branches; next 1.65; 1.65 date 2002.09.27.19.30.46; author bouyer; state Exp; branches; next 1.64; 1.64 date 2002.09.26.20.41.25; author bouyer; state Exp; branches; next 1.63; 1.63 date 2002.09.26.20.38.04; author bouyer; state Exp; branches; next 1.62; 1.62 date 2001.11.10.10.59.09; author lukem; state Exp; branches 1.62.10.1; next 1.61; 1.61 date 2001.09.23.01.37.03; author chs; state Exp; branches 1.61.2.1; next 1.60; 1.60 date 2001.07.24.15.39.33; author assar; state Exp; branches 1.60.2.1; next 1.59; 1.59 date 2000.11.27.08.39.49; author chs; state Exp; branches 1.59.2.1 1.59.4.1; next 1.58; 1.58 date 2000.09.19.22.05.29; author fvdl; state Exp; branches; next 1.57; 1.57 date 2000.08.03.20.41.31; author thorpej; state Exp; branches; next 1.56; 1.56 date 2000.08.03.06.15.03; author thorpej; state Exp; branches; next 1.55; 1.55 date 2000.06.27.17.52.32; author mrg; state Exp; branches; next 1.54; 1.54 date 2000.03.30.12.51.15; author augustss; state Exp; branches 1.54.4.1; next 1.53; 1.53 date 2000.03.30.02.42.17; author simonb; state Exp; branches; next 1.52; 1.52 date 99.12.05.01.43.06; author fvdl; state Exp; branches; next 1.51; 1.51 date 99.05.04.16.01.37; author sommerfe; state Exp; branches 1.51.2.1 1.51.8.1; next 1.50; 1.50 date 99.03.30.12.01.18; author mycroft; state Exp; branches 1.50.2.1; next 1.49; 1.49 date 99.03.24.05.51.28; author mrg; state Exp; branches; next 1.48; 1.48 date 99.03.06.05.34.41; author fair; state Exp; branches; next 1.47; 1.47 date 99.03.05.07.27.58; author mycroft; state Exp; branches; next 1.46; 1.46 date 99.01.31.09.24.10; author mrg; state Exp; branches; next 1.45; 1.45 date 98.08.18.06.45.04; author thorpej; state Exp; branches; next 1.44; 1.44 date 98.08.09.21.19.51; author perry; state Exp; branches; next 1.43; 1.43 date 98.06.05.19.53.01; author kleink; state Exp; branches; next 1.42; 1.42 date 98.03.01.02.24.28; author fvdl; state Exp; branches; next 1.41; 1.41 date 98.02.10.14.10.12; author mrg; state Exp; branches; next 1.40; 1.40 date 98.02.05.08.00.21; author mrg; state Exp; branches; next 1.39; 1.39 date 97.12.22.00.09.02; author fvdl; state Exp; branches; next 1.38; 1.38 date 97.10.10.01.53.22; author fvdl; state Exp; branches 1.38.2.1; next 1.37; 1.37 date 97.07.17.23.54.29; author fvdl; state Exp; branches 1.37.2.1; next 1.36; 1.36 date 97.07.15.01.07.47; author fvdl; state Exp; branches; next 1.35; 1.35 date 97.06.24.23.32.45; author fvdl; state Exp; branches; next 1.34; 1.34 date 97.05.12.23.37.12; author fvdl; state Exp; branches; next 1.33; 1.33 date 97.05.08.16.20.32; author mycroft; state Exp; branches; next 1.32; 1.32 date 97.05.08.10.57.41; author mycroft; state Exp; branches; next 1.31; 1.31 date 97.02.22.02.56.01; author fvdl; state Exp; branches; next 1.30; 1.30 date 97.02.10.12.20.49; author fvdl; state Exp; branches; next 1.29; 1.29 date 97.01.31.16.12.26; author fvdl; state Exp; branches 1.29.2.1; next 1.28; 1.28 date 97.01.31.09.09.43; author fvdl; state Exp; branches; next 1.27; 1.27 date 96.12.11.00.01.56; author fvdl; state Exp; branches; next 1.26; 1.26 date 96.07.01.11.16.03; author fvdl; state Exp; branches; next 1.25; 1.25 date 96.03.02.15.55.52; author jtk; state Exp; branches 1.25.4.1; next 1.24; 1.24 date 96.02.20.23.45.10; author cgd; state Exp; branches; next 1.23; 1.23 date 96.02.18.11.53.45; author fvdl; state Exp; branches; next 1.22; 1.22 date 96.02.09.21.48.27; author christos; state Exp; branches; next 1.21; 1.21 date 96.02.09.15.47.11; author mycroft; state Exp; branches; next 1.20; 1.20 date 96.02.01.00.40.13; author jtc; state Exp; branches; next 1.19; 1.19 date 95.12.19.23.07.32; author cgd; state Exp; branches; next 1.18; 1.18 date 95.05.23.06.22.47; author mycroft; state Exp; branches; next 1.17; 1.17 date 94.12.13.17.17.01; author mycroft; state Exp; branches; next 1.16; 1.16 date 94.06.29.06.42.13; author cgd; state Exp; branches; next 1.15; 1.15 date 94.06.08.11.36.55; author mycroft; state Exp; branches; next 1.14; 1.14 date 94.04.21.07.49.09; author cgd; state Exp; branches; next 1.13; 1.13 date 94.04.10.06.45.56; author cgd; state Exp; branches; next 1.12; 1.12 date 94.03.12.01.31.32; author cgd; state Exp; branches; next 1.11; 1.11 date 94.03.09.21.24.30; author ws; state Exp; branches; next 1.10; 1.10 date 93.12.18.00.45.00; author mycroft; state Exp; branches; next 1.9; 1.9 date 93.11.26.19.57.04; author ws; state Exp; branches; next 1.8; 1.8 date 93.09.07.15.41.40; author ws; state Exp; branches 1.8.2.1; next 1.7; 1.7 date 93.09.03.23.57.25; author jtc; state Exp; branches; next 1.6; 1.6 date 93.07.16.00.52.50; author cgd; state Exp; branches; next 1.5; 1.5 date 93.07.16.00.51.55; author cgd; state Exp; branches; next 1.4; 1.4 date 93.07.16.00.50.30; author cgd; state Exp; branches; next 1.3; 1.3 date 93.04.10.20.19.19; author glass; state Exp; branches; next 1.2; 1.2 date 93.03.21.18.04.42; author cgd; state Exp; branches; next 1.1; 1.1 date 93.03.21.09.45.37; author cgd; state Exp; branches 1.1.1.1; next ; 1.183.4.1 date 2023.03.30.11.57.26; author martin; state Exp; branches; next ; commitid cu3UA4hk78UbU8jE; 1.178.2.1 date 2020.01.17.21.47.36; author ad; state Exp; branches; next ; commitid T9pwLWote7xbI5TB; 1.177.4.1 date 2023.03.30.11.59.24; author martin; state Exp; branches; next ; commitid c84sc3Dzi6IRU8jE; 1.174.2.1 date 2019.06.10.22.09.49; author christos; state Exp; branches; next 1.174.2.2; commitid jtc8rnCzWiEEHGqB; 1.174.2.2 date 2020.04.08.14.08.59; author martin; state Exp; branches; next ; commitid Qli2aW9E74UFuA3C; 1.173.4.1 date 2023.03.30.12.01.25; author martin; state Exp; branches; next ; commitid wLYce0vH4GAyV8jE; 1.173.10.1 date 2018.05.21.04.36.17; author pgoyette; state Exp; branches; next 1.173.10.2; commitid X5L8kSrBWQcDt7DA; 1.173.10.2 date 2018.09.06.06.56.45; author pgoyette; state Exp; branches; next ; commitid HCi1bXD317XIK0RA; 1.170.6.1 date 2015.06.06.14.40.26; author skrll; state Exp; branches; next 1.170.6.2; 1.170.6.2 date 2017.08.28.17.53.13; author skrll; state Exp; branches; next ; commitid UQQpnjvcNkUZn05A; 1.165.2.1 date 2014.08.20.00.04.36; author tls; state Exp; branches; next 1.165.2.2; 1.165.2.2 date 2017.12.03.11.39.05; author jdolecek; state Exp; branches; next ; commitid XcIYRZTAh1LmerhA; 1.165.4.1 date 2014.05.18.17.46.14; author rmind; state Exp; branches; next ; 1.163.2.1 date 2012.09.03.18.57.11; author riz; state Exp; branches; next 1.163.2.2; 1.163.2.2 date 2012.09.03.19.15.54; author riz; state Exp; branches; next ; 1.163.4.1 date 2012.11.01.16.45.04; author matt; state Exp; branches; next ; 1.162.2.1 date 2012.02.18.07.35.45; author mrg; state Exp; branches; next ; 1.161.2.1 date 2012.04.17.00.08.47; author yamt; state Exp; branches; next 1.161.2.2; 1.161.2.2 date 2012.10.30.17.22.51; author yamt; state Exp; branches; next 1.161.2.3; 1.161.2.3 date 2014.05.22.11.41.11; author yamt; state Exp; branches; next ; 1.155.2.1 date 2011.06.06.09.10.02; author jruoho; state Exp; branches; next ; 1.155.4.1 date 2011.02.08.16.20.02; author bouyer; state Exp; branches; next ; 1.150.2.1 date 2010.08.17.06.47.51; author uebayasi; state Exp; branches; next ; 1.150.4.1 date 2010.07.03.01.20.00; author rmind; state Exp; branches; next 1.150.4.2; 1.150.4.2 date 2011.03.05.20.56.03; author rmind; state Exp; branches; next 1.150.4.3; 1.150.4.3 date 2011.04.21.01.42.15; author rmind; state Exp; branches; next ; 1.142.2.1 date 2009.05.13.17.22.51; author jym; state Exp; branches; next 1.142.2.2; 1.142.2.2 date 2009.07.23.23.32.53; author jym; state Exp; branches; next ; 1.138.2.1 date 2008.03.29.20.47.02; author christos; state Exp; branches; next 1.138.2.2; 1.138.2.2 date 2008.11.20.20.45.39; author christos; state Exp; branches; next 1.138.2.3; 1.138.2.3 date 2008.12.27.23.14.25; author christos; state Exp; branches; next ; 1.138.6.1 date 2009.05.04.08.14.22; author yamt; state Exp; branches; next 1.138.6.2; 1.138.6.2 date 2009.06.20.07.20.34; author yamt; state Exp; branches; next 1.138.6.3; 1.138.6.3 date 2010.03.11.15.04.31; author yamt; state Exp; branches; next 1.138.6.4; 1.138.6.4 date 2010.08.11.22.54.59; author yamt; state Exp; branches; next ; 1.138.12.1 date 2008.12.13.01.15.28; author haad; state Exp; branches; next ; 1.138.14.1 date 2009.01.19.13.20.20; author skrll; state Exp; branches; next 1.138.14.2; 1.138.14.2 date 2009.04.28.07.37.45; author skrll; state Exp; branches; next ; 1.138.16.1 date 2009.04.13.21.06.50; author snj; state Exp; branches 1.138.16.1.4.1; next 1.138.16.2; 1.138.16.2 date 2010.02.14.13.27.45; author bouyer; state Exp; branches; next 1.138.16.3; 1.138.16.3 date 2012.09.30.17.59.57; author bouyer; state Exp; branches; next ; 1.138.16.1.4.1 date 2010.04.20.21.29.06; author matt; state Exp; branches; next 1.138.16.1.4.2; 1.138.16.1.4.2 date 2011.12.24.02.00.13; author matt; state Exp; branches; next ; 1.135.2.1 date 2008.03.24.07.16.27; author keiichi; state Exp; branches; next ; 1.135.6.1 date 2008.04.03.12.43.10; author mjf; state Exp; branches; next 1.135.6.2; 1.135.6.2 date 2009.01.17.13.29.34; author mjf; state Exp; branches; next ; 1.132.4.1 date 2008.01.02.21.57.42; author bouyer; state Exp; branches; next ; 1.131.2.1 date 2007.12.04.13.03.34; author ad; state Exp; branches; next 1.131.2.2; 1.131.2.2 date 2007.12.08.17.58.03; author ad; state Exp; branches; next 1.131.2.3; 1.131.2.3 date 2007.12.26.21.39.53; author ad; state Exp; branches; next ; 1.130.4.1 date 2007.12.08.18.21.23; author mjf; state Exp; branches; next 1.130.4.2; 1.130.4.2 date 2007.12.27.00.46.35; author mjf; state Exp; branches; next 1.130.4.3; 1.130.4.3 date 2008.02.18.21.07.18; author mjf; state Exp; branches; next ; 1.129.4.1 date 2007.10.26.15.49.12; author joerg; state Exp; branches; next 1.129.4.2; 1.129.4.2 date 2007.11.27.19.39.01; author joerg; state Exp; branches; next 1.129.4.3; 1.129.4.3 date 2007.12.09.19.38.43; author jmcneill; state Exp; branches; next ; 1.129.6.1 date 2007.11.06.23.34.21; author matt; state Exp; branches; next 1.129.6.2; 1.129.6.2 date 2008.01.09.01.57.52; author matt; state Exp; branches; next 1.129.6.3; 1.129.6.3 date 2008.03.23.02.05.08; author matt; state Exp; branches; next ; 1.129.8.1 date 2007.10.14.11.49.03; author yamt; state Exp; branches; next ; 1.129.10.1 date 2007.07.27.10.03.58; author yamt; state dead; branches; next 1.129.10.2; 1.129.10.2 date 2007.07.27.10.03.59; author yamt; state Exp; branches; next ; 1.128.4.1 date 2007.08.15.13.50.01; author skrll; state Exp; branches; next ; 1.127.2.1 date 2007.04.10.13.26.54; author ad; state Exp; branches; next 1.127.2.2; 1.127.2.2 date 2007.06.17.21.31.56; author ad; state Exp; branches; next 1.127.2.3; 1.127.2.3 date 2007.08.20.21.28.11; author ad; state Exp; branches; next 1.127.2.4; 1.127.2.4 date 2007.08.26.15.00.05; author yamt; state Exp; branches; next ; 1.127.4.1 date 2007.07.11.20.12.11; author mjf; state Exp; branches; next ; 1.123.2.1 date 2007.02.28.09.35.39; author yamt; state Exp; branches; next 1.123.2.2; 1.123.2.2 date 2007.03.12.06.00.36; author rmind; state Exp; branches; next 1.123.2.3; 1.123.2.3 date 2007.04.15.16.04.04; author yamt; state Exp; branches; next ; 1.119.2.1 date 2007.02.17.23.27.51; author tron; state Exp; branches; next 1.119.2.2; 1.119.2.2 date 2007.03.10.18.38.31; author bouyer; state Exp; branches; next ; 1.117.2.1 date 2006.11.18.21.39.44; author ad; state Exp; branches; next 1.117.2.2; 1.117.2.2 date 2007.01.12.01.04.19; author ad; state Exp; branches; next 1.117.2.3; 1.117.2.3 date 2007.02.09.21.03.53; author ad; state Exp; branches; next ; 1.117.4.1 date 2006.10.22.06.07.43; author yamt; state Exp; branches; next 1.117.4.2; 1.117.4.2 date 2006.12.10.07.19.24; author yamt; state Exp; branches; next ; 1.111.2.1 date 2006.07.13.17.50.06; author gdamore; state Exp; branches; next ; 1.109.2.1 date 2006.06.19.04.10.37; author chap; state Exp; branches; next ; 1.101.2.1 date 2006.04.01.12.07.50; author yamt; state Exp; branches; next 1.101.2.2; 1.101.2.2 date 2006.05.24.10.59.15; author yamt; state Exp; branches; next 1.101.2.3; 1.101.2.3 date 2006.06.26.12.54.28; author yamt; state Exp; branches; next 1.101.2.4; 1.101.2.4 date 2006.08.11.15.47.05; author yamt; state Exp; branches; next 1.101.2.5; 1.101.2.5 date 2006.09.03.15.25.56; author yamt; state Exp; branches; next ; 1.101.4.1 date 2006.03.08.01.06.28; author elad; state Exp; branches; next 1.101.4.2; 1.101.4.2 date 2006.03.10.13.37.46; author elad; state Exp; branches; next 1.101.4.3; 1.101.4.3 date 2006.03.12.00.07.42; author elad; state Exp; branches; next 1.101.4.4; 1.101.4.4 date 2006.04.19.05.06.37; author elad; state Exp; branches; next 1.101.4.5; 1.101.4.5 date 2006.05.06.23.32.11; author christos; state Exp; branches; next 1.101.4.6; 1.101.4.6 date 2006.05.11.23.31.35; author elad; state Exp; branches; next ; 1.101.6.1 date 2006.03.28.09.42.28; author tron; state Exp; branches; next 1.101.6.2; 1.101.6.2 date 2006.05.24.15.50.46; author tron; state Exp; branches; next ; 1.100.2.1 date 2006.09.09.02.59.24; author rpaulo; state Exp; branches; next ; 1.100.4.1 date 2006.02.04.14.12.50; author simonb; state Exp; branches; next 1.100.4.2; 1.100.4.2 date 2006.04.22.11.40.15; author simonb; state Exp; branches; next 1.100.4.3; 1.100.4.3 date 2006.06.01.22.39.13; author kardel; state Exp; branches; next ; 1.99.2.1 date 2005.12.31.16.29.01; author yamt; state Exp; branches; next 1.99.2.2; 1.99.2.2 date 2006.01.15.10.03.04; author yamt; state Exp; branches; next ; 1.98.6.1 date 2005.11.15.03.48.47; author yamt; state Exp; branches; next 1.98.6.2; 1.98.6.2 date 2005.11.18.08.44.54; author yamt; state Exp; branches; next ; 1.95.2.1 date 2005.07.07.13.03.20; author yamt; state Exp; branches; next 1.95.2.2; 1.95.2.2 date 2006.06.21.15.11.58; author yamt; state Exp; branches; next 1.95.2.3; 1.95.2.3 date 2006.12.30.20.50.51; author yamt; state Exp; branches; next 1.95.2.4; 1.95.2.4 date 2007.02.26.09.12.05; author yamt; state Exp; branches; next 1.95.2.5; 1.95.2.5 date 2007.09.03.14.44.18; author yamt; state Exp; branches; next 1.95.2.6; 1.95.2.6 date 2007.10.27.11.36.16; author yamt; state Exp; branches; next 1.95.2.7; 1.95.2.7 date 2007.12.07.17.34.43; author yamt; state Exp; branches; next 1.95.2.8; 1.95.2.8 date 2008.01.21.09.47.33; author yamt; state Exp; branches; next 1.95.2.9; 1.95.2.9 date 2008.02.04.09.24.44; author yamt; state Exp; branches; next 1.95.2.10; 1.95.2.10 date 2008.02.27.08.37.04; author yamt; state Exp; branches; next 1.95.2.11; 1.95.2.11 date 2008.02.27.09.24.06; author yamt; state Exp; branches; next 1.95.2.12; 1.95.2.12 date 2008.03.17.09.15.46; author yamt; state Exp; branches; next ; 1.93.2.1 date 2005.04.29.11.29.36; author kent; state Exp; branches; next ; 1.93.4.1 date 2005.03.19.08.36.51; author yamt; state Exp; branches; next ; 1.87.2.1 date 2004.06.05.20.43.20; author jdc; state Exp; branches; next ; 1.79.2.1 date 2003.07.02.15.27.09; author darrenr; state Exp; branches; next 1.79.2.2; 1.79.2.2 date 2004.08.03.10.56.17; author skrll; state Exp; branches; next 1.79.2.3; 1.79.2.3 date 2004.08.24.17.57.41; author skrll; state Exp; branches; next 1.79.2.4; 1.79.2.4 date 2004.09.18.14.56.20; author skrll; state Exp; branches; next 1.79.2.5; 1.79.2.5 date 2004.09.21.13.38.38; author skrll; state Exp; branches; next 1.79.2.6; 1.79.2.6 date 2004.12.18.09.33.17; author skrll; state Exp; branches; next 1.79.2.7; 1.79.2.7 date 2005.03.04.16.54.20; author skrll; state Exp; branches; next 1.79.2.8; 1.79.2.8 date 2005.11.10.14.11.55; author skrll; state Exp; branches; next ; 1.62.10.1 date 2002.09.30.13.47.00; author lukem; state Exp; branches; next 1.62.10.2; 1.62.10.2 date 2002.09.30.13.49.53; author lukem; state Exp; branches; next 1.62.10.3; 1.62.10.3 date 2002.09.30.13.52.26; author lukem; state Exp; branches; next 1.62.10.4; 1.62.10.4 date 2003.07.10.15.30.18; author tron; state Exp; branches; next 1.62.10.5; 1.62.10.5 date 2004.06.05.19.46.25; author jdc; state Exp; branches; next ; 1.61.2.1 date 2001.11.12.21.19.37; author thorpej; state Exp; branches; next ; 1.60.2.1 date 2001.10.01.12.48.00; author fvdl; state Exp; branches; next ; 1.59.2.1 date 2001.08.24.00.12.56; author nathanw; state Exp; branches; next 1.59.2.2; 1.59.2.2 date 2001.09.26.19.55.11; author nathanw; state Exp; branches; next 1.59.2.3; 1.59.2.3 date 2001.11.14.19.18.43; author nathanw; state Exp; branches; next 1.59.2.4; 1.59.2.4 date 2002.10.18.02.45.34; author nathanw; state Exp; branches; next 1.59.2.5; 1.59.2.5 date 2002.12.11.06.46.48; author thorpej; state Exp; branches; next ; 1.59.4.1 date 2001.08.03.04.14.02; author lukem; state Exp; branches; next 1.59.4.2; 1.59.4.2 date 2002.01.10.20.04.23; author thorpej; state Exp; branches; next 1.59.4.3; 1.59.4.3 date 2002.10.10.18.44.37; author jdolecek; state Exp; branches; next ; 1.54.4.1 date 2000.12.14.23.36.57; author he; state Exp; branches; next ; 1.51.2.1 date 2000.11.20.18.11.17; author bouyer; state Exp; branches; next 1.51.2.2; 1.51.2.2 date 2000.12.08.09.19.21; author bouyer; state Exp; branches; next ; 1.51.8.1 date 99.12.27.18.36.30; author wrstuden; state Exp; branches; next ; 1.50.2.1 date 99.05.04.17.10.00; author perry; state Exp; branches 1.50.2.1.2.1; next 1.50.2.2; 1.50.2.2 date 99.12.16.22.07.54; author he; state Exp; branches; next ; 1.50.2.1.2.1 date 99.06.21.01.28.55; author thorpej; state Exp; branches; next 1.50.2.1.2.2; 1.50.2.1.2.2 date 99.07.11.05.43.57; author chs; state Exp; branches; next ; 1.38.2.1 date 97.12.22.01.25.18; author perry; state Exp; branches; next 1.38.2.2; 1.38.2.2 date 99.02.01.04.44.28; author cgd; state Exp; branches; next ; 1.37.2.1 date 97.10.14.15.58.29; author thorpej; state Exp; branches; next ; 1.29.2.1 date 97.03.12.21.25.01; author is; state Exp; branches; next ; 1.25.4.1 date 96.12.11.10.02.54; author mycroft; state Exp; branches; next 1.25.4.2; 1.25.4.2 date 97.03.04.18.06.26; author mycroft; state Exp; branches; next ; 1.8.2.1 date 93.09.24.08.56.32; author mycroft; state Exp; branches; next 1.8.2.2; 1.8.2.2 date 93.11.14.22.22.22; author mycroft; state Exp; branches; next 1.8.2.3; 1.8.2.3 date 93.11.26.23.27.25; author mycroft; state Exp; branches; next ; 1.1.1.1 date 93.03.21.09.45.37; author cgd; state Exp; branches; next 1.1.1.2; 1.1.1.2 date 98.03.01.02.10.39; author fvdl; state Exp; branches; next 1.1.1.3; 1.1.1.3 date 98.03.01.02.13.45; author fvdl; state Exp; branches; next 1.1.1.4; 1.1.1.4 date 98.03.01.02.56.16; author fvdl; state Exp; branches; next ; desc @@ 1.184 log @nfs: Avoid free of uninitialized on bad name size in create, mknod. XXX These error branches are a nightmare and need to be more systematically cleaned up. Even if they are correct now, they are impossible to audit and extremely fragile in case anyone ever needs to make other changes to them. XXX pullup-8 XXX pullup-9 XXX pullup-10 @ text @/* $NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Rick Macklem at The University of Guelph. * * 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. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @@(#)nfs_serv.c 8.8 (Berkeley) 7/31/95 */ /* * nfs version 2 and 3 server calls to vnode ops * - these routines generally have 3 phases * 1 - break down and validate rpc request in mbuf list * 2 - do the vnode ops for the request * (surprisingly ?? many are very similar to syscalls in vfs_syscalls.c) * 3 - build the rpc reply in an mbuf list * nb: * - do not mix the phases, since the nfsm_?? macros can return failures * on a bad rpc or similar and do not do any vrele() or vput()'s * * - the nfsm_reply() macro generates an nfs rpc reply with the nfs * error number iff error != 0 whereas * returning an error from the server function implies a fatal error * such as a badly constructed rpc request that should be dropped without * a reply. * For Version 3, nfsm_reply() does not return for the error case, since * most version 3 rpcs return more than the status for error cases. */ #include __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include MODULE(MODULE_CLASS_MISC, nfsserver, "nfs"); /* Global vars */ extern u_int32_t nfs_xdrneg1; extern u_int32_t nfs_false, nfs_true; extern const enum vtype nv3tov_type[8]; extern struct nfsstats nfsstats; extern const nfstype nfsv2_type[9]; extern const nfstype nfsv3_type[9]; int nfsrvw_procrastinate = NFS_GATHERDELAY * 1000; bool nfsd_use_loan = true; /* use page-loan for READ OP */ #define nqsrv_getl(vp, rw) /* nothing */ static const struct syscall_package nfsserver_syscalls[] = { { SYS_nfssvc, 0, (sy_call_t *)sys_nfssvc }, { 0, 0, NULL }, }; static int nfsserver_modcmd(modcmd_t cmd, void *arg) { extern struct vfs_hooks nfs_export_hooks; /* XXX */ int error; switch (cmd) { case MODULE_CMD_INIT: error = syscall_establish(NULL, nfsserver_syscalls); if (error != 0) { return error; } nfs_init(); /* XXX for monolithic kernel */ netexport_init(); nfsrv_initcache(); /* Init the server request cache */ nfsrv_init(0); /* Init server data structures */ vfs_hooks_attach(&nfs_export_hooks); nfs_timer_srvinit(nfsrv_timer); return 0; case MODULE_CMD_FINI: error = syscall_disestablish(NULL, nfsserver_syscalls); if (error != 0) { return error; } /* * Kill export list before detaching VFS hooks, so we * we don't leak state due to a concurrent umount(). */ netexport_fini(); vfs_hooks_detach(&nfs_export_hooks); /* Kill timer before server goes away. */ nfs_timer_srvfini(); nfsrv_fini(); /* Server uses server cache, so kill cache last. */ nfsrv_finicache(); nfs_fini(); return 0; case MODULE_CMD_AUTOUNLOAD: if (netexport_hasexports()) return EBUSY; /*FALLTHROUGH*/ default: return ENOTTY; } } /* * nfs v3 access service */ int nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct vnode *vp; nfsrvfh_t nsfh; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, getret; char *cp2; struct mbuf *mb, *mreq __unused; struct vattr va; u_long inmode, testmode, outmode; u_quad_t frev; nfsm_srvmtofh(&nsfh); nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(1, (struct vattr *)0); return (0); } inmode = fxdr_unsigned(u_int32_t, *tl); outmode = 0; if ((inmode & NFSV3ACCESS_READ) && nfsrv_access(vp, VREAD, cred, rdonly, lwp, 0) == 0) outmode |= NFSV3ACCESS_READ; if (vp->v_type != VDIR) { testmode = inmode & (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND); if (testmode && nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0) == 0) outmode |= testmode; if ((inmode & NFSV3ACCESS_EXECUTE) && nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0) == 0) outmode |= NFSV3ACCESS_EXECUTE; } else { testmode = inmode & (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND | NFSV3ACCESS_DELETE); if (testmode && nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0) == 0) outmode |= testmode; if ((inmode & NFSV3ACCESS_LOOKUP) && nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0) == 0) outmode |= NFSV3ACCESS_LOOKUP; } getret = VOP_GETATTR(vp, &va, cred); vput(vp); nfsm_reply(NFSX_POSTOPATTR(1) + NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &va); nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); *tl = txdr_unsigned(outmode); nfsm_srvdone; } /* * nfs getattr service */ int nfsrv_getattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct nfs_fattr *fp; struct vattr va; struct vnode *vp; nfsrvfh_t nsfh; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0; char *cp2; struct mbuf *mb, *mreq __unused; u_quad_t frev; nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(0); return (0); } nqsrv_getl(vp, ND_READ); error = VOP_GETATTR(vp, &va, cred); vput(vp); nfsm_reply(NFSX_FATTR(nfsd->nd_flag & ND_NFSV3)); if (error) return (0); nfsm_build(fp, struct nfs_fattr *, NFSX_FATTR(nfsd->nd_flag & ND_NFSV3)); nfsm_srvfillattr(&va, fp); nfsm_srvdone; } /* * nfs setattr service */ int nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct vattr va, preat; struct nfsv2_sattr *sp; struct nfs_fattr *fp; struct vnode *vp; nfsrvfh_t nsfh; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, preat_ret = 1, postat_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3), gcheck = 0; char *cp2; struct mbuf *mb, *mreq __unused; u_quad_t frev; struct timespec guard; memset(&guard, 0, sizeof guard); /* XXX gcc */ nfsm_srvmtofh(&nsfh); vattr_null(&va); if (v3) { nfsm_srvsattr(&va); nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); gcheck = fxdr_unsigned(int, *tl); if (gcheck) { nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); fxdr_nfsv3time(tl, &guard); } } else { nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); /* * Nah nah nah nah na nah * There is a bug in the Sun client that puts 0xffff in the mode * field of sattr when it should put in 0xffffffff. The u_short * doesn't sign extend. * --> check the low order 2 bytes for 0xffff */ if ((fxdr_unsigned(int, sp->sa_mode) & 0xffff) != 0xffff) va.va_mode = nfstov_mode(sp->sa_mode); if (sp->sa_uid != nfs_xdrneg1) va.va_uid = fxdr_unsigned(uid_t, sp->sa_uid); if (sp->sa_gid != nfs_xdrneg1) va.va_gid = fxdr_unsigned(gid_t, sp->sa_gid); if (sp->sa_size != nfs_xdrneg1) va.va_size = fxdr_unsigned(u_quad_t, sp->sa_size); if (sp->sa_atime.nfsv2_sec != nfs_xdrneg1) { #ifdef notyet fxdr_nfsv2time(&sp->sa_atime, &va.va_atime); #else va.va_atime.tv_sec = fxdr_unsigned(u_int32_t,sp->sa_atime.nfsv2_sec); va.va_atime.tv_nsec = 0; #endif } if (sp->sa_mtime.nfsv2_sec != nfs_xdrneg1) fxdr_nfsv2time(&sp->sa_mtime, &va.va_mtime); } /* * Now that we have all the fields, lets do it. */ error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(preat_ret, &preat, postat_ret, &va); return (0); } nqsrv_getl(vp, ND_WRITE); if (v3) { error = preat_ret = VOP_GETATTR(vp, &preat, cred); if (!error && gcheck && (preat.va_ctime.tv_sec != guard.tv_sec || preat.va_ctime.tv_nsec != guard.tv_nsec)) error = NFSERR_NOT_SYNC; if (error) { vput(vp); nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(preat_ret, &preat, postat_ret, &va); return (0); } } /* * If the size is being changed write access is required, otherwise * just check for a read only file system. */ if (va.va_size == ((u_quad_t)((quad_t) -1))) { if (rdonly || (vp->v_mount->mnt_flag & MNT_RDONLY)) { error = EROFS; goto out; } } else { if (vp->v_type == VDIR) { error = EISDIR; goto out; } else if ((error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0)) != 0) goto out; } error = VOP_SETATTR(vp, &va, cred); postat_ret = VOP_GETATTR(vp, &va, cred); if (!error) error = postat_ret; out: vput(vp); nfsm_reply(NFSX_WCCORFATTR(v3)); if (v3) { nfsm_srvwcc_data(preat_ret, &preat, postat_ret, &va); return (0); } else { nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(&va, fp); } nfsm_srvdone; } /* * nfs lookup rpc */ int nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct nfs_fattr *fp; struct nameidata nd, ind, *ndp = &nd; struct pathbuf *ipb = NULL; struct vnode *vp, *dirp; nfsrvfh_t nsfh; char *cp; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, cache = 0, dirattr_ret = 1; uint32_t len; int v3 = (nfsd->nd_flag & ND_NFSV3), pubflag; char *cp2; struct mbuf *mb, *mreq __unused; struct vattr va, dirattr; u_quad_t frev; nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); pubflag = nfs_ispublicfh(&nsfh); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags = LOCKLEAF; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, NULL, NULL, lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag); if (!error && pubflag) { if (nd.ni_vp->v_type == VDIR && nfs_pub.np_index != NULL && (ipb = pathbuf_create(nfs_pub.np_index)) != NULL) { /* * Setup call to lookup() to see if we can find * the index file. Arguably, this doesn't belong * in a kernel.. Ugh. */ ind = nd; VOP_UNLOCK(nd.ni_vp); ind.ni_pathbuf = ipb; error = lookup_for_nfsd_index(&ind, nd.ni_vp); if (!error) { /* * Found an index file. Get rid of * the old references. */ if (dirp) vrele(dirp); dirp = nd.ni_vp; ndp = &ind; } else error = 0; } /* * If the public filehandle was used, check that this lookup * didn't result in a filehandle outside the publicly exported * filesystem. */ if (!error && ndp->ni_vp->v_mount != nfs_pub.np_mount) { vput(nd.ni_vp); error = EPERM; } } if (error) { if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); } if (ipb != NULL) { pathbuf_destroy(ipb); } if (dirp) { if (v3) { vn_lock(dirp, LK_SHARED | LK_RETRY); dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred); vput(dirp); } else vrele(dirp); } nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(dirattr_ret, &dirattr); return (0); } nqsrv_getl(ndp->ni_startdir, ND_READ); pathbuf_destroy(nd.ni_pathbuf); if (ipb != NULL) { pathbuf_destroy(ipb); } vp = ndp->ni_vp; error = nfsrv_composefh(vp, &nsfh, v3); if (!error) error = VOP_GETATTR(vp, &va, cred); vput(vp); if (dirp) { if (v3) { vn_lock(dirp, LK_SHARED | LK_RETRY); dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred); vput(dirp); } else vrele(dirp); } nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPORFATTR(v3) + NFSX_POSTOPATTR(v3)); if (error) { nfsm_srvpostop_attr(dirattr_ret, &dirattr); return (0); } nfsm_srvfhtom(&nsfh, v3); if (v3) { nfsm_srvpostop_attr(0, &va); nfsm_srvpostop_attr(dirattr_ret, &dirattr); } else { nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(&va, fp); } nfsm_srvdone; } /* * nfs readlink service */ int nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct iovec iv[(NFS_MAXPATHLEN+MLEN-1)/MLEN]; struct iovec *ivp = iv; struct mbuf *mp; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, i, padlen, getret; uint32_t len; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mp2 = NULL, *mp3 = NULL, *mreq __unused; struct vnode *vp; struct vattr attr; nfsrvfh_t nsfh; struct uio io, *uiop = &io; u_quad_t frev; nfsm_srvmtofh(&nsfh); len = 0; i = 0; while (len < NFS_MAXPATHLEN) { mp = m_get(M_WAIT, MT_DATA); MCLAIM(mp, &nfs_mowner); m_clget(mp, M_WAIT); mp->m_len = NFSMSIZ(mp); if (len == 0) mp3 = mp2 = mp; else { mp2->m_next = mp; mp2 = mp; } if ((len+mp->m_len) > NFS_MAXPATHLEN) { mp->m_len = NFS_MAXPATHLEN-len; len = NFS_MAXPATHLEN; } else len += mp->m_len; ivp->iov_base = mtod(mp, void *); ivp->iov_len = mp->m_len; i++; ivp++; } uiop->uio_iov = iv; uiop->uio_iovcnt = i; uiop->uio_offset = 0; uiop->uio_resid = len; uiop->uio_rw = UIO_READ; UIO_SETUP_SYSSPACE(uiop); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { m_freem(mp3); nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvpostop_attr(1, (struct vattr *)0); return (0); } if (vp->v_type != VLNK) { if (v3) error = EINVAL; else error = ENXIO; goto out; } nqsrv_getl(vp, ND_READ); error = VOP_READLINK(vp, uiop, cred); out: getret = VOP_GETATTR(vp, &attr, cred); vput(vp); if (error) m_freem(mp3); nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_UNSIGNED); if (v3) { nfsm_srvpostop_attr(getret, &attr); if (error) return (0); } len -= uiop->uio_resid; padlen = nfsm_padlen(len); if (len == 0) { m_freem(mp3); mp3 = NULL; } else if (uiop->uio_resid || padlen) nfs_zeropad(mp3, uiop->uio_resid, padlen); nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); *tl = txdr_unsigned(len); mb->m_next = mp3; nfsm_srvdone; } /* * nfs read service */ int nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct mbuf *m; struct nfs_fattr *fp; u_int32_t *tl; int32_t t1; int i; char *bpos; int error = 0, rdonly, cache = 0, getret; int v3 = (nfsd->nd_flag & ND_NFSV3); uint32_t reqlen, len, cnt, left; int padlen; char *cp2; struct mbuf *mb, *mreq; struct vnode *vp; nfsrvfh_t nsfh; struct uio io, *uiop = &io; struct vattr va; off_t off; u_quad_t frev; nfsm_srvmtofh(&nsfh); if (v3) { nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); off = fxdr_hyper(tl); } else { nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); off = (off_t)fxdr_unsigned(u_int32_t, *tl); } nfsm_dissect(tl, uint32_t *, NFSX_UNSIGNED); reqlen = fxdr_unsigned(uint32_t, *tl); reqlen = MIN(reqlen, NFS_SRVMAXDATA(nfsd)); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvpostop_attr(1, (struct vattr *)0); return (0); } if (vp->v_type != VREG) { if (v3) error = EINVAL; else error = (vp->v_type == VDIR) ? EISDIR : EACCES; } if (!error) { nqsrv_getl(vp, ND_READ); if ((error = nfsrv_access(vp, VREAD, cred, rdonly, lwp, 1)) != 0) error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 1); } getret = VOP_GETATTR(vp, &va, cred); if (!error) error = getret; if (error) { vput(vp); nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(getret, &va); return (0); } if (off >= va.va_size) cnt = 0; else if ((off + reqlen) > va.va_size) cnt = va.va_size - off; else cnt = reqlen; nfsm_reply(NFSX_POSTOPORFATTR(v3) + 3 * NFSX_UNSIGNED+nfsm_rndup(cnt)); if (v3) { nfsm_build(tl, u_int32_t *, NFSX_V3FATTR + 4 * NFSX_UNSIGNED); *tl++ = nfs_true; fp = (struct nfs_fattr *)tl; tl += (NFSX_V3FATTR / sizeof (u_int32_t)); } else { nfsm_build(tl, u_int32_t *, NFSX_V2FATTR + NFSX_UNSIGNED); fp = (struct nfs_fattr *)tl; tl += (NFSX_V2FATTR / sizeof (u_int32_t)); } len = left = cnt; if (cnt > 0) { if (nfsd_use_loan) { struct vm_page **pgpp; voff_t pgoff = trunc_page(off); int npages; vaddr_t lva; npages = (round_page(off + cnt) - pgoff) >> PAGE_SHIFT; KASSERT(npages <= M_EXT_MAXPAGES); /* XXX */ /* allocate kva for mbuf data */ lva = sokvaalloc(pgoff, npages << PAGE_SHIFT, slp->ns_so); if (lva == 0) { /* fall back to VOP_READ */ goto loan_fail; } /* allocate mbuf */ m = m_get(M_WAIT, MT_DATA); MCLAIM(m, &nfs_mowner); pgpp = m->m_ext.ext_pgs; /* loan pages */ error = uvm_loanuobjpages(&vp->v_uobj, pgoff, npages, pgpp); if (error) { sokvafree(lva, npages << PAGE_SHIFT); m_free(m); if (error == EBUSY) goto loan_fail; goto read_error; } /* associate kva to mbuf */ MEXTADD(m, (void *)(lva + ((vaddr_t)off & PAGE_MASK)), cnt, M_MBUF, soloanfree, slp->ns_so); m->m_flags |= M_EXT_PAGES | M_EXT_ROMAP; m->m_len = cnt; /* map pages */ for (i = 0; i < npages; i++) { pmap_kenter_pa(lva, VM_PAGE_TO_PHYS(pgpp[i]), VM_PROT_READ, 0); lva += PAGE_SIZE; } pmap_update(pmap_kernel()); mb->m_next = m; mb = m; error = 0; uiop->uio_resid = 0; } else { struct iovec *iv; struct iovec *iv2; struct mbuf *m2; int siz; loan_fail: /* * Generate the mbuf list with the uio_iov ref. to it. */ i = 0; m = m2 = mb; while (left > 0) { siz = uimin(M_TRAILINGSPACE(m), left); if (siz > 0) { left -= siz; i++; } if (left > 0) { m = m_get(M_WAIT, MT_DATA); MCLAIM(m, &nfs_mowner); m_clget(m, M_WAIT); m->m_len = 0; m2->m_next = m; m2 = m; } } iv = malloc(i * sizeof(struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = iv2 = iv; m = mb; left = cnt; i = 0; while (left > 0) { if (m == NULL) panic("nfsrv_read iov"); siz = uimin(M_TRAILINGSPACE(m), left); if (siz > 0) { iv->iov_base = mtod(m, char *) + m->m_len; iv->iov_len = siz; m->m_len += siz; left -= siz; iv++; i++; } m = m->m_next; } uiop->uio_iovcnt = i; uiop->uio_offset = off; uiop->uio_resid = cnt; uiop->uio_rw = UIO_READ; UIO_SETUP_SYSSPACE(uiop); error = VOP_READ(vp, uiop, IO_NODELOCKED, cred); free((void *)iv2, M_TEMP); } read_error: if (error || (getret = VOP_GETATTR(vp, &va, cred)) != 0){ if (!error) error = getret; m_freem(mreq); vput(vp); nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(getret, &va); return (0); } } else { uiop->uio_resid = 0; } vput(vp); nfsm_srvfillattr(&va, fp); len -= uiop->uio_resid; padlen = nfsm_padlen(len); if (uiop->uio_resid || padlen) nfs_zeropad(mb, uiop->uio_resid, padlen); if (v3) { /* count */ *tl++ = txdr_unsigned(len); /* eof */ if (off + len >= va.va_size) *tl++ = nfs_true; else *tl++ = nfs_false; } *tl = txdr_unsigned(len); nfsm_srvdone; } /* * nfs write service */ int nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct iovec *ivp; int i, cnt; struct mbuf *mp; struct nfs_fattr *fp; struct iovec *iv; struct vattr va, forat; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, len, forat_ret = 1; int ioflags, aftat_ret = 1, retlen, zeroing, adjust; int stable = NFSV3WRITE_FILESYNC; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq __unused; struct vnode *vp; nfsrvfh_t nsfh; struct uio io, *uiop = &io; off_t off; u_quad_t frev; if (mrep == NULL) { *mrq = NULL; return (0); } nfsm_srvmtofh(&nsfh); if (v3) { nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); off = fxdr_hyper(tl); tl += 3; stable = fxdr_unsigned(int, *tl++); } else { nfsm_dissect(tl, u_int32_t *, 4 * NFSX_UNSIGNED); off = (off_t)fxdr_unsigned(u_int32_t, *++tl); tl += 2; } retlen = len = fxdr_unsigned(int32_t, *tl); cnt = i = 0; /* * For NFS Version 2, it is not obvious what a write of zero length * should do, but I might as well be consistent with Version 3, * which is to return ok so long as there are no permission problems. */ if (len > 0) { zeroing = 1; mp = mrep; while (mp) { if (mp == md) { zeroing = 0; adjust = dpos - mtod(mp, char *); mp->m_len -= adjust; if (mp->m_len > 0 && adjust > 0) NFSMADV(mp, adjust); } if (zeroing) mp->m_len = 0; else if (mp->m_len > 0) { i += mp->m_len; if (i > len) { mp->m_len -= (i - len); zeroing = 1; } if (mp->m_len > 0) cnt++; } mp = mp->m_next; } } if (len > NFS_MAXDATA || len < 0 || i < len) { error = EIO; nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); return (0); } error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); return (0); } if (v3) forat_ret = VOP_GETATTR(vp, &forat, cred); if (vp->v_type != VREG) { if (v3) error = EINVAL; else error = (vp->v_type == VDIR) ? EISDIR : EACCES; } if (!error) { nqsrv_getl(vp, ND_WRITE); error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 1); } if (error) { vput(vp); nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); return (0); } if (len > 0) { ivp = malloc(cnt * sizeof (struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = iv = ivp; uiop->uio_iovcnt = cnt; mp = mrep; while (mp) { if (mp->m_len > 0) { ivp->iov_base = mtod(mp, void *); ivp->iov_len = mp->m_len; ivp++; } mp = mp->m_next; } /* * XXX * The IO_METASYNC flag indicates that all metadata (and not * just enough to ensure data integrity) must be written to * stable storage synchronously. * (IO_METASYNC is not yet implemented in 4.4BSD-Lite.) */ if (stable == NFSV3WRITE_UNSTABLE) ioflags = IO_NODELOCKED; else if (stable == NFSV3WRITE_DATASYNC) ioflags = (IO_SYNC | IO_NODELOCKED); else ioflags = (IO_METASYNC | IO_SYNC | IO_NODELOCKED); uiop->uio_resid = len; uiop->uio_rw = UIO_WRITE; uiop->uio_offset = off; UIO_SETUP_SYSSPACE(uiop); error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; free(iv, M_TEMP); } aftat_ret = VOP_GETATTR(vp, &va, cred); vput(vp); if (!error) error = aftat_ret; nfsm_reply(NFSX_PREOPATTR(v3) + NFSX_POSTOPORFATTR(v3) + 2 * NFSX_UNSIGNED + NFSX_WRITEVERF(v3)); if (v3) { nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); if (error) return (0); nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(retlen); if (stable == NFSV3WRITE_UNSTABLE) *tl++ = txdr_unsigned(stable); else *tl++ = txdr_unsigned(NFSV3WRITE_FILESYNC); /* * Actually, there is no need to txdr these fields, * but it may make the values more human readable, * for debugging purposes. */ struct timeval btv; getmicroboottime(&btv); *tl++ = txdr_unsigned(btv.tv_sec); *tl = txdr_unsigned(btv.tv_usec); } else { nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(&va, fp); } nfsm_srvdone; } /* * XXX elad: the original NFSW_SAMECRED() macro also made sure the * two nd_flag fields of the descriptors contained * ND_KERBAUTH. */ static int nfsrv_samecred(kauth_cred_t cred1, kauth_cred_t cred2) { int i, do_ngroups; if (kauth_cred_geteuid(cred1) != kauth_cred_geteuid(cred2)) return (0); if (kauth_cred_ngroups(cred1) != kauth_cred_ngroups(cred2)) return (0); do_ngroups = kauth_cred_ngroups(cred1); for (i = 0; i < do_ngroups; i++) if (kauth_cred_group(cred1, i) != kauth_cred_group(cred2, i)) return (0); return (1); } static struct nfsrvw_delayhash * nfsrv_nwdelayhash(struct nfssvc_sock *slp, const nfsrvfh_t *nsfh) { uint32_t hash; hash = hash32_buf(NFSRVFH_DATA(nsfh), NFSRVFH_SIZE(nsfh), HASH32_BUF_INIT); return &slp->ns_wdelayhashtbl[hash % NFS_WDELAYHASHSIZ]; } /* * NFS write service with write gathering support. Called when * nfsrvw_procrastinate > 0. * See: Chet Juszczak, "Improving the Write Performance of an NFS Server", * in Proc. of the Winter 1994 Usenix Conference, pg. 247-259, San Franscisco, * Jan. 1994. */ int nfsrv_writegather(struct nfsrv_descript **ndp, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct timeval now; struct iovec *ivp; struct mbuf *mp; struct nfsrv_descript *wp, *nfsd, *owp, *swp; struct nfs_fattr *fp; int i = 0; struct iovec *iov; struct nfsrvw_delayhash *wpp; kauth_cred_t cred; struct vattr va, forat; u_int32_t *tl; int32_t t1; char *bpos, *dpos; int error = 0, rdonly, cache = 0, len = 0, forat_ret = 1; int ioflags, aftat_ret = 1, adjust, v3, zeroing; char *cp2; struct mbuf *mb, *mreq, *mrep, *md; struct vnode *vp; struct uio io, *uiop = &io; u_quad_t frev, cur_usec; *mrq = NULL; if (*ndp) { nfsd = *ndp; *ndp = NULL; mrep = nfsd->nd_mrep; md = nfsd->nd_md; dpos = nfsd->nd_dpos; cred = nfsd->nd_cr; v3 = (nfsd->nd_flag & ND_NFSV3); LIST_INIT(&nfsd->nd_coalesce); nfsd->nd_mreq = NULL; nfsd->nd_stable = NFSV3WRITE_FILESYNC; getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; nfsd->nd_time = cur_usec + nfsrvw_procrastinate; /* * Now, get the write header.. */ nfsm_srvmtofh(&nfsd->nd_fh); if (v3) { nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); nfsd->nd_off = fxdr_hyper(tl); tl += 3; nfsd->nd_stable = fxdr_unsigned(int, *tl++); } else { nfsm_dissect(tl, u_int32_t *, 4 * NFSX_UNSIGNED); nfsd->nd_off = (off_t)fxdr_unsigned(u_int32_t, *++tl); tl += 2; } len = fxdr_unsigned(int32_t, *tl); nfsd->nd_len = len; nfsd->nd_eoff = nfsd->nd_off + len; /* * Trim the header out of the mbuf list and trim off any trailing * junk so that the mbuf list has only the write data. */ zeroing = 1; i = 0; mp = mrep; while (mp) { if (mp == md) { zeroing = 0; adjust = dpos - mtod(mp, char *); mp->m_len -= adjust; if (mp->m_len > 0 && adjust > 0) NFSMADV(mp, adjust); } if (zeroing) mp->m_len = 0; else { i += mp->m_len; if (i > len) { mp->m_len -= (i - len); zeroing = 1; } } mp = mp->m_next; } if (len > NFS_MAXDATA || len < 0 || i < len) { nfsmout: m_freem(mrep); error = EIO; nfsm_writereply(2 * NFSX_UNSIGNED, v3); if (v3) nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); nfsd->nd_mreq = mreq; nfsd->nd_mrep = NULL; nfsd->nd_time = 0; } /* * Add this entry to the hash and time queues. */ owp = NULL; mutex_enter(&nfsd_lock); wp = LIST_FIRST(&slp->ns_tq); while (wp && wp->nd_time < nfsd->nd_time) { owp = wp; wp = LIST_NEXT(wp, nd_tq); } if (owp) { LIST_INSERT_AFTER(owp, nfsd, nd_tq); } else { LIST_INSERT_HEAD(&slp->ns_tq, nfsd, nd_tq); } if (nfsd->nd_mrep) { wpp = nfsrv_nwdelayhash(slp, &nfsd->nd_fh); owp = NULL; wp = LIST_FIRST(wpp); while (wp && nfsrv_comparefh(&nfsd->nd_fh, &wp->nd_fh)) { owp = wp; wp = LIST_NEXT(wp, nd_hash); } while (wp && wp->nd_off < nfsd->nd_off && !nfsrv_comparefh(&nfsd->nd_fh, &wp->nd_fh)) { owp = wp; wp = LIST_NEXT(wp, nd_hash); } if (owp) { LIST_INSERT_AFTER(owp, nfsd, nd_hash); /* * Search the hash list for overlapping entries and * coalesce. */ for(; nfsd && NFSW_CONTIG(owp, nfsd); nfsd = wp) { wp = LIST_NEXT(nfsd, nd_hash); if (nfsrv_samecred(owp->nd_cr, nfsd->nd_cr)) nfsrvw_coalesce(owp, nfsd); } } else { LIST_INSERT_HEAD(wpp, nfsd, nd_hash); } } mutex_exit(&nfsd_lock); } /* * Now, do VOP_WRITE()s for any one(s) that need to be done now * and generate the associated reply mbuf list(s). */ loop1: getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; mutex_enter(&nfsd_lock); for (nfsd = LIST_FIRST(&slp->ns_tq); nfsd; nfsd = owp) { owp = LIST_NEXT(nfsd, nd_tq); if (nfsd->nd_time > cur_usec) break; if (nfsd->nd_mreq) continue; LIST_REMOVE(nfsd, nd_tq); LIST_REMOVE(nfsd, nd_hash); mutex_exit(&nfsd_lock); mrep = nfsd->nd_mrep; nfsd->nd_mrep = NULL; cred = nfsd->nd_cr; v3 = (nfsd->nd_flag & ND_NFSV3); forat_ret = aftat_ret = 1; error = nfsrv_fhtovp(&nfsd->nd_fh, 1, &vp, cred, slp, nfsd->nd_nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (!error) { if (v3) forat_ret = VOP_GETATTR(vp, &forat, cred); if (vp->v_type != VREG) { if (v3) error = EINVAL; else error = (vp->v_type == VDIR) ? EISDIR : EACCES; } } else vp = NULL; if (!error) { nqsrv_getl(vp, ND_WRITE); error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 1); } if (nfsd->nd_stable == NFSV3WRITE_UNSTABLE) ioflags = IO_NODELOCKED; else if (nfsd->nd_stable == NFSV3WRITE_DATASYNC) ioflags = (IO_SYNC | IO_NODELOCKED); else ioflags = (IO_METASYNC | IO_SYNC | IO_NODELOCKED); uiop->uio_rw = UIO_WRITE; uiop->uio_offset = nfsd->nd_off; uiop->uio_resid = nfsd->nd_eoff - nfsd->nd_off; UIO_SETUP_SYSSPACE(uiop); if (uiop->uio_resid > 0) { mp = mrep; i = 0; while (mp) { if (mp->m_len > 0) i++; mp = mp->m_next; } uiop->uio_iovcnt = i; iov = malloc(i * sizeof (struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = ivp = iov; mp = mrep; while (mp) { if (mp->m_len > 0) { ivp->iov_base = mtod(mp, void *); ivp->iov_len = mp->m_len; ivp++; } mp = mp->m_next; } if (!error) { error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; } free((void *)iov, M_TEMP); } m_freem(mrep); if (vp) { aftat_ret = VOP_GETATTR(vp, &va, cred); vput(vp); } /* * Loop around generating replies for all write rpcs that have * now been completed. */ swp = nfsd; do { if (error) { nfsm_writereply(NFSX_WCCDATA(v3), v3); if (v3) { nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); } } else { nfsm_writereply(NFSX_PREOPATTR(v3) + NFSX_POSTOPORFATTR(v3) + 2 * NFSX_UNSIGNED + NFSX_WRITEVERF(v3), v3); if (v3) { nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(nfsd->nd_len); *tl++ = txdr_unsigned(swp->nd_stable); /* * Actually, there is no need to txdr these fields, * but it may make the values more human readable, * for debugging purposes. */ struct timeval btv; getmicroboottime(&btv); *tl++ = txdr_unsigned(btv.tv_sec); *tl = txdr_unsigned(btv.tv_usec); } else { nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(&va, fp); } } nfsd->nd_mreq = mreq; if (nfsd->nd_mrep) panic("nfsrv_write: nd_mrep not free"); /* * Done. Put it at the head of the timer queue so that * the final phase can return the reply. */ mutex_enter(&nfsd_lock); if (nfsd != swp) { nfsd->nd_time = 0; LIST_INSERT_HEAD(&slp->ns_tq, nfsd, nd_tq); } nfsd = LIST_FIRST(&swp->nd_coalesce); if (nfsd) { LIST_REMOVE(nfsd, nd_tq); } mutex_exit(&nfsd_lock); } while (nfsd); swp->nd_time = 0; mutex_enter(&nfsd_lock); LIST_INSERT_HEAD(&slp->ns_tq, swp, nd_tq); mutex_exit(&nfsd_lock); goto loop1; } mutex_exit(&nfsd_lock); nfs_timer_start(); /* * Search for a reply to return. */ mutex_enter(&nfsd_lock); LIST_FOREACH(nfsd, &slp->ns_tq, nd_tq) { if (nfsd->nd_mreq) { LIST_REMOVE(nfsd, nd_tq); *mrq = nfsd->nd_mreq; *ndp = nfsd; break; } } mutex_exit(&nfsd_lock); return (0); } /* * Coalesce the write request nfsd into owp. To do this we must: * - remove nfsd from the queues * - merge nfsd->nd_mrep into owp->nd_mrep * - update the nd_eoff and nd_stable for owp * - put nfsd on owp's nd_coalesce list * NB: Must be called at splsoftclock(). */ void nfsrvw_coalesce(struct nfsrv_descript *owp, struct nfsrv_descript *nfsd) { int overlap; struct mbuf *mp; struct nfsrv_descript *m; KASSERT(mutex_owned(&nfsd_lock)); LIST_REMOVE(nfsd, nd_hash); LIST_REMOVE(nfsd, nd_tq); if (owp->nd_eoff < nfsd->nd_eoff) { overlap = owp->nd_eoff - nfsd->nd_off; if (overlap < 0) panic("nfsrv_coalesce: bad off"); if (overlap > 0) m_adj(nfsd->nd_mrep, overlap); mp = owp->nd_mrep; while (mp->m_next) mp = mp->m_next; mp->m_next = nfsd->nd_mrep; owp->nd_eoff = nfsd->nd_eoff; } else m_freem(nfsd->nd_mrep); nfsd->nd_mrep = NULL; if (nfsd->nd_stable == NFSV3WRITE_FILESYNC) owp->nd_stable = NFSV3WRITE_FILESYNC; else if (nfsd->nd_stable == NFSV3WRITE_DATASYNC && owp->nd_stable == NFSV3WRITE_UNSTABLE) owp->nd_stable = NFSV3WRITE_DATASYNC; LIST_INSERT_HEAD(&owp->nd_coalesce, nfsd, nd_tq); /* * nfsd might hold coalesce elements! Move them to owp. * Otherwise, requests may be lost and clients will be stuck. */ while ((m = LIST_FIRST(&nfsd->nd_coalesce)) != NULL) { LIST_REMOVE(m, nd_tq); LIST_INSERT_HEAD(&owp->nd_coalesce, m, nd_tq); } } /* * nfs create service * now does a truncate to 0 length via. setattr if it already exists */ int nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct nfs_fattr *fp; struct vattr va, dirfor, diraft; struct nfsv2_sattr *sp; u_int32_t *tl; struct nameidata nd; char *cp; int32_t t1; char *bpos; int error = 0, cache = 0, len, tsize, dirfor_ret = 1, diraft_ret = 1; int rdev = 0, abort = 0; int v3 = (nfsd->nd_flag & ND_NFSV3), how, exclusive_flag = 0; char *cp2; struct mbuf *mb, *mreq __unused; struct vnode *vp = NULL, *dirp = NULL; nfsrvfh_t nsfh; u_quad_t frev, tempsize; u_char cverf[NFSX_V3CREATEVERF]; nd.ni_cnd.cn_nameiop = 0; nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, (v3 ? &dirfor_ret : NULL), &dirfor, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); if (dirp) vrele(dirp); if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } return (0); } abort = 1; vattr_null(&va); if (v3) { va.va_mode = 0; nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); how = fxdr_unsigned(int, *tl); switch (how) { case NFSV3CREATE_GUARDED: if (nd.ni_vp) { error = EEXIST; break; } /* FALLTHROUGH */ case NFSV3CREATE_UNCHECKED: nfsm_srvsattr(&va); break; case NFSV3CREATE_EXCLUSIVE: nfsm_dissect(cp, void *, NFSX_V3CREATEVERF); memcpy(cverf, cp, NFSX_V3CREATEVERF); exclusive_flag = 1; break; }; va.va_type = VREG; } else { nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); va.va_type = IFTOVT(fxdr_unsigned(u_int32_t, sp->sa_mode)); if (va.va_type == VNON) va.va_type = VREG; va.va_mode = nfstov_mode(sp->sa_mode); switch (va.va_type) { case VREG: tsize = fxdr_unsigned(int32_t, sp->sa_size); if (tsize != -1) va.va_size = (u_quad_t)tsize; break; case VCHR: case VBLK: case VFIFO: rdev = fxdr_unsigned(int32_t, sp->sa_size); break; default: break; }; } /* * Iff doesn't exist, create it * otherwise just truncate to 0 length * should I set the mode too ?? */ if (nd.ni_vp == NULL) { if (va.va_type == VREG || va.va_type == VSOCK) { nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va); if (!error) { vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY); if (exclusive_flag) { exclusive_flag = 0; vattr_null(&va); /* * XXX * assuming NFSX_V3CREATEVERF * == sizeof(nfstime3) */ fxdr_nfsv3time(cverf, &va.va_atime); error = VOP_SETATTR(nd.ni_vp, &va, cred); } } } else if (va.va_type == VCHR || va.va_type == VBLK || va.va_type == VFIFO) { if (va.va_type == VCHR && rdev == 0xffffffff) va.va_type = VFIFO; if (va.va_type != VFIFO && (error = kauth_authorize_system(cred, KAUTH_SYSTEM_MKNOD, 0, NULL, NULL, NULL))) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); abort = 0; nfsm_reply(0); if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } return (error); } else va.va_rdev = (dev_t)rdev; nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va); if (!error) { vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY); } else { nfsm_reply(0); } } else { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } error = ENXIO; abort = 0; } vp = nd.ni_vp; } else { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } vp = nd.ni_vp; abort = 0; if (!error && va.va_size != -1) { error = nfsrv_access(vp, VWRITE, cred, (nd.ni_cnd.cn_flags & RDONLY), lwp, 0); if (!error) { nqsrv_getl(vp, ND_WRITE); tempsize = va.va_size; vattr_null(&va); va.va_size = tempsize; error = VOP_SETATTR(vp, &va, cred); } } if (error) vput(vp); } if (!error) { error = nfsrv_composefh(vp, &nsfh, v3); if (!error) error = VOP_GETATTR(vp, &va, cred); vput(vp); } if (nd.ni_dvp == vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (v3) { if (exclusive_flag && !error) { /* * XXX assuming NFSX_V3CREATEVERF == sizeof(nfstime3) */ char oldverf[NFSX_V3CREATEVERF]; txdr_nfsv3time(&va.va_atime, oldverf); if (memcmp(cverf, oldverf, NFSX_V3CREATEVERF)) error = EEXIST; } if (dirp) { vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, &diraft, cred); VOP_UNLOCK(dirp); } } if (dirp) { vrele(dirp); dirp = NULL; } if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } abort = 0; nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { if (!error) { nfsm_srvpostop_fh(&nsfh); nfsm_srvpostop_attr(0, &va); } nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); } else { nfsm_srvfhtom(&nsfh, v3); nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(&va, fp); } return (0); nfsmout: if (dirp) vrele(dirp); if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } } return (error); } /* * nfs v3 mknod service */ int nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct vattr va, dirfor, diraft; u_int32_t *tl; struct nameidata nd; int32_t t1; char *bpos; int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; int abort = 0; u_int32_t major, minor; enum vtype vtyp; char *cp2; struct mbuf *mb, *mreq __unused; struct vnode *vp, *dirp = (struct vnode *)0; nfsrvfh_t nsfh; u_quad_t frev; nd.ni_cnd.cn_nameiop = 0; nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, &dirfor_ret, &dirfor, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(NFSX_WCCDATA(1)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); if (dirp) vrele(dirp); if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } return (0); } abort = 1; nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); vtyp = nfsv3tov_type(*tl); if (vtyp != VCHR && vtyp != VBLK && vtyp != VSOCK && vtyp != VFIFO) { error = NFSERR_BADTYPE; goto abort; } vattr_null(&va); va.va_mode = 0; nfsm_srvsattr(&va); if (vtyp == VCHR || vtyp == VBLK) { dev_t rdev; nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); major = fxdr_unsigned(u_int32_t, *tl++); minor = fxdr_unsigned(u_int32_t, *tl); rdev = makedev(major, minor); if (major(rdev) != major || minor(rdev) != minor) { error = EINVAL; goto abort; } va.va_rdev = rdev; } /* * Iff doesn't exist, create it. */ if (nd.ni_vp) { error = EEXIST; abort: VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_vp) vput(nd.ni_vp); if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } goto out; } va.va_type = vtyp; if (vtyp == VSOCK) { nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va); } else { if (va.va_type != VFIFO && (error = kauth_authorize_system(cred, KAUTH_SYSTEM_MKNOD, 0, NULL, NULL, NULL))) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); goto out; } nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va); if (error) goto out; } if (!error) { vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY); } out: vp = nd.ni_vp; if (!error) { error = nfsrv_composefh(vp, &nsfh, true); if (!error) error = VOP_GETATTR(vp, &va, cred); vput(vp); } if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (dirp) { vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, &diraft, cred); VOP_UNLOCK(dirp); vrele(dirp); dirp = NULL; } if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } abort = 0; nfsm_reply(NFSX_SRVFH(&nsfh, true) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1)); if (!error) { nfsm_srvpostop_fh(&nsfh); nfsm_srvpostop_attr(0, &va); } nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); nfsmout: if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } } if (dirp) vrele(dirp); return (error); } /* * nfs remove service */ int nfsrv_remove(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct nameidata nd; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq __unused; struct vnode *vp, *dirp; struct vattr dirfor, diraft; nfsrvfh_t nsfh; u_quad_t frev; #ifndef nolint vp = (struct vnode *)0; #endif nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = DELETE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, (v3 ? &dirfor_ret : NULL), &dirfor, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (!error) { vp = nd.ni_vp; if (vp->v_type == VDIR) { error = EPERM; goto out; } /* * The root of a mounted filesystem cannot be deleted. */ if (vp->v_vflag & VV_ROOT) { error = EBUSY; } out: if (!error) { nqsrv_getl(nd.ni_dvp, ND_WRITE); nqsrv_getl(vp, ND_WRITE); error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); vput(nd.ni_dvp); } else { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); vput(vp); } } if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } if (dirp) { if (v3) { vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, &diraft, cred); VOP_UNLOCK(dirp); } vrele(dirp); } nfsm_reply(NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); } nfsm_srvdone; } /* * nfs rename service */ int nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, cache = 0, fdirfor_ret = 1, fdiraft_ret = 1; uint32_t len, len2; int tdirfor_ret = 1, tdiraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq __unused; struct nameidata fromnd, tond; struct vnode *fvp, *tvp, *tdvp; struct vnode *fdirp = NULL, *tdirp = NULL; struct mount *localfs = NULL; struct vattr fdirfor, fdiraft, tdirfor, tdiraft; nfsrvfh_t fnsfh, tnsfh; u_quad_t frev; uid_t saved_uid; #ifndef nolint fvp = (struct vnode *)0; #endif fromnd.ni_cnd.cn_nameiop = 0; tond.ni_cnd.cn_nameiop = 0; nfsm_srvmtofh(&fnsfh); nfsm_srvnamesiz(len); /* * Remember our original uid so that we can reset cr_uid before * the second nfs_namei() call, in case it is remapped. */ saved_uid = kauth_cred_geteuid(cred); fromnd.ni_cnd.cn_cred = cred; fromnd.ni_cnd.cn_nameiop = DELETE; fromnd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&fromnd, &fnsfh, len, slp, nam, &md, &dpos, &fdirp, (v3 ? &fdirfor_ret : NULL), &fdirfor, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { fromnd.ni_cnd.cn_nameiop = 0; nfsm_reply(2 * NFSX_WCCDATA(v3)); nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft); nfsm_srvwcc_data(tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft); if (fdirp) vrele(fdirp); if (fromnd.ni_pathbuf != NULL) { pathbuf_destroy(fromnd.ni_pathbuf); } return (0); } localfs = fromnd.ni_dvp->v_mount; fstrans_start(localfs); if (fromnd.ni_dvp != fromnd.ni_vp) { VOP_UNLOCK(fromnd.ni_dvp); } fvp = fromnd.ni_vp; error = VFS_RENAMELOCK_ENTER(localfs); if (error) { VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); vrele(fvp); goto out1; } /* Copied, regrettably, from vfs_syscalls.c (q.v.) */ vrele(fvp); if ((fromnd.ni_cnd.cn_namelen == 1 && fromnd.ni_cnd.cn_nameptr[0] == '.') || (fromnd.ni_cnd.cn_namelen == 2 && fromnd.ni_cnd.cn_nameptr[0] == '.' && fromnd.ni_cnd.cn_nameptr[1] == '.')) { error = EINVAL; VFS_RENAMELOCK_EXIT(localfs); VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); goto out1; } vn_lock(fromnd.ni_dvp, LK_EXCLUSIVE | LK_RETRY); error = relookup(fromnd.ni_dvp, &fromnd.ni_vp, &fromnd.ni_cnd, 0); if (error) { VOP_UNLOCK(fromnd.ni_dvp); VFS_RENAMELOCK_EXIT(localfs); VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); goto out1; } VOP_UNLOCK(fromnd.ni_vp); if (fromnd.ni_dvp != fromnd.ni_vp) VOP_UNLOCK(fromnd.ni_dvp); fvp = fromnd.ni_vp; nfsm_srvmtofh(&tnsfh); if (v3) { nfsm_dissect(tl, uint32_t *, NFSX_UNSIGNED); len2 = fxdr_unsigned(uint32_t, *tl); /* len2 will be checked by nfs_namei */ } else { /* NFSv2 */ nfsm_strsiz(len2, NFS_MAXNAMLEN); } kauth_cred_seteuid(cred, saved_uid); tond.ni_cnd.cn_cred = cred; tond.ni_cnd.cn_nameiop = RENAME; tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE; error = nfs_namei(&tond, &tnsfh, len2, slp, nam, &md, &dpos, &tdirp, (v3 ? &tdirfor_ret : NULL), &tdirfor, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { VFS_RENAMELOCK_EXIT(localfs); VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); vrele(fvp); goto out1; } tdvp = tond.ni_dvp; tvp = tond.ni_vp; if (tvp != NULL) { if (fvp->v_type == VDIR && tvp->v_type != VDIR) { if (v3) error = EEXIST; else error = EISDIR; goto out; } else if (fvp->v_type != VDIR && tvp->v_type == VDIR) { if (v3) error = EEXIST; else error = ENOTDIR; goto out; } if (tvp->v_type == VDIR && tvp->v_mountedhere) { if (v3) error = EXDEV; else error = ENOTEMPTY; goto out; } } if (fvp->v_type == VDIR && fvp->v_mountedhere) { if (v3) error = EXDEV; else error = ENOTEMPTY; goto out; } if (fvp->v_mount != tdvp->v_mount) { if (v3) error = EXDEV; else error = ENOTEMPTY; goto out; } if (fvp == tdvp) { if (v3) error = EINVAL; else error = ENOTEMPTY; } /* * If source is the same as the destination (that is the * same vnode with the same name in the same directory), * then there is nothing to do. */ if (fvp == tvp && fromnd.ni_dvp == tdvp && fromnd.ni_cnd.cn_namelen == tond.ni_cnd.cn_namelen && !memcmp(fromnd.ni_cnd.cn_nameptr, tond.ni_cnd.cn_nameptr, fromnd.ni_cnd.cn_namelen)) error = -1; out: if (!error) { nqsrv_getl(fromnd.ni_dvp, ND_WRITE); nqsrv_getl(tdvp, ND_WRITE); if (tvp) { nqsrv_getl(tvp, ND_WRITE); } error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd, tond.ni_dvp, tond.ni_vp, &tond.ni_cnd); VFS_RENAMELOCK_EXIT(localfs); } else { VOP_ABORTOP(tond.ni_dvp, &tond.ni_cnd); if (tdvp == tvp) vrele(tdvp); else vput(tdvp); if (tvp) vput(tvp); VFS_RENAMELOCK_EXIT(localfs); VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); vrele(fvp); if (error == -1) error = 0; } if (tond.ni_pathbuf != NULL) { pathbuf_destroy(tond.ni_pathbuf); tond.ni_pathbuf = NULL; } tond.ni_cnd.cn_nameiop = 0; out1: if (fdirp) { if (v3) { vn_lock(fdirp, LK_SHARED | LK_RETRY); fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred); VOP_UNLOCK(fdirp); } vrele(fdirp); fdirp = NULL; } if (tdirp) { if (v3) { vn_lock(tdirp, LK_SHARED | LK_RETRY); tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred); VOP_UNLOCK(tdirp); } vrele(tdirp); tdirp = NULL; } pathbuf_destroy(fromnd.ni_pathbuf); fromnd.ni_pathbuf = NULL; fromnd.ni_cnd.cn_nameiop = 0; fstrans_done(localfs); localfs = NULL; nfsm_reply(2 * NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft); nfsm_srvwcc_data(tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft); } return (0); nfsmout: if (fdirp) vrele(fdirp); #ifdef notdef if (tdirp) vrele(tdirp); #endif if (tond.ni_cnd.cn_nameiop) { if (tond.ni_pathbuf != NULL) { pathbuf_destroy(tond.ni_pathbuf); tond.ni_pathbuf = NULL; } } if (localfs) { VFS_RENAMELOCK_EXIT(localfs); fstrans_done(localfs); } if (fromnd.ni_cnd.cn_nameiop) { VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); if (fromnd.ni_pathbuf != NULL) { pathbuf_destroy(fromnd.ni_pathbuf); fromnd.ni_pathbuf = NULL; } vrele(fromnd.ni_dvp); vrele(fvp); } return (error); } /* * nfs link service */ int nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct nameidata nd; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; int getret = 1, v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq __unused; struct vnode *vp, *xp, *dirp = (struct vnode *)0; struct vattr dirfor, diraft, at; nfsrvfh_t nsfh, dnsfh; u_quad_t frev; nfsm_srvmtofh(&nsfh); nfsm_srvmtofh(&dnsfh); nfsm_srvnamesiz(len); error = nfsrv_fhtovp(&nsfh, false, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); nfsm_srvpostop_attr(getret, &at); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); } if (vp->v_type == VDIR) { error = EPERM; goto out1; } nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&nd, &dnsfh, len, slp, nam, &md, &dpos, &dirp, (v3 ? &dirfor_ret : NULL), &dirfor, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) goto out1; xp = nd.ni_vp; if (xp != NULL) { error = EEXIST; goto out; } xp = nd.ni_dvp; if (vp->v_mount != xp->v_mount) error = EXDEV; out: if (!error) { nqsrv_getl(vp, ND_WRITE); nqsrv_getl(xp, ND_WRITE); error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); if (nd.ni_dvp != nd.ni_vp) VOP_UNLOCK(nd.ni_dvp); vrele(nd.ni_dvp); } else { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); } out1: if (v3) { vn_lock(vp, LK_SHARED | LK_RETRY); getret = VOP_GETATTR(vp, &at, cred); VOP_UNLOCK(vp); } if (dirp) { if (v3) { vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, &diraft, cred); VOP_UNLOCK(dirp); } vrele(dirp); } vrele(vp); if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { nfsm_srvpostop_attr(getret, &at); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); } nfsm_srvdone; } /* * nfs symbolic link service */ int nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct vattr va, dirfor, diraft; struct nameidata nd; u_int32_t *tl; int32_t t1; struct nfsv2_sattr *sp; char *bpos, *pathcp = NULL, *cp2; struct uio io; struct iovec iv; int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1, abort = 0; uint32_t len, len2; int v3 = (nfsd->nd_flag & ND_NFSV3); struct mbuf *mb, *mreq __unused; struct vnode *dirp = (struct vnode *)0; nfsrvfh_t nsfh; u_quad_t frev; nd.ni_cnd.cn_nameiop = 0; nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, (v3 ? &dirfor_ret : NULL), &dirfor, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) goto out; abort = 1; vattr_null(&va); va.va_type = VLNK; if (v3) { va.va_mode = 0; nfsm_srvsattr(&va); nfsm_dissect(tl, uint32_t *, NFSX_UNSIGNED); len2 = fxdr_unsigned(uint32_t, *tl); if (len2 > PATH_MAX) { /* XXX should check _PC_NO_TRUNC */ error = ENAMETOOLONG; goto abortop; } } else { /* NFSv2 */ nfsm_strsiz(len2, NFS_MAXPATHLEN); } pathcp = malloc(len2 + 1, M_TEMP, M_WAITOK); iv.iov_base = pathcp; iv.iov_len = len2; io.uio_resid = len2; io.uio_offset = 0; io.uio_iov = &iv; io.uio_iovcnt = 1; io.uio_rw = UIO_READ; UIO_SETUP_SYSSPACE(&io); nfsm_mtouio(&io, len2); if (!v3) { nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); va.va_mode = fxdr_unsigned(u_int16_t, sp->sa_mode); } *(pathcp + len2) = '\0'; if (nd.ni_vp) { error = EEXIST; abortop: VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); goto out; } nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va, pathcp); if (!error) { if (v3) { vn_lock(nd.ni_vp, LK_SHARED | LK_RETRY); error = nfsrv_composefh(nd.ni_vp, &nsfh, v3); if (!error) error = VOP_GETATTR(nd.ni_vp, &va, cred); vput(nd.ni_vp); } else { vrele(nd.ni_vp); } } vput(nd.ni_dvp); out: if (pathcp) free(pathcp, M_TEMP); if (dirp) { if (v3) { vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, &diraft, cred); VOP_UNLOCK(dirp); } vrele(dirp); dirp = NULL; } if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } abort = 0; nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { if (!error) { nfsm_srvpostop_fh(&nsfh); nfsm_srvpostop_attr(0, &va); } nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); } return (0); nfsmout: if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } } if (dirp) vrele(dirp); if (pathcp) free(pathcp, M_TEMP); return (error); } /* * nfs mkdir service */ int nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct vattr va, dirfor, diraft; struct nfs_fattr *fp; struct nameidata nd; char *cp; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; int abort = 0; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq __unused; struct vnode *vp, *dirp = (struct vnode *)0; nfsrvfh_t nsfh; u_quad_t frev; nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, (v3 ? &dirfor_ret : NULL), &dirfor, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); if (dirp) vrele(dirp); return (0); } abort = 1; vattr_null(&va); if (v3) { va.va_mode = 0; nfsm_srvsattr(&va); } else { nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); va.va_mode = nfstov_mode(*tl++); } va.va_type = VDIR; vp = nd.ni_vp; if (vp != NULL) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); vrele(vp); error = EEXIST; goto out; } nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va); if (!error) { vp = nd.ni_vp; vn_lock(vp, LK_SHARED | LK_RETRY); error = nfsrv_composefh(vp, &nsfh, v3); if (!error) error = VOP_GETATTR(vp, &va, cred); vput(vp); } vput(nd.ni_dvp); out: if (dirp) { if (v3) { vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, &diraft, cred); VOP_UNLOCK(dirp); } vrele(dirp); dirp = NULL; } if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } abort = 0; nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { if (!error) { nfsm_srvpostop_fh(&nsfh); nfsm_srvpostop_attr(0, &va); } nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); } else { nfsm_srvfhtom(&nsfh, v3); nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(&va, fp); } return (0); nfsmout: if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } } if (dirp) vrele(dirp); return (error); } /* * nfs rmdir service */ int nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq __unused; struct vnode *vp, *dirp = (struct vnode *)0; struct vattr dirfor, diraft; nfsrvfh_t nsfh; struct nameidata nd; u_quad_t frev; nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = DELETE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, (v3 ? &dirfor_ret : NULL), &dirfor, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); if (dirp) vrele(dirp); return (0); } vp = nd.ni_vp; if (vp->v_type != VDIR) { error = ENOTDIR; goto out; } /* * No rmdir "." please. */ if (nd.ni_dvp == vp) { error = EINVAL; goto out; } /* * The root of a mounted filesystem cannot be deleted. */ if (vp->v_vflag & VV_ROOT) error = EBUSY; out: if (!error) { nqsrv_getl(nd.ni_dvp, ND_WRITE); nqsrv_getl(vp, ND_WRITE); error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); vput(nd.ni_dvp); } else { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); vput(vp); } if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } if (dirp) { if (v3) { vn_lock(dirp, LK_SHARED | LK_RETRY); diraft_ret = VOP_GETATTR(dirp, &diraft, cred); VOP_UNLOCK(dirp); } vrele(dirp); } nfsm_reply(NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); } nfsm_srvdone; } /* * nfs readdir service * - mallocs what it thinks is enough to read * count rounded up to a multiple of NFS_SRVDIRBLKSIZ <= NFS_MAXREADDIR * - calls VOP_READDIR() * - loops around building the reply * if the output generated exceeds count break out of loop * The nfsm_clget macro is used here so that the reply will be packed * tightly in mbuf clusters. * - it only knows that it has encountered eof when the VOP_READDIR() * reads nothing * - as such one readdir rpc will return eof false although you are there * and then the next will return eof * - it trims out records with d_fileno == 0 * this doesn't matter for Unix clients, but they might confuse clients * for other os'. * - it trims out records with d_type == DT_WHT * these cannot be seen through NFS (unless we extend the protocol) * NB: It is tempting to set eof to true if the VOP_READDIR() reads less * than requested, but this may not apply to all filesystems. For * example, client NFS does not { although it is never remote mounted * anyhow } * The alternate call nfsrv_readdirplus() does lookups as well. * PS: The NFS protocol spec. does not clarify what the "count" byte * argument is a count of.. just name strings and file id's or the * entire reply rpc or ... * I tried just file name and id sizes and it confused the Sun client, * so I am using the full rpc size now. The "paranoia.." comment refers * to including the status longwords that are not a part of the dir. * "entry" structures, but are in the rpc. */ #define NFS_SRVDIRBLKSIZ 1024 struct flrep { nfsuint64 fl_off; u_int32_t fl_postopok; struct nfs_fattr fl_fattr; /* XXX: must be of fattr3 size */ u_int32_t fl_fhok; u_int32_t fl_fhsize; /* handle comes here, filled in dynamically */ }; int nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; char *bp, *be; struct mbuf *mp; struct dirent *dp; char *cp; u_int32_t *tl; int32_t t1; char *bpos; struct mbuf *mb, *mreq __unused, *mp2; char *cpos, *cend, *cp2, *rbuf; struct vnode *vp; struct vattr at; nfsrvfh_t nsfh; struct uio io; struct iovec iv; int len, nlen, rem, xfer, tsiz, i, error = 0, getret = 1; int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, ncookies; int v3 = (nfsd->nd_flag & ND_NFSV3); u_quad_t frev, off, toff; #ifdef NFS3_STRICTVERF u_quad_t verf; #endif off_t *cookies = NULL, *cookiep; nfsuint64 jar; nfsm_srvmtofh(&nsfh); if (v3) { nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); toff = fxdr_hyper(tl); tl += 2; #ifdef NFS3_STRICTVERF verf = fxdr_hyper(tl); #endif tl += 2; } else { nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); toff = fxdr_unsigned(u_quad_t, *tl++); } off = toff; cnt = fxdr_unsigned(int, *tl); siz = ((cnt + NFS_SRVDIRBLKSIZ - 1) & ~(NFS_SRVDIRBLKSIZ - 1)); xfer = NFS_SRVMAXDATA(nfsd); if (siz > xfer) siz = xfer; fullsiz = siz; error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (!error && vp->v_type != VDIR) { error = ENOTDIR; vput(vp); } if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } nqsrv_getl(vp, ND_READ); if (v3) { error = getret = VOP_GETATTR(vp, &at, cred); #ifdef NFS3_STRICTVERF /* * XXX This check is too strict for Solaris 2.5 clients. */ if (!error && toff && verf != at.va_filerev) error = NFSERR_BAD_COOKIE; #endif } if (!error) error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0); if (error) { vput(vp); nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(getret, &at); return (0); } VOP_UNLOCK(vp); rbuf = malloc(siz, M_TEMP, M_WAITOK); again: iv.iov_base = rbuf; iv.iov_len = fullsiz; io.uio_iov = &iv; io.uio_iovcnt = 1; io.uio_offset = (off_t)off; io.uio_resid = fullsiz; io.uio_rw = UIO_READ; UIO_SETUP_SYSSPACE(&io); eofflag = 0; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = VOP_READDIR(vp, &io, cred, &eofflag, &cookies, &ncookies); off = (off_t)io.uio_offset; if (!cookies && !error) error = NFSERR_PERM; if (v3) { getret = VOP_GETATTR(vp, &at, cred); if (!error) error = getret; } VOP_UNLOCK(vp); if (error) { vrele(vp); free((void *)rbuf, M_TEMP); if (cookies) free((void *)cookies, M_TEMP); nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(getret, &at); return (0); } if (io.uio_resid) { siz -= io.uio_resid; /* * If nothing read, return eof * rpc reply */ if (siz == 0) { vrele(vp); nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_COOKIEVERF(v3) + 2 * NFSX_UNSIGNED); if (v3) { nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED); txdr_hyper(at.va_filerev, tl); tl += 2; } else nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); *tl++ = nfs_false; *tl = nfs_true; free((void *)rbuf, M_TEMP); free((void *)cookies, M_TEMP); return (0); } } /* * Check for degenerate cases of nothing useful read. * If so go try again */ cpos = rbuf; cend = rbuf + siz; dp = (struct dirent *)cpos; cookiep = cookies; while (cpos < cend && ncookies > 0 && (dp->d_fileno == 0 || dp->d_type == DT_WHT)) { cpos += dp->d_reclen; dp = (struct dirent *)cpos; cookiep++; ncookies--; } if (cpos >= cend || ncookies == 0) { toff = off; siz = fullsiz; free(cookies, M_TEMP); cookies = NULL; goto again; } len = 3 * NFSX_UNSIGNED; /* paranoia, probably can be 0 */ nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_COOKIEVERF(v3) + siz); if (v3) { nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); txdr_hyper(at.va_filerev, tl); } mp = mp2 = mb; bp = bpos; be = bp + M_TRAILINGSPACE(mp); /* Loop through the records and build reply */ while (cpos < cend && ncookies > 0) { if (dp->d_fileno != 0 && dp->d_type != DT_WHT) { nlen = dp->d_namlen; rem = nfsm_rndup(nlen)-nlen; len += (4 * NFSX_UNSIGNED + nlen + rem); if (v3) len += 2 * NFSX_UNSIGNED; if (len > cnt) { eofflag = 0; break; } /* * Build the directory record xdr from * the dirent entry. */ nfsm_clget; *tl = nfs_true; bp += NFSX_UNSIGNED; if (v3) { nfsm_clget; *tl = txdr_unsigned(dp->d_fileno >> 32); bp += NFSX_UNSIGNED; } nfsm_clget; *tl = txdr_unsigned(dp->d_fileno); bp += NFSX_UNSIGNED; nfsm_clget; *tl = txdr_unsigned(nlen); bp += NFSX_UNSIGNED; /* And loop around copying the name */ xfer = nlen; cp = dp->d_name; while (xfer > 0) { nfsm_clget; if ((bp+xfer) > be) tsiz = be-bp; else tsiz = xfer; memcpy(bp, cp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } /* And null pad to an int32_t boundary */ for (i = 0; i < rem; i++) *bp++ = '\0'; nfsm_clget; /* Finish off the record */ txdr_hyper(*cookiep, &jar); if (v3) { *tl = jar.nfsuquad[0]; bp += NFSX_UNSIGNED; nfsm_clget; } *tl = jar.nfsuquad[1]; bp += NFSX_UNSIGNED; } cpos += dp->d_reclen; dp = (struct dirent *)cpos; cookiep++; ncookies--; } vrele(vp); nfsm_clget; *tl = nfs_false; bp += NFSX_UNSIGNED; nfsm_clget; if (eofflag) *tl = nfs_true; else *tl = nfs_false; bp += NFSX_UNSIGNED; if (mp != mb) { if (bp < be) mp->m_len = bp - mtod(mp, char *); } else mp->m_len += bp - bpos; free((void *)rbuf, M_TEMP); free((void *)cookies, M_TEMP); nfsm_srvdone; } int nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; char *bp, *be; struct mbuf *mp; struct dirent *dp; char *cp; u_int32_t *tl; int32_t t1; char *bpos; struct mbuf *mb, *mreq __unused, *mp2; char *cpos, *cend, *cp2, *rbuf; struct vnode *vp, *nvp; struct flrep fl; nfsrvfh_t nsfh; struct uio io; struct iovec iv; struct vattr va, at, *vap = &va; struct nfs_fattr *fp; int len, nlen, rem, xfer, tsiz, i, error = 0, getret = 1; int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, dirlen, ncookies; u_quad_t frev, off, toff; #ifdef NFS3_STRICTVERF u_quad_t verf; #endif off_t *cookies = NULL, *cookiep; nfsm_srvmtofh(&nsfh); nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); toff = fxdr_hyper(tl); tl += 2; #ifdef NFS3_STRICTVERF verf = fxdr_hyper(tl); #endif tl += 2; siz = fxdr_unsigned(int, *tl++); cnt = fxdr_unsigned(int, *tl); off = toff; siz = ((siz + NFS_SRVDIRBLKSIZ - 1) & ~(NFS_SRVDIRBLKSIZ - 1)); xfer = NFS_SRVMAXDATA(nfsd); if (siz > xfer) siz = xfer; fullsiz = siz; error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (!error && vp->v_type != VDIR) { error = ENOTDIR; vput(vp); } if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } error = getret = VOP_GETATTR(vp, &at, cred); #ifdef NFS3_STRICTVERF /* * XXX This check is too strict for Solaris 2.5 clients. */ if (!error && toff && verf != at.va_filerev) error = NFSERR_BAD_COOKIE; #endif if (!error) { nqsrv_getl(vp, ND_READ); error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0); } if (error) { vput(vp); nfsm_reply(NFSX_V3POSTOPATTR); nfsm_srvpostop_attr(getret, &at); return (0); } VOP_UNLOCK(vp); rbuf = malloc(siz, M_TEMP, M_WAITOK); again: iv.iov_base = rbuf; iv.iov_len = fullsiz; io.uio_iov = &iv; io.uio_iovcnt = 1; io.uio_offset = (off_t)off; io.uio_resid = fullsiz; io.uio_rw = UIO_READ; UIO_SETUP_SYSSPACE(&io); eofflag = 0; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = VOP_READDIR(vp, &io, cred, &eofflag, &cookies, &ncookies); off = (u_quad_t)io.uio_offset; getret = VOP_GETATTR(vp, &at, cred); VOP_UNLOCK(vp); /* * If the VGET operation doesn't work for this filesystem, * we can't support readdirplus. Returning NOTSUPP should * make clients fall back to plain readdir. * There's no need to check for VPTOFH as well, we wouldn't * even be here otherwise. */ if (!getret) { if ((getret = VFS_VGET(vp->v_mount, at.va_fileid, LK_EXCLUSIVE, &nvp))) getret = (getret == EOPNOTSUPP) ? NFSERR_NOTSUPP : NFSERR_IO; else vput(nvp); } if (!cookies && !error) error = NFSERR_PERM; if (!error) error = getret; if (error) { vrele(vp); if (cookies) free((void *)cookies, M_TEMP); free((void *)rbuf, M_TEMP); nfsm_reply(NFSX_V3POSTOPATTR); nfsm_srvpostop_attr(getret, &at); return (0); } if (io.uio_resid) { siz -= io.uio_resid; /* * If nothing read, return eof * rpc reply */ if (siz == 0) { vrele(vp); nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF + 2 * NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED); txdr_hyper(at.va_filerev, tl); tl += 2; *tl++ = nfs_false; *tl = nfs_true; free((void *)cookies, M_TEMP); free((void *)rbuf, M_TEMP); return (0); } } /* * Check for degenerate cases of nothing useful read. * If so go try again */ cpos = rbuf; cend = rbuf + siz; dp = (struct dirent *)cpos; cookiep = cookies; while (cpos < cend && ncookies > 0 && (dp->d_fileno == 0 || dp->d_type == DT_WHT)) { cpos += dp->d_reclen; dp = (struct dirent *)cpos; cookiep++; ncookies--; } if (cpos >= cend || ncookies == 0) { toff = off; siz = fullsiz; free(cookies, M_TEMP); cookies = NULL; goto again; } dirlen = len = NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF + 2 * NFSX_UNSIGNED; nfsm_reply(cnt); nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); txdr_hyper(at.va_filerev, tl); mp = mp2 = mb; bp = bpos; be = bp + M_TRAILINGSPACE(mp); /* Loop through the records and build reply */ while (cpos < cend && ncookies > 0) { if (dp->d_fileno != 0 && dp->d_type != DT_WHT) { nfsrvfh_t nnsfh; nlen = dp->d_namlen; rem = nfsm_rndup(nlen)-nlen; /* * For readdir_and_lookup get the vnode using * the file number. */ if (VFS_VGET(vp->v_mount, dp->d_fileno, LK_EXCLUSIVE, &nvp)) goto invalid; if (nfsrv_composefh(nvp, &nnsfh, true)) { vput(nvp); goto invalid; } if (VOP_GETATTR(nvp, vap, cred)) { vput(nvp); goto invalid; } vput(nvp); /* * If either the dircount or maxcount will be * exceeded, get out now. Both of these lengths * are calculated conservatively, including all * XDR overheads. */ len += (8 * NFSX_UNSIGNED + nlen + rem + NFSX_V3FH + NFSX_V3POSTOPATTR); dirlen += (6 * NFSX_UNSIGNED + nlen + rem); if (len > cnt || dirlen > fullsiz) { eofflag = 0; break; } /* * Build the directory record xdr from * the dirent entry. */ fp = (struct nfs_fattr *)&fl.fl_fattr; nfsm_srvfillattr(vap, fp); fl.fl_fhsize = txdr_unsigned(NFSX_V3FH); fl.fl_fhok = nfs_true; fl.fl_postopok = nfs_true; txdr_hyper(*cookiep, fl.fl_off.nfsuquad); nfsm_clget; *tl = nfs_true; bp += NFSX_UNSIGNED; nfsm_clget; *tl = txdr_unsigned(dp->d_fileno >> 32); bp += NFSX_UNSIGNED; nfsm_clget; *tl = txdr_unsigned(dp->d_fileno); bp += NFSX_UNSIGNED; nfsm_clget; *tl = txdr_unsigned(nlen); bp += NFSX_UNSIGNED; /* And loop around copying the name */ xfer = nlen; cp = dp->d_name; while (xfer > 0) { nfsm_clget; if ((bp + xfer) > be) tsiz = be - bp; else tsiz = xfer; memcpy(bp, cp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } /* And null pad to an int32_t boundary */ for (i = 0; i < rem; i++) *bp++ = '\0'; /* * Now copy the flrep structure out. */ xfer = sizeof(struct flrep); cp = (void *)&fl; while (xfer > 0) { nfsm_clget; if ((bp + xfer) > be) tsiz = be - bp; else tsiz = xfer; memcpy(bp, cp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } /* * ... and filehandle. */ xfer = NFSRVFH_SIZE(&nnsfh); cp = NFSRVFH_DATA(&nnsfh); while (xfer > 0) { nfsm_clget; if ((bp + xfer) > be) tsiz = be - bp; else tsiz = xfer; memcpy(bp, cp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } } invalid: cpos += dp->d_reclen; dp = (struct dirent *)cpos; cookiep++; ncookies--; } vrele(vp); nfsm_clget; *tl = nfs_false; bp += NFSX_UNSIGNED; nfsm_clget; if (eofflag) *tl = nfs_true; else *tl = nfs_false; bp += NFSX_UNSIGNED; if (mp != mb) { if (bp < be) mp->m_len = bp - mtod(mp, char *); } else mp->m_len += bp - bpos; free((void *)cookies, M_TEMP); free((void *)rbuf, M_TEMP); nfsm_srvdone; } /* * nfs commit service */ int nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct vattr bfor, aft; struct vnode *vp; nfsrvfh_t nsfh; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, for_ret = 1, aft_ret = 1, cache = 0; uint32_t cnt; char *cp2; struct mbuf *mb, *mreq __unused; u_quad_t frev, off, end; nfsm_srvmtofh(&nsfh); nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED); off = fxdr_hyper(tl); tl += 2; cnt = fxdr_unsigned(uint32_t, *tl); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft); return (0); } for_ret = VOP_GETATTR(vp, &bfor, cred); end = (cnt > 0) ? off + cnt : vp->v_size; if (end < off || end > vp->v_size) end = vp->v_size; if (off < vp->v_size) error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end); /* else error == 0, from nfsrv_fhtovp() */ aft_ret = VOP_GETATTR(vp, &aft, cred); vput(vp); nfsm_reply(NFSX_V3WCCDATA + NFSX_V3WRITEVERF); nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft); if (!error) { nfsm_build(tl, u_int32_t *, NFSX_V3WRITEVERF); struct timeval btv; getmicroboottime(&btv); *tl++ = txdr_unsigned(btv.tv_sec); *tl = txdr_unsigned(btv.tv_usec); } else { return (0); } nfsm_srvdone; } /* * nfs statfs service */ int nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct statvfs *sf = NULL; struct nfs_statfs *sfp; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, getret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq __unused; struct vnode *vp; struct vattr at; nfsrvfh_t nsfh; u_quad_t frev, tval; nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } sf = malloc(sizeof(*sf), M_TEMP, M_WAITOK); error = VFS_STATVFS(vp->v_mount, sf); getret = VOP_GETATTR(vp, &at, cred); vput(vp); nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_STATFS(v3)); if (v3) nfsm_srvpostop_attr(getret, &at); if (error) { free(sf, M_TEMP); return (0); } nfsm_build(sfp, struct nfs_statfs *, NFSX_STATFS(v3)); if (v3) { tval = (u_quad_t)((quad_t)sf->f_blocks * (quad_t)sf->f_frsize); txdr_hyper(tval, &sfp->sf_tbytes); tval = (u_quad_t)((quad_t)sf->f_bfree * (quad_t)sf->f_frsize); txdr_hyper(tval, &sfp->sf_fbytes); tval = (u_quad_t)((quad_t)sf->f_bavail * (quad_t)sf->f_frsize); txdr_hyper(tval, &sfp->sf_abytes); tval = (u_quad_t)sf->f_files; txdr_hyper(tval, &sfp->sf_tfiles); tval = (u_quad_t)sf->f_ffree; txdr_hyper(tval, &sfp->sf_ffiles); txdr_hyper(tval, &sfp->sf_afiles); sfp->sf_invarsec = 0; } else { sfp->sf_tsize = txdr_unsigned(NFS_MAXDGRAMDATA); sfp->sf_bsize = txdr_unsigned(NFS_V2CLAMP16(sf->f_frsize)); sfp->sf_blocks = txdr_unsigned(NFS_V2CLAMP32(sf->f_blocks)); sfp->sf_bfree = txdr_unsigned(NFS_V2CLAMP32(sf->f_bfree)); sfp->sf_bavail = txdr_unsigned(NFS_V2CLAMP32(sf->f_bavail)); } nfsmout: if (sf) free(sf, M_TEMP); return error; } /* * nfs fsinfo service */ int nfsrv_fsinfo(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; u_int32_t *tl; struct nfsv3_fsinfo *sip; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, getret = 1; uint32_t maxdata; char *cp2; struct mbuf *mb, *mreq __unused; struct vnode *vp; struct vattr at; nfsrvfh_t nsfh; u_quad_t frev, maxfsize; struct statvfs *sb; nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } /* XXX Try to make a guess on the max file size. */ sb = malloc(sizeof(*sb), M_TEMP, M_WAITOK); VFS_STATVFS(vp->v_mount, sb); maxfsize = (u_quad_t)0x80000000 * sb->f_frsize - 1; free(sb, M_TEMP); getret = VOP_GETATTR(vp, &at, cred); vput(vp); nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3FSINFO); nfsm_srvpostop_attr(getret, &at); nfsm_build(sip, struct nfsv3_fsinfo *, NFSX_V3FSINFO); /* * XXX * There should be file system VFS OP(s) to get this information. * For now, assume ufs. */ if (slp->ns_so->so_type == SOCK_DGRAM) maxdata = NFS_MAXDGRAMDATA; else maxdata = NFS_MAXDATA; sip->fs_rtmax = txdr_unsigned(maxdata); sip->fs_rtpref = txdr_unsigned(maxdata); sip->fs_rtmult = txdr_unsigned(NFS_FABLKSIZE); sip->fs_wtmax = txdr_unsigned(maxdata); sip->fs_wtpref = txdr_unsigned(maxdata); sip->fs_wtmult = txdr_unsigned(NFS_FABLKSIZE); sip->fs_dtpref = txdr_unsigned(maxdata); txdr_hyper(maxfsize, &sip->fs_maxfilesize); sip->fs_timedelta.nfsv3_sec = 0; sip->fs_timedelta.nfsv3_nsec = txdr_unsigned(1); sip->fs_properties = txdr_unsigned(NFSV3FSINFO_LINK | NFSV3FSINFO_SYMLINK | NFSV3FSINFO_HOMOGENEOUS | NFSV3FSINFO_CANSETTIME); nfsm_srvdone; } /* * nfs pathconf service */ int nfsrv_pathconf(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; u_int32_t *tl; struct nfsv3_pathconf *pc; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, getret = 1; register_t linkmax, namemax, chownres, notrunc; char *cp2; struct mbuf *mb, *mreq __unused; struct vnode *vp; struct vattr at; nfsrvfh_t nsfh; u_quad_t frev; nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } error = VOP_PATHCONF(vp, _PC_LINK_MAX, &linkmax); if (!error) error = VOP_PATHCONF(vp, _PC_NAME_MAX, &namemax); if (!error) error = VOP_PATHCONF(vp, _PC_CHOWN_RESTRICTED, &chownres); if (!error) error = VOP_PATHCONF(vp, _PC_NO_TRUNC, ¬runc); getret = VOP_GETATTR(vp, &at, cred); vput(vp); nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3PATHCONF); nfsm_srvpostop_attr(getret, &at); if (error) return (0); nfsm_build(pc, struct nfsv3_pathconf *, NFSX_V3PATHCONF); pc->pc_linkmax = txdr_unsigned(linkmax); pc->pc_namemax = txdr_unsigned(namemax); pc->pc_notrunc = txdr_unsigned(notrunc); pc->pc_chownrestricted = txdr_unsigned(chownres); /* * These should probably be supported by VOP_PATHCONF(), but * until msdosfs is exportable (why would you want to?), the * Unix defaults should be ok. */ pc->pc_caseinsensitive = nfs_false; pc->pc_casepreserving = nfs_true; nfsm_srvdone; } /* * Null operation, used by clients to ping server */ /* ARGSUSED */ int nfsrv_null(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep; char *bpos; int error = NFSERR_RETVOID, cache = 0; struct mbuf *mb, *mreq __unused; u_quad_t frev; nfsm_reply(0); nfsmout: return (0); } /* * No operation, used for obsolete procedures */ /* ARGSUSED */ int nfsrv_noop(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep; char *bpos; int error, cache = 0; struct mbuf *mb, *mreq __unused; u_quad_t frev; if (nfsd->nd_repstat) error = nfsd->nd_repstat; else error = EPROCUNAVAIL; nfsm_reply(0); nfsmout: return (0); } /* * Perform access checking for vnodes obtained from file handles that would * refer to files already opened by a Unix client. You cannot just use * vn_writechk() and VOP_ACCESS() for two reasons. * 1 - You must check for exported rdonly as well as MNT_RDONLY for the write case * 2 - The owner is to be given access irrespective of mode bits for some * operations, so that processes that chmod after opening a file don't * break. I don't like this because it opens a security hole, but since * the nfs server opens a security hole the size of a barn door anyhow, * what the heck. * * The exception to rule 2 is EPERM. If a file is IMMUTABLE, VOP_ACCESS() * will return EPERM instead of EACCES. EPERM is always an error. */ int nfsrv_access(struct vnode *vp, int flags, kauth_cred_t cred, int rdonly, struct lwp *lwp, int override) { struct vattr vattr; int error; if (flags & VWRITE) { /* Just vn_writechk() changed to check rdonly */ /* * Disallow write attempts on read-only file systems; * unless the file is a socket or a block or character * device resident on the file system. */ if (rdonly || (vp->v_mount->mnt_flag & MNT_RDONLY)) { switch (vp->v_type) { case VREG: case VDIR: case VLNK: return (EROFS); default: break; } } /* * If the vnode is in use as a process's text, * we can't allow writing. */ if (vp->v_iflag & VI_TEXT) return (ETXTBSY); } error = VOP_GETATTR(vp, &vattr, cred); if (error) return (error); error = VOP_ACCESS(vp, flags, cred); /* * Allow certain operations for the owner (reads and writes * on files that are already open). */ if (override && error == EACCES && kauth_cred_geteuid(cred) == vattr.va_uid) error = 0; return error; } @ 1.183 log @As VOP_GETATTR() needs a shared lock at least move the preopattr lookup inside nfs_namei() where we may lock the start directory without violating the lock order. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.182 2021/09/16 20:17:47 andvar Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.182 2021/09/16 20:17:47 andvar Exp $"); d1651 4 a1654 4 } if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; d1804 4 a1807 4 } if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; @ 1.183.4.1 log @Pull up following revision(s) (requested by riastradh in ticket #134): sys/nfs/nfs_serv.c: revision 1.184 sys/nfs/nfs_srvsubs.c: revision 1.17 sys/nfs/nfsm_subs.h: revision 1.56 sys/nfs/nfsm_subs.h: revision 1.57 nfs: Use unsigned fhlen so we don't trip over negative values. nfs: Avoid integer overflow in nfs_namei bounds check. nfs: Use unsigned name lengths so we don't trip over negative ones. - nfsm_strsiz is only used with uint32_t in callers, but let's not leave it as a rake to step on. - nfsm_srvnamesiz is abused with signed s. The internal conversion to unsigned serves to reject both negative and too-large values in such callers. XXX Should make all callers use unsigned, rather than flipping back and forth between signed and unsigned for name lengths. nfs: Avoid free of uninitialized on bad name size in create, mknod. XXX These error branches are a nightmare and need to be more systematically cleaned up. Even if they are correct now, they are impossible to audit and extremely fragile in case anyone ever needs to make other changes to them. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $"); d1651 4 a1654 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } d1804 4 a1807 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } @ 1.182 log @fix various typos, mainly in comments. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.181 2020/09/05 16:30:12 riastradh Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.181 2020/09/05 16:30:12 riastradh Exp $"); d425 2 a426 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag); d1451 2 a1452 4 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); } d1691 2 a1692 3 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (dirp) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d1846 2 a1847 8 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (error == 0 && dirp && v3) { if (nd.ni_dvp == nd.ni_vp) vn_lock(dirp, LK_SHARED | LK_RETRY); dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); if (nd.ni_dvp == nd.ni_vp) VOP_UNLOCK(dirp); } d1939 2 a1940 8 &dpos, &fdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (error == 0 && fdirp && v3) { if (fromnd.ni_dvp == fromnd.ni_vp) vn_lock(fdirp, LK_SHARED | LK_RETRY); fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred); if (fromnd.ni_dvp == fromnd.ni_vp) VOP_UNLOCK(fdirp); } d2010 2 a2011 4 &dpos, &tdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (tdirp && v3) { tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred); } d2205 2 a2206 4 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); } d2295 2 a2296 4 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); } d2438 2 a2439 4 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); } d2560 2 a2561 4 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); } @ 1.181 log @Round of uvm.h cleanup. The poorly named uvm.h is generally supposed to be for uvm-internal users only. - Narrow it to files that actually need it -- mostly files that need to query whether curlwp is the pagedaemon, which should maybe be exposed by an external header. - Use uvm_extern.h where feasible and uvm_*.h for things not exposed by it. We should split up uvm_extern.h but this will serve for now to reduce the uvm.h dependencies. - Use uvm_stat.h and #ifdef UVMHIST uvm.h for files that use UVMHIST(ubchist), since ubchist is declared in uvm.h but the reference evaporates if UVMHIST is not defined, so we reduce header file dependencies. - Make uvm_device.h and uvm_swap.h independently includable while here. ok chs@@ @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.180 2020/04/04 07:07:20 mlelstv Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.180 2020/04/04 07:07:20 mlelstv Exp $"); d356 1 a356 1 * If the size is being changed write acces is required, otherwise @ 1.180 log @NFSv2 is limited to use only 32bit in metadata. Prevent that larger metadata values are simply truncated. -> clamp filesystem block counts to signed 32bit. -> clamp file sizes to signed 32bit (*) Some NFSv2 clients also have problems to handle buffer sizes larger than (signed) 16bit. -> clamp buffer sizes to signed 16bit for better compatibility. (*) This can lead to erroneous behaviour for files larger than 2GB that NFSv2 cannot handle but it is still better than before. An alternative would be to (partially) reject operations on files larger than 2GB, but which causes other problems. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.179 2020/01/17 20:08:09 ad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.179 2020/01/17 20:08:09 ad Exp $"); d81 3 a83 1 #include @ 1.179 log @VFS_VGET(), VFS_ROOT(), VFS_FHTOVP(): give them a "int lktype" argument, to allow us to get shared locks (or no lock) on the returned vnode. Matches FreeBSD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.178 2020/01/02 15:42:27 thorpej Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.178 2020/01/02 15:42:27 thorpej Exp $"); d3397 4 a3400 4 sfp->sf_bsize = txdr_unsigned(sf->f_frsize); sfp->sf_blocks = txdr_unsigned(sf->f_blocks); sfp->sf_bfree = txdr_unsigned(sf->f_bfree); sfp->sf_bavail = txdr_unsigned(sf->f_bavail); @ 1.178 log @- Eliminate the global "boottime" variable, which was being accessed without any synchronization against changes by e.g. clock_settime(). - Replace with new getbinboottime() / getnanoboottime() / getmicroboottime() functions (naming mirrors that of other time access functions in kern_tc.c). It returns the (maybe-converted) value of timebasebin, which also tracks our estimate of when the system was booted (i.e. the legacy "boottime" was redundant). XXX There needs to be a lockless synchronization mechanism for reading timebasebin, but this is a problem in kern_tc.c that pre-existed these "boottime" changes. At least now the problem is centralized in one location. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.177 2019/02/20 10:05:20 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.177 2019/02/20 10:05:20 hannken Exp $"); d3059 2 a3060 1 if ((getret = VFS_VGET(vp->v_mount, at.va_fileid, &nvp))) d3148 2 a3149 1 if (VFS_VGET(vp->v_mount, dp->d_fileno, &nvp)) @ 1.178.2.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.179 2020/01/17 20:08:09 ad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.179 2020/01/17 20:08:09 ad Exp $"); d3059 1 a3059 2 if ((getret = VFS_VGET(vp->v_mount, at.va_fileid, LK_EXCLUSIVE, &nvp))) d3147 1 a3147 2 if (VFS_VGET(vp->v_mount, dp->d_fileno, LK_EXCLUSIVE, &nvp)) @ 1.177 log @Bracket do_sys_renameat() and nfsrv_rename() with fstrans. The v_mount field for vnodes on the same file system as "from" is now stable for referenced vnodes. VFS_RENAMELOCK no longer may use lock from an unreferenced and freed "struct mount". @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.176 2019/02/03 03:19:28 mrg Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.176 2019/02/03 03:19:28 mrg Exp $"); d1006 4 a1009 2 *tl++ = txdr_unsigned(boottime.tv_sec); *tl = txdr_unsigned(boottime.tv_nsec / 1000); d1309 4 a1312 2 *tl++ = txdr_unsigned(boottime.tv_sec); *tl = txdr_unsigned(boottime.tv_nsec / 1000); d3326 4 a3329 2 *tl++ = txdr_unsigned(boottime.tv_sec); *tl = txdr_unsigned(boottime.tv_nsec / 1000); @ 1.177.4.1 log @Pull up following revision(s) (requested by riastradh in ticket #1617): sys/nfs/nfs_serv.c: revision 1.184 sys/nfs/nfs_srvsubs.c: revision 1.17 sys/nfs/nfsm_subs.h: revision 1.56 sys/nfs/nfsm_subs.h: revision 1.57 nfs: Use unsigned fhlen so we don't trip over negative values. nfs: Avoid integer overflow in nfs_namei bounds check. nfs: Use unsigned name lengths so we don't trip over negative ones. - nfsm_strsiz is only used with uint32_t in callers, but let's not leave it as a rake to step on. - nfsm_srvnamesiz is abused with signed s. The internal conversion to unsigned serves to reject both negative and too-large values in such callers. XXX Should make all callers use unsigned, rather than flipping back and forth between signed and unsigned for name lengths. nfs: Avoid free of uninitialized on bad name size in create, mknod. XXX These error branches are a nightmare and need to be more systematically cleaned up. Even if they are correct now, they are impossible to audit and extremely fragile in case anyone ever needs to make other changes to them. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.177 2019/02/20 10:05:20 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.177 2019/02/20 10:05:20 hannken Exp $"); d1646 4 a1649 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } d1800 4 a1803 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } @ 1.176 log @- add or adjust /* FALLTHROUGH */ where appropriate - add __unreachable() after functions that can return but won't in this case, and thus can't be marked __dead easily @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.175 2018/09/03 16:29:36 riastradh Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.175 2018/09/03 16:29:36 riastradh Exp $"); d67 1 d1961 2 a1967 1 localfs = fvp->v_mount; d2135 1 d2159 1 @ 1.175 log @Rename min/max -> uimin/uimax for better honesty. These functions are defined on unsigned int. The generic name min/max should not silently truncate to 32 bits on 64-bit systems. This is purely a name change -- no functional change intended. HOWEVER! Some subsystems have #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) even though our standard name for that is MIN/MAX. Although these may invite multiple evaluation bugs, these do _not_ cause integer truncation. To avoid `fixing' these cases, I first changed the name in libkern, and then compile-tested every file where min/max occurred in order to confirm that it failed -- and thus confirm that nothing shadowed min/max -- before changing it. I have left a handful of bootloaders that are too annoying to compile-test, and some dead code: cobalt ews4800mips hp300 hppa ia64 luna68k vax acorn32/if_ie.c (not included in any kernels) macppc/if_gm.c (superseded by gem(4)) It should be easy to fix the fallout once identified -- this way of doing things fails safe, and the goal here, after all, is to _avoid_ silent integer truncations, not introduce them. Maybe one day we can reintroduce min/max as type-generic things that never silently truncate. But we should avoid doing that for a while, so that existing code has a chance to be detected by the compiler for conversion to uimin/uimax without changing the semantics until we can properly audit it all. (Who knows, maybe in some cases integer truncation is actually intended!) @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); d1470 1 @ 1.174 log @nfsrv_readlink: stop attaching a zero-length mbuf for zero length symlinks. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.173 2017/04/26 03:02:49 riastradh Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.173 2017/04/26 03:02:49 riastradh Exp $"); d764 1 a764 1 siz = min(M_TRAILINGSPACE(m), left); d786 1 a786 1 siz = min(M_TRAILINGSPACE(m), left); @ 1.174.2.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.177 2019/02/20 10:05:20 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.177 2019/02/20 10:05:20 hannken Exp $"); a66 1 #include d764 1 a764 1 siz = uimin(M_TRAILINGSPACE(m), left); d786 1 a786 1 siz = uimin(M_TRAILINGSPACE(m), left); a1469 1 /* FALLTHROUGH */ a1958 2 localfs = fromnd.ni_dvp->v_mount; fstrans_start(localfs); d1964 1 a2131 1 fstrans_done(localfs); a2154 1 fstrans_done(localfs); @ 1.174.2.2 log @Merge changes from current as of 20200406 @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); d1006 2 a1007 4 struct timeval btv; getmicroboottime(&btv); *tl++ = txdr_unsigned(btv.tv_sec); *tl = txdr_unsigned(btv.tv_usec); d1307 2 a1308 4 struct timeval btv; getmicroboottime(&btv); *tl++ = txdr_unsigned(btv.tv_sec); *tl = txdr_unsigned(btv.tv_usec); d3055 1 a3055 2 if ((getret = VFS_VGET(vp->v_mount, at.va_fileid, LK_EXCLUSIVE, &nvp))) d3143 1 a3143 2 if (VFS_VGET(vp->v_mount, dp->d_fileno, LK_EXCLUSIVE, &nvp)) d3322 2 a3323 4 struct timeval btv; getmicroboottime(&btv); *tl++ = txdr_unsigned(btv.tv_sec); *tl = txdr_unsigned(btv.tv_usec); d3389 4 a3392 4 sfp->sf_bsize = txdr_unsigned(NFS_V2CLAMP16(sf->f_frsize)); sfp->sf_blocks = txdr_unsigned(NFS_V2CLAMP32(sf->f_blocks)); sfp->sf_bfree = txdr_unsigned(NFS_V2CLAMP32(sf->f_bfree)); sfp->sf_bavail = txdr_unsigned(NFS_V2CLAMP32(sf->f_bavail)); @ 1.173 log @Change VOP_REMOVE and VOP_RMDIR to preserve lock/ref on dvp. No change to vp -- the plan is to replace the node by the componentname in the vop parameters, and let all directory vops do lookups internally. Proposed on tech-kern with no objections: https://mail-index.netbsd.org/tech-kern/2017/04/17/msg021825.html @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.172 2015/04/21 03:19:03 riastradh Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.172 2015/04/21 03:19:03 riastradh Exp $"); d603 4 a606 1 if (uiop->uio_resid || padlen) @ 1.173.4.1 log @Pull up following revision(s) (requested by riastradh in ticket #1810): sys/nfs/nfs_serv.c: revision 1.184 sys/nfs/nfs_srvsubs.c: revision 1.17 sys/nfs/nfsm_subs.h: revision 1.56 sys/nfs/nfsm_subs.h: revision 1.57 nfs: Use unsigned fhlen so we don't trip over negative values. nfs: Avoid integer overflow in nfs_namei bounds check. nfs: Use unsigned name lengths so we don't trip over negative ones. - nfsm_strsiz is only used with uint32_t in callers, but let's not leave it as a rake to step on. - nfsm_srvnamesiz is abused with signed s. The internal conversion to unsigned serves to reject both negative and too-large values in such callers. XXX Should make all callers use unsigned, rather than flipping back and forth between signed and unsigned for name lengths. nfs: Avoid free of uninitialized on bad name size in create, mknod. XXX These error branches are a nightmare and need to be more systematically cleaned up. Even if they are correct now, they are impossible to audit and extremely fragile in case anyone ever needs to make other changes to them. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.173 2017/04/26 03:02:49 riastradh Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.173 2017/04/26 03:02:49 riastradh Exp $"); d1641 4 a1644 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } d1795 4 a1798 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } @ 1.173.10.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.174 2018/05/03 07:28:43 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.174 2018/05/03 07:28:43 hannken Exp $"); d603 1 a603 4 if (len == 0) { m_freem(mp3); mp3 = NULL; } else if (uiop->uio_resid || padlen) @ 1.173.10.2 log @Sync with HEAD Resolve a couple of conflicts (result of the uimin/uimax changes) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.175 2018/09/03 16:29:36 riastradh Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.175 2018/09/03 16:29:36 riastradh Exp $"); d764 1 a764 1 siz = uimin(M_TRAILINGSPACE(m), left); d786 1 a786 1 siz = uimin(M_TRAILINGSPACE(m), left); @ 1.172 log @Cull unused INRENAME and INRELOOKUP from callers. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.171 2015/04/20 23:03:09 riastradh Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.171 2015/04/20 23:03:09 riastradh Exp $"); d1862 1 d2605 1 @ 1.171 log @Make VOP_LINK return directory still locked and referenced. Ride 7.99.10 bump. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.170 2014/01/23 10:13:57 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.170 2014/01/23 10:13:57 hannken Exp $"); d1933 1 a1933 1 fromnd.ni_cnd.cn_flags = LOCKPARENT | INRENAME; d2009 1 a2009 1 tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | INRENAME; @ 1.170 log @Change vnode operations create, mknod, mkdir and symlink to return the resulting vnode *vpp unlocked. Discussed on tech-kern@@ Welcome to 6.99.30 @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.169 2014/01/17 10:55:02 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.169 2014/01/17 10:55:02 hannken Exp $"); d2225 3 @ 1.170.6.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.172 2015/04/21 03:19:03 riastradh Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.172 2015/04/21 03:19:03 riastradh Exp $"); d1933 1 a1933 1 fromnd.ni_cnd.cn_flags = LOCKPARENT; d2009 1 a2009 1 tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE; a2224 3 if (nd.ni_dvp != nd.ni_vp) VOP_UNLOCK(nd.ni_dvp); vrele(nd.ni_dvp); @ 1.170.6.2 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.170.6.1 2015/06/06 14:40:26 skrll Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.170.6.1 2015/06/06 14:40:26 skrll Exp $"); a1861 1 vput(nd.ni_dvp); a2603 1 vput(nd.ni_dvp); @ 1.169 log @Change vnode operations create, mknod, mkdir and symlink to keep the directory node dvp locked on return. Discussed on tech-kern@@ Welcome to 6.99.29 @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.168 2013/12/14 22:04:03 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.168 2013/12/14 22:04:03 christos Exp $"); d1509 1 d1544 3 a1546 1 if (error) { d1751 3 d2350 1 d2356 1 a2356 1 vput(nd.ni_vp); d2480 1 @ 1.168 log @only prevent autounload, not regular unload when we have exports @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.167 2013/12/14 16:19:28 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.167 2013/12/14 16:19:28 christos Exp $"); a1551 1 vput(nd.ni_dvp); a1562 4 if (nd.ni_dvp == vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); d1584 4 a1722 4 if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); d1756 4 d2352 1 d2478 1 @ 1.167 log @don't allow the nfs server module to unload if it has exported filesystems. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.166 2013/09/14 22:29:08 martin Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.166 2013/09/14 22:29:08 martin Exp $"); a127 2 if (netexport_hasexports()) return EBUSY; d147 4 @ 1.166 log @Backout wildcard pragma to kill warnings and instead sprinkle a few dozen __unused attributes. Requested by joerg@@ @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.165 2012/08/29 14:00:22 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.165 2012/08/29 14:00:22 christos Exp $"); d128 2 @ 1.165 log @When unloading the nfsserver module, call nfs_fini() so that the nfsrvdescpl pool gets destroyed. Otherwise we are left with a stray pool that points to unmapped memory behind (and bad things happen). Typically you get seemingly random page faults (without printing uvm_fault) that happen in various pool operations. Most frequent one is the pool_drain() from the page daemon. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.164 2012/08/27 11:35:13 chs Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.164 2012/08/27 11:35:13 chs Exp $"); d169 1 a169 1 struct mbuf *mb, *mreq; d234 1 a234 1 struct mbuf *mb, *mreq; d276 1 a276 1 struct mbuf *mb, *mreq; d405 1 a405 1 struct mbuf *mb, *mreq; d532 1 a532 1 struct mbuf *mb, *mp2 = NULL, *mp3 = NULL, *mreq; d855 1 a855 1 struct mbuf *mb, *mreq; d1423 1 a1423 1 struct mbuf *mb, *mreq; d1663 1 a1663 1 struct mbuf *mb, *mreq; d1813 1 a1813 1 struct mbuf *mb, *mreq; d1900 1 a1900 1 struct mbuf *mb, *mreq; d2172 1 a2172 1 struct mbuf *mb, *mreq; d2274 1 a2274 1 struct mbuf *mb, *mreq; d2418 1 a2418 1 struct mbuf *mb, *mreq; d2538 1 a2538 1 struct mbuf *mb, *mreq; d2673 1 a2673 1 struct mbuf *mb, *mreq, *mp2; d2683 4 a2686 1 u_quad_t frev, off, toff, verf; d2695 1 d2697 1 d2936 1 a2936 1 struct mbuf *mb, *mreq, *mp2; d2947 4 a2950 1 u_quad_t frev, off, toff, verf; d2957 1 d2959 1 d3267 1 a3267 1 struct mbuf *mb, *mreq; d3322 1 a3322 1 struct mbuf *mb, *mreq; d3391 1 a3391 1 struct mbuf *mb, *mreq; d3461 1 a3461 1 struct mbuf *mb, *mreq; d3516 1 a3516 1 struct mbuf *mb, *mreq; d3535 1 a3535 1 struct mbuf *mb, *mreq; @ 1.165.2.1 log @Rebase to HEAD as of a few days ago. @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); a146 4 case MODULE_CMD_AUTOUNLOAD: if (netexport_hasexports()) return EBUSY; /*FALLTHROUGH*/ d169 1 a169 1 struct mbuf *mb, *mreq __unused; d234 1 a234 1 struct mbuf *mb, *mreq __unused; d276 1 a276 1 struct mbuf *mb, *mreq __unused; d405 1 a405 1 struct mbuf *mb, *mreq __unused; d532 1 a532 1 struct mbuf *mb, *mp2 = NULL, *mp3 = NULL, *mreq __unused; d855 1 a855 1 struct mbuf *mb, *mreq __unused; d1423 1 a1423 1 struct mbuf *mb, *mreq __unused; a1504 1 vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY); d1539 1 a1539 3 if (!error) { vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY); } else { d1548 1 d1560 4 a1584 4 if (nd.ni_dvp == vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); d1663 1 a1663 1 struct mbuf *mb, *mreq __unused; d1720 4 a1748 3 if (!error) { vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY); } a1756 4 if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); d1813 1 a1813 1 struct mbuf *mb, *mreq __unused; d1900 1 a1900 1 struct mbuf *mb, *mreq __unused; d2172 1 a2172 1 struct mbuf *mb, *mreq __unused; d2274 1 a2274 1 struct mbuf *mb, *mreq __unused; a2340 1 vn_lock(nd.ni_vp, LK_SHARED | LK_RETRY); d2346 1 a2346 1 vrele(nd.ni_vp); a2348 1 vput(nd.ni_dvp); d2418 1 a2418 1 struct mbuf *mb, *mreq __unused; a2468 1 vn_lock(vp, LK_SHARED | LK_RETRY); a2473 1 vput(nd.ni_dvp); d2538 1 a2538 1 struct mbuf *mb, *mreq __unused; d2673 1 a2673 1 struct mbuf *mb, *mreq __unused, *mp2; d2683 1 a2683 4 u_quad_t frev, off, toff; #ifdef NFS3_STRICTVERF u_quad_t verf; #endif a2691 1 #ifdef NFS3_STRICTVERF a2692 1 #endif d2931 1 a2931 1 struct mbuf *mb, *mreq __unused, *mp2; d2942 1 a2942 4 u_quad_t frev, off, toff; #ifdef NFS3_STRICTVERF u_quad_t verf; #endif a2948 1 #ifdef NFS3_STRICTVERF a2949 1 #endif d3257 1 a3257 1 struct mbuf *mb, *mreq __unused; d3312 1 a3312 1 struct mbuf *mb, *mreq __unused; d3381 1 a3381 1 struct mbuf *mb, *mreq __unused; d3451 1 a3451 1 struct mbuf *mb, *mreq __unused; d3506 1 a3506 1 struct mbuf *mb, *mreq __unused; d3525 1 a3525 1 struct mbuf *mb, *mreq __unused; @ 1.165.2.2 log @update from HEAD @ text @a1861 1 vput(nd.ni_dvp); d1933 1 a1933 1 fromnd.ni_cnd.cn_flags = LOCKPARENT; d2009 1 a2009 1 tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE; a2224 3 if (nd.ni_dvp != nd.ni_vp) VOP_UNLOCK(nd.ni_dvp); vrele(nd.ni_dvp); a2600 1 vput(nd.ni_dvp); @ 1.165.4.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.165 2012/08/29 14:00:22 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.165 2012/08/29 14:00:22 christos Exp $"); a146 4 case MODULE_CMD_AUTOUNLOAD: if (netexport_hasexports()) return EBUSY; /*FALLTHROUGH*/ d169 1 a169 1 struct mbuf *mb, *mreq __unused; d234 1 a234 1 struct mbuf *mb, *mreq __unused; d276 1 a276 1 struct mbuf *mb, *mreq __unused; d405 1 a405 1 struct mbuf *mb, *mreq __unused; d532 1 a532 1 struct mbuf *mb, *mp2 = NULL, *mp3 = NULL, *mreq __unused; d855 1 a855 1 struct mbuf *mb, *mreq __unused; d1423 1 a1423 1 struct mbuf *mb, *mreq __unused; a1504 1 vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY); d1539 1 a1539 3 if (!error) { vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY); } else { d1548 1 d1560 4 a1584 4 if (nd.ni_dvp == vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); d1663 1 a1663 1 struct mbuf *mb, *mreq __unused; d1720 4 a1748 3 if (!error) { vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY); } a1756 4 if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); d1813 1 a1813 1 struct mbuf *mb, *mreq __unused; d1900 1 a1900 1 struct mbuf *mb, *mreq __unused; d2172 1 a2172 1 struct mbuf *mb, *mreq __unused; d2274 1 a2274 1 struct mbuf *mb, *mreq __unused; a2340 1 vn_lock(nd.ni_vp, LK_SHARED | LK_RETRY); d2346 1 a2346 1 vrele(nd.ni_vp); a2348 1 vput(nd.ni_dvp); d2418 1 a2418 1 struct mbuf *mb, *mreq __unused; a2468 1 vn_lock(vp, LK_SHARED | LK_RETRY); a2473 1 vput(nd.ni_dvp); d2538 1 a2538 1 struct mbuf *mb, *mreq __unused; d2673 1 a2673 1 struct mbuf *mb, *mreq __unused, *mp2; d2683 1 a2683 4 u_quad_t frev, off, toff; #ifdef NFS3_STRICTVERF u_quad_t verf; #endif a2691 1 #ifdef NFS3_STRICTVERF a2692 1 #endif d2931 1 a2931 1 struct mbuf *mb, *mreq __unused, *mp2; d2942 1 a2942 4 u_quad_t frev, off, toff; #ifdef NFS3_STRICTVERF u_quad_t verf; #endif a2948 1 #ifdef NFS3_STRICTVERF a2949 1 #endif d3257 1 a3257 1 struct mbuf *mb, *mreq __unused; d3312 1 a3312 1 struct mbuf *mb, *mreq __unused; d3381 1 a3381 1 struct mbuf *mb, *mreq __unused; d3451 1 a3451 1 struct mbuf *mb, *mreq __unused; d3506 1 a3506 1 struct mbuf *mb, *mreq __unused; d3525 1 a3525 1 struct mbuf *mb, *mreq __unused; @ 1.164 log @fix error handling in nfsrv_rename(): when the first nfs_namei() fails, don't try to free the resources allocated by a successful lookup. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.163 2012/02/01 02:27:24 matt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.163 2012/02/01 02:27:24 matt Exp $"); d145 1 @ 1.163 log @When using socket loaning, make sure the KVA used for the loan has the same color as the UVA being loaned. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.162 2011/11/21 09:07:59 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.162 2011/11/21 09:07:59 hannken Exp $"); d1934 1 @ 1.163.4.1 log @sync with netbsd-6-0-RELEASE. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.163.2.2 2012/09/03 19:15:54 riz Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.163.2.2 2012/09/03 19:15:54 riz Exp $"); a144 1 nfs_fini(); a1933 1 fromnd.ni_cnd.cn_nameiop = 0; @ 1.163.2.1 log @Pull up following revision(s) (requested by chs in ticket #530): sys/nfs/nfs_serv.c: revision 1.164 fix error handling in nfsrv_rename(): when the first nfs_namei() fails, don't try to free the resources allocated by a successful lookup. @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); a1933 1 fromnd.ni_cnd.cn_nameiop = 0; @ 1.163.2.2 log @Pull up following revision(s) (requested by christos in ticket #537): sys/nfs/nfs_serv.c: revision 1.165 When unloading the nfsserver module, call nfs_fini() so that the nfsrvdescpl pool gets destroyed. Otherwise we are left with a stray pool that points to unmapped memory behind (and bad things happen). Typically you get seemingly random page faults (without printing uvm_fault) that happen in various pool operations. Most frequent one is the pool_drain() from the page daemon. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.163.2.1 2012/09/03 18:57:11 riz Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.163.2.1 2012/09/03 18:57:11 riz Exp $"); a144 1 nfs_fini(); @ 1.162 log @nfsrv_lookup(): Defer the postopattr lookup on dirp until the child node is unlocked. Ok: YAMAMOTO Takashi @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $"); d702 2 a703 1 lva = sokvaalloc(npages << PAGE_SHIFT, slp->ns_so); @ 1.162.2.1 log @merge to -current. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.163 2012/02/01 02:27:24 matt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.163 2012/02/01 02:27:24 matt Exp $"); d702 1 a702 2 lva = sokvaalloc(pgoff, npages << PAGE_SHIFT, slp->ns_so); @ 1.161 log @VOP_GETATTR() needs a shared lock at least. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.160 2011/08/08 16:04:07 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.160 2011/08/08 16:04:07 dholland Exp $"); a455 9 if (dirp) { if (v3) { vn_lock(dirp, LK_SHARED | LK_RETRY); dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred); VOP_UNLOCK(dirp); } vrele(dirp); } d463 8 d486 8 @ 1.161.2.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.161 2011/10/30 12:00:27 hannken Exp $"); d456 9 a471 8 if (dirp) { if (v3) { vn_lock(dirp, LK_SHARED | LK_RETRY); dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred); vput(dirp); } else vrele(dirp); } a486 8 if (dirp) { if (v3) { vn_lock(dirp, LK_SHARED | LK_RETRY); dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred); vput(dirp); } else vrele(dirp); } d695 1 a695 2 lva = sokvaalloc(pgoff, npages << PAGE_SHIFT, slp->ns_so); @ 1.161.2.2 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.161.2.1 2012/04/17 00:08:47 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.161.2.1 2012/04/17 00:08:47 yamt Exp $"); a144 1 nfs_fini(); a1933 1 fromnd.ni_cnd.cn_nameiop = 0; @ 1.161.2.3 log @sync with head. for a reference, the tree before this commit was tagged as yamt-pagecache-tag8. this commit was splitted into small chunks to avoid a limitation of cvs. ("Protocol error: too many arguments") @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.161.2.2 2012/10/30 17:22:51 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.161.2.2 2012/10/30 17:22:51 yamt Exp $"); a146 4 case MODULE_CMD_AUTOUNLOAD: if (netexport_hasexports()) return EBUSY; /*FALLTHROUGH*/ d169 1 a169 1 struct mbuf *mb, *mreq __unused; d234 1 a234 1 struct mbuf *mb, *mreq __unused; d276 1 a276 1 struct mbuf *mb, *mreq __unused; d405 1 a405 1 struct mbuf *mb, *mreq __unused; d532 1 a532 1 struct mbuf *mb, *mp2 = NULL, *mp3 = NULL, *mreq __unused; d855 1 a855 1 struct mbuf *mb, *mreq __unused; d1423 1 a1423 1 struct mbuf *mb, *mreq __unused; a1504 1 vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY); d1539 1 a1539 3 if (!error) { vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY); } else { d1548 1 d1560 4 a1584 4 if (nd.ni_dvp == vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); d1663 1 a1663 1 struct mbuf *mb, *mreq __unused; d1720 4 a1748 3 if (!error) { vn_lock(nd.ni_vp, LK_EXCLUSIVE | LK_RETRY); } a1756 4 if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); d1813 1 a1813 1 struct mbuf *mb, *mreq __unused; d1900 1 a1900 1 struct mbuf *mb, *mreq __unused; d2172 1 a2172 1 struct mbuf *mb, *mreq __unused; d2274 1 a2274 1 struct mbuf *mb, *mreq __unused; a2340 1 vn_lock(nd.ni_vp, LK_SHARED | LK_RETRY); d2346 1 a2346 1 vrele(nd.ni_vp); a2348 1 vput(nd.ni_dvp); d2418 1 a2418 1 struct mbuf *mb, *mreq __unused; a2468 1 vn_lock(vp, LK_SHARED | LK_RETRY); a2473 1 vput(nd.ni_dvp); d2538 1 a2538 1 struct mbuf *mb, *mreq __unused; d2673 1 a2673 1 struct mbuf *mb, *mreq __unused, *mp2; d2683 1 a2683 4 u_quad_t frev, off, toff; #ifdef NFS3_STRICTVERF u_quad_t verf; #endif a2691 1 #ifdef NFS3_STRICTVERF a2692 1 #endif d2931 1 a2931 1 struct mbuf *mb, *mreq __unused, *mp2; d2942 1 a2942 4 u_quad_t frev, off, toff; #ifdef NFS3_STRICTVERF u_quad_t verf; #endif a2948 1 #ifdef NFS3_STRICTVERF a2949 1 #endif d3257 1 a3257 1 struct mbuf *mb, *mreq __unused; d3312 1 a3312 1 struct mbuf *mb, *mreq __unused; d3381 1 a3381 1 struct mbuf *mb, *mreq __unused; d3451 1 a3451 1 struct mbuf *mb, *mreq __unused; d3506 1 a3506 1 struct mbuf *mb, *mreq __unused; d3525 1 a3525 1 struct mbuf *mb, *mreq __unused; @ 1.160 log @nfs_namei() should not return a non-null path buffer except on success, even though the callers are apparently prepared to cope. Fixes last tidyup part of PR 44625. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.159 2011/04/18 00:38:33 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.159 2011/04/18 00:38:33 dholland Exp $"); d457 2 a458 1 if (v3) d460 2 d1588 1 d1590 1 d1749 1 d1751 1 d1820 3 a1822 1 if (dirp && v3) { d1824 2 d1859 1 d1861 1 d1918 3 a1920 1 if (fdirp && v3) { d1922 2 d2090 1 d2092 1 d2099 1 d2101 1 d2216 2 a2217 1 if (v3) d2219 2 d2223 1 d2225 1 d2344 1 d2346 1 d2467 1 d2469 1 d2592 1 d2594 1 @ 1.159 log @Back in -r1.60 of nfs_serv.c (a long time ago) VOP_MKNOD was changed so nfsd no longer needed to do a lookup() call immediately afterwards to retrieve the newly created object. Since that change there has been no way for ISSYMLINK to be set upon return from VOP_MKNOD (or before the call to VOP_MKNOD either) so remove the test for it and associated block of dead code. (I do not understand how this code was reachable before then either. The logic in question is only reached if no object by that name existed, and there's no reasonable way that a successful call to VOP_MKNOD should ever create a symlink. The code appears to come from 4.4lite; maybe they had locking bugs?) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.158 2011/04/11 01:33:05 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.158 2011/04/11 01:33:05 dholland Exp $"); d1914 3 a1916 1 pathbuf_destroy(fromnd.ni_pathbuf); d2065 4 a2068 1 pathbuf_destroy(tond.ni_pathbuf); d2086 1 d2104 4 a2107 1 pathbuf_destroy(tond.ni_pathbuf); d2114 4 a2117 1 pathbuf_destroy(fromnd.ni_pathbuf); d2204 4 a2207 1 pathbuf_destroy(nd.ni_pathbuf); d2323 4 a2326 1 pathbuf_destroy(nd.ni_pathbuf); d2347 4 a2350 1 pathbuf_destroy(nd.ni_pathbuf); d2398 1 d2444 4 a2447 1 pathbuf_destroy(nd.ni_pathbuf); d2472 4 a2475 1 pathbuf_destroy(nd.ni_pathbuf); d2518 1 d2556 4 a2559 1 pathbuf_destroy(nd.ni_pathbuf); @ 1.158 log @Clean up. Move some more code across from nfsd's private entry points. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.157 2011/03/19 01:34:24 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.157 2011/03/19 01:34:24 dholland Exp $"); a1529 12 if (nd.ni_cnd.cn_flags & ISSYMLINK) { vput(nd.ni_vp); vrele(nd.ni_dvp); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } error = EINVAL; abort = 0; nfsm_reply(0); } a1733 5 if (nd.ni_cnd.cn_flags & ISSYMLINK) { vput(nd.ni_vp); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); error = EINVAL; } @ 1.157 log @Fix memory leak introduced with the struct pathbuf changes. Hi, me. Closes PR 44625. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.156 2011/02/05 13:35:11 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.156 2011/02/05 13:35:11 yamt Exp $"); a429 3 ind.ni_pathlen = strlen(nfs_pub.np_index); ind.ni_pnbuf = NULL; ind.ni_cnd.cn_nameptr = NULL; @ 1.156 log @typo in a comment @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.155 2011/01/02 05:12:34 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.155 2011/01/02 05:12:34 dholland Exp $"); d466 6 @ 1.155 log @Remove remaining references to SAVESTART. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.154 2011/01/02 05:09:31 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.154 2011/01/02 05:09:31 dholland Exp $"); d3489 1 a3489 1 * will return EPERM instead of EACCESS. EPERM is always an error. @ 1.155.2.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.159 2011/04/18 00:38:33 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.159 2011/04/18 00:38:33 dholland Exp $"); d430 3 a465 6 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); } if (ipb != NULL) { pathbuf_destroy(ipb); } d1527 12 d1743 5 d3489 1 a3489 1 * will return EPERM instead of EACCES. EPERM is always an error. @ 1.155.4.1 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.156 2011/02/05 13:35:11 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.156 2011/02/05 13:35:11 yamt Exp $"); d3489 1 a3489 1 * will return EPERM instead of EACCES. EPERM is always an error. @ 1.154 log @Remove the special refcount behavior (adding an extra reference to the parent dir) associated with SAVESTART in relookup(). Check all call sites to make sure that SAVESTART wasn't set while calling relookup(); if it was, adjust the refcount behavior. Remove related references to SAVESTART. The only code that was reaching the extra ref was msdosfs_rename, where the refcount behavior was already fairly broken and/or gross; repair it. Add a dummy 4th argument to relookup to make sure code that hasn't been inspected won't compile. (This will go away next time the relookup semantics change, which they will.) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.153 2011/01/02 05:01:21 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.153 2011/01/02 05:01:21 dholland Exp $"); d415 1 a415 1 nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART; d1916 1 a1916 1 fromnd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART | INRENAME; d1985 1 a1985 2 tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | INRENAME; @ 1.153 log @Remove unused nameidata field ni_startdir. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.152 2010/11/30 10:30:03 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.152 2010/11/30 10:30:03 dholland Exp $"); a1900 1 uint32_t saveflag; a1957 2 saveflag = fromnd.ni_cnd.cn_flags & SAVESTART; fromnd.ni_cnd.cn_flags &= ~SAVESTART; d1959 1 a1959 2 error = relookup(fromnd.ni_dvp, &fromnd.ni_vp, &fromnd.ni_cnd); fromnd.ni_cnd.cn_flags |= saveflag; @ 1.152 log @Abolish struct componentname's cn_pnbuf. Use the path buffer in the pathbuf object passed to namei as work space instead. (For now a pnbuf pointer appears in struct nameidata, to support certain unclean things that haven't been fixed yet, but it will be going away in the future.) This removes the need for the SAVENAME and HASBUF namei flags. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.151 2010/06/24 13:03:17 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.151 2010/06/24 13:03:17 hannken Exp $"); d433 2 a434 3 ind.ni_startdir = nd.ni_vp; vref(ind.ni_startdir); error = lookup_for_nfsd_index(&ind); a442 1 vrele(nd.ni_startdir); a480 1 vrele(ndp->ni_startdir); a2081 1 vrele(tond.ni_startdir); a2098 1 vrele(fromnd.ni_startdir); a2116 1 vrele(tond.ni_startdir); a2122 1 vrele(fromnd.ni_startdir); @ 1.151 log @Clean up vnode lock operations pass 2: VOP_UNLOCK(vp, flags) -> VOP_UNLOCK(vp): Remove the unneeded flags argument. Welcome to 5.99.32. Discussed on tech-kern. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.150 2010/01/08 11:35:11 pooka Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.150 2010/01/08 11:35:11 pooka Exp $"); d393 1 d420 2 a421 1 if (nd.ni_vp->v_type == VDIR && nfs_pub.np_index != NULL) { d429 1 d431 2 a432 2 ind.ni_cnd.cn_nameptr = ind.ni_cnd.cn_pnbuf = nfs_pub.np_index; d474 4 a477 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1433 4 d1517 4 d1534 4 d1544 4 d1555 4 d1604 4 d1634 4 d1681 4 d1724 4 d1765 4 d1788 4 d1859 4 d1932 1 d2086 1 a2086 1 PNBUF_PUT(tond.ni_cnd.cn_pnbuf); d2104 1 a2104 1 PNBUF_PUT(fromnd.ni_cnd.cn_pnbuf); d2123 1 a2123 1 PNBUF_PUT(tond.ni_cnd.cn_pnbuf); a2129 1 PNBUF_PUT(fromnd.ni_cnd.cn_pnbuf); d2131 1 d2218 1 d2334 1 d2355 1 d2401 3 d2448 1 d2473 1 d2514 3 d2553 1 @ 1.150 log @The VATTR_NULL/VREF/VHOLD/HOLDRELE() macros lost their will to live years ago when the kernel was modified to not alter ABI based on DIAGNOSTIC, and now just call the respective function interfaces (in lowercase). Plenty of mix'n match upper/lowercase has creeped into the tree since then. Nuke the macros and convert all callsites to lowercase. no functional change @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.149 2009/12/23 01:09:25 pooka Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.149 2009/12/23 01:09:25 pooka Exp $"); d426 1 a426 1 VOP_UNLOCK(nd.ni_vp, 0); d1881 1 a1881 1 VOP_UNLOCK(fromnd.ni_dvp, 0); d1913 1 a1913 1 VOP_UNLOCK(fromnd.ni_dvp, 0); d1919 1 a1919 1 VOP_UNLOCK(fromnd.ni_vp, 0); d1921 1 a1921 1 VOP_UNLOCK(fromnd.ni_dvp, 0); d2620 1 a2620 1 VOP_UNLOCK(vp, 0); d2645 1 a2645 1 VOP_UNLOCK(vp, 0); d2873 1 a2873 1 VOP_UNLOCK(vp, 0); d2894 1 a2894 1 VOP_UNLOCK(vp, 0); @ 1.150.2.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); d426 1 a426 1 VOP_UNLOCK(nd.ni_vp); d1881 1 a1881 1 VOP_UNLOCK(fromnd.ni_dvp); d1913 1 a1913 1 VOP_UNLOCK(fromnd.ni_dvp); d1919 1 a1919 1 VOP_UNLOCK(fromnd.ni_vp); d1921 1 a1921 1 VOP_UNLOCK(fromnd.ni_dvp); d2620 1 a2620 1 VOP_UNLOCK(vp); d2645 1 a2645 1 VOP_UNLOCK(vp); d2873 1 a2873 1 VOP_UNLOCK(vp); d2894 1 a2894 1 VOP_UNLOCK(vp); @ 1.150.4.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.150 2010/01/08 11:35:11 pooka Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.150 2010/01/08 11:35:11 pooka Exp $"); d426 1 a426 1 VOP_UNLOCK(nd.ni_vp); d1881 1 a1881 1 VOP_UNLOCK(fromnd.ni_dvp); d1913 1 a1913 1 VOP_UNLOCK(fromnd.ni_dvp); d1919 1 a1919 1 VOP_UNLOCK(fromnd.ni_vp); d1921 1 a1921 1 VOP_UNLOCK(fromnd.ni_dvp); d2620 1 a2620 1 VOP_UNLOCK(vp); d2645 1 a2645 1 VOP_UNLOCK(vp); d2873 1 a2873 1 VOP_UNLOCK(vp); d2894 1 a2894 1 VOP_UNLOCK(vp); @ 1.150.4.2 log @sync with head @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); a392 1 struct pathbuf *ipb = NULL; d414 1 a414 1 nd.ni_cnd.cn_flags = LOCKLEAF; d419 1 a419 2 if (nd.ni_vp->v_type == VDIR && nfs_pub.np_index != NULL && (ipb = pathbuf_create(nfs_pub.np_index)) != NULL) { a426 1 ind.ni_pathbuf = ipb; d428 5 a432 4 ind.ni_pnbuf = NULL; ind.ni_cnd.cn_nameptr = NULL; error = lookup_for_nfsd_index(&ind, nd.ni_vp); d441 1 d471 1 a471 4 pathbuf_destroy(nd.ni_pathbuf); if (ipb != NULL) { pathbuf_destroy(ipb); } d477 1 a1426 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } a1506 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } a1519 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } a1525 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } a1532 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } a1577 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } a1603 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } a1646 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } a1685 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } a1722 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } a1741 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } a1808 4 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); nd.ni_pathbuf = NULL; } d1850 1 d1866 1 a1866 1 fromnd.ni_cnd.cn_flags = LOCKPARENT | INRENAME; a1877 1 pathbuf_destroy(fromnd.ni_pathbuf); d1907 2 d1910 2 a1911 1 error = relookup(fromnd.ni_dvp, &fromnd.ni_vp, &fromnd.ni_cnd, 0); d1937 2 a1938 1 tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | INRENAME; d2030 2 a2031 1 pathbuf_destroy(tond.ni_pathbuf); d2048 2 a2049 1 pathbuf_destroy(fromnd.ni_pathbuf); d2067 2 a2068 1 pathbuf_destroy(tond.ni_pathbuf); d2074 2 a2076 1 pathbuf_destroy(fromnd.ni_pathbuf); a2162 1 pathbuf_destroy(nd.ni_pathbuf); a2277 1 pathbuf_destroy(nd.ni_pathbuf); a2297 1 pathbuf_destroy(nd.ni_pathbuf); a2342 3 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); } a2386 1 pathbuf_destroy(nd.ni_pathbuf); a2410 1 pathbuf_destroy(nd.ni_pathbuf); a2450 3 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); } a2486 1 pathbuf_destroy(nd.ni_pathbuf); d3434 1 a3434 1 * will return EPERM instead of EACCES. EPERM is always an error. @ 1.150.4.3 log @sync with head @ text @d430 3 a465 6 if (nd.ni_pathbuf != NULL) { pathbuf_destroy(nd.ni_pathbuf); } if (ipb != NULL) { pathbuf_destroy(ipb); } d1527 12 d1743 5 @ 1.149 log @Define namei flag INRENAME and set it if a lookup operation is part of rename. This helps with building better asserts for rename in the DELETE lookup ... the RENAME lookup is quite obviously a part of rename. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.148 2009/11/07 07:27:49 cegger Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.148 2009/11/07 07:27:49 cegger Exp $"); d282 1 a282 1 VATTR_NULL(&va); d431 1 a431 1 VREF(ind.ni_startdir); d1430 1 a1430 1 VATTR_NULL(&va); d1485 1 a1485 1 VATTR_NULL(&va); d1545 1 a1545 1 VATTR_NULL(&va); d1656 1 a1656 1 VATTR_NULL(&va); d2212 1 a2212 1 VATTR_NULL(&va); d2350 1 a2350 1 VATTR_NULL(&va); @ 1.148 log @Add a flags argument to pmap_kenter_pa(9). Patch showed on tech-kern@@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html No objections. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.147 2009/09/27 17:19:07 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.147 2009/09/27 17:19:07 dholland Exp $"); d1866 1 a1866 1 fromnd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART; d1937 2 a1938 1 tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART; @ 1.147 log @Rename lookup() to lookup_for_nfsd(), to make it clear just whose private backdoor entry point this is. Also, clone the lookup_for_nfsd() entry point as lookup_for_nfsd_index(), for use by a different call site in nfsd that does different unclean things with nameidata. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.146 2009/05/23 15:31:21 ad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.146 2009/05/23 15:31:21 ad Exp $"); d717 1 a717 1 VM_PROT_READ); @ 1.146 log @- Fix a race between umount()/mount() and nfssvc(). - Toss netexport state on nfsserver module unload. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.145 2009/05/23 14:45:18 ad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.145 2009/05/23 14:45:18 ad Exp $"); d432 1 a432 1 error = lookup(&ind); @ 1.145 log @Fix a crash when unloading nfsserver module. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.144 2009/04/10 18:58:50 bouyer Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.144 2009/04/10 18:58:50 bouyer Exp $"); a110 1 extern krwlock_t netexport_lock; /* XXX */ d121 1 a121 1 rw_init(&netexport_lock); d132 8 a140 1 vfs_hooks_detach(&nfs_export_hooks); d142 2 a144 1 rw_destroy(&netexport_lock); @ 1.144 log @PR kern/41158: nfs_rename() locking against myself nfsrv_rename() can exit without calling genfs_renamelock_exit() because the nfsm_reply() can do return (0) on error. Change nfsm_reply to use 'error = 0; goto nfsmout' instead. Fix a few place so it's safe to goto nfsmout from nfsm_reply, or other macros calling it. As a side effect it could fix a missing vrele(dirp) in various place where nfsm_reply could return(0). @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.143 2009/03/14 15:36:24 dsl Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.143 2009/03/14 15:36:24 dsl Exp $"); d123 1 a124 1 nfsrv_initcache(); /* Init the server request cache */ d135 1 a136 1 nfsrv_fini(); @ 1.143 log @Change about 4500 of the K&R function definitions to ANSI ones. There are still about 1600 left, but they have ',' or /* ... */ in the actual variable definitions - which my awk script doesn't handle. There are also many that need () -> (void). (The script does handle misordered arguments.) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.142 2009/01/11 02:45:54 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.142 2009/01/11 02:45:54 christos Exp $"); d1395 1 a1395 1 int rdev = 0; d1422 1 d1498 1 d1514 1 d1521 1 d1531 1 d1569 1 d1571 1 d1588 9 a1596 7 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); d1616 1 d1642 1 d1714 1 d1716 1 d1726 9 a1734 7 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); d2024 1 d2031 1 d2038 1 d2042 2 d2182 1 a2182 1 int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1; d2203 1 d2268 1 d2270 1 d2282 9 a2290 7 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); d2316 1 d2341 1 d2377 1 d2379 1 d2395 9 a2403 7 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); d3387 1 d3410 1 @ 1.142 log @merge christos-time_t @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.138.2.3 2008/12/27 23:14:25 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.138.2.3 2008/12/27 23:14:25 christos Exp $"); d148 1 a148 5 nfsrv3_access(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d211 1 a211 5 nfsrv_getattr(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d251 1 a251 5 nfsrv_setattr(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d378 1 a378 5 nfsrv_lookup(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d492 1 a492 5 nfsrv_readlink(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d587 1 a587 5 nfsrv_read(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d810 1 a810 5 nfsrv_write(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d1023 1 a1023 5 nfsrv_writegather(ndp, slp, lwp, mrq) struct nfsrv_descript **ndp; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d1335 1 a1335 3 nfsrvw_coalesce(owp, nfsd) struct nfsrv_descript *owp; struct nfsrv_descript *nfsd; d1380 1 a1380 5 nfsrv_create(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d1595 1 a1595 5 nfsrv_mknod(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d1729 1 a1729 5 nfsrv_remove(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d1805 1 a1805 5 nfsrv_rename(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d2059 1 a2059 5 nfsrv_link(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d2148 1 a2148 5 nfsrv_symlink(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d2277 1 a2277 5 nfsrv_mkdir(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d2382 1 a2382 5 nfsrv_rmdir(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d2506 1 a2506 5 nfsrv_readdir(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d2764 1 a2764 5 nfsrv_readdirplus(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d3088 1 a3088 5 nfsrv_commit(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d3144 1 a3144 5 nfsrv_statfs(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d3214 1 a3214 5 nfsrv_fsinfo(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d3284 1 a3284 5 nfsrv_pathconf(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d3396 1 a3396 7 nfsrv_access(vp, flags, cred, rdonly, lwp, override) struct vnode *vp; int flags; kauth_cred_t cred; int rdonly; struct lwp *lwp; int override; @ 1.142.2.1 log @Sync with HEAD. Commit is split, to avoid a "too many arguments" protocol error. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.144 2009/04/10 18:58:50 bouyer Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.144 2009/04/10 18:58:50 bouyer Exp $"); d148 5 a152 1 nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d215 5 a219 1 nfsrv_getattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d259 5 a263 1 nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d390 5 a394 1 nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d508 5 a512 1 nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d607 5 a611 1 nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d834 5 a838 1 nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d1051 5 a1055 1 nfsrv_writegather(struct nfsrv_descript **ndp, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d1367 3 a1369 1 nfsrvw_coalesce(struct nfsrv_descript *owp, struct nfsrv_descript *nfsd) d1414 5 a1418 1 nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d1433 1 a1433 1 int rdev = 0, abort = 0; a1459 1 abort = 1; a1534 1 abort = 0; a1549 1 abort = 0; a1555 1 abort = 0; a1564 1 abort = 0; a1601 1 dirp = NULL; a1602 1 abort = 0; d1619 7 a1625 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); } d1633 5 a1637 1 nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) a1648 1 int abort = 0; a1673 1 abort = 1; a1744 1 dirp = NULL; a1745 1 abort = 0; d1755 7 a1761 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); } d1771 5 a1775 1 nfsrv_remove(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d1851 5 a1855 1 nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) a2058 1 tond.ni_cnd.cn_nameiop = 0; a2064 1 fdirp = NULL; a2070 1 tdirp = NULL; a2073 2 fromnd.ni_cnd.cn_nameiop = 0; localfs = NULL; d2109 5 a2113 1 nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d2202 5 a2206 1 nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d2220 1 a2220 1 int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1, abort = 0; a2240 1 abort = 1; a2304 1 dirp = NULL; a2305 1 abort = 0; d2317 7 a2323 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); } d2335 5 a2339 1 nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) a2352 1 int abort = 0; a2376 1 abort = 1; a2411 1 dirp = NULL; a2412 1 abort = 0; d2428 7 a2434 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); } d2444 5 a2448 1 nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d2572 5 a2576 1 nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d2834 5 a2838 1 nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3162 5 a3166 1 nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3222 5 a3226 1 nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3296 5 a3300 1 nfsrv_fsinfo(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3370 5 a3374 1 nfsrv_pathconf(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) a3445 1 nfsmout: a3467 1 nfsmout: d3486 7 a3492 1 nfsrv_access(struct vnode *vp, int flags, kauth_cred_t cred, int rdonly, struct lwp *lwp, int override) @ 1.142.2.2 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.146 2009/05/23 15:31:21 ad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.146 2009/05/23 15:31:21 ad Exp $"); d111 1 d122 2 a123 1 netexport_init(); a124 1 nfsrv_init(0); /* Init server data structures */ d133 1 a133 5 /* * Kill export list before detaching VFS hooks, so we * we don't leak state due to a concurrent umount(). */ netexport_fini(); d135 1 a135 3 /* Kill timer before server goes away. */ nfs_timer_srvfini(); d137 1 a137 3 /* Server uses server cache, so kill cache last. */ nfsrv_finicache(); @ 1.141 log @nfsd_use_loan: int -> bool @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.140 2008/11/27 14:04:58 pooka Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.140 2008/11/27 14:04:58 pooka Exp $"); d1002 1 a1002 1 *tl = txdr_unsigned(boottime.tv_usec); d1307 1 a1307 1 *tl = txdr_unsigned(boottime.tv_usec); d3211 1 a3211 1 *tl = txdr_unsigned(boottime.tv_usec); @ 1.140 log @Use struct nfs_fattr in struct flrep instead of uint32_t array acrobatics to get rid of type punning warning. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.139 2008/11/19 18:36:09 ad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.139 2008/11/19 18:36:09 ad Exp $"); d99 1 a99 1 int nfsd_use_loan = 1; /* use page-loan for READ OP */ @ 1.139 log @Make the emulations, exec formats, coredump, NFS, and the NFS server into modules. By and large this commit: - shuffles header files and ifdefs - splits code out where necessary to be modular - adds module glue for each of the components - adds/replaces hooks for things that can be installed at runtime @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.138 2008/03/28 05:02:08 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.138 2008/03/28 05:02:08 dholland Exp $"); d2565 1 a2565 1 u_int32_t fl_fattr[NFSX_V3FATTR / sizeof (u_int32_t)]; d2568 1 @ 1.138 log @Yet another rename workaround - this time check for . and .. early because relookup() objects to being asked to handle them. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.137 2008/03/08 08:03:46 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.137 2008/03/08 08:03:46 yamt Exp $"); d75 4 d89 2 d103 41 @ 1.138.6.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.138 2008/03/28 05:02:08 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.138 2008/03/28 05:02:08 dholland Exp $"); a74 4 #include #include #include #include a84 2 MODULE(MODULE_CLASS_MISC, nfsserver, "nfs"); d93 1 a93 1 bool nfsd_use_loan = true; /* use page-loan for READ OP */ a96 41 static const struct syscall_package nfsserver_syscalls[] = { { SYS_nfssvc, 0, (sy_call_t *)sys_nfssvc }, { 0, 0, NULL }, }; static int nfsserver_modcmd(modcmd_t cmd, void *arg) { extern krwlock_t netexport_lock; /* XXX */ extern struct vfs_hooks nfs_export_hooks; /* XXX */ int error; switch (cmd) { case MODULE_CMD_INIT: error = syscall_establish(NULL, nfsserver_syscalls); if (error != 0) { return error; } nfs_init(); /* XXX for monolithic kernel */ rw_init(&netexport_lock); nfsrv_init(0); /* Init server data structures */ nfsrv_initcache(); /* Init the server request cache */ vfs_hooks_attach(&nfs_export_hooks); nfs_timer_srvinit(nfsrv_timer); return 0; case MODULE_CMD_FINI: error = syscall_disestablish(NULL, nfsserver_syscalls); if (error != 0) { return error; } nfs_timer_srvfini(); vfs_hooks_detach(&nfs_export_hooks); nfsrv_finicache(); nfsrv_fini(); rw_destroy(&netexport_lock); return 0; default: return ENOTTY; } } d101 5 a105 1 nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d168 5 a172 1 nfsrv_getattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d212 5 a216 1 nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d343 5 a347 1 nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d461 5 a465 1 nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d560 5 a564 1 nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d787 5 a791 1 nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d955 1 a955 1 *tl = txdr_unsigned(boottime.tv_nsec / 1000); d1004 5 a1008 1 nfsrv_writegather(struct nfsrv_descript **ndp, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d1260 1 a1260 1 *tl = txdr_unsigned(boottime.tv_nsec / 1000); d1320 3 a1322 1 nfsrvw_coalesce(struct nfsrv_descript *owp, struct nfsrv_descript *nfsd) d1367 5 a1371 1 nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d1386 1 a1386 1 int rdev = 0, abort = 0; a1412 1 abort = 1; a1487 1 abort = 0; a1502 1 abort = 0; a1508 1 abort = 0; a1517 1 abort = 0; a1554 1 dirp = NULL; a1555 1 abort = 0; d1572 7 a1578 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); } d1586 5 a1590 1 nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) a1601 1 int abort = 0; a1626 1 abort = 1; a1697 1 dirp = NULL; a1698 1 abort = 0; d1708 7 a1714 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); } d1724 5 a1728 1 nfsrv_remove(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d1804 5 a1808 1 nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) a2011 1 tond.ni_cnd.cn_nameiop = 0; a2017 1 fdirp = NULL; a2023 1 tdirp = NULL; a2026 2 fromnd.ni_cnd.cn_nameiop = 0; localfs = NULL; d2062 5 a2066 1 nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d2155 5 a2159 1 nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d2173 1 a2173 1 int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1, abort = 0; a2193 1 abort = 1; a2257 1 dirp = NULL; a2258 1 abort = 0; d2270 7 a2276 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); } d2288 5 a2292 1 nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) a2305 1 int abort = 0; a2329 1 abort = 1; a2364 1 dirp = NULL; a2365 1 abort = 0; d2381 7 a2387 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); } d2397 5 a2401 1 nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d2518 1 a2518 1 struct nfs_fattr fl_fattr; /* XXX: must be of fattr3 size */ a2520 1 /* handle comes here, filled in dynamically */ d2524 5 a2528 1 nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d2786 5 a2790 1 nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3114 5 a3118 1 nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3163 1 a3163 1 *tl = txdr_unsigned(boottime.tv_nsec / 1000); d3174 5 a3178 1 nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3248 5 a3252 1 nfsrv_fsinfo(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3322 5 a3326 1 nfsrv_pathconf(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) a3397 1 nfsmout: a3419 1 nfsmout: d3438 7 a3444 1 nfsrv_access(struct vnode *vp, int flags, kauth_cred_t cred, int rdonly, struct lwp *lwp, int override) @ 1.138.6.2 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.138.6.1 2009/05/04 08:14:22 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.138.6.1 2009/05/04 08:14:22 yamt Exp $"); d111 1 d122 2 a123 1 netexport_init(); a124 1 nfsrv_init(0); /* Init server data structures */ d133 1 a133 5 /* * Kill export list before detaching VFS hooks, so we * we don't leak state due to a concurrent umount(). */ netexport_fini(); d135 1 a135 3 /* Kill timer before server goes away. */ nfs_timer_srvfini(); d137 1 a137 3 /* Server uses server cache, so kill cache last. */ nfsrv_finicache(); @ 1.138.6.3 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.138.6.2 2009/06/20 07:20:34 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.138.6.2 2009/06/20 07:20:34 yamt Exp $"); d282 1 a282 1 vattr_null(&va); d431 2 a432 2 vref(ind.ni_startdir); error = lookup_for_nfsd_index(&ind); d717 1 a717 1 VM_PROT_READ, 0); d1430 1 a1430 1 vattr_null(&va); d1485 1 a1485 1 vattr_null(&va); d1545 1 a1545 1 vattr_null(&va); d1656 1 a1656 1 vattr_null(&va); d1866 1 a1866 1 fromnd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART | INRENAME; d1937 1 a1937 2 tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | INRENAME; d2211 1 a2211 1 vattr_null(&va); d2349 1 a2349 1 vattr_null(&va); @ 1.138.6.4 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.138.6.3 2010/03/11 15:04:31 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.138.6.3 2010/03/11 15:04:31 yamt Exp $"); d426 1 a426 1 VOP_UNLOCK(nd.ni_vp); d1881 1 a1881 1 VOP_UNLOCK(fromnd.ni_dvp); d1913 1 a1913 1 VOP_UNLOCK(fromnd.ni_dvp); d1919 1 a1919 1 VOP_UNLOCK(fromnd.ni_vp); d1921 1 a1921 1 VOP_UNLOCK(fromnd.ni_dvp); d2620 1 a2620 1 VOP_UNLOCK(vp); d2645 1 a2645 1 VOP_UNLOCK(vp); d2873 1 a2873 1 VOP_UNLOCK(vp); d2894 1 a2894 1 VOP_UNLOCK(vp); @ 1.138.16.1 log @Pull up following revision(s) (requested by ad in ticket #700): sys/nfs/nfs_serv.c: revision 1.144 sys/nfs/nfsm_subs.h: revision 1.51 PR kern/41158: nfs_rename() locking against myself nfsrv_rename() can exit without calling genfs_renamelock_exit() because the nfsm_reply() can do return (0) on error. Change nfsm_reply to use 'error = 0; goto nfsmout' instead. Fix a few place so it's safe to goto nfsmout from nfsm_reply, or other macros calling it. As a side effect it could fix a missing vrele(dirp) in various place where nfsm_reply could return(0). @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.138 2008/03/28 05:02:08 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.138 2008/03/28 05:02:08 dholland Exp $"); d1386 1 a1386 1 int rdev = 0, abort = 0; a1412 1 abort = 1; a1487 1 abort = 0; a1502 1 abort = 0; a1508 1 abort = 0; a1517 1 abort = 0; a1554 1 dirp = NULL; a1555 1 abort = 0; d1572 7 a1578 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); } a1601 1 int abort = 0; a1626 1 abort = 1; a1697 1 dirp = NULL; a1698 1 abort = 0; d1708 7 a1714 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); } a2011 1 tond.ni_cnd.cn_nameiop = 0; a2017 1 fdirp = NULL; a2023 1 tdirp = NULL; a2026 2 fromnd.ni_cnd.cn_nameiop = 0; localfs = NULL; d2173 1 a2173 1 int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1, abort = 0; a2193 1 abort = 1; a2257 1 dirp = NULL; a2258 1 abort = 0; d2270 7 a2276 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); } a2305 1 int abort = 0; a2329 1 abort = 1; a2364 1 dirp = NULL; a2365 1 abort = 0; d2381 7 a2387 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); } a3397 1 nfsmout: a3419 1 nfsmout: @ 1.138.16.1.4.1 log @Pullin some NFS fixes from netbsd-5. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.138.16.2 2010/02/14 13:27:45 bouyer Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.138.16.2 2010/02/14 13:27:45 bouyer Exp $"); d1862 1 a1862 1 fromnd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART | INRENAME; d1933 1 a1933 2 tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | INRENAME; @ 1.138.16.1.4.2 log @Fix call to sokvaalloc (now takes 3 arguments) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.138.16.1.4.1 2010/04/20 21:29:06 matt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.138.16.1.4.1 2010/04/20 21:29:06 matt Exp $"); d656 1 a656 1 lva = sokvaalloc(pgoff, npages << PAGE_SHIFT, slp->ns_so); @ 1.138.16.2 log @Pull up following revision(s) (requested by pooka in ticket #1289): sys/sys/namei.src: revision 1.14 sys/kern/vfs_syscalls.c: revision 1.401 sys/nfs/nfs_serv.c: revision 1.149 sys/sys/namei.h: regen Define namei flag INRENAME and set it if a lookup operation is part of rename. This helps with building better asserts for rename in the DELETE lookup ... the RENAME lookup is quite obviously a part of rename. @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); d1862 1 a1862 1 fromnd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART | INRENAME; d1933 1 a1933 2 tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | INRENAME; @ 1.138.16.3 log @Pull up following revision(s) (requested by chs in ticket #1794): sys/nfs/nfs_serv.c: revision 1.164 via patch fix error handling in nfsrv_rename(): when the first nfs_namei() fails, don't try to free the resources allocated by a successful lookup. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.138.16.2 2010/02/14 13:27:45 bouyer Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.138.16.2 2010/02/14 13:27:45 bouyer Exp $"); a1868 1 fromnd.ni_cnd.cn_nameiop = 0; @ 1.138.14.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.142 2009/01/11 02:45:54 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.142 2009/01/11 02:45:54 christos Exp $"); a74 4 #include #include #include #include a84 2 MODULE(MODULE_CLASS_MISC, nfsserver, "nfs"); d93 1 a93 1 bool nfsd_use_loan = true; /* use page-loan for READ OP */ a96 41 static const struct syscall_package nfsserver_syscalls[] = { { SYS_nfssvc, 0, (sy_call_t *)sys_nfssvc }, { 0, 0, NULL }, }; static int nfsserver_modcmd(modcmd_t cmd, void *arg) { extern krwlock_t netexport_lock; /* XXX */ extern struct vfs_hooks nfs_export_hooks; /* XXX */ int error; switch (cmd) { case MODULE_CMD_INIT: error = syscall_establish(NULL, nfsserver_syscalls); if (error != 0) { return error; } nfs_init(); /* XXX for monolithic kernel */ rw_init(&netexport_lock); nfsrv_init(0); /* Init server data structures */ nfsrv_initcache(); /* Init the server request cache */ vfs_hooks_attach(&nfs_export_hooks); nfs_timer_srvinit(nfsrv_timer); return 0; case MODULE_CMD_FINI: error = syscall_disestablish(NULL, nfsserver_syscalls); if (error != 0) { return error; } nfs_timer_srvfini(); vfs_hooks_detach(&nfs_export_hooks); nfsrv_finicache(); nfsrv_fini(); rw_destroy(&netexport_lock); return 0; default: return ENOTTY; } } d955 1 a955 1 *tl = txdr_unsigned(boottime.tv_nsec / 1000); d1260 1 a1260 1 *tl = txdr_unsigned(boottime.tv_nsec / 1000); d2518 1 a2518 1 struct nfs_fattr fl_fattr; /* XXX: must be of fattr3 size */ a2520 1 /* handle comes here, filled in dynamically */ d3163 1 a3163 1 *tl = txdr_unsigned(boottime.tv_nsec / 1000); @ 1.138.14.2 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.138.14.1 2009/01/19 13:20:20 skrll Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.138.14.1 2009/01/19 13:20:20 skrll Exp $"); d148 5 a152 1 nfsrv3_access(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d215 5 a219 1 nfsrv_getattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d259 5 a263 1 nfsrv_setattr(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d390 5 a394 1 nfsrv_lookup(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d508 5 a512 1 nfsrv_readlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d607 5 a611 1 nfsrv_read(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d834 5 a838 1 nfsrv_write(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d1051 5 a1055 1 nfsrv_writegather(struct nfsrv_descript **ndp, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d1367 3 a1369 1 nfsrvw_coalesce(struct nfsrv_descript *owp, struct nfsrv_descript *nfsd) d1414 5 a1418 1 nfsrv_create(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d1433 1 a1433 1 int rdev = 0, abort = 0; a1459 1 abort = 1; a1534 1 abort = 0; a1549 1 abort = 0; a1555 1 abort = 0; a1564 1 abort = 0; a1601 1 dirp = NULL; a1602 1 abort = 0; d1619 7 a1625 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); } d1633 5 a1637 1 nfsrv_mknod(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) a1648 1 int abort = 0; a1673 1 abort = 1; a1744 1 dirp = NULL; a1745 1 abort = 0; d1755 7 a1761 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); } d1771 5 a1775 1 nfsrv_remove(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d1851 5 a1855 1 nfsrv_rename(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) a2058 1 tond.ni_cnd.cn_nameiop = 0; a2064 1 fdirp = NULL; a2070 1 tdirp = NULL; a2073 2 fromnd.ni_cnd.cn_nameiop = 0; localfs = NULL; d2109 5 a2113 1 nfsrv_link(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d2202 5 a2206 1 nfsrv_symlink(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d2220 1 a2220 1 int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1, abort = 0; a2240 1 abort = 1; a2304 1 dirp = NULL; a2305 1 abort = 0; d2317 7 a2323 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); } d2335 5 a2339 1 nfsrv_mkdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) a2352 1 int abort = 0; a2376 1 abort = 1; a2411 1 dirp = NULL; a2412 1 abort = 0; d2428 7 a2434 9 if (abort) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); } d2444 5 a2448 1 nfsrv_rmdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d2572 5 a2576 1 nfsrv_readdir(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d2834 5 a2838 1 nfsrv_readdirplus(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3162 5 a3166 1 nfsrv_commit(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3222 5 a3226 1 nfsrv_statfs(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3296 5 a3300 1 nfsrv_fsinfo(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3370 5 a3374 1 nfsrv_pathconf(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) a3445 1 nfsmout: a3467 1 nfsmout: d3486 7 a3492 1 nfsrv_access(struct vnode *vp, int flags, kauth_cred_t cred, int rdonly, struct lwp *lwp, int override) @ 1.138.12.1 log @Update haad-dm branch to haad-dm-base2. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.141 2008/12/03 14:56:05 pooka Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.141 2008/12/03 14:56:05 pooka Exp $"); a74 4 #include #include #include #include a84 2 MODULE(MODULE_CLASS_MISC, nfsserver, "nfs"); d93 1 a93 1 bool nfsd_use_loan = true; /* use page-loan for READ OP */ a96 41 static const struct syscall_package nfsserver_syscalls[] = { { SYS_nfssvc, 0, (sy_call_t *)sys_nfssvc }, { 0, 0, NULL }, }; static int nfsserver_modcmd(modcmd_t cmd, void *arg) { extern krwlock_t netexport_lock; /* XXX */ extern struct vfs_hooks nfs_export_hooks; /* XXX */ int error; switch (cmd) { case MODULE_CMD_INIT: error = syscall_establish(NULL, nfsserver_syscalls); if (error != 0) { return error; } nfs_init(); /* XXX for monolithic kernel */ rw_init(&netexport_lock); nfsrv_init(0); /* Init server data structures */ nfsrv_initcache(); /* Init the server request cache */ vfs_hooks_attach(&nfs_export_hooks); nfs_timer_srvinit(nfsrv_timer); return 0; case MODULE_CMD_FINI: error = syscall_disestablish(NULL, nfsserver_syscalls); if (error != 0) { return error; } nfs_timer_srvfini(); vfs_hooks_detach(&nfs_export_hooks); nfsrv_finicache(); nfsrv_fini(); rw_destroy(&netexport_lock); return 0; default: return ENOTTY; } } d2518 1 a2518 1 struct nfs_fattr fl_fattr; /* XXX: must be of fattr3 size */ a2520 1 /* handle comes here, filled in dynamically */ @ 1.138.2.1 log @Welcome to the time_t=long long dev_t=uint64_t branch. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.138 2008/03/28 05:02:08 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.138 2008/03/28 05:02:08 dholland Exp $"); d955 1 a955 1 *tl = txdr_unsigned(boottime.tv_nsec / 1000); d1260 1 a1260 1 *tl = txdr_unsigned(boottime.tv_nsec / 1000); d3163 1 a3163 1 *tl = txdr_unsigned(boottime.tv_nsec / 1000); @ 1.138.2.2 log @merge with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.139 2008/11/19 18:36:09 ad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.139 2008/11/19 18:36:09 ad Exp $"); a74 4 #include #include #include #include a84 2 MODULE(MODULE_CLASS_MISC, nfsserver, "nfs"); a96 41 static const struct syscall_package nfsserver_syscalls[] = { { SYS_nfssvc, 0, (sy_call_t *)sys_nfssvc }, { 0, 0, NULL }, }; static int nfsserver_modcmd(modcmd_t cmd, void *arg) { extern krwlock_t netexport_lock; /* XXX */ extern struct vfs_hooks nfs_export_hooks; /* XXX */ int error; switch (cmd) { case MODULE_CMD_INIT: error = syscall_establish(NULL, nfsserver_syscalls); if (error != 0) { return error; } nfs_init(); /* XXX for monolithic kernel */ rw_init(&netexport_lock); nfsrv_init(0); /* Init server data structures */ nfsrv_initcache(); /* Init the server request cache */ vfs_hooks_attach(&nfs_export_hooks); nfs_timer_srvinit(nfsrv_timer); return 0; case MODULE_CMD_FINI: error = syscall_disestablish(NULL, nfsserver_syscalls); if (error != 0) { return error; } nfs_timer_srvfini(); vfs_hooks_detach(&nfs_export_hooks); nfsrv_finicache(); nfsrv_fini(); rw_destroy(&netexport_lock); return 0; default: return ENOTTY; } } @ 1.138.2.3 log @merge with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.141 2008/12/03 14:56:05 pooka Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.141 2008/12/03 14:56:05 pooka Exp $"); d99 1 a99 1 bool nfsd_use_loan = true; /* use page-loan for READ OP */ d2565 1 a2565 1 struct nfs_fattr fl_fattr; /* XXX: must be of fattr3 size */ a2567 1 /* handle comes here, filled in dynamically */ @ 1.137 log @desupport link/unlink of directories. noted by Elad Efrat. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.136 2008/02/28 17:07:49 elad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.136 2008/02/28 17:07:49 elad Exp $"); d1877 11 @ 1.136 log @Introduce a new kauth action, KAUTH_NETWORK_NFS, and two requests, KAUTH_REQ_NETWORK_NFS_EXPORT and KAUTH_REQ_NETWORK_NFS_SVC, and use them to replace two KAUTH_GENERIC_ISSUSER calls in the NFS code. Also replace two more with KAUTH_SYSTEM_MKNOD, where appropriate. Documetnation and examples updated. More to come. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.135 2008/02/20 17:15:51 matt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.135 2008/02/20 17:15:51 matt Exp $"); d1762 2 a1763 3 if (vp->v_type == VDIR && (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL)) != 0) d1765 1 a1770 1 goto out; d2085 2 a2086 2 if (vp->v_type == VDIR && (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL)) != 0) d2088 1 @ 1.135 log @Fix extern declaration to match actual declaration (add const). @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.134 2008/01/28 14:31:19 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.134 2008/01/28 14:31:19 dholland Exp $"); d1484 2 a1485 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL))) { d1671 2 a1672 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL))) { @ 1.135.6.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); d1484 2 a1485 2 (error = kauth_authorize_system(cred, KAUTH_SYSTEM_MKNOD, 0, NULL, NULL, NULL))) { d1671 2 a1672 2 (error = kauth_authorize_system(cred, KAUTH_SYSTEM_MKNOD, 0, NULL, NULL, NULL))) { d1762 3 a1764 2 if (vp->v_type == VDIR) { error = EPERM; a1765 1 } d1771 1 a1877 11 if ((fromnd.ni_cnd.cn_namelen == 1 && fromnd.ni_cnd.cn_nameptr[0] == '.') || (fromnd.ni_cnd.cn_namelen == 2 && fromnd.ni_cnd.cn_nameptr[0] == '.' && fromnd.ni_cnd.cn_nameptr[1] == '.')) { error = EINVAL; VFS_RENAMELOCK_EXIT(localfs); VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); goto out1; } d2086 2 a2087 2 if (vp->v_type == VDIR) { error = EPERM; a2088 1 } @ 1.135.6.2 log @Sync with HEAD. @ text @a74 4 #include #include #include #include a84 2 MODULE(MODULE_CLASS_MISC, nfsserver, "nfs"); d93 1 a93 1 bool nfsd_use_loan = true; /* use page-loan for READ OP */ a96 41 static const struct syscall_package nfsserver_syscalls[] = { { SYS_nfssvc, 0, (sy_call_t *)sys_nfssvc }, { 0, 0, NULL }, }; static int nfsserver_modcmd(modcmd_t cmd, void *arg) { extern krwlock_t netexport_lock; /* XXX */ extern struct vfs_hooks nfs_export_hooks; /* XXX */ int error; switch (cmd) { case MODULE_CMD_INIT: error = syscall_establish(NULL, nfsserver_syscalls); if (error != 0) { return error; } nfs_init(); /* XXX for monolithic kernel */ rw_init(&netexport_lock); nfsrv_init(0); /* Init server data structures */ nfsrv_initcache(); /* Init the server request cache */ vfs_hooks_attach(&nfs_export_hooks); nfs_timer_srvinit(nfsrv_timer); return 0; case MODULE_CMD_FINI: error = syscall_disestablish(NULL, nfsserver_syscalls); if (error != 0) { return error; } nfs_timer_srvfini(); vfs_hooks_detach(&nfs_export_hooks); nfsrv_finicache(); nfsrv_fini(); rw_destroy(&netexport_lock); return 0; default: return ENOTTY; } } d955 1 a955 1 *tl = txdr_unsigned(boottime.tv_nsec / 1000); d1260 1 a1260 1 *tl = txdr_unsigned(boottime.tv_nsec / 1000); d2518 1 a2518 1 struct nfs_fattr fl_fattr; /* XXX: must be of fattr3 size */ a2520 1 /* handle comes here, filled in dynamically */ d3163 1 a3163 1 *tl = txdr_unsigned(boottime.tv_nsec / 1000); @ 1.135.2.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.137 2008/03/08 08:03:46 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.137 2008/03/08 08:03:46 yamt Exp $"); d1484 2 a1485 2 (error = kauth_authorize_system(cred, KAUTH_SYSTEM_MKNOD, 0, NULL, NULL, NULL))) { d1671 2 a1672 2 (error = kauth_authorize_system(cred, KAUTH_SYSTEM_MKNOD, 0, NULL, NULL, NULL))) { d1762 3 a1764 2 if (vp->v_type == VDIR) { error = EPERM; a1765 1 } d1771 1 d2086 2 a2087 2 if (vp->v_type == VDIR) { error = EPERM; a2088 1 } @ 1.134 log @Fix some race conditions in rename. Introduce a per-FS rename lock and new vfsops to manipulate it. Get this lock while renaming. Also add another relookup() in do_sys_rename, which is a hack to kludge around some of the worst deficiencies of ufs_rename. reviewed-by: pooka (and an earlier rev by ad) posted on tech-kern with no objections. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.133 2007/12/22 03:31:15 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.133 2007/12/22 03:31:15 yamt Exp $"); d88 1 a88 1 extern enum vtype nv3tov_type[8]; @ 1.133 log @nfsrv_create: fix a use-after-release. @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); d1827 1 d1832 1 d1866 29 d1915 1 d1984 1 d1993 1 d2035 3 @ 1.132 log @merge non-intrusive nfs changes from vmlocking. @ text @d1512 1 a1517 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); @ 1.132.4.1 log @Sync with HEAD @ text @a1511 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d1517 1 @ 1.131 log @Remove the "struct lwp *" argument from all VFS and VOP interfaces. The general trend is to remove it from all kernel interfaces and this is a start. In case the calling lwp is desired, curlwp should be used. quick consensus on tech-kern @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.130 2007/10/10 20:42:31 ad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.130 2007/10/10 20:42:31 ad Exp $"); d1024 1 a1024 1 int ioflags, aftat_ret = 1, s, adjust, v3, zeroing; a1105 1 s = splsoftclock(); d1107 1 d1147 1 a1147 1 splx(s); d1157 1 a1157 1 s = splsoftclock(); d1166 2 a1167 1 splx(s); d1274 1 a1274 1 s = splsoftclock(); d1283 1 a1283 1 splx(s); a1284 1 s = splsoftclock(); d1286 2 d1289 1 a1289 1 splx(s); d1292 1 a1293 1 splx(s); d1298 1 a1298 1 s = splsoftclock(); d1307 1 a1307 1 splx(s); d1328 2 @ 1.131.2.1 log @Pull the vmlocking changes into a new branch. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.131 2007/11/26 19:02:20 pooka Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.131 2007/11/26 19:02:20 pooka Exp $"); d1024 1 a1024 1 int ioflags, aftat_ret = 1, adjust, v3, zeroing; d1106 1 a1107 1 mutex_enter(&nfsd_lock); d1147 1 a1147 1 mutex_exit(&nfsd_lock); d1157 1 a1157 1 mutex_enter(&nfsd_lock); d1166 1 a1166 2 mutex_exit(&nfsd_lock); d1273 1 a1273 1 mutex_enter(&nfsd_lock); d1282 1 a1282 1 mutex_exit(&nfsd_lock); d1284 1 a1285 2 mutex_enter(&nfsd_lock); d1287 1 a1287 1 mutex_exit(&nfsd_lock); a1289 1 mutex_exit(&nfsd_lock); d1291 1 d1296 1 a1296 1 mutex_enter(&nfsd_lock); d1305 1 a1305 1 mutex_exit(&nfsd_lock); a1325 2 KASSERT(mutex_owned(&nfsd_lock)); @ 1.131.2.2 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.132 2007/12/04 17:42:30 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.132 2007/12/04 17:42:30 yamt Exp $"); @ 1.131.2.3 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.131.2.2 2007/12/08 17:58:03 ad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.131.2.2 2007/12/08 17:58:03 ad Exp $"); a1511 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d1517 1 @ 1.130 log @Merge from vmlocking: - Split vnode::v_flag into three fields, depending on field locking. - simple_lock -> kmutex in a few places. - Fix some simple locking problems. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.129 2007/07/27 10:03:58 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.129 2007/07/27 10:03:58 yamt Exp $"); d155 1 a155 1 getret = VOP_GETATTR(vp, &va, cred, lwp); d198 1 a198 1 error = VOP_GETATTR(vp, &va, cred, lwp); d292 1 a292 1 error = preat_ret = VOP_GETATTR(vp, &preat, cred, lwp); d322 2 a323 2 error = VOP_SETATTR(vp, &va, cred, lwp); postat_ret = VOP_GETATTR(vp, &va, cred, lwp); d422 1 a422 1 dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, lwp); d437 1 a437 1 error = VOP_GETATTR(vp, &va, cred, lwp); d536 1 a536 1 getret = VOP_GETATTR(vp, &attr, cred, lwp); d618 1 a618 1 getret = VOP_GETATTR(vp, &va, cred, lwp); d752 1 a752 1 if (error || (getret = VOP_GETATTR(vp, &va, cred, lwp)) != 0){ d880 1 a880 1 forat_ret = VOP_GETATTR(vp, &forat, cred, lwp); d933 1 a933 1 aftat_ret = VOP_GETATTR(vp, &va, cred, lwp); d1177 1 a1177 1 forat_ret = VOP_GETATTR(vp, &forat, cred, lwp); d1229 1 a1229 1 aftat_ret = VOP_GETATTR(vp, &va, cred, lwp); d1400 1 a1400 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1471 2 a1472 2 error = VOP_SETATTR(nd.ni_vp, &va, cred, lwp); d1522 1 a1522 1 error = VOP_SETATTR(vp, &va, cred, lwp); d1531 1 a1531 1 error = VOP_GETATTR(vp, &va, cred, lwp); d1546 1 a1546 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1615 1 a1615 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1688 1 a1688 1 error = VOP_GETATTR(vp, &va, cred, lwp); d1692 1 a1692 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1754 1 a1754 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1785 1 a1785 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1846 1 a1846 1 fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, lwp); d1877 1 a1877 1 tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, lwp); d1967 1 a1967 1 fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, lwp); d1973 1 a1973 1 tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, lwp); d2054 1 a2054 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2082 1 a2082 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d2085 1 a2085 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2138 1 a2138 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2192 1 a2192 1 error = VOP_GETATTR(nd.ni_vp, &va, cred, lwp); d2203 1 a2203 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2269 1 a2269 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2304 1 a2304 1 error = VOP_GETATTR(vp, &va, cred, lwp); d2310 1 a2310 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2376 1 a2376 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2417 1 a2417 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2534 1 a2534 1 error = getret = VOP_GETATTR(vp, &at, cred, lwp); d2571 1 a2571 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d2790 1 a2790 1 error = getret = VOP_GETATTR(vp, &at, cred, lwp); d2827 1 a2827 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d2933 1 a2933 1 if (VOP_GETATTR(nvp, vap, cred, lwp)) { d3097 1 a3097 1 for_ret = VOP_GETATTR(vp, &bfor, cred, lwp); d3102 1 a3102 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, lwp); d3104 1 a3104 1 aft_ret = VOP_GETATTR(vp, &aft, cred, lwp); d3155 2 a3156 2 error = VFS_STATVFS(vp->v_mount, sf, lwp); getret = VOP_GETATTR(vp, &at, cred, lwp); d3231 1 a3231 1 VFS_STATVFS(vp->v_mount, sb, (struct lwp *)0); d3235 1 a3235 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d3308 1 a3308 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d3421 1 a3421 1 error = VOP_GETATTR(vp, &vattr, cred, lwp); d3424 1 a3424 1 error = VOP_ACCESS(vp, flags, cred, lwp); @ 1.130.4.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.132 2007/12/04 17:42:30 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.132 2007/12/04 17:42:30 yamt Exp $"); d155 1 a155 1 getret = VOP_GETATTR(vp, &va, cred); d198 1 a198 1 error = VOP_GETATTR(vp, &va, cred); d292 1 a292 1 error = preat_ret = VOP_GETATTR(vp, &preat, cred); d322 2 a323 2 error = VOP_SETATTR(vp, &va, cred); postat_ret = VOP_GETATTR(vp, &va, cred); d422 1 a422 1 dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred); d437 1 a437 1 error = VOP_GETATTR(vp, &va, cred); d536 1 a536 1 getret = VOP_GETATTR(vp, &attr, cred); d618 1 a618 1 getret = VOP_GETATTR(vp, &va, cred); d752 1 a752 1 if (error || (getret = VOP_GETATTR(vp, &va, cred)) != 0){ d880 1 a880 1 forat_ret = VOP_GETATTR(vp, &forat, cred); d933 1 a933 1 aftat_ret = VOP_GETATTR(vp, &va, cred); d1024 1 a1024 1 int ioflags, aftat_ret = 1, adjust, v3, zeroing; d1106 1 a1107 1 mutex_enter(&nfsd_lock); d1147 1 a1147 1 mutex_exit(&nfsd_lock); d1157 1 a1157 1 mutex_enter(&nfsd_lock); d1166 1 a1166 2 mutex_exit(&nfsd_lock); d1177 1 a1177 1 forat_ret = VOP_GETATTR(vp, &forat, cred); d1229 1 a1229 1 aftat_ret = VOP_GETATTR(vp, &va, cred); d1273 1 a1273 1 mutex_enter(&nfsd_lock); d1282 1 a1282 1 mutex_exit(&nfsd_lock); d1284 1 a1285 2 mutex_enter(&nfsd_lock); d1287 1 a1287 1 mutex_exit(&nfsd_lock); a1289 1 mutex_exit(&nfsd_lock); d1291 1 d1296 1 a1296 1 mutex_enter(&nfsd_lock); d1305 1 a1305 1 mutex_exit(&nfsd_lock); a1325 2 KASSERT(mutex_owned(&nfsd_lock)); d1400 1 a1400 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d1471 2 a1472 2 error = VOP_SETATTR(nd.ni_vp, &va, cred); d1522 1 a1522 1 error = VOP_SETATTR(vp, &va, cred); d1531 1 a1531 1 error = VOP_GETATTR(vp, &va, cred); d1546 1 a1546 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d1615 1 a1615 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d1688 1 a1688 1 error = VOP_GETATTR(vp, &va, cred); d1692 1 a1692 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d1754 1 a1754 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d1785 1 a1785 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d1846 1 a1846 1 fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred); d1877 1 a1877 1 tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred); d1967 1 a1967 1 fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred); d1973 1 a1973 1 tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred); d2054 1 a2054 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2082 1 a2082 1 getret = VOP_GETATTR(vp, &at, cred); d2085 1 a2085 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2138 1 a2138 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2192 1 a2192 1 error = VOP_GETATTR(nd.ni_vp, &va, cred); d2203 1 a2203 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2269 1 a2269 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2304 1 a2304 1 error = VOP_GETATTR(vp, &va, cred); d2310 1 a2310 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2376 1 a2376 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2417 1 a2417 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2534 1 a2534 1 error = getret = VOP_GETATTR(vp, &at, cred); d2571 1 a2571 1 getret = VOP_GETATTR(vp, &at, cred); d2790 1 a2790 1 error = getret = VOP_GETATTR(vp, &at, cred); d2827 1 a2827 1 getret = VOP_GETATTR(vp, &at, cred); d2933 1 a2933 1 if (VOP_GETATTR(nvp, vap, cred)) { d3097 1 a3097 1 for_ret = VOP_GETATTR(vp, &bfor, cred); d3102 1 a3102 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end); d3104 1 a3104 1 aft_ret = VOP_GETATTR(vp, &aft, cred); d3155 2 a3156 2 error = VFS_STATVFS(vp->v_mount, sf); getret = VOP_GETATTR(vp, &at, cred); d3231 1 a3231 1 VFS_STATVFS(vp->v_mount, sb); d3235 1 a3235 1 getret = VOP_GETATTR(vp, &at, cred); d3308 1 a3308 1 getret = VOP_GETATTR(vp, &at, cred); d3421 1 a3421 1 error = VOP_GETATTR(vp, &vattr, cred); d3424 1 a3424 1 error = VOP_ACCESS(vp, flags, cred); @ 1.130.4.2 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.133 2007/12/22 03:31:15 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.133 2007/12/22 03:31:15 yamt Exp $"); a1511 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d1517 1 @ 1.130.4.3 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.134 2008/01/28 14:31:19 dholland Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.134 2008/01/28 14:31:19 dholland Exp $"); a1826 1 struct mount *localfs = NULL; a1830 1 uint32_t saveflag; a1863 29 localfs = fvp->v_mount; error = VFS_RENAMELOCK_ENTER(localfs); if (error) { VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); vrele(fvp); goto out1; } /* Copied, regrettably, from vfs_syscalls.c (q.v.) */ vrele(fvp); saveflag = fromnd.ni_cnd.cn_flags & SAVESTART; fromnd.ni_cnd.cn_flags &= ~SAVESTART; vn_lock(fromnd.ni_dvp, LK_EXCLUSIVE | LK_RETRY); error = relookup(fromnd.ni_dvp, &fromnd.ni_vp, &fromnd.ni_cnd); fromnd.ni_cnd.cn_flags |= saveflag; if (error) { VOP_UNLOCK(fromnd.ni_dvp, 0); VFS_RENAMELOCK_EXIT(localfs); VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); goto out1; } VOP_UNLOCK(fromnd.ni_vp, 0); if (fromnd.ni_dvp != fromnd.ni_vp) VOP_UNLOCK(fromnd.ni_dvp, 0); fvp = fromnd.ni_vp; a1883 1 VFS_RENAMELOCK_EXIT(localfs); a1951 1 VFS_RENAMELOCK_EXIT(localfs); a1959 1 VFS_RENAMELOCK_EXIT(localfs); a2000 3 if (localfs) { VFS_RENAMELOCK_EXIT(localfs); } @ 1.129 log @stop nfs tick when we have nothing to do. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.128 2007/04/06 14:28:28 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.128 2007/04/06 14:28:28 hannken Exp $"); d1765 1 a1765 1 if (vp->v_flag & VROOT) { d2400 1 a2400 1 if (vp->v_flag & VROOT) d3418 1 a3418 1 if (vp->v_flag & VTEXT) @ 1.129.10.1 log @file nfs_serv.c was added on branch matt-mips64 on 2007-07-27 10:03:59 +0000 @ text @d1 3432 @ 1.129.10.2 log @stop nfs tick when we have nothing to do. @ text @a0 3432 /* $NetBSD: nfs_serv.c,v 1.129 2007/07/27 10:03:58 yamt Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Rick Macklem at The University of Guelph. * * 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. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * @@(#)nfs_serv.c 8.8 (Berkeley) 7/31/95 */ /* * nfs version 2 and 3 server calls to vnode ops * - these routines generally have 3 phases * 1 - break down and validate rpc request in mbuf list * 2 - do the vnode ops for the request * (surprisingly ?? many are very similar to syscalls in vfs_syscalls.c) * 3 - build the rpc reply in an mbuf list * nb: * - do not mix the phases, since the nfsm_?? macros can return failures * on a bad rpc or similar and do not do any vrele() or vput()'s * * - the nfsm_reply() macro generates an nfs rpc reply with the nfs * error number iff error != 0 whereas * returning an error from the server function implies a fatal error * such as a badly constructed rpc request that should be dropped without * a reply. * For Version 3, nfsm_reply() does not return for the error case, since * most version 3 rpcs return more than the status for error cases. */ #include __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.129 2007/07/27 10:03:58 yamt Exp $"); #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include /* Global vars */ extern u_int32_t nfs_xdrneg1; extern u_int32_t nfs_false, nfs_true; extern enum vtype nv3tov_type[8]; extern struct nfsstats nfsstats; extern const nfstype nfsv2_type[9]; extern const nfstype nfsv3_type[9]; int nfsrvw_procrastinate = NFS_GATHERDELAY * 1000; int nfsd_use_loan = 1; /* use page-loan for READ OP */ #define nqsrv_getl(vp, rw) /* nothing */ /* * nfs v3 access service */ int nfsrv3_access(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct vnode *vp; nfsrvfh_t nsfh; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, getret; char *cp2; struct mbuf *mb, *mreq; struct vattr va; u_long inmode, testmode, outmode; u_quad_t frev; nfsm_srvmtofh(&nsfh); nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(1, (struct vattr *)0); return (0); } inmode = fxdr_unsigned(u_int32_t, *tl); outmode = 0; if ((inmode & NFSV3ACCESS_READ) && nfsrv_access(vp, VREAD, cred, rdonly, lwp, 0) == 0) outmode |= NFSV3ACCESS_READ; if (vp->v_type != VDIR) { testmode = inmode & (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND); if (testmode && nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0) == 0) outmode |= testmode; if ((inmode & NFSV3ACCESS_EXECUTE) && nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0) == 0) outmode |= NFSV3ACCESS_EXECUTE; } else { testmode = inmode & (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND | NFSV3ACCESS_DELETE); if (testmode && nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0) == 0) outmode |= testmode; if ((inmode & NFSV3ACCESS_LOOKUP) && nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0) == 0) outmode |= NFSV3ACCESS_LOOKUP; } getret = VOP_GETATTR(vp, &va, cred, lwp); vput(vp); nfsm_reply(NFSX_POSTOPATTR(1) + NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &va); nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); *tl = txdr_unsigned(outmode); nfsm_srvdone; } /* * nfs getattr service */ int nfsrv_getattr(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct nfs_fattr *fp; struct vattr va; struct vnode *vp; nfsrvfh_t nsfh; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0; char *cp2; struct mbuf *mb, *mreq; u_quad_t frev; nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(0); return (0); } nqsrv_getl(vp, ND_READ); error = VOP_GETATTR(vp, &va, cred, lwp); vput(vp); nfsm_reply(NFSX_FATTR(nfsd->nd_flag & ND_NFSV3)); if (error) return (0); nfsm_build(fp, struct nfs_fattr *, NFSX_FATTR(nfsd->nd_flag & ND_NFSV3)); nfsm_srvfillattr(&va, fp); nfsm_srvdone; } /* * nfs setattr service */ int nfsrv_setattr(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct vattr va, preat; struct nfsv2_sattr *sp; struct nfs_fattr *fp; struct vnode *vp; nfsrvfh_t nsfh; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, preat_ret = 1, postat_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3), gcheck = 0; char *cp2; struct mbuf *mb, *mreq; u_quad_t frev; struct timespec guard; memset(&guard, 0, sizeof guard); /* XXX gcc */ nfsm_srvmtofh(&nsfh); VATTR_NULL(&va); if (v3) { nfsm_srvsattr(&va); nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); gcheck = fxdr_unsigned(int, *tl); if (gcheck) { nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); fxdr_nfsv3time(tl, &guard); } } else { nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); /* * Nah nah nah nah na nah * There is a bug in the Sun client that puts 0xffff in the mode * field of sattr when it should put in 0xffffffff. The u_short * doesn't sign extend. * --> check the low order 2 bytes for 0xffff */ if ((fxdr_unsigned(int, sp->sa_mode) & 0xffff) != 0xffff) va.va_mode = nfstov_mode(sp->sa_mode); if (sp->sa_uid != nfs_xdrneg1) va.va_uid = fxdr_unsigned(uid_t, sp->sa_uid); if (sp->sa_gid != nfs_xdrneg1) va.va_gid = fxdr_unsigned(gid_t, sp->sa_gid); if (sp->sa_size != nfs_xdrneg1) va.va_size = fxdr_unsigned(u_quad_t, sp->sa_size); if (sp->sa_atime.nfsv2_sec != nfs_xdrneg1) { #ifdef notyet fxdr_nfsv2time(&sp->sa_atime, &va.va_atime); #else va.va_atime.tv_sec = fxdr_unsigned(u_int32_t,sp->sa_atime.nfsv2_sec); va.va_atime.tv_nsec = 0; #endif } if (sp->sa_mtime.nfsv2_sec != nfs_xdrneg1) fxdr_nfsv2time(&sp->sa_mtime, &va.va_mtime); } /* * Now that we have all the fields, lets do it. */ error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(preat_ret, &preat, postat_ret, &va); return (0); } nqsrv_getl(vp, ND_WRITE); if (v3) { error = preat_ret = VOP_GETATTR(vp, &preat, cred, lwp); if (!error && gcheck && (preat.va_ctime.tv_sec != guard.tv_sec || preat.va_ctime.tv_nsec != guard.tv_nsec)) error = NFSERR_NOT_SYNC; if (error) { vput(vp); nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(preat_ret, &preat, postat_ret, &va); return (0); } } /* * If the size is being changed write acces is required, otherwise * just check for a read only file system. */ if (va.va_size == ((u_quad_t)((quad_t) -1))) { if (rdonly || (vp->v_mount->mnt_flag & MNT_RDONLY)) { error = EROFS; goto out; } } else { if (vp->v_type == VDIR) { error = EISDIR; goto out; } else if ((error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0)) != 0) goto out; } error = VOP_SETATTR(vp, &va, cred, lwp); postat_ret = VOP_GETATTR(vp, &va, cred, lwp); if (!error) error = postat_ret; out: vput(vp); nfsm_reply(NFSX_WCCORFATTR(v3)); if (v3) { nfsm_srvwcc_data(preat_ret, &preat, postat_ret, &va); return (0); } else { nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(&va, fp); } nfsm_srvdone; } /* * nfs lookup rpc */ int nfsrv_lookup(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct nfs_fattr *fp; struct nameidata nd, ind, *ndp = &nd; struct vnode *vp, *dirp; nfsrvfh_t nsfh; char *cp; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, cache = 0, dirattr_ret = 1; uint32_t len; int v3 = (nfsd->nd_flag & ND_NFSV3), pubflag; char *cp2; struct mbuf *mb, *mreq; struct vattr va, dirattr; u_quad_t frev; nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); pubflag = nfs_ispublicfh(&nsfh); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag); if (!error && pubflag) { if (nd.ni_vp->v_type == VDIR && nfs_pub.np_index != NULL) { /* * Setup call to lookup() to see if we can find * the index file. Arguably, this doesn't belong * in a kernel.. Ugh. */ ind = nd; VOP_UNLOCK(nd.ni_vp, 0); ind.ni_pathlen = strlen(nfs_pub.np_index); ind.ni_cnd.cn_nameptr = ind.ni_cnd.cn_pnbuf = nfs_pub.np_index; ind.ni_startdir = nd.ni_vp; VREF(ind.ni_startdir); error = lookup(&ind); if (!error) { /* * Found an index file. Get rid of * the old references. */ if (dirp) vrele(dirp); dirp = nd.ni_vp; vrele(nd.ni_startdir); ndp = &ind; } else error = 0; } /* * If the public filehandle was used, check that this lookup * didn't result in a filehandle outside the publicly exported * filesystem. */ if (!error && ndp->ni_vp->v_mount != nfs_pub.np_mount) { vput(nd.ni_vp); error = EPERM; } } if (dirp) { if (v3) dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, lwp); vrele(dirp); } if (error) { nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(dirattr_ret, &dirattr); return (0); } nqsrv_getl(ndp->ni_startdir, ND_READ); PNBUF_PUT(nd.ni_cnd.cn_pnbuf); vp = ndp->ni_vp; error = nfsrv_composefh(vp, &nsfh, v3); if (!error) error = VOP_GETATTR(vp, &va, cred, lwp); vput(vp); vrele(ndp->ni_startdir); nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPORFATTR(v3) + NFSX_POSTOPATTR(v3)); if (error) { nfsm_srvpostop_attr(dirattr_ret, &dirattr); return (0); } nfsm_srvfhtom(&nsfh, v3); if (v3) { nfsm_srvpostop_attr(0, &va); nfsm_srvpostop_attr(dirattr_ret, &dirattr); } else { nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(&va, fp); } nfsm_srvdone; } /* * nfs readlink service */ int nfsrv_readlink(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct iovec iv[(NFS_MAXPATHLEN+MLEN-1)/MLEN]; struct iovec *ivp = iv; struct mbuf *mp; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, i, padlen, getret; uint32_t len; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mp2 = NULL, *mp3 = NULL, *mreq; struct vnode *vp; struct vattr attr; nfsrvfh_t nsfh; struct uio io, *uiop = &io; u_quad_t frev; nfsm_srvmtofh(&nsfh); len = 0; i = 0; while (len < NFS_MAXPATHLEN) { mp = m_get(M_WAIT, MT_DATA); MCLAIM(mp, &nfs_mowner); m_clget(mp, M_WAIT); mp->m_len = NFSMSIZ(mp); if (len == 0) mp3 = mp2 = mp; else { mp2->m_next = mp; mp2 = mp; } if ((len+mp->m_len) > NFS_MAXPATHLEN) { mp->m_len = NFS_MAXPATHLEN-len; len = NFS_MAXPATHLEN; } else len += mp->m_len; ivp->iov_base = mtod(mp, void *); ivp->iov_len = mp->m_len; i++; ivp++; } uiop->uio_iov = iv; uiop->uio_iovcnt = i; uiop->uio_offset = 0; uiop->uio_resid = len; uiop->uio_rw = UIO_READ; UIO_SETUP_SYSSPACE(uiop); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { m_freem(mp3); nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvpostop_attr(1, (struct vattr *)0); return (0); } if (vp->v_type != VLNK) { if (v3) error = EINVAL; else error = ENXIO; goto out; } nqsrv_getl(vp, ND_READ); error = VOP_READLINK(vp, uiop, cred); out: getret = VOP_GETATTR(vp, &attr, cred, lwp); vput(vp); if (error) m_freem(mp3); nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_UNSIGNED); if (v3) { nfsm_srvpostop_attr(getret, &attr); if (error) return (0); } len -= uiop->uio_resid; padlen = nfsm_padlen(len); if (uiop->uio_resid || padlen) nfs_zeropad(mp3, uiop->uio_resid, padlen); nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); *tl = txdr_unsigned(len); mb->m_next = mp3; nfsm_srvdone; } /* * nfs read service */ int nfsrv_read(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct mbuf *m; struct nfs_fattr *fp; u_int32_t *tl; int32_t t1; int i; char *bpos; int error = 0, rdonly, cache = 0, getret; int v3 = (nfsd->nd_flag & ND_NFSV3); uint32_t reqlen, len, cnt, left; int padlen; char *cp2; struct mbuf *mb, *mreq; struct vnode *vp; nfsrvfh_t nsfh; struct uio io, *uiop = &io; struct vattr va; off_t off; u_quad_t frev; nfsm_srvmtofh(&nsfh); if (v3) { nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); off = fxdr_hyper(tl); } else { nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); off = (off_t)fxdr_unsigned(u_int32_t, *tl); } nfsm_dissect(tl, uint32_t *, NFSX_UNSIGNED); reqlen = fxdr_unsigned(uint32_t, *tl); reqlen = MIN(reqlen, NFS_SRVMAXDATA(nfsd)); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvpostop_attr(1, (struct vattr *)0); return (0); } if (vp->v_type != VREG) { if (v3) error = EINVAL; else error = (vp->v_type == VDIR) ? EISDIR : EACCES; } if (!error) { nqsrv_getl(vp, ND_READ); if ((error = nfsrv_access(vp, VREAD, cred, rdonly, lwp, 1)) != 0) error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 1); } getret = VOP_GETATTR(vp, &va, cred, lwp); if (!error) error = getret; if (error) { vput(vp); nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(getret, &va); return (0); } if (off >= va.va_size) cnt = 0; else if ((off + reqlen) > va.va_size) cnt = va.va_size - off; else cnt = reqlen; nfsm_reply(NFSX_POSTOPORFATTR(v3) + 3 * NFSX_UNSIGNED+nfsm_rndup(cnt)); if (v3) { nfsm_build(tl, u_int32_t *, NFSX_V3FATTR + 4 * NFSX_UNSIGNED); *tl++ = nfs_true; fp = (struct nfs_fattr *)tl; tl += (NFSX_V3FATTR / sizeof (u_int32_t)); } else { nfsm_build(tl, u_int32_t *, NFSX_V2FATTR + NFSX_UNSIGNED); fp = (struct nfs_fattr *)tl; tl += (NFSX_V2FATTR / sizeof (u_int32_t)); } len = left = cnt; if (cnt > 0) { if (nfsd_use_loan) { struct vm_page **pgpp; voff_t pgoff = trunc_page(off); int npages; vaddr_t lva; npages = (round_page(off + cnt) - pgoff) >> PAGE_SHIFT; KASSERT(npages <= M_EXT_MAXPAGES); /* XXX */ /* allocate kva for mbuf data */ lva = sokvaalloc(npages << PAGE_SHIFT, slp->ns_so); if (lva == 0) { /* fall back to VOP_READ */ goto loan_fail; } /* allocate mbuf */ m = m_get(M_WAIT, MT_DATA); MCLAIM(m, &nfs_mowner); pgpp = m->m_ext.ext_pgs; /* loan pages */ error = uvm_loanuobjpages(&vp->v_uobj, pgoff, npages, pgpp); if (error) { sokvafree(lva, npages << PAGE_SHIFT); m_free(m); if (error == EBUSY) goto loan_fail; goto read_error; } /* associate kva to mbuf */ MEXTADD(m, (void *)(lva + ((vaddr_t)off & PAGE_MASK)), cnt, M_MBUF, soloanfree, slp->ns_so); m->m_flags |= M_EXT_PAGES | M_EXT_ROMAP; m->m_len = cnt; /* map pages */ for (i = 0; i < npages; i++) { pmap_kenter_pa(lva, VM_PAGE_TO_PHYS(pgpp[i]), VM_PROT_READ); lva += PAGE_SIZE; } pmap_update(pmap_kernel()); mb->m_next = m; mb = m; error = 0; uiop->uio_resid = 0; } else { struct iovec *iv; struct iovec *iv2; struct mbuf *m2; int siz; loan_fail: /* * Generate the mbuf list with the uio_iov ref. to it. */ i = 0; m = m2 = mb; while (left > 0) { siz = min(M_TRAILINGSPACE(m), left); if (siz > 0) { left -= siz; i++; } if (left > 0) { m = m_get(M_WAIT, MT_DATA); MCLAIM(m, &nfs_mowner); m_clget(m, M_WAIT); m->m_len = 0; m2->m_next = m; m2 = m; } } iv = malloc(i * sizeof(struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = iv2 = iv; m = mb; left = cnt; i = 0; while (left > 0) { if (m == NULL) panic("nfsrv_read iov"); siz = min(M_TRAILINGSPACE(m), left); if (siz > 0) { iv->iov_base = mtod(m, char *) + m->m_len; iv->iov_len = siz; m->m_len += siz; left -= siz; iv++; i++; } m = m->m_next; } uiop->uio_iovcnt = i; uiop->uio_offset = off; uiop->uio_resid = cnt; uiop->uio_rw = UIO_READ; UIO_SETUP_SYSSPACE(uiop); error = VOP_READ(vp, uiop, IO_NODELOCKED, cred); free((void *)iv2, M_TEMP); } read_error: if (error || (getret = VOP_GETATTR(vp, &va, cred, lwp)) != 0){ if (!error) error = getret; m_freem(mreq); vput(vp); nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(getret, &va); return (0); } } else { uiop->uio_resid = 0; } vput(vp); nfsm_srvfillattr(&va, fp); len -= uiop->uio_resid; padlen = nfsm_padlen(len); if (uiop->uio_resid || padlen) nfs_zeropad(mb, uiop->uio_resid, padlen); if (v3) { /* count */ *tl++ = txdr_unsigned(len); /* eof */ if (off + len >= va.va_size) *tl++ = nfs_true; else *tl++ = nfs_false; } *tl = txdr_unsigned(len); nfsm_srvdone; } /* * nfs write service */ int nfsrv_write(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct iovec *ivp; int i, cnt; struct mbuf *mp; struct nfs_fattr *fp; struct iovec *iv; struct vattr va, forat; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, len, forat_ret = 1; int ioflags, aftat_ret = 1, retlen, zeroing, adjust; int stable = NFSV3WRITE_FILESYNC; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq; struct vnode *vp; nfsrvfh_t nsfh; struct uio io, *uiop = &io; off_t off; u_quad_t frev; if (mrep == NULL) { *mrq = NULL; return (0); } nfsm_srvmtofh(&nsfh); if (v3) { nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); off = fxdr_hyper(tl); tl += 3; stable = fxdr_unsigned(int, *tl++); } else { nfsm_dissect(tl, u_int32_t *, 4 * NFSX_UNSIGNED); off = (off_t)fxdr_unsigned(u_int32_t, *++tl); tl += 2; } retlen = len = fxdr_unsigned(int32_t, *tl); cnt = i = 0; /* * For NFS Version 2, it is not obvious what a write of zero length * should do, but I might as well be consistent with Version 3, * which is to return ok so long as there are no permission problems. */ if (len > 0) { zeroing = 1; mp = mrep; while (mp) { if (mp == md) { zeroing = 0; adjust = dpos - mtod(mp, char *); mp->m_len -= adjust; if (mp->m_len > 0 && adjust > 0) NFSMADV(mp, adjust); } if (zeroing) mp->m_len = 0; else if (mp->m_len > 0) { i += mp->m_len; if (i > len) { mp->m_len -= (i - len); zeroing = 1; } if (mp->m_len > 0) cnt++; } mp = mp->m_next; } } if (len > NFS_MAXDATA || len < 0 || i < len) { error = EIO; nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); return (0); } error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); return (0); } if (v3) forat_ret = VOP_GETATTR(vp, &forat, cred, lwp); if (vp->v_type != VREG) { if (v3) error = EINVAL; else error = (vp->v_type == VDIR) ? EISDIR : EACCES; } if (!error) { nqsrv_getl(vp, ND_WRITE); error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 1); } if (error) { vput(vp); nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); return (0); } if (len > 0) { ivp = malloc(cnt * sizeof (struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = iv = ivp; uiop->uio_iovcnt = cnt; mp = mrep; while (mp) { if (mp->m_len > 0) { ivp->iov_base = mtod(mp, void *); ivp->iov_len = mp->m_len; ivp++; } mp = mp->m_next; } /* * XXX * The IO_METASYNC flag indicates that all metadata (and not * just enough to ensure data integrity) must be written to * stable storage synchronously. * (IO_METASYNC is not yet implemented in 4.4BSD-Lite.) */ if (stable == NFSV3WRITE_UNSTABLE) ioflags = IO_NODELOCKED; else if (stable == NFSV3WRITE_DATASYNC) ioflags = (IO_SYNC | IO_NODELOCKED); else ioflags = (IO_METASYNC | IO_SYNC | IO_NODELOCKED); uiop->uio_resid = len; uiop->uio_rw = UIO_WRITE; uiop->uio_offset = off; UIO_SETUP_SYSSPACE(uiop); error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; free(iv, M_TEMP); } aftat_ret = VOP_GETATTR(vp, &va, cred, lwp); vput(vp); if (!error) error = aftat_ret; nfsm_reply(NFSX_PREOPATTR(v3) + NFSX_POSTOPORFATTR(v3) + 2 * NFSX_UNSIGNED + NFSX_WRITEVERF(v3)); if (v3) { nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); if (error) return (0); nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(retlen); if (stable == NFSV3WRITE_UNSTABLE) *tl++ = txdr_unsigned(stable); else *tl++ = txdr_unsigned(NFSV3WRITE_FILESYNC); /* * Actually, there is no need to txdr these fields, * but it may make the values more human readable, * for debugging purposes. */ *tl++ = txdr_unsigned(boottime.tv_sec); *tl = txdr_unsigned(boottime.tv_usec); } else { nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(&va, fp); } nfsm_srvdone; } /* * XXX elad: the original NFSW_SAMECRED() macro also made sure the * two nd_flag fields of the descriptors contained * ND_KERBAUTH. */ static int nfsrv_samecred(kauth_cred_t cred1, kauth_cred_t cred2) { int i, do_ngroups; if (kauth_cred_geteuid(cred1) != kauth_cred_geteuid(cred2)) return (0); if (kauth_cred_ngroups(cred1) != kauth_cred_ngroups(cred2)) return (0); do_ngroups = kauth_cred_ngroups(cred1); for (i = 0; i < do_ngroups; i++) if (kauth_cred_group(cred1, i) != kauth_cred_group(cred2, i)) return (0); return (1); } static struct nfsrvw_delayhash * nfsrv_nwdelayhash(struct nfssvc_sock *slp, const nfsrvfh_t *nsfh) { uint32_t hash; hash = hash32_buf(NFSRVFH_DATA(nsfh), NFSRVFH_SIZE(nsfh), HASH32_BUF_INIT); return &slp->ns_wdelayhashtbl[hash % NFS_WDELAYHASHSIZ]; } /* * NFS write service with write gathering support. Called when * nfsrvw_procrastinate > 0. * See: Chet Juszczak, "Improving the Write Performance of an NFS Server", * in Proc. of the Winter 1994 Usenix Conference, pg. 247-259, San Franscisco, * Jan. 1994. */ int nfsrv_writegather(ndp, slp, lwp, mrq) struct nfsrv_descript **ndp; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct timeval now; struct iovec *ivp; struct mbuf *mp; struct nfsrv_descript *wp, *nfsd, *owp, *swp; struct nfs_fattr *fp; int i = 0; struct iovec *iov; struct nfsrvw_delayhash *wpp; kauth_cred_t cred; struct vattr va, forat; u_int32_t *tl; int32_t t1; char *bpos, *dpos; int error = 0, rdonly, cache = 0, len = 0, forat_ret = 1; int ioflags, aftat_ret = 1, s, adjust, v3, zeroing; char *cp2; struct mbuf *mb, *mreq, *mrep, *md; struct vnode *vp; struct uio io, *uiop = &io; u_quad_t frev, cur_usec; *mrq = NULL; if (*ndp) { nfsd = *ndp; *ndp = NULL; mrep = nfsd->nd_mrep; md = nfsd->nd_md; dpos = nfsd->nd_dpos; cred = nfsd->nd_cr; v3 = (nfsd->nd_flag & ND_NFSV3); LIST_INIT(&nfsd->nd_coalesce); nfsd->nd_mreq = NULL; nfsd->nd_stable = NFSV3WRITE_FILESYNC; getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; nfsd->nd_time = cur_usec + nfsrvw_procrastinate; /* * Now, get the write header.. */ nfsm_srvmtofh(&nfsd->nd_fh); if (v3) { nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); nfsd->nd_off = fxdr_hyper(tl); tl += 3; nfsd->nd_stable = fxdr_unsigned(int, *tl++); } else { nfsm_dissect(tl, u_int32_t *, 4 * NFSX_UNSIGNED); nfsd->nd_off = (off_t)fxdr_unsigned(u_int32_t, *++tl); tl += 2; } len = fxdr_unsigned(int32_t, *tl); nfsd->nd_len = len; nfsd->nd_eoff = nfsd->nd_off + len; /* * Trim the header out of the mbuf list and trim off any trailing * junk so that the mbuf list has only the write data. */ zeroing = 1; i = 0; mp = mrep; while (mp) { if (mp == md) { zeroing = 0; adjust = dpos - mtod(mp, char *); mp->m_len -= adjust; if (mp->m_len > 0 && adjust > 0) NFSMADV(mp, adjust); } if (zeroing) mp->m_len = 0; else { i += mp->m_len; if (i > len) { mp->m_len -= (i - len); zeroing = 1; } } mp = mp->m_next; } if (len > NFS_MAXDATA || len < 0 || i < len) { nfsmout: m_freem(mrep); error = EIO; nfsm_writereply(2 * NFSX_UNSIGNED, v3); if (v3) nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); nfsd->nd_mreq = mreq; nfsd->nd_mrep = NULL; nfsd->nd_time = 0; } /* * Add this entry to the hash and time queues. */ s = splsoftclock(); owp = NULL; wp = LIST_FIRST(&slp->ns_tq); while (wp && wp->nd_time < nfsd->nd_time) { owp = wp; wp = LIST_NEXT(wp, nd_tq); } if (owp) { LIST_INSERT_AFTER(owp, nfsd, nd_tq); } else { LIST_INSERT_HEAD(&slp->ns_tq, nfsd, nd_tq); } if (nfsd->nd_mrep) { wpp = nfsrv_nwdelayhash(slp, &nfsd->nd_fh); owp = NULL; wp = LIST_FIRST(wpp); while (wp && nfsrv_comparefh(&nfsd->nd_fh, &wp->nd_fh)) { owp = wp; wp = LIST_NEXT(wp, nd_hash); } while (wp && wp->nd_off < nfsd->nd_off && !nfsrv_comparefh(&nfsd->nd_fh, &wp->nd_fh)) { owp = wp; wp = LIST_NEXT(wp, nd_hash); } if (owp) { LIST_INSERT_AFTER(owp, nfsd, nd_hash); /* * Search the hash list for overlapping entries and * coalesce. */ for(; nfsd && NFSW_CONTIG(owp, nfsd); nfsd = wp) { wp = LIST_NEXT(nfsd, nd_hash); if (nfsrv_samecred(owp->nd_cr, nfsd->nd_cr)) nfsrvw_coalesce(owp, nfsd); } } else { LIST_INSERT_HEAD(wpp, nfsd, nd_hash); } } splx(s); } /* * Now, do VOP_WRITE()s for any one(s) that need to be done now * and generate the associated reply mbuf list(s). */ loop1: getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; s = splsoftclock(); for (nfsd = LIST_FIRST(&slp->ns_tq); nfsd; nfsd = owp) { owp = LIST_NEXT(nfsd, nd_tq); if (nfsd->nd_time > cur_usec) break; if (nfsd->nd_mreq) continue; LIST_REMOVE(nfsd, nd_tq); LIST_REMOVE(nfsd, nd_hash); splx(s); mrep = nfsd->nd_mrep; nfsd->nd_mrep = NULL; cred = nfsd->nd_cr; v3 = (nfsd->nd_flag & ND_NFSV3); forat_ret = aftat_ret = 1; error = nfsrv_fhtovp(&nfsd->nd_fh, 1, &vp, cred, slp, nfsd->nd_nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (!error) { if (v3) forat_ret = VOP_GETATTR(vp, &forat, cred, lwp); if (vp->v_type != VREG) { if (v3) error = EINVAL; else error = (vp->v_type == VDIR) ? EISDIR : EACCES; } } else vp = NULL; if (!error) { nqsrv_getl(vp, ND_WRITE); error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 1); } if (nfsd->nd_stable == NFSV3WRITE_UNSTABLE) ioflags = IO_NODELOCKED; else if (nfsd->nd_stable == NFSV3WRITE_DATASYNC) ioflags = (IO_SYNC | IO_NODELOCKED); else ioflags = (IO_METASYNC | IO_SYNC | IO_NODELOCKED); uiop->uio_rw = UIO_WRITE; uiop->uio_offset = nfsd->nd_off; uiop->uio_resid = nfsd->nd_eoff - nfsd->nd_off; UIO_SETUP_SYSSPACE(uiop); if (uiop->uio_resid > 0) { mp = mrep; i = 0; while (mp) { if (mp->m_len > 0) i++; mp = mp->m_next; } uiop->uio_iovcnt = i; iov = malloc(i * sizeof (struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = ivp = iov; mp = mrep; while (mp) { if (mp->m_len > 0) { ivp->iov_base = mtod(mp, void *); ivp->iov_len = mp->m_len; ivp++; } mp = mp->m_next; } if (!error) { error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; } free((void *)iov, M_TEMP); } m_freem(mrep); if (vp) { aftat_ret = VOP_GETATTR(vp, &va, cred, lwp); vput(vp); } /* * Loop around generating replies for all write rpcs that have * now been completed. */ swp = nfsd; do { if (error) { nfsm_writereply(NFSX_WCCDATA(v3), v3); if (v3) { nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); } } else { nfsm_writereply(NFSX_PREOPATTR(v3) + NFSX_POSTOPORFATTR(v3) + 2 * NFSX_UNSIGNED + NFSX_WRITEVERF(v3), v3); if (v3) { nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(nfsd->nd_len); *tl++ = txdr_unsigned(swp->nd_stable); /* * Actually, there is no need to txdr these fields, * but it may make the values more human readable, * for debugging purposes. */ *tl++ = txdr_unsigned(boottime.tv_sec); *tl = txdr_unsigned(boottime.tv_usec); } else { nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(&va, fp); } } nfsd->nd_mreq = mreq; if (nfsd->nd_mrep) panic("nfsrv_write: nd_mrep not free"); /* * Done. Put it at the head of the timer queue so that * the final phase can return the reply. */ s = splsoftclock(); if (nfsd != swp) { nfsd->nd_time = 0; LIST_INSERT_HEAD(&slp->ns_tq, nfsd, nd_tq); } nfsd = LIST_FIRST(&swp->nd_coalesce); if (nfsd) { LIST_REMOVE(nfsd, nd_tq); } splx(s); } while (nfsd); s = splsoftclock(); swp->nd_time = 0; LIST_INSERT_HEAD(&slp->ns_tq, swp, nd_tq); splx(s); goto loop1; } nfs_timer_start(); splx(s); /* * Search for a reply to return. */ s = splsoftclock(); LIST_FOREACH(nfsd, &slp->ns_tq, nd_tq) { if (nfsd->nd_mreq) { LIST_REMOVE(nfsd, nd_tq); *mrq = nfsd->nd_mreq; *ndp = nfsd; break; } } splx(s); return (0); } /* * Coalesce the write request nfsd into owp. To do this we must: * - remove nfsd from the queues * - merge nfsd->nd_mrep into owp->nd_mrep * - update the nd_eoff and nd_stable for owp * - put nfsd on owp's nd_coalesce list * NB: Must be called at splsoftclock(). */ void nfsrvw_coalesce(owp, nfsd) struct nfsrv_descript *owp; struct nfsrv_descript *nfsd; { int overlap; struct mbuf *mp; struct nfsrv_descript *m; LIST_REMOVE(nfsd, nd_hash); LIST_REMOVE(nfsd, nd_tq); if (owp->nd_eoff < nfsd->nd_eoff) { overlap = owp->nd_eoff - nfsd->nd_off; if (overlap < 0) panic("nfsrv_coalesce: bad off"); if (overlap > 0) m_adj(nfsd->nd_mrep, overlap); mp = owp->nd_mrep; while (mp->m_next) mp = mp->m_next; mp->m_next = nfsd->nd_mrep; owp->nd_eoff = nfsd->nd_eoff; } else m_freem(nfsd->nd_mrep); nfsd->nd_mrep = NULL; if (nfsd->nd_stable == NFSV3WRITE_FILESYNC) owp->nd_stable = NFSV3WRITE_FILESYNC; else if (nfsd->nd_stable == NFSV3WRITE_DATASYNC && owp->nd_stable == NFSV3WRITE_UNSTABLE) owp->nd_stable = NFSV3WRITE_DATASYNC; LIST_INSERT_HEAD(&owp->nd_coalesce, nfsd, nd_tq); /* * nfsd might hold coalesce elements! Move them to owp. * Otherwise, requests may be lost and clients will be stuck. */ while ((m = LIST_FIRST(&nfsd->nd_coalesce)) != NULL) { LIST_REMOVE(m, nd_tq); LIST_INSERT_HEAD(&owp->nd_coalesce, m, nd_tq); } } /* * nfs create service * now does a truncate to 0 length via. setattr if it already exists */ int nfsrv_create(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct nfs_fattr *fp; struct vattr va, dirfor, diraft; struct nfsv2_sattr *sp; u_int32_t *tl; struct nameidata nd; char *cp; int32_t t1; char *bpos; int error = 0, cache = 0, len, tsize, dirfor_ret = 1, diraft_ret = 1; int rdev = 0; int v3 = (nfsd->nd_flag & ND_NFSV3), how, exclusive_flag = 0; char *cp2; struct mbuf *mb, *mreq; struct vnode *vp = NULL, *dirp = NULL; nfsrvfh_t nsfh; u_quad_t frev, tempsize; u_char cverf[NFSX_V3CREATEVERF]; nd.ni_cnd.cn_nameiop = 0; nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); } if (error) { nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); if (dirp) vrele(dirp); return (0); } VATTR_NULL(&va); if (v3) { va.va_mode = 0; nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); how = fxdr_unsigned(int, *tl); switch (how) { case NFSV3CREATE_GUARDED: if (nd.ni_vp) { error = EEXIST; break; } case NFSV3CREATE_UNCHECKED: nfsm_srvsattr(&va); break; case NFSV3CREATE_EXCLUSIVE: nfsm_dissect(cp, void *, NFSX_V3CREATEVERF); memcpy(cverf, cp, NFSX_V3CREATEVERF); exclusive_flag = 1; break; }; va.va_type = VREG; } else { nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); va.va_type = IFTOVT(fxdr_unsigned(u_int32_t, sp->sa_mode)); if (va.va_type == VNON) va.va_type = VREG; va.va_mode = nfstov_mode(sp->sa_mode); switch (va.va_type) { case VREG: tsize = fxdr_unsigned(int32_t, sp->sa_size); if (tsize != -1) va.va_size = (u_quad_t)tsize; break; case VCHR: case VBLK: case VFIFO: rdev = fxdr_unsigned(int32_t, sp->sa_size); break; default: break; }; } /* * Iff doesn't exist, create it * otherwise just truncate to 0 length * should I set the mode too ?? */ if (nd.ni_vp == NULL) { if (va.va_type == VREG || va.va_type == VSOCK) { nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va); if (!error) { if (exclusive_flag) { exclusive_flag = 0; VATTR_NULL(&va); /* * XXX * assuming NFSX_V3CREATEVERF * == sizeof(nfstime3) */ fxdr_nfsv3time(cverf, &va.va_atime); error = VOP_SETATTR(nd.ni_vp, &va, cred, lwp); } } } else if (va.va_type == VCHR || va.va_type == VBLK || va.va_type == VFIFO) { if (va.va_type == VCHR && rdev == 0xffffffff) va.va_type = VFIFO; if (va.va_type != VFIFO && (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL))) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); nfsm_reply(0); return (error); } else va.va_rdev = (dev_t)rdev; nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va); if (error) { nfsm_reply(0); } if (nd.ni_cnd.cn_flags & ISSYMLINK) { vput(nd.ni_vp); vrele(nd.ni_dvp); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); error = EINVAL; nfsm_reply(0); } } else { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); error = ENXIO; } vp = nd.ni_vp; } else { vp = nd.ni_vp; if (nd.ni_dvp == vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (!error && va.va_size != -1) { error = nfsrv_access(vp, VWRITE, cred, (nd.ni_cnd.cn_flags & RDONLY), lwp, 0); if (!error) { nqsrv_getl(vp, ND_WRITE); tempsize = va.va_size; VATTR_NULL(&va); va.va_size = tempsize; error = VOP_SETATTR(vp, &va, cred, lwp); } } if (error) vput(vp); } if (!error) { error = nfsrv_composefh(vp, &nsfh, v3); if (!error) error = VOP_GETATTR(vp, &va, cred, lwp); vput(vp); } if (v3) { if (exclusive_flag && !error) { /* * XXX assuming NFSX_V3CREATEVERF == sizeof(nfstime3) */ char oldverf[NFSX_V3CREATEVERF]; txdr_nfsv3time(&va.va_atime, oldverf); if (memcmp(cverf, oldverf, NFSX_V3CREATEVERF)) error = EEXIST; } if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } } if (dirp) { vrele(dirp); } nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { if (!error) { nfsm_srvpostop_fh(&nsfh); nfsm_srvpostop_attr(0, &va); } nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); } else { nfsm_srvfhtom(&nsfh, v3); nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(&va, fp); } return (0); nfsmout: if (dirp) vrele(dirp); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); return (error); } /* * nfs v3 mknod service */ int nfsrv_mknod(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct vattr va, dirfor, diraft; u_int32_t *tl; struct nameidata nd; int32_t t1; char *bpos; int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; u_int32_t major, minor; enum vtype vtyp; char *cp2; struct mbuf *mb, *mreq; struct vnode *vp, *dirp = (struct vnode *)0; nfsrvfh_t nsfh; u_quad_t frev; nd.ni_cnd.cn_nameiop = 0; nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (dirp) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); if (error) { nfsm_reply(NFSX_WCCDATA(1)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); if (dirp) vrele(dirp); return (0); } nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); vtyp = nfsv3tov_type(*tl); if (vtyp != VCHR && vtyp != VBLK && vtyp != VSOCK && vtyp != VFIFO) { error = NFSERR_BADTYPE; goto abort; } VATTR_NULL(&va); va.va_mode = 0; nfsm_srvsattr(&va); if (vtyp == VCHR || vtyp == VBLK) { dev_t rdev; nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); major = fxdr_unsigned(u_int32_t, *tl++); minor = fxdr_unsigned(u_int32_t, *tl); rdev = makedev(major, minor); if (major(rdev) != major || minor(rdev) != minor) { error = EINVAL; goto abort; } va.va_rdev = rdev; } /* * Iff doesn't exist, create it. */ if (nd.ni_vp) { error = EEXIST; abort: VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); goto out; } va.va_type = vtyp; if (vtyp == VSOCK) { nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va); } else { if (va.va_type != VFIFO && (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL))) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); goto out; } nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va); if (error) goto out; if (nd.ni_cnd.cn_flags & ISSYMLINK) { vput(nd.ni_vp); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); error = EINVAL; } } out: vp = nd.ni_vp; if (!error) { error = nfsrv_composefh(vp, &nsfh, true); if (!error) error = VOP_GETATTR(vp, &va, cred, lwp); vput(vp); } if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); } nfsm_reply(NFSX_SRVFH(&nsfh, true) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1)); if (!error) { nfsm_srvpostop_fh(&nsfh); nfsm_srvpostop_attr(0, &va); } nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); nfsmout: VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); if (dirp) vrele(dirp); return (error); } /* * nfs remove service */ int nfsrv_remove(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct nameidata nd; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq; struct vnode *vp, *dirp; struct vattr dirfor, diraft; nfsrvfh_t nsfh; u_quad_t frev; #ifndef nolint vp = (struct vnode *)0; #endif nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = DELETE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); } if (!error) { vp = nd.ni_vp; if (vp->v_type == VDIR && (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL)) != 0) goto out; /* * The root of a mounted filesystem cannot be deleted. */ if (vp->v_flag & VROOT) { error = EBUSY; goto out; } out: if (!error) { nqsrv_getl(nd.ni_dvp, ND_WRITE); nqsrv_getl(vp, ND_WRITE); error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); } else { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); vput(vp); } } if (dirp) { if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } vrele(dirp); } nfsm_reply(NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); } nfsm_srvdone; } /* * nfs rename service */ int nfsrv_rename(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, cache = 0, fdirfor_ret = 1, fdiraft_ret = 1; uint32_t len, len2; int tdirfor_ret = 1, tdiraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq; struct nameidata fromnd, tond; struct vnode *fvp, *tvp, *tdvp; struct vnode *fdirp = NULL, *tdirp = NULL; struct vattr fdirfor, fdiraft, tdirfor, tdiraft; nfsrvfh_t fnsfh, tnsfh; u_quad_t frev; uid_t saved_uid; #ifndef nolint fvp = (struct vnode *)0; #endif fromnd.ni_cnd.cn_nameiop = 0; tond.ni_cnd.cn_nameiop = 0; nfsm_srvmtofh(&fnsfh); nfsm_srvnamesiz(len); /* * Remember our original uid so that we can reset cr_uid before * the second nfs_namei() call, in case it is remapped. */ saved_uid = kauth_cred_geteuid(cred); fromnd.ni_cnd.cn_cred = cred; fromnd.ni_cnd.cn_nameiop = DELETE; fromnd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART; error = nfs_namei(&fromnd, &fnsfh, len, slp, nam, &md, &dpos, &fdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (fdirp && v3) { fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, lwp); } if (error) { nfsm_reply(2 * NFSX_WCCDATA(v3)); nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft); nfsm_srvwcc_data(tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft); if (fdirp) vrele(fdirp); return (0); } if (fromnd.ni_dvp != fromnd.ni_vp) { VOP_UNLOCK(fromnd.ni_dvp, 0); } fvp = fromnd.ni_vp; nfsm_srvmtofh(&tnsfh); if (v3) { nfsm_dissect(tl, uint32_t *, NFSX_UNSIGNED); len2 = fxdr_unsigned(uint32_t, *tl); /* len2 will be checked by nfs_namei */ } else { /* NFSv2 */ nfsm_strsiz(len2, NFS_MAXNAMLEN); } kauth_cred_seteuid(cred, saved_uid); tond.ni_cnd.cn_cred = cred; tond.ni_cnd.cn_nameiop = RENAME; tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART; error = nfs_namei(&tond, &tnsfh, len2, slp, nam, &md, &dpos, &tdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (tdirp && v3) { tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, lwp); } if (error) { VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); vrele(fvp); goto out1; } tdvp = tond.ni_dvp; tvp = tond.ni_vp; if (tvp != NULL) { if (fvp->v_type == VDIR && tvp->v_type != VDIR) { if (v3) error = EEXIST; else error = EISDIR; goto out; } else if (fvp->v_type != VDIR && tvp->v_type == VDIR) { if (v3) error = EEXIST; else error = ENOTDIR; goto out; } if (tvp->v_type == VDIR && tvp->v_mountedhere) { if (v3) error = EXDEV; else error = ENOTEMPTY; goto out; } } if (fvp->v_type == VDIR && fvp->v_mountedhere) { if (v3) error = EXDEV; else error = ENOTEMPTY; goto out; } if (fvp->v_mount != tdvp->v_mount) { if (v3) error = EXDEV; else error = ENOTEMPTY; goto out; } if (fvp == tdvp) { if (v3) error = EINVAL; else error = ENOTEMPTY; } /* * If source is the same as the destination (that is the * same vnode with the same name in the same directory), * then there is nothing to do. */ if (fvp == tvp && fromnd.ni_dvp == tdvp && fromnd.ni_cnd.cn_namelen == tond.ni_cnd.cn_namelen && !memcmp(fromnd.ni_cnd.cn_nameptr, tond.ni_cnd.cn_nameptr, fromnd.ni_cnd.cn_namelen)) error = -1; out: if (!error) { nqsrv_getl(fromnd.ni_dvp, ND_WRITE); nqsrv_getl(tdvp, ND_WRITE); if (tvp) { nqsrv_getl(tvp, ND_WRITE); } error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd, tond.ni_dvp, tond.ni_vp, &tond.ni_cnd); } else { VOP_ABORTOP(tond.ni_dvp, &tond.ni_cnd); if (tdvp == tvp) vrele(tdvp); else vput(tdvp); if (tvp) vput(tvp); VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); vrele(fvp); if (error == -1) error = 0; } vrele(tond.ni_startdir); PNBUF_PUT(tond.ni_cnd.cn_pnbuf); out1: if (fdirp) { if (v3) { fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, lwp); } vrele(fdirp); } if (tdirp) { if (v3) { tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, lwp); } vrele(tdirp); } vrele(fromnd.ni_startdir); PNBUF_PUT(fromnd.ni_cnd.cn_pnbuf); nfsm_reply(2 * NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft); nfsm_srvwcc_data(tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft); } return (0); nfsmout: if (fdirp) vrele(fdirp); #ifdef notdef if (tdirp) vrele(tdirp); #endif if (tond.ni_cnd.cn_nameiop) { vrele(tond.ni_startdir); PNBUF_PUT(tond.ni_cnd.cn_pnbuf); } if (fromnd.ni_cnd.cn_nameiop) { vrele(fromnd.ni_startdir); PNBUF_PUT(fromnd.ni_cnd.cn_pnbuf); VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); vrele(fvp); } return (error); } /* * nfs link service */ int nfsrv_link(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct nameidata nd; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; int getret = 1, v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq; struct vnode *vp, *xp, *dirp = (struct vnode *)0; struct vattr dirfor, diraft, at; nfsrvfh_t nsfh, dnsfh; u_quad_t frev; nfsm_srvmtofh(&nsfh); nfsm_srvmtofh(&dnsfh); nfsm_srvnamesiz(len); error = nfsrv_fhtovp(&nsfh, false, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); nfsm_srvpostop_attr(getret, &at); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); } if (vp->v_type == VDIR && (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, NULL)) != 0) goto out1; nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&nd, &dnsfh, len, slp, nam, &md, &dpos, &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); } if (error) goto out1; xp = nd.ni_vp; if (xp != NULL) { error = EEXIST; goto out; } xp = nd.ni_dvp; if (vp->v_mount != xp->v_mount) error = EXDEV; out: if (!error) { nqsrv_getl(vp, ND_WRITE); nqsrv_getl(xp, ND_WRITE); error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); } else { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); } out1: if (v3) getret = VOP_GETATTR(vp, &at, cred, lwp); if (dirp) { if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } vrele(dirp); } vrele(vp); nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { nfsm_srvpostop_attr(getret, &at); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); } nfsm_srvdone; } /* * nfs symbolic link service */ int nfsrv_symlink(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct vattr va, dirfor, diraft; struct nameidata nd; u_int32_t *tl; int32_t t1; struct nfsv2_sattr *sp; char *bpos, *pathcp = NULL, *cp2; struct uio io; struct iovec iv; int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1; uint32_t len, len2; int v3 = (nfsd->nd_flag & ND_NFSV3); struct mbuf *mb, *mreq; struct vnode *dirp = (struct vnode *)0; nfsrvfh_t nsfh; u_quad_t frev; nd.ni_cnd.cn_nameiop = 0; nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); } if (error) goto out; VATTR_NULL(&va); va.va_type = VLNK; if (v3) { va.va_mode = 0; nfsm_srvsattr(&va); nfsm_dissect(tl, uint32_t *, NFSX_UNSIGNED); len2 = fxdr_unsigned(uint32_t, *tl); if (len2 > PATH_MAX) { /* XXX should check _PC_NO_TRUNC */ error = ENAMETOOLONG; goto abortop; } } else { /* NFSv2 */ nfsm_strsiz(len2, NFS_MAXPATHLEN); } pathcp = malloc(len2 + 1, M_TEMP, M_WAITOK); iv.iov_base = pathcp; iv.iov_len = len2; io.uio_resid = len2; io.uio_offset = 0; io.uio_iov = &iv; io.uio_iovcnt = 1; io.uio_rw = UIO_READ; UIO_SETUP_SYSSPACE(&io); nfsm_mtouio(&io, len2); if (!v3) { nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); va.va_mode = fxdr_unsigned(u_int16_t, sp->sa_mode); } *(pathcp + len2) = '\0'; if (nd.ni_vp) { error = EEXIST; abortop: VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); goto out; } nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va, pathcp); if (!error) { if (v3) { error = nfsrv_composefh(nd.ni_vp, &nsfh, v3); if (!error) error = VOP_GETATTR(nd.ni_vp, &va, cred, lwp); vput(nd.ni_vp); } else { vput(nd.ni_vp); } } out: if (pathcp) free(pathcp, M_TEMP); if (dirp) { if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } vrele(dirp); } nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { if (!error) { nfsm_srvpostop_fh(&nsfh); nfsm_srvpostop_attr(0, &va); } nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); } return (0); nfsmout: VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); if (dirp) vrele(dirp); if (pathcp) free(pathcp, M_TEMP); return (error); } /* * nfs mkdir service */ int nfsrv_mkdir(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct vattr va, dirfor, diraft; struct nfs_fattr *fp; struct nameidata nd; char *cp; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq; struct vnode *vp, *dirp = (struct vnode *)0; nfsrvfh_t nsfh; u_quad_t frev; nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); } if (error) { nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); if (dirp) vrele(dirp); return (0); } VATTR_NULL(&va); if (v3) { va.va_mode = 0; nfsm_srvsattr(&va); } else { nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); va.va_mode = nfstov_mode(*tl++); } va.va_type = VDIR; vp = nd.ni_vp; if (vp != NULL) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); vrele(vp); error = EEXIST; goto out; } nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va); if (!error) { vp = nd.ni_vp; error = nfsrv_composefh(vp, &nsfh, v3); if (!error) error = VOP_GETATTR(vp, &va, cred, lwp); vput(vp); } out: if (dirp) { if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } vrele(dirp); } nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { if (!error) { nfsm_srvpostop_fh(&nsfh); nfsm_srvpostop_attr(0, &va); } nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); } else { nfsm_srvfhtom(&nsfh, v3); nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(&va, fp); } return (0); nfsmout: VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vrele(nd.ni_vp); if (dirp) vrele(dirp); return (error); } /* * nfs rmdir service */ int nfsrv_rmdir(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq; struct vnode *vp, *dirp = (struct vnode *)0; struct vattr dirfor, diraft; nfsrvfh_t nsfh; struct nameidata nd; u_quad_t frev; nfsm_srvmtofh(&nsfh); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = DELETE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); } if (error) { nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); if (dirp) vrele(dirp); return (0); } vp = nd.ni_vp; if (vp->v_type != VDIR) { error = ENOTDIR; goto out; } /* * No rmdir "." please. */ if (nd.ni_dvp == vp) { error = EINVAL; goto out; } /* * The root of a mounted filesystem cannot be deleted. */ if (vp->v_flag & VROOT) error = EBUSY; out: if (!error) { nqsrv_getl(nd.ni_dvp, ND_WRITE); nqsrv_getl(vp, ND_WRITE); error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); } else { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); vput(vp); } if (dirp) { if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } vrele(dirp); } nfsm_reply(NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); } nfsm_srvdone; } /* * nfs readdir service * - mallocs what it thinks is enough to read * count rounded up to a multiple of NFS_SRVDIRBLKSIZ <= NFS_MAXREADDIR * - calls VOP_READDIR() * - loops around building the reply * if the output generated exceeds count break out of loop * The nfsm_clget macro is used here so that the reply will be packed * tightly in mbuf clusters. * - it only knows that it has encountered eof when the VOP_READDIR() * reads nothing * - as such one readdir rpc will return eof false although you are there * and then the next will return eof * - it trims out records with d_fileno == 0 * this doesn't matter for Unix clients, but they might confuse clients * for other os'. * - it trims out records with d_type == DT_WHT * these cannot be seen through NFS (unless we extend the protocol) * NB: It is tempting to set eof to true if the VOP_READDIR() reads less * than requested, but this may not apply to all filesystems. For * example, client NFS does not { although it is never remote mounted * anyhow } * The alternate call nfsrv_readdirplus() does lookups as well. * PS: The NFS protocol spec. does not clarify what the "count" byte * argument is a count of.. just name strings and file id's or the * entire reply rpc or ... * I tried just file name and id sizes and it confused the Sun client, * so I am using the full rpc size now. The "paranoia.." comment refers * to including the status longwords that are not a part of the dir. * "entry" structures, but are in the rpc. */ #define NFS_SRVDIRBLKSIZ 1024 struct flrep { nfsuint64 fl_off; u_int32_t fl_postopok; u_int32_t fl_fattr[NFSX_V3FATTR / sizeof (u_int32_t)]; u_int32_t fl_fhok; u_int32_t fl_fhsize; }; int nfsrv_readdir(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; char *bp, *be; struct mbuf *mp; struct dirent *dp; char *cp; u_int32_t *tl; int32_t t1; char *bpos; struct mbuf *mb, *mreq, *mp2; char *cpos, *cend, *cp2, *rbuf; struct vnode *vp; struct vattr at; nfsrvfh_t nsfh; struct uio io; struct iovec iv; int len, nlen, rem, xfer, tsiz, i, error = 0, getret = 1; int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, ncookies; int v3 = (nfsd->nd_flag & ND_NFSV3); u_quad_t frev, off, toff, verf; off_t *cookies = NULL, *cookiep; nfsuint64 jar; nfsm_srvmtofh(&nsfh); if (v3) { nfsm_dissect(tl, u_int32_t *, 5 * NFSX_UNSIGNED); toff = fxdr_hyper(tl); tl += 2; verf = fxdr_hyper(tl); tl += 2; } else { nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); toff = fxdr_unsigned(u_quad_t, *tl++); } off = toff; cnt = fxdr_unsigned(int, *tl); siz = ((cnt + NFS_SRVDIRBLKSIZ - 1) & ~(NFS_SRVDIRBLKSIZ - 1)); xfer = NFS_SRVMAXDATA(nfsd); if (siz > xfer) siz = xfer; fullsiz = siz; error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (!error && vp->v_type != VDIR) { error = ENOTDIR; vput(vp); } if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } nqsrv_getl(vp, ND_READ); if (v3) { error = getret = VOP_GETATTR(vp, &at, cred, lwp); #ifdef NFS3_STRICTVERF /* * XXX This check is too strict for Solaris 2.5 clients. */ if (!error && toff && verf != at.va_filerev) error = NFSERR_BAD_COOKIE; #endif } if (!error) error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0); if (error) { vput(vp); nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(getret, &at); return (0); } VOP_UNLOCK(vp, 0); rbuf = malloc(siz, M_TEMP, M_WAITOK); again: iv.iov_base = rbuf; iv.iov_len = fullsiz; io.uio_iov = &iv; io.uio_iovcnt = 1; io.uio_offset = (off_t)off; io.uio_resid = fullsiz; io.uio_rw = UIO_READ; UIO_SETUP_SYSSPACE(&io); eofflag = 0; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = VOP_READDIR(vp, &io, cred, &eofflag, &cookies, &ncookies); off = (off_t)io.uio_offset; if (!cookies && !error) error = NFSERR_PERM; if (v3) { getret = VOP_GETATTR(vp, &at, cred, lwp); if (!error) error = getret; } VOP_UNLOCK(vp, 0); if (error) { vrele(vp); free((void *)rbuf, M_TEMP); if (cookies) free((void *)cookies, M_TEMP); nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(getret, &at); return (0); } if (io.uio_resid) { siz -= io.uio_resid; /* * If nothing read, return eof * rpc reply */ if (siz == 0) { vrele(vp); nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_COOKIEVERF(v3) + 2 * NFSX_UNSIGNED); if (v3) { nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED); txdr_hyper(at.va_filerev, tl); tl += 2; } else nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); *tl++ = nfs_false; *tl = nfs_true; free((void *)rbuf, M_TEMP); free((void *)cookies, M_TEMP); return (0); } } /* * Check for degenerate cases of nothing useful read. * If so go try again */ cpos = rbuf; cend = rbuf + siz; dp = (struct dirent *)cpos; cookiep = cookies; while (cpos < cend && ncookies > 0 && (dp->d_fileno == 0 || dp->d_type == DT_WHT)) { cpos += dp->d_reclen; dp = (struct dirent *)cpos; cookiep++; ncookies--; } if (cpos >= cend || ncookies == 0) { toff = off; siz = fullsiz; free(cookies, M_TEMP); cookies = NULL; goto again; } len = 3 * NFSX_UNSIGNED; /* paranoia, probably can be 0 */ nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_COOKIEVERF(v3) + siz); if (v3) { nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); txdr_hyper(at.va_filerev, tl); } mp = mp2 = mb; bp = bpos; be = bp + M_TRAILINGSPACE(mp); /* Loop through the records and build reply */ while (cpos < cend && ncookies > 0) { if (dp->d_fileno != 0 && dp->d_type != DT_WHT) { nlen = dp->d_namlen; rem = nfsm_rndup(nlen)-nlen; len += (4 * NFSX_UNSIGNED + nlen + rem); if (v3) len += 2 * NFSX_UNSIGNED; if (len > cnt) { eofflag = 0; break; } /* * Build the directory record xdr from * the dirent entry. */ nfsm_clget; *tl = nfs_true; bp += NFSX_UNSIGNED; if (v3) { nfsm_clget; *tl = txdr_unsigned(dp->d_fileno >> 32); bp += NFSX_UNSIGNED; } nfsm_clget; *tl = txdr_unsigned(dp->d_fileno); bp += NFSX_UNSIGNED; nfsm_clget; *tl = txdr_unsigned(nlen); bp += NFSX_UNSIGNED; /* And loop around copying the name */ xfer = nlen; cp = dp->d_name; while (xfer > 0) { nfsm_clget; if ((bp+xfer) > be) tsiz = be-bp; else tsiz = xfer; memcpy(bp, cp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } /* And null pad to an int32_t boundary */ for (i = 0; i < rem; i++) *bp++ = '\0'; nfsm_clget; /* Finish off the record */ txdr_hyper(*cookiep, &jar); if (v3) { *tl = jar.nfsuquad[0]; bp += NFSX_UNSIGNED; nfsm_clget; } *tl = jar.nfsuquad[1]; bp += NFSX_UNSIGNED; } cpos += dp->d_reclen; dp = (struct dirent *)cpos; cookiep++; ncookies--; } vrele(vp); nfsm_clget; *tl = nfs_false; bp += NFSX_UNSIGNED; nfsm_clget; if (eofflag) *tl = nfs_true; else *tl = nfs_false; bp += NFSX_UNSIGNED; if (mp != mb) { if (bp < be) mp->m_len = bp - mtod(mp, char *); } else mp->m_len += bp - bpos; free((void *)rbuf, M_TEMP); free((void *)cookies, M_TEMP); nfsm_srvdone; } int nfsrv_readdirplus(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; char *bp, *be; struct mbuf *mp; struct dirent *dp; char *cp; u_int32_t *tl; int32_t t1; char *bpos; struct mbuf *mb, *mreq, *mp2; char *cpos, *cend, *cp2, *rbuf; struct vnode *vp, *nvp; struct flrep fl; nfsrvfh_t nsfh; struct uio io; struct iovec iv; struct vattr va, at, *vap = &va; struct nfs_fattr *fp; int len, nlen, rem, xfer, tsiz, i, error = 0, getret = 1; int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, dirlen, ncookies; u_quad_t frev, off, toff, verf; off_t *cookies = NULL, *cookiep; nfsm_srvmtofh(&nsfh); nfsm_dissect(tl, u_int32_t *, 6 * NFSX_UNSIGNED); toff = fxdr_hyper(tl); tl += 2; verf = fxdr_hyper(tl); tl += 2; siz = fxdr_unsigned(int, *tl++); cnt = fxdr_unsigned(int, *tl); off = toff; siz = ((siz + NFS_SRVDIRBLKSIZ - 1) & ~(NFS_SRVDIRBLKSIZ - 1)); xfer = NFS_SRVMAXDATA(nfsd); if (siz > xfer) siz = xfer; fullsiz = siz; error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (!error && vp->v_type != VDIR) { error = ENOTDIR; vput(vp); } if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } error = getret = VOP_GETATTR(vp, &at, cred, lwp); #ifdef NFS3_STRICTVERF /* * XXX This check is too strict for Solaris 2.5 clients. */ if (!error && toff && verf != at.va_filerev) error = NFSERR_BAD_COOKIE; #endif if (!error) { nqsrv_getl(vp, ND_READ); error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0); } if (error) { vput(vp); nfsm_reply(NFSX_V3POSTOPATTR); nfsm_srvpostop_attr(getret, &at); return (0); } VOP_UNLOCK(vp, 0); rbuf = malloc(siz, M_TEMP, M_WAITOK); again: iv.iov_base = rbuf; iv.iov_len = fullsiz; io.uio_iov = &iv; io.uio_iovcnt = 1; io.uio_offset = (off_t)off; io.uio_resid = fullsiz; io.uio_rw = UIO_READ; UIO_SETUP_SYSSPACE(&io); eofflag = 0; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = VOP_READDIR(vp, &io, cred, &eofflag, &cookies, &ncookies); off = (u_quad_t)io.uio_offset; getret = VOP_GETATTR(vp, &at, cred, lwp); VOP_UNLOCK(vp, 0); /* * If the VGET operation doesn't work for this filesystem, * we can't support readdirplus. Returning NOTSUPP should * make clients fall back to plain readdir. * There's no need to check for VPTOFH as well, we wouldn't * even be here otherwise. */ if (!getret) { if ((getret = VFS_VGET(vp->v_mount, at.va_fileid, &nvp))) getret = (getret == EOPNOTSUPP) ? NFSERR_NOTSUPP : NFSERR_IO; else vput(nvp); } if (!cookies && !error) error = NFSERR_PERM; if (!error) error = getret; if (error) { vrele(vp); if (cookies) free((void *)cookies, M_TEMP); free((void *)rbuf, M_TEMP); nfsm_reply(NFSX_V3POSTOPATTR); nfsm_srvpostop_attr(getret, &at); return (0); } if (io.uio_resid) { siz -= io.uio_resid; /* * If nothing read, return eof * rpc reply */ if (siz == 0) { vrele(vp); nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF + 2 * NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_int32_t *, 4 * NFSX_UNSIGNED); txdr_hyper(at.va_filerev, tl); tl += 2; *tl++ = nfs_false; *tl = nfs_true; free((void *)cookies, M_TEMP); free((void *)rbuf, M_TEMP); return (0); } } /* * Check for degenerate cases of nothing useful read. * If so go try again */ cpos = rbuf; cend = rbuf + siz; dp = (struct dirent *)cpos; cookiep = cookies; while (cpos < cend && ncookies > 0 && (dp->d_fileno == 0 || dp->d_type == DT_WHT)) { cpos += dp->d_reclen; dp = (struct dirent *)cpos; cookiep++; ncookies--; } if (cpos >= cend || ncookies == 0) { toff = off; siz = fullsiz; free(cookies, M_TEMP); cookies = NULL; goto again; } dirlen = len = NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF + 2 * NFSX_UNSIGNED; nfsm_reply(cnt); nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); txdr_hyper(at.va_filerev, tl); mp = mp2 = mb; bp = bpos; be = bp + M_TRAILINGSPACE(mp); /* Loop through the records and build reply */ while (cpos < cend && ncookies > 0) { if (dp->d_fileno != 0 && dp->d_type != DT_WHT) { nfsrvfh_t nnsfh; nlen = dp->d_namlen; rem = nfsm_rndup(nlen)-nlen; /* * For readdir_and_lookup get the vnode using * the file number. */ if (VFS_VGET(vp->v_mount, dp->d_fileno, &nvp)) goto invalid; if (nfsrv_composefh(nvp, &nnsfh, true)) { vput(nvp); goto invalid; } if (VOP_GETATTR(nvp, vap, cred, lwp)) { vput(nvp); goto invalid; } vput(nvp); /* * If either the dircount or maxcount will be * exceeded, get out now. Both of these lengths * are calculated conservatively, including all * XDR overheads. */ len += (8 * NFSX_UNSIGNED + nlen + rem + NFSX_V3FH + NFSX_V3POSTOPATTR); dirlen += (6 * NFSX_UNSIGNED + nlen + rem); if (len > cnt || dirlen > fullsiz) { eofflag = 0; break; } /* * Build the directory record xdr from * the dirent entry. */ fp = (struct nfs_fattr *)&fl.fl_fattr; nfsm_srvfillattr(vap, fp); fl.fl_fhsize = txdr_unsigned(NFSX_V3FH); fl.fl_fhok = nfs_true; fl.fl_postopok = nfs_true; txdr_hyper(*cookiep, fl.fl_off.nfsuquad); nfsm_clget; *tl = nfs_true; bp += NFSX_UNSIGNED; nfsm_clget; *tl = txdr_unsigned(dp->d_fileno >> 32); bp += NFSX_UNSIGNED; nfsm_clget; *tl = txdr_unsigned(dp->d_fileno); bp += NFSX_UNSIGNED; nfsm_clget; *tl = txdr_unsigned(nlen); bp += NFSX_UNSIGNED; /* And loop around copying the name */ xfer = nlen; cp = dp->d_name; while (xfer > 0) { nfsm_clget; if ((bp + xfer) > be) tsiz = be - bp; else tsiz = xfer; memcpy(bp, cp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } /* And null pad to an int32_t boundary */ for (i = 0; i < rem; i++) *bp++ = '\0'; /* * Now copy the flrep structure out. */ xfer = sizeof(struct flrep); cp = (void *)&fl; while (xfer > 0) { nfsm_clget; if ((bp + xfer) > be) tsiz = be - bp; else tsiz = xfer; memcpy(bp, cp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } /* * ... and filehandle. */ xfer = NFSRVFH_SIZE(&nnsfh); cp = NFSRVFH_DATA(&nnsfh); while (xfer > 0) { nfsm_clget; if ((bp + xfer) > be) tsiz = be - bp; else tsiz = xfer; memcpy(bp, cp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } } invalid: cpos += dp->d_reclen; dp = (struct dirent *)cpos; cookiep++; ncookies--; } vrele(vp); nfsm_clget; *tl = nfs_false; bp += NFSX_UNSIGNED; nfsm_clget; if (eofflag) *tl = nfs_true; else *tl = nfs_false; bp += NFSX_UNSIGNED; if (mp != mb) { if (bp < be) mp->m_len = bp - mtod(mp, char *); } else mp->m_len += bp - bpos; free((void *)cookies, M_TEMP); free((void *)rbuf, M_TEMP); nfsm_srvdone; } /* * nfs commit service */ int nfsrv_commit(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct vattr bfor, aft; struct vnode *vp; nfsrvfh_t nsfh; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, for_ret = 1, aft_ret = 1, cache = 0; uint32_t cnt; char *cp2; struct mbuf *mb, *mreq; u_quad_t frev, off, end; nfsm_srvmtofh(&nsfh); nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED); off = fxdr_hyper(tl); tl += 2; cnt = fxdr_unsigned(uint32_t, *tl); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft); return (0); } for_ret = VOP_GETATTR(vp, &bfor, cred, lwp); end = (cnt > 0) ? off + cnt : vp->v_size; if (end < off || end > vp->v_size) end = vp->v_size; if (off < vp->v_size) error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, lwp); /* else error == 0, from nfsrv_fhtovp() */ aft_ret = VOP_GETATTR(vp, &aft, cred, lwp); vput(vp); nfsm_reply(NFSX_V3WCCDATA + NFSX_V3WRITEVERF); nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft); if (!error) { nfsm_build(tl, u_int32_t *, NFSX_V3WRITEVERF); *tl++ = txdr_unsigned(boottime.tv_sec); *tl = txdr_unsigned(boottime.tv_usec); } else { return (0); } nfsm_srvdone; } /* * nfs statfs service */ int nfsrv_statfs(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; struct statvfs *sf = NULL; struct nfs_statfs *sfp; u_int32_t *tl; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, getret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq; struct vnode *vp; struct vattr at; nfsrvfh_t nsfh; u_quad_t frev, tval; nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } sf = malloc(sizeof(*sf), M_TEMP, M_WAITOK); error = VFS_STATVFS(vp->v_mount, sf, lwp); getret = VOP_GETATTR(vp, &at, cred, lwp); vput(vp); nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_STATFS(v3)); if (v3) nfsm_srvpostop_attr(getret, &at); if (error) { free(sf, M_TEMP); return (0); } nfsm_build(sfp, struct nfs_statfs *, NFSX_STATFS(v3)); if (v3) { tval = (u_quad_t)((quad_t)sf->f_blocks * (quad_t)sf->f_frsize); txdr_hyper(tval, &sfp->sf_tbytes); tval = (u_quad_t)((quad_t)sf->f_bfree * (quad_t)sf->f_frsize); txdr_hyper(tval, &sfp->sf_fbytes); tval = (u_quad_t)((quad_t)sf->f_bavail * (quad_t)sf->f_frsize); txdr_hyper(tval, &sfp->sf_abytes); tval = (u_quad_t)sf->f_files; txdr_hyper(tval, &sfp->sf_tfiles); tval = (u_quad_t)sf->f_ffree; txdr_hyper(tval, &sfp->sf_ffiles); txdr_hyper(tval, &sfp->sf_afiles); sfp->sf_invarsec = 0; } else { sfp->sf_tsize = txdr_unsigned(NFS_MAXDGRAMDATA); sfp->sf_bsize = txdr_unsigned(sf->f_frsize); sfp->sf_blocks = txdr_unsigned(sf->f_blocks); sfp->sf_bfree = txdr_unsigned(sf->f_bfree); sfp->sf_bavail = txdr_unsigned(sf->f_bavail); } nfsmout: if (sf) free(sf, M_TEMP); return error; } /* * nfs fsinfo service */ int nfsrv_fsinfo(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; u_int32_t *tl; struct nfsv3_fsinfo *sip; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, getret = 1; uint32_t maxdata; char *cp2; struct mbuf *mb, *mreq; struct vnode *vp; struct vattr at; nfsrvfh_t nsfh; u_quad_t frev, maxfsize; struct statvfs *sb; nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } /* XXX Try to make a guess on the max file size. */ sb = malloc(sizeof(*sb), M_TEMP, M_WAITOK); VFS_STATVFS(vp->v_mount, sb, (struct lwp *)0); maxfsize = (u_quad_t)0x80000000 * sb->f_frsize - 1; free(sb, M_TEMP); getret = VOP_GETATTR(vp, &at, cred, lwp); vput(vp); nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3FSINFO); nfsm_srvpostop_attr(getret, &at); nfsm_build(sip, struct nfsv3_fsinfo *, NFSX_V3FSINFO); /* * XXX * There should be file system VFS OP(s) to get this information. * For now, assume ufs. */ if (slp->ns_so->so_type == SOCK_DGRAM) maxdata = NFS_MAXDGRAMDATA; else maxdata = NFS_MAXDATA; sip->fs_rtmax = txdr_unsigned(maxdata); sip->fs_rtpref = txdr_unsigned(maxdata); sip->fs_rtmult = txdr_unsigned(NFS_FABLKSIZE); sip->fs_wtmax = txdr_unsigned(maxdata); sip->fs_wtpref = txdr_unsigned(maxdata); sip->fs_wtmult = txdr_unsigned(NFS_FABLKSIZE); sip->fs_dtpref = txdr_unsigned(maxdata); txdr_hyper(maxfsize, &sip->fs_maxfilesize); sip->fs_timedelta.nfsv3_sec = 0; sip->fs_timedelta.nfsv3_nsec = txdr_unsigned(1); sip->fs_properties = txdr_unsigned(NFSV3FSINFO_LINK | NFSV3FSINFO_SYMLINK | NFSV3FSINFO_HOMOGENEOUS | NFSV3FSINFO_CANSETTIME); nfsm_srvdone; } /* * nfs pathconf service */ int nfsrv_pathconf(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; char *dpos = nfsd->nd_dpos; kauth_cred_t cred = nfsd->nd_cr; u_int32_t *tl; struct nfsv3_pathconf *pc; int32_t t1; char *bpos; int error = 0, rdonly, cache = 0, getret = 1; register_t linkmax, namemax, chownres, notrunc; char *cp2; struct mbuf *mb, *mreq; struct vnode *vp; struct vattr at; nfsrvfh_t nsfh; u_quad_t frev; nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); if (error) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } error = VOP_PATHCONF(vp, _PC_LINK_MAX, &linkmax); if (!error) error = VOP_PATHCONF(vp, _PC_NAME_MAX, &namemax); if (!error) error = VOP_PATHCONF(vp, _PC_CHOWN_RESTRICTED, &chownres); if (!error) error = VOP_PATHCONF(vp, _PC_NO_TRUNC, ¬runc); getret = VOP_GETATTR(vp, &at, cred, lwp); vput(vp); nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3PATHCONF); nfsm_srvpostop_attr(getret, &at); if (error) return (0); nfsm_build(pc, struct nfsv3_pathconf *, NFSX_V3PATHCONF); pc->pc_linkmax = txdr_unsigned(linkmax); pc->pc_namemax = txdr_unsigned(namemax); pc->pc_notrunc = txdr_unsigned(notrunc); pc->pc_chownrestricted = txdr_unsigned(chownres); /* * These should probably be supported by VOP_PATHCONF(), but * until msdosfs is exportable (why would you want to?), the * Unix defaults should be ok. */ pc->pc_caseinsensitive = nfs_false; pc->pc_casepreserving = nfs_true; nfsm_srvdone; } /* * Null operation, used by clients to ping server */ /* ARGSUSED */ int nfsrv_null(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep; char *bpos; int error = NFSERR_RETVOID, cache = 0; struct mbuf *mb, *mreq; u_quad_t frev; nfsm_reply(0); return (0); } /* * No operation, used for obsolete procedures */ /* ARGSUSED */ int nfsrv_noop(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) { struct mbuf *mrep = nfsd->nd_mrep; char *bpos; int error, cache = 0; struct mbuf *mb, *mreq; u_quad_t frev; if (nfsd->nd_repstat) error = nfsd->nd_repstat; else error = EPROCUNAVAIL; nfsm_reply(0); return (0); } /* * Perform access checking for vnodes obtained from file handles that would * refer to files already opened by a Unix client. You cannot just use * vn_writechk() and VOP_ACCESS() for two reasons. * 1 - You must check for exported rdonly as well as MNT_RDONLY for the write case * 2 - The owner is to be given access irrespective of mode bits for some * operations, so that processes that chmod after opening a file don't * break. I don't like this because it opens a security hole, but since * the nfs server opens a security hole the size of a barn door anyhow, * what the heck. * * The exception to rule 2 is EPERM. If a file is IMMUTABLE, VOP_ACCESS() * will return EPERM instead of EACCESS. EPERM is always an error. */ int nfsrv_access(vp, flags, cred, rdonly, lwp, override) struct vnode *vp; int flags; kauth_cred_t cred; int rdonly; struct lwp *lwp; int override; { struct vattr vattr; int error; if (flags & VWRITE) { /* Just vn_writechk() changed to check rdonly */ /* * Disallow write attempts on read-only file systems; * unless the file is a socket or a block or character * device resident on the file system. */ if (rdonly || (vp->v_mount->mnt_flag & MNT_RDONLY)) { switch (vp->v_type) { case VREG: case VDIR: case VLNK: return (EROFS); default: break; } } /* * If the vnode is in use as a process's text, * we can't allow writing. */ if (vp->v_flag & VTEXT) return (ETXTBSY); } error = VOP_GETATTR(vp, &vattr, cred, lwp); if (error) return (error); error = VOP_ACCESS(vp, flags, cred, lwp); /* * Allow certain operations for the owner (reads and writes * on files that are already open). */ if (override && error == EACCES && kauth_cred_geteuid(cred) == vattr.va_uid) error = 0; return error; } @ 1.129.6.1 log @sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.130 2007/10/10 20:42:31 ad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.130 2007/10/10 20:42:31 ad Exp $"); d1765 1 a1765 1 if (vp->v_vflag & VV_ROOT) { d2400 1 a2400 1 if (vp->v_vflag & VV_ROOT) d3418 1 a3418 1 if (vp->v_iflag & VI_TEXT) @ 1.129.6.2 log @sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.129.6.1 2007/11/06 23:34:21 matt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.129.6.1 2007/11/06 23:34:21 matt Exp $"); d155 1 a155 1 getret = VOP_GETATTR(vp, &va, cred); d198 1 a198 1 error = VOP_GETATTR(vp, &va, cred); d292 1 a292 1 error = preat_ret = VOP_GETATTR(vp, &preat, cred); d322 2 a323 2 error = VOP_SETATTR(vp, &va, cred); postat_ret = VOP_GETATTR(vp, &va, cred); d422 1 a422 1 dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred); d437 1 a437 1 error = VOP_GETATTR(vp, &va, cred); d536 1 a536 1 getret = VOP_GETATTR(vp, &attr, cred); d618 1 a618 1 getret = VOP_GETATTR(vp, &va, cred); d752 1 a752 1 if (error || (getret = VOP_GETATTR(vp, &va, cred)) != 0){ d880 1 a880 1 forat_ret = VOP_GETATTR(vp, &forat, cred); d933 1 a933 1 aftat_ret = VOP_GETATTR(vp, &va, cred); d1024 1 a1024 1 int ioflags, aftat_ret = 1, adjust, v3, zeroing; d1106 1 a1107 1 mutex_enter(&nfsd_lock); d1147 1 a1147 1 mutex_exit(&nfsd_lock); d1157 1 a1157 1 mutex_enter(&nfsd_lock); d1166 1 a1166 2 mutex_exit(&nfsd_lock); d1177 1 a1177 1 forat_ret = VOP_GETATTR(vp, &forat, cred); d1229 1 a1229 1 aftat_ret = VOP_GETATTR(vp, &va, cred); d1273 1 a1273 1 mutex_enter(&nfsd_lock); d1282 1 a1282 1 mutex_exit(&nfsd_lock); d1284 1 a1285 2 mutex_enter(&nfsd_lock); d1287 1 a1287 1 mutex_exit(&nfsd_lock); a1289 1 mutex_exit(&nfsd_lock); d1291 1 d1296 1 a1296 1 mutex_enter(&nfsd_lock); d1305 1 a1305 1 mutex_exit(&nfsd_lock); a1325 2 KASSERT(mutex_owned(&nfsd_lock)); d1400 1 a1400 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d1471 2 a1472 2 error = VOP_SETATTR(nd.ni_vp, &va, cred); a1507 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d1513 1 d1522 1 a1522 1 error = VOP_SETATTR(vp, &va, cred); d1531 1 a1531 1 error = VOP_GETATTR(vp, &va, cred); d1546 1 a1546 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d1615 1 a1615 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d1688 1 a1688 1 error = VOP_GETATTR(vp, &va, cred); d1692 1 a1692 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d1754 1 a1754 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d1785 1 a1785 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d1846 1 a1846 1 fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred); d1877 1 a1877 1 tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred); d1967 1 a1967 1 fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred); d1973 1 a1973 1 tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred); d2054 1 a2054 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2082 1 a2082 1 getret = VOP_GETATTR(vp, &at, cred); d2085 1 a2085 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2138 1 a2138 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2192 1 a2192 1 error = VOP_GETATTR(nd.ni_vp, &va, cred); d2203 1 a2203 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2269 1 a2269 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2304 1 a2304 1 error = VOP_GETATTR(vp, &va, cred); d2310 1 a2310 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2376 1 a2376 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2417 1 a2417 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2534 1 a2534 1 error = getret = VOP_GETATTR(vp, &at, cred); d2571 1 a2571 1 getret = VOP_GETATTR(vp, &at, cred); d2790 1 a2790 1 error = getret = VOP_GETATTR(vp, &at, cred); d2827 1 a2827 1 getret = VOP_GETATTR(vp, &at, cred); d2933 1 a2933 1 if (VOP_GETATTR(nvp, vap, cred)) { d3097 1 a3097 1 for_ret = VOP_GETATTR(vp, &bfor, cred); d3102 1 a3102 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end); d3104 1 a3104 1 aft_ret = VOP_GETATTR(vp, &aft, cred); d3155 2 a3156 2 error = VFS_STATVFS(vp->v_mount, sf); getret = VOP_GETATTR(vp, &at, cred); d3231 1 a3231 1 VFS_STATVFS(vp->v_mount, sb); d3235 1 a3235 1 getret = VOP_GETATTR(vp, &at, cred); d3308 1 a3308 1 getret = VOP_GETATTR(vp, &at, cred); d3421 1 a3421 1 error = VOP_GETATTR(vp, &vattr, cred); d3424 1 a3424 1 error = VOP_ACCESS(vp, flags, cred); @ 1.129.6.3 log @sync with HEAD @ text @d1 1 a1 1 /* nfs_serv.c,v 1.129.6.2 2008/01/09 01:57:52 matt Exp */ d58 1 a58 1 __KERNEL_RCSID(0, "nfs_serv.c,v 1.129.6.2 2008/01/09 01:57:52 matt Exp"); d88 1 a88 1 extern const enum vtype nv3tov_type[8]; d1484 2 a1485 2 (error = kauth_authorize_system(cred, KAUTH_SYSTEM_MKNOD, 0, NULL, NULL, NULL))) { d1671 2 a1672 2 (error = kauth_authorize_system(cred, KAUTH_SYSTEM_MKNOD, 0, NULL, NULL, NULL))) { d1762 3 a1764 2 if (vp->v_type == VDIR) { error = EPERM; a1765 1 } d1771 1 a1826 1 struct mount *localfs = NULL; a1830 1 uint32_t saveflag; a1863 29 localfs = fvp->v_mount; error = VFS_RENAMELOCK_ENTER(localfs); if (error) { VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); vrele(fvp); goto out1; } /* Copied, regrettably, from vfs_syscalls.c (q.v.) */ vrele(fvp); saveflag = fromnd.ni_cnd.cn_flags & SAVESTART; fromnd.ni_cnd.cn_flags &= ~SAVESTART; vn_lock(fromnd.ni_dvp, LK_EXCLUSIVE | LK_RETRY); error = relookup(fromnd.ni_dvp, &fromnd.ni_vp, &fromnd.ni_cnd); fromnd.ni_cnd.cn_flags |= saveflag; if (error) { VOP_UNLOCK(fromnd.ni_dvp, 0); VFS_RENAMELOCK_EXIT(localfs); VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); goto out1; } VOP_UNLOCK(fromnd.ni_vp, 0); if (fromnd.ni_dvp != fromnd.ni_vp) VOP_UNLOCK(fromnd.ni_dvp, 0); fvp = fromnd.ni_vp; a1883 1 VFS_RENAMELOCK_EXIT(localfs); a1951 1 VFS_RENAMELOCK_EXIT(localfs); a1959 1 VFS_RENAMELOCK_EXIT(localfs); a2000 3 if (localfs) { VFS_RENAMELOCK_EXIT(localfs); } d2049 2 a2050 2 if (vp->v_type == VDIR) { error = EPERM; a2051 1 } @ 1.129.4.1 log @Sync with HEAD. Follow the merge of pmap.c on i386 and amd64 and move pmap_init_tmp_pgtbl into arch/x86/x86/pmap.c. Modify the ACPI wakeup code to restore CR4 before jumping back into kernel space as the large page option might cover that. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.129 2007/07/27 10:03:58 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.129 2007/07/27 10:03:58 yamt Exp $"); d1765 1 a1765 1 if (vp->v_vflag & VV_ROOT) { d2400 1 a2400 1 if (vp->v_vflag & VV_ROOT) d3418 1 a3418 1 if (vp->v_iflag & VI_TEXT) @ 1.129.4.2 log @Sync with HEAD. amd64 Xen support needs testing. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.129.4.1 2007/10/26 15:49:12 joerg Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.129.4.1 2007/10/26 15:49:12 joerg Exp $"); d155 1 a155 1 getret = VOP_GETATTR(vp, &va, cred); d198 1 a198 1 error = VOP_GETATTR(vp, &va, cred); d292 1 a292 1 error = preat_ret = VOP_GETATTR(vp, &preat, cred); d322 2 a323 2 error = VOP_SETATTR(vp, &va, cred); postat_ret = VOP_GETATTR(vp, &va, cred); d422 1 a422 1 dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred); d437 1 a437 1 error = VOP_GETATTR(vp, &va, cred); d536 1 a536 1 getret = VOP_GETATTR(vp, &attr, cred); d618 1 a618 1 getret = VOP_GETATTR(vp, &va, cred); d752 1 a752 1 if (error || (getret = VOP_GETATTR(vp, &va, cred)) != 0){ d880 1 a880 1 forat_ret = VOP_GETATTR(vp, &forat, cred); d933 1 a933 1 aftat_ret = VOP_GETATTR(vp, &va, cred); d1177 1 a1177 1 forat_ret = VOP_GETATTR(vp, &forat, cred); d1229 1 a1229 1 aftat_ret = VOP_GETATTR(vp, &va, cred); d1400 1 a1400 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d1471 2 a1472 2 error = VOP_SETATTR(nd.ni_vp, &va, cred); d1522 1 a1522 1 error = VOP_SETATTR(vp, &va, cred); d1531 1 a1531 1 error = VOP_GETATTR(vp, &va, cred); d1546 1 a1546 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d1615 1 a1615 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d1688 1 a1688 1 error = VOP_GETATTR(vp, &va, cred); d1692 1 a1692 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d1754 1 a1754 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d1785 1 a1785 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d1846 1 a1846 1 fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred); d1877 1 a1877 1 tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred); d1967 1 a1967 1 fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred); d1973 1 a1973 1 tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred); d2054 1 a2054 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2082 1 a2082 1 getret = VOP_GETATTR(vp, &at, cred); d2085 1 a2085 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2138 1 a2138 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2192 1 a2192 1 error = VOP_GETATTR(nd.ni_vp, &va, cred); d2203 1 a2203 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2269 1 a2269 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2304 1 a2304 1 error = VOP_GETATTR(vp, &va, cred); d2310 1 a2310 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2376 1 a2376 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2417 1 a2417 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2534 1 a2534 1 error = getret = VOP_GETATTR(vp, &at, cred); d2571 1 a2571 1 getret = VOP_GETATTR(vp, &at, cred); d2790 1 a2790 1 error = getret = VOP_GETATTR(vp, &at, cred); d2827 1 a2827 1 getret = VOP_GETATTR(vp, &at, cred); d2933 1 a2933 1 if (VOP_GETATTR(nvp, vap, cred)) { d3097 1 a3097 1 for_ret = VOP_GETATTR(vp, &bfor, cred); d3102 1 a3102 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end); d3104 1 a3104 1 aft_ret = VOP_GETATTR(vp, &aft, cred); d3155 2 a3156 2 error = VFS_STATVFS(vp->v_mount, sf); getret = VOP_GETATTR(vp, &at, cred); d3231 1 a3231 1 VFS_STATVFS(vp->v_mount, sb); d3235 1 a3235 1 getret = VOP_GETATTR(vp, &at, cred); d3308 1 a3308 1 getret = VOP_GETATTR(vp, &at, cred); d3421 1 a3421 1 error = VOP_GETATTR(vp, &vattr, cred); d3424 1 a3424 1 error = VOP_ACCESS(vp, flags, cred); @ 1.129.4.3 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.132 2007/12/04 17:42:30 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.132 2007/12/04 17:42:30 yamt Exp $"); d1024 1 a1024 1 int ioflags, aftat_ret = 1, adjust, v3, zeroing; d1106 1 a1107 1 mutex_enter(&nfsd_lock); d1147 1 a1147 1 mutex_exit(&nfsd_lock); d1157 1 a1157 1 mutex_enter(&nfsd_lock); d1166 1 a1166 2 mutex_exit(&nfsd_lock); d1273 1 a1273 1 mutex_enter(&nfsd_lock); d1282 1 a1282 1 mutex_exit(&nfsd_lock); d1284 1 a1285 2 mutex_enter(&nfsd_lock); d1287 1 a1287 1 mutex_exit(&nfsd_lock); a1289 1 mutex_exit(&nfsd_lock); d1291 1 d1296 1 a1296 1 mutex_enter(&nfsd_lock); d1305 1 a1305 1 mutex_exit(&nfsd_lock); a1325 2 KASSERT(mutex_owned(&nfsd_lock)); @ 1.129.8.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.129 2007/07/27 10:03:58 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.129 2007/07/27 10:03:58 yamt Exp $"); d1765 1 a1765 1 if (vp->v_vflag & VV_ROOT) { d2400 1 a2400 1 if (vp->v_vflag & VV_ROOT) d3418 1 a3418 1 if (vp->v_iflag & VI_TEXT) @ 1.128 log @Remove calls to now obsolete vn_start_write() and vn_finished_write(). @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.127 2007/03/05 23:18:50 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.127 2007/03/05 23:18:50 yamt Exp $"); d1290 1 @ 1.128.4.1 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.129 2007/07/27 10:03:58 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.129 2007/07/27 10:03:58 yamt Exp $"); a1289 1 nfs_timer_start(); @ 1.127 log @nfsrv_setattr: revive nfsm_srvsattr which was (mistakenly?) removed with caddr_t. @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); a235 1 struct mount *mp = NULL; a239 3 if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a287 1 vn_finished_write(mp, 0); a300 1 vn_finished_write(mp, 0); a327 1 vn_finished_write(mp, 0); a816 1 struct mount *mntp = NULL; a822 3 if ((mntp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mntp, V_WAIT); a869 1 vn_finished_write(mntp, 0); a876 1 vn_finished_write(mntp, 0); a894 1 vn_finished_write(mntp, 0); a934 1 vn_finished_write(mntp, 0); a1029 1 struct mount *mntp = NULL; d1222 2 a1223 10 if (vn_start_write(vp, &mntp, V_NOWAIT) != 0) { VOP_UNLOCK(vp, 0); vn_start_write(NULL, &mntp, V_WAIT); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); } if (!error) { error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; vn_finished_write(mntp, 0); } a1388 1 struct mount *mp = NULL; a1391 3 if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a1405 1 vn_finished_write(mp, 0); a1483 1 vn_finished_write(mp, 0); a1562 1 vn_finished_write(mp, 0); a1573 1 vn_finished_write(mp, 0); a1603 1 struct mount *mp = NULL; a1606 3 if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a1619 1 vn_finished_write(mp, 0); a1700 1 vn_finished_write(mp, 0); a1711 1 vn_finished_write(mp, 0); a1740 1 struct mount *mp = NULL; a1745 3 if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a1790 1 vn_finished_write(mp, 0); a1792 1 vn_finished_write(mp, 0); a1825 1 struct mount *mp = NULL; a1832 3 if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&fnsfh)->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a1852 1 vn_finished_write(mp, 0); a1982 1 vn_finished_write(mp, 0); a2031 1 struct mount *mp = NULL; a2033 3 if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a2041 1 vn_finished_write(mp, 0); a2092 1 vn_finished_write(mp, 0); a2094 1 vn_finished_write(mp, 0); a2126 1 struct mount *mp = NULL; a2129 3 if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a2214 1 vn_finished_write(mp, 0); a2227 1 vn_finished_write(mp, 0); a2258 1 struct mount *mp = NULL; a2260 3 if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a2274 1 vn_finished_write(mp, 0); a2325 1 vn_finished_write(mp, 0); a2336 1 vn_finished_write(mp, 0); a2365 1 struct mount *mp = NULL; a2367 3 if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a2381 1 vn_finished_write(mp, 0); a2422 1 vn_finished_write(mp, 0); a2424 1 vn_finished_write(mp, 0); a3081 1 struct mount *mp = NULL; a3083 3 if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a3093 1 vn_finished_write(mp, 0); a3111 1 vn_finished_write(mp, 0); a3113 1 vn_finished_write(mp, 0); @ 1.127.4.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.128 2007/04/06 14:28:28 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.128 2007/04/06 14:28:28 hannken Exp $"); d236 1 d241 3 d292 1 d306 1 d334 1 d824 1 d831 3 d881 1 d889 1 d908 1 d949 1 d1045 1 d1238 10 a1247 2 error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; d1413 1 d1417 3 d1434 1 d1513 1 d1593 1 d1605 1 d1636 1 d1640 3 d1656 1 d1738 1 d1750 1 d1780 1 d1786 3 d1834 1 d1837 1 d1871 1 d1879 3 d1902 1 d2033 1 d2083 1 d2086 3 d2097 1 d2149 1 d2152 1 d2185 1 d2189 3 d2277 1 d2291 1 d2323 1 d2326 3 d2343 1 d2395 1 d2407 1 d2437 1 d2440 3 d2457 1 d2499 1 d2502 1 d3160 1 d3163 3 d3176 1 d3195 1 d3198 1 @ 1.127.2.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.127 2007/03/05 23:18:50 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.127 2007/03/05 23:18:50 yamt Exp $"); d236 1 d241 3 d292 1 d306 1 d334 1 d824 1 d831 3 d881 1 d889 1 d908 1 d949 1 d1045 1 d1238 10 a1247 2 error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; d1413 1 d1417 3 d1434 1 d1513 1 d1593 1 d1605 1 d1636 1 d1640 3 d1656 1 d1738 1 d1750 1 d1780 1 d1786 3 d1834 1 d1837 1 d1871 1 d1879 3 d1902 1 d2033 1 d2083 1 d2086 3 d2097 1 d2149 1 d2152 1 d2185 1 d2189 3 d2277 1 d2291 1 d2323 1 d2326 3 d2343 1 d2395 1 d2407 1 d2437 1 d2440 3 d2457 1 d2499 1 d2502 1 d3160 1 d3163 3 d3176 1 d3195 1 d3198 1 @ 1.127.2.2 log @- Increase the number of thread priorities from 128 to 256. How the space is set up is to be revisited. - Implement soft interrupts as kernel threads. A generic implementation is provided, with hooks for fast-path MD code that can run the interrupt threads over the top of other threads executing in the kernel. - Split vnode::v_flag into three fields, depending on how the flag is locked (by the interlock, by the vnode lock, by the file system). - Miscellaneous locking fixes and improvements. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.127.2.1 2007/04/10 13:26:54 ad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.127.2.1 2007/04/10 13:26:54 ad Exp $"); d1764 1 a1764 1 if (vp->v_vflag & VV_ROOT) { d2399 1 a2399 1 if (vp->v_vflag & VV_ROOT) d3417 1 a3417 1 if (vp->v_iflag & VI_TEXT) @ 1.127.2.3 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.127.2.2 2007/06/17 21:31:56 ad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.127.2.2 2007/06/17 21:31:56 ad Exp $"); a1289 1 nfs_timer_start(); @ 1.127.2.4 log @- mark nfssvc(2) MPSAFE and move the most of nfsd out of the kernel lock. - remove unused ns_solock. - remove some of KERNEL_LOCK/UNLOCK which are not necessary on this branch. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.127.2.3 2007/08/20 21:28:11 ad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.127.2.3 2007/08/20 21:28:11 ad Exp $"); d1024 1 a1024 1 int ioflags, aftat_ret = 1, adjust, v3, zeroing; d1106 1 a1107 1 mutex_enter(&nfsd_lock); d1147 1 a1147 1 mutex_exit(&nfsd_lock); d1157 1 a1157 1 mutex_enter(&nfsd_lock); d1166 1 a1166 2 mutex_exit(&nfsd_lock); d1273 1 a1273 1 mutex_enter(&nfsd_lock); d1282 1 a1282 1 mutex_exit(&nfsd_lock); d1284 1 a1285 2 mutex_enter(&nfsd_lock); d1287 1 a1287 1 mutex_exit(&nfsd_lock); a1289 1 mutex_exit(&nfsd_lock); d1291 1 d1296 1 a1296 1 mutex_enter(&nfsd_lock); d1305 1 a1305 1 mutex_exit(&nfsd_lock); a1325 2 KASSERT(mutex_owned(&nfsd_lock)); @ 1.126 log @Kill caddr_t; there will be some MI fallout, but it will be fixed shortly. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.125 2007/02/22 06:14:28 thorpej Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.125 2007/02/22 06:14:28 thorpej Exp $"); d246 1 @ 1.125 log @TRUE -> true, FALSE -> false @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.124 2007/02/20 16:27:21 pooka Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.124 2007/02/20 16:27:21 pooka Exp $"); d109 1 a109 1 caddr_t dpos = nfsd->nd_dpos; d115 1 a115 1 caddr_t bpos; d176 1 a176 1 caddr_t dpos = nfsd->nd_dpos; d184 1 a184 1 caddr_t bpos; d220 1 a220 1 caddr_t dpos = nfsd->nd_dpos; d229 1 a229 1 caddr_t bpos; a245 1 nfsm_srvsattr(&va); d357 1 a357 1 caddr_t dpos = nfsd->nd_dpos; d363 1 a363 1 caddr_t cp; d366 1 a366 1 caddr_t bpos; d475 1 a475 1 caddr_t dpos = nfsd->nd_dpos; d482 1 a482 1 caddr_t bpos; d513 1 a513 1 ivp->iov_base = mtod(mp, caddr_t); d574 1 a574 1 caddr_t dpos = nfsd->nd_dpos; d581 1 a581 1 caddr_t bpos; d739 1 a739 1 iv->iov_base = mtod(m, caddr_t) + d755 1 a755 1 free((caddr_t)iv2, M_TEMP); d801 1 a801 1 caddr_t dpos = nfsd->nd_dpos; d811 1 a811 1 caddr_t bpos; d857 1 a857 1 adjust = dpos - mtod(mp, caddr_t); d918 1 a918 1 ivp->iov_base = mtod(mp, caddr_t); d1036 1 a1036 1 caddr_t bpos, dpos; d1090 1 a1090 1 adjust = dpos - mtod(mp, caddr_t); d1230 1 a1230 1 ivp->iov_base = mtod(mp, caddr_t); d1248 1 a1248 1 free((caddr_t)iov, M_TEMP); d1393 1 a1393 1 caddr_t dpos = nfsd->nd_dpos; d1400 1 a1400 1 caddr_t cp; d1402 1 a1402 1 caddr_t bpos; d1451 1 a1451 1 nfsm_dissect(cp, caddr_t, NFSX_V3CREATEVERF); d1620 1 a1620 1 caddr_t dpos = nfsd->nd_dpos; d1626 1 a1626 1 caddr_t bpos; d1765 1 a1765 1 caddr_t dpos = nfsd->nd_dpos; d1770 1 a1770 1 caddr_t bpos; d1852 1 a1852 1 caddr_t dpos = nfsd->nd_dpos; d1856 1 a1856 1 caddr_t bpos; d2068 1 a2068 1 caddr_t dpos = nfsd->nd_dpos; d2073 1 a2073 1 caddr_t bpos; d2167 1 a2167 1 caddr_t dpos = nfsd->nd_dpos; d2306 1 a2306 1 caddr_t dpos = nfsd->nd_dpos; d2311 1 a2311 1 caddr_t cp; d2314 1 a2314 1 caddr_t bpos; d2422 1 a2422 1 caddr_t dpos = nfsd->nd_dpos; d2426 1 a2426 1 caddr_t bpos; d2556 1 a2556 1 caddr_t dpos = nfsd->nd_dpos; d2561 1 a2561 1 caddr_t cp; d2564 1 a2564 1 caddr_t bpos; d2655 1 a2655 1 free((caddr_t)rbuf, M_TEMP); d2657 1 a2657 1 free((caddr_t)cookies, M_TEMP); d2682 2 a2683 2 free((caddr_t)rbuf, M_TEMP); free((caddr_t)cookies, M_TEMP); d2801 1 a2801 1 mp->m_len = bp - mtod(mp, caddr_t); d2804 2 a2805 2 free((caddr_t)rbuf, M_TEMP); free((caddr_t)cookies, M_TEMP); d2818 1 a2818 1 caddr_t dpos = nfsd->nd_dpos; d2823 1 a2823 1 caddr_t cp; d2826 1 a2826 1 caddr_t bpos; d2929 2 a2930 2 free((caddr_t)cookies, M_TEMP); free((caddr_t)rbuf, M_TEMP); d2952 2 a2953 2 free((caddr_t)cookies, M_TEMP); free((caddr_t)rbuf, M_TEMP); d3076 1 a3076 1 cp = (caddr_t)&fl; d3126 1 a3126 1 mp->m_len = bp - mtod(mp, caddr_t); d3129 2 a3130 2 free((caddr_t)cookies, M_TEMP); free((caddr_t)rbuf, M_TEMP); d3146 1 a3146 1 caddr_t dpos = nfsd->nd_dpos; d3153 1 a3153 1 caddr_t bpos; d3213 1 a3213 1 caddr_t dpos = nfsd->nd_dpos; d3219 1 a3219 1 caddr_t bpos; d3287 1 a3287 1 caddr_t dpos = nfsd->nd_dpos; d3292 1 a3292 1 caddr_t bpos; d3361 1 a3361 1 caddr_t dpos = nfsd->nd_dpos; d3366 1 a3366 1 caddr_t bpos; d3423 1 a3423 1 caddr_t bpos; d3441 1 a3441 1 caddr_t bpos; @ 1.124 log @after freeing cookies, set the pointer to NULL to prevent dangling reuse @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.123 2007/02/04 14:48:51 chs Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.123 2007/02/04 14:48:51 chs Exp $"); d126 1 a126 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE); d192 1 a192 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE); d288 1 a288 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE); d526 1 a526 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d608 1 a608 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d885 1 a885 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1190 1 a1190 1 FALSE); d1425 1 a1425 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1648 1 a1648 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1722 1 a1722 1 error = nfsrv_composefh(vp, &nsfh, TRUE); d1731 1 a1731 1 nfsm_reply(NFSX_SRVFH(&nsfh, TRUE) + NFSX_POSTOPATTR(1) + d1794 1 a1794 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1892 1 a1892 1 &dpos, &fdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1924 1 a1924 1 &dpos, &tdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2091 2 a2092 2 error = nfsrv_fhtovp(&nsfh, FALSE, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2107 1 a2107 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2197 1 a2197 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2334 1 a2334 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2448 1 a2448 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2599 1 a2599 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2857 1 a2857 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d3006 1 a3006 1 if (nfsrv_composefh(nvp, &nnsfh, TRUE)) { d3172 1 a3172 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d3232 1 a3232 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d3306 1 a3306 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d3379 1 a3379 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); @ 1.123 log @in nfsrv_rename(), change vput(fdirp) back to vrele() since the dirp returned from nfs_namei() is not locked in this case. fixes PR 35542. also, apply the same fix here as was made in rename_files() to handle the case when dvp and vp are the same. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.122 2007/01/04 20:24:08 elad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.122 2007/01/04 20:24:08 elad Exp $"); d2709 1 d2979 1 @ 1.123.2.1 log @sync with head. (somehow missed in the previous) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.123 2007/02/04 14:48:51 chs Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.123 2007/02/04 14:48:51 chs Exp $"); d126 1 a126 1 (nfsd->nd_flag & ND_KERBAUTH), false); d192 1 a192 1 (nfsd->nd_flag & ND_KERBAUTH), false); d288 1 a288 1 (nfsd->nd_flag & ND_KERBAUTH), false); d526 1 a526 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d608 1 a608 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d885 1 a885 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d1190 1 a1190 1 false); d1425 1 a1425 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d1648 1 a1648 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d1722 1 a1722 1 error = nfsrv_composefh(vp, &nsfh, true); d1731 1 a1731 1 nfsm_reply(NFSX_SRVFH(&nsfh, true) + NFSX_POSTOPATTR(1) + d1794 1 a1794 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d1892 1 a1892 1 &dpos, &fdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d1924 1 a1924 1 &dpos, &tdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d2091 2 a2092 2 error = nfsrv_fhtovp(&nsfh, false, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d2107 1 a2107 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d2197 1 a2197 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d2334 1 a2334 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d2448 1 a2448 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d2599 1 a2599 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); a2708 1 cookies = NULL; d2856 1 a2856 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); a2977 1 cookies = NULL; d3004 1 a3004 1 if (nfsrv_composefh(nvp, &nnsfh, true)) { d3170 1 a3170 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d3230 1 a3230 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d3304 1 a3304 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d3377 1 a3377 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); @ 1.123.2.2 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.123.2.1 2007/02/28 09:35:39 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.123.2.1 2007/02/28 09:35:39 yamt Exp $"); d109 1 a109 1 char *dpos = nfsd->nd_dpos; d115 1 a115 1 char *bpos; d176 1 a176 1 char *dpos = nfsd->nd_dpos; d184 1 a184 1 char *bpos; d220 1 a220 1 char *dpos = nfsd->nd_dpos; d229 1 a229 1 char *bpos; d358 1 a358 1 char *dpos = nfsd->nd_dpos; d364 1 a364 1 char *cp; d367 1 a367 1 char *bpos; d476 1 a476 1 char *dpos = nfsd->nd_dpos; d483 1 a483 1 char *bpos; d514 1 a514 1 ivp->iov_base = mtod(mp, void *); d575 1 a575 1 char *dpos = nfsd->nd_dpos; d582 1 a582 1 char *bpos; d740 1 a740 1 iv->iov_base = mtod(m, char *) + d756 1 a756 1 free((void *)iv2, M_TEMP); d802 1 a802 1 char *dpos = nfsd->nd_dpos; d812 1 a812 1 char *bpos; d858 1 a858 1 adjust = dpos - mtod(mp, char *); d919 1 a919 1 ivp->iov_base = mtod(mp, void *); d1037 1 a1037 1 char *bpos, *dpos; d1091 1 a1091 1 adjust = dpos - mtod(mp, char *); d1231 1 a1231 1 ivp->iov_base = mtod(mp, void *); d1249 1 a1249 1 free((void *)iov, M_TEMP); d1394 1 a1394 1 char *dpos = nfsd->nd_dpos; d1401 1 a1401 1 char *cp; d1403 1 a1403 1 char *bpos; d1452 1 a1452 1 nfsm_dissect(cp, void *, NFSX_V3CREATEVERF); d1621 1 a1621 1 char *dpos = nfsd->nd_dpos; d1627 1 a1627 1 char *bpos; d1766 1 a1766 1 char *dpos = nfsd->nd_dpos; d1771 1 a1771 1 char *bpos; d1853 1 a1853 1 char *dpos = nfsd->nd_dpos; d1857 1 a1857 1 char *bpos; d2069 1 a2069 1 char *dpos = nfsd->nd_dpos; d2074 1 a2074 1 char *bpos; d2168 1 a2168 1 char *dpos = nfsd->nd_dpos; d2307 1 a2307 1 char *dpos = nfsd->nd_dpos; d2312 1 a2312 1 char *cp; d2315 1 a2315 1 char *bpos; d2423 1 a2423 1 char *dpos = nfsd->nd_dpos; d2427 1 a2427 1 char *bpos; d2557 1 a2557 1 char *dpos = nfsd->nd_dpos; d2562 1 a2562 1 char *cp; d2565 1 a2565 1 char *bpos; d2656 1 a2656 1 free((void *)rbuf, M_TEMP); d2658 1 a2658 1 free((void *)cookies, M_TEMP); d2683 2 a2684 2 free((void *)rbuf, M_TEMP); free((void *)cookies, M_TEMP); d2802 1 a2802 1 mp->m_len = bp - mtod(mp, char *); d2805 2 a2806 2 free((void *)rbuf, M_TEMP); free((void *)cookies, M_TEMP); d2819 1 a2819 1 char *dpos = nfsd->nd_dpos; d2824 1 a2824 1 char *cp; d2827 1 a2827 1 char *bpos; d2930 2 a2931 2 free((void *)cookies, M_TEMP); free((void *)rbuf, M_TEMP); d2953 2 a2954 2 free((void *)cookies, M_TEMP); free((void *)rbuf, M_TEMP); d3077 1 a3077 1 cp = (void *)&fl; d3127 1 a3127 1 mp->m_len = bp - mtod(mp, char *); d3130 2 a3131 2 free((void *)cookies, M_TEMP); free((void *)rbuf, M_TEMP); d3147 1 a3147 1 char *dpos = nfsd->nd_dpos; d3154 1 a3154 1 char *bpos; d3214 1 a3214 1 char *dpos = nfsd->nd_dpos; d3220 1 a3220 1 char *bpos; d3288 1 a3288 1 char *dpos = nfsd->nd_dpos; d3293 1 a3293 1 char *bpos; d3362 1 a3362 1 char *dpos = nfsd->nd_dpos; d3367 1 a3367 1 char *bpos; d3424 1 a3424 1 char *bpos; d3442 1 a3442 1 char *bpos; @ 1.123.2.3 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.123.2.2 2007/03/12 06:00:36 rmind Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.123.2.2 2007/03/12 06:00:36 rmind Exp $"); d236 1 d241 3 d292 1 d306 1 d334 1 d824 1 d831 3 d881 1 d889 1 d908 1 d949 1 d1045 1 d1238 10 a1247 2 error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; d1413 1 d1417 3 d1434 1 d1513 1 d1593 1 d1605 1 d1636 1 d1640 3 d1656 1 d1738 1 d1750 1 d1780 1 d1786 3 d1834 1 d1837 1 d1871 1 d1879 3 d1902 1 d2033 1 d2083 1 d2086 3 d2097 1 d2149 1 d2152 1 d2185 1 d2189 3 d2277 1 d2291 1 d2323 1 d2326 3 d2343 1 d2395 1 d2407 1 d2437 1 d2440 3 d2457 1 d2499 1 d2502 1 d3160 1 d3163 3 d3176 1 d3195 1 d3198 1 @ 1.122 log @Consistent usage of KAUTH_GENERIC_ISSUSER. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.121 2006/12/27 12:10:09 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.121 2006/12/27 12:10:09 yamt Exp $"); d1901 1 a1901 1 vput(fdirp); d1905 3 a1907 1 VOP_UNLOCK(fdirp, 0); @ 1.121 log @remove nqnfs. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.120 2006/12/09 16:11:52 chs Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.120 2006/12/09 16:11:52 chs Exp $"); d1509 1 a1509 1 KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1704 1 a1704 1 KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1802 1 a1802 1 KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d2099 1 a2099 1 KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) @ 1.120 log @a smorgasbord of improvements to vnode locking and path lookup: - LOCKPARENT is no longer relevant for lookup(), relookup() or VOP_LOOKUP(). these now always return the parent vnode locked. namei() works as before. lookup() and various other paths no longer acquire vnode locks in the wrong order via vrele(). fixes PR 32535. as a nice side effect, path lookup is also up to 25% faster. - the above allows us to get rid of PDIRUNLOCK. - also get rid of WANTPARENT (just use LOCKPARENT and unlock it). - remove an assumption in layer_node_find() that all file systems implement a recursive VOP_LOCK() (unionfs doesn't). - require that all file systems supply vfs_vptofh and vfs_fhtovp routines. fill in eopnotsupp() for file systems that don't support being exported and remove the checks for NULL. (layerfs calls these without checking.) - in union_lookup1(), don't change refcounts in the ISDOTDOT case, just adjust which vnode is locked. fixes PR 33374. - apply fixes for ufs_rename() from ufs_vnops.c rev. 1.61 to ext2fs_rename(). @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.119 2006/11/09 09:53:57 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.119 2006/11/09 09:53:57 yamt Exp $"); a82 1 #include d95 2 @ 1.119 log @remove some __unused in function parameters. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.118 2006/10/12 01:32:47 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.118 2006/10/12 01:32:47 christos Exp $"); a438 1 vrele(ndp->ni_startdir); d445 1 d1425 2 a1426 7 if (dirp) { if (v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); else { vrele(dirp); dirp = (struct vnode *)0; } d1523 1 a1524 1 vput(nd.ni_vp); a1574 1 vrele(dirp); d1577 3 a1739 2 if (dirp) vrele(dirp); d1747 2 d1794 2 a1795 5 if (dirp) { if (v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); else vrele(dirp); d1824 4 a1827 2 if (dirp && v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1864 2 a1865 2 struct vnode *fvp, *tvp, *tdvp, *fdirp = (struct vnode *)0; struct vnode *tdirp = (struct vnode *)0; d1889 1 a1889 1 fromnd.ni_cnd.cn_flags = WANTPARENT | SAVESTART; d1892 2 a1893 7 if (fdirp) { if (v3) fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, lwp); else { vrele(fdirp); fdirp = (struct vnode *)0; } d1900 1 a1900 1 vrele(fdirp); d1904 1 d1922 2 a1923 7 if (tdirp) { if (v3) tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, lwp); else { vrele(tdirp); tdirp = (struct vnode *)0; } d2012 3 a2014 1 fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, lwp); d2018 3 a2020 1 tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, lwp); d2105 2 a2106 7 if (dirp) { if (v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); else { vrele(dirp); dirp = (struct vnode *)0; } d2136 3 a2138 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2195 2 a2196 7 if (dirp) { if (v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); else { vrele(dirp); dirp = (struct vnode *)0; } d2260 3 a2262 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); a2276 2 if (dirp) vrele(dirp); d2284 2 d2332 2 a2333 7 if (dirp) { if (v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); else { vrele(dirp); dirp = (struct vnode *)0; } d2374 3 a2376 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); a2394 2 if (dirp) vrele(dirp); d2402 2 d2446 2 a2447 7 if (dirp) { if (v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); else { vrele(dirp); dirp = (struct vnode *)0; } d2488 3 a2490 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); @ 1.119.2.1 log @Apply patch (requested by chs in ticket #422): - Fix various deadlock problems with nullfs and unionfs. - Speed up path lookups by upto 25%. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.119 2006/11/09 09:53:57 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.119 2006/11/09 09:53:57 yamt Exp $"); d439 1 a445 1 vrele(ndp->ni_startdir); d1425 7 a1431 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1528 1 a1529 1 vrele(nd.ni_dvp); d1580 1 a1582 3 if (dirp) { vrele(dirp); } d1743 2 a1751 2 if (dirp) vrele(dirp); d1797 5 a1801 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1830 2 a1831 4 if (dirp) { if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d1868 2 a1869 2 struct vnode *fvp, *tvp, *tdvp; struct vnode *fdirp = NULL, *tdirp = NULL; d1893 1 a1893 1 fromnd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART; d1896 7 a1902 2 if (fdirp && v3) { fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, lwp); a1912 3 if (fromnd.ni_dvp != fromnd.ni_vp) { VOP_UNLOCK(fromnd.ni_dvp, 0); } d1930 7 a1936 2 if (tdirp && v3) { tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, lwp); d2025 1 a2025 3 if (v3) { fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, lwp); } d2029 1 a2029 3 if (v3) { tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, lwp); } d2114 7 a2120 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2150 1 a2150 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d2207 7 a2213 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2277 1 a2277 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d2292 2 a2300 2 if (dirp) vrele(dirp); d2347 7 a2353 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2394 1 a2394 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d2413 2 a2421 2 if (dirp) vrele(dirp); d2464 7 a2470 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2511 1 a2511 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } @ 1.119.2.2 log @Pull up following revision(s) (requested by chs in ticket #506): sys/nfs/nfs_serv.c: revision 1.124 after freeing cookies, set the pointer to NULL to prevent dangling reuse @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); a2707 1 cookies = NULL; a2976 1 cookies = NULL; @ 1.118 log @- sprinkle __unused on function decls. - fix a couple of unused bugs - no more -Wno-unused for i386 @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.117 2006/09/02 12:40:36 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.117 2006/09/02 12:40:36 yamt Exp $"); d3436 2 a3437 6 nfsrv_null( struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp __unused, struct mbuf **mrq ) d3454 2 a3455 6 nfsrv_noop( struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp __unused, struct mbuf **mrq ) @ 1.117 log @nfsd: deal with variable-sized filehandles. @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); d3436 6 a3441 5 nfsrv_null(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; d3458 6 a3463 5 nfsrv_noop(nfsd, slp, lwp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct lwp *lwp; struct mbuf **mrq; @ 1.117.2.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.119 2006/11/09 09:53:57 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.119 2006/11/09 09:53:57 yamt Exp $"); d3436 5 a3440 2 nfsrv_null(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3457 5 a3461 2 nfsrv_noop(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) @ 1.117.2.2 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.122 2007/01/04 20:24:08 elad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.122 2007/01/04 20:24:08 elad Exp $"); d83 1 a95 2 #define nqsrv_getl(vp, rw) /* nothing */ d439 1 a445 1 vrele(ndp->ni_startdir); d1425 7 a1431 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1513 1 a1513 1 KAUTH_GENERIC_ISSUSER, NULL))) { d1528 1 a1529 1 vrele(nd.ni_dvp); d1580 1 a1582 3 if (dirp) { vrele(dirp); } d1706 1 a1706 1 KAUTH_GENERIC_ISSUSER, NULL))) { d1743 2 a1751 2 if (dirp) vrele(dirp); d1797 5 a1801 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1807 1 a1807 1 KAUTH_GENERIC_ISSUSER, NULL)) != 0) d1830 2 a1831 4 if (dirp) { if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d1868 2 a1869 2 struct vnode *fvp, *tvp, *tdvp; struct vnode *fdirp = NULL, *tdirp = NULL; d1893 1 a1893 1 fromnd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART; d1896 7 a1902 2 if (fdirp && v3) { fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, lwp); d1909 1 a1909 1 vput(fdirp); a1912 1 VOP_UNLOCK(fdirp, 0); d1930 7 a1936 2 if (tdirp && v3) { tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, lwp); d2025 1 a2025 3 if (v3) { fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, lwp); } d2029 1 a2029 3 if (v3) { tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, lwp); } d2107 1 a2107 1 KAUTH_GENERIC_ISSUSER, NULL)) != 0) d2114 7 a2120 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2150 1 a2150 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d2207 7 a2213 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2277 1 a2277 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d2292 2 a2300 2 if (dirp) vrele(dirp); d2347 7 a2353 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2394 1 a2394 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d2413 2 a2421 2 if (dirp) vrele(dirp); d2464 7 a2470 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2511 1 a2511 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } @ 1.117.2.3 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.123 2007/02/04 14:48:51 chs Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.123 2007/02/04 14:48:51 chs Exp $"); d1901 1 a1901 1 vrele(fdirp); d1905 1 a1905 3 if (fromnd.ni_dvp != fromnd.ni_vp) { VOP_UNLOCK(fromnd.ni_dvp, 0); } @ 1.117.4.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.117 2006/09/02 12:40:36 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.117 2006/09/02 12:40:36 yamt Exp $"); d3436 5 a3440 6 nfsrv_null( struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp __unused, struct mbuf **mrq ) d3457 5 a3461 6 nfsrv_noop( struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp __unused, struct mbuf **mrq ) @ 1.117.4.2 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.117.4.1 2006/10/22 06:07:43 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.117.4.1 2006/10/22 06:07:43 yamt Exp $"); d439 1 a445 1 vrele(ndp->ni_startdir); d1425 7 a1431 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1528 1 a1529 1 vrele(nd.ni_dvp); d1580 1 a1582 3 if (dirp) { vrele(dirp); } d1743 2 a1751 2 if (dirp) vrele(dirp); d1797 5 a1801 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1830 2 a1831 4 if (dirp) { if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d1868 2 a1869 2 struct vnode *fvp, *tvp, *tdvp; struct vnode *fdirp = NULL, *tdirp = NULL; d1893 1 a1893 1 fromnd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART; d1896 7 a1902 2 if (fdirp && v3) { fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, lwp); d1909 1 a1909 1 vput(fdirp); a1912 1 VOP_UNLOCK(fdirp, 0); d1930 7 a1936 2 if (tdirp && v3) { tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, lwp); d2025 1 a2025 3 if (v3) { fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, lwp); } d2029 1 a2029 3 if (v3) { tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, lwp); } d2114 7 a2120 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2150 1 a2150 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d2207 7 a2213 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2277 1 a2277 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d2292 2 a2300 2 if (dirp) vrele(dirp); d2347 7 a2353 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2394 1 a2394 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d2413 2 a2421 2 if (dirp) vrele(dirp); d2464 7 a2470 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2511 1 a2511 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d3436 6 a3441 2 nfsrv_null(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3458 6 a3463 2 nfsrv_noop(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) @ 1.116 log @fix default type decls fix incomplete initializer @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.115 2006/07/20 15:12:23 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.115 2006/07/20 15:12:23 christos Exp $"); d73 1 d111 1 a111 2 nfsfh_t nfh; fhandle_t *fhp; d122 1 a122 2 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); d124 1 a124 1 error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, d180 1 a180 2 nfsfh_t nfh; fhandle_t *fhp; d189 2 a190 3 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, d225 1 a225 2 nfsfh_t nfh; fhandle_t *fhp; d239 2 a240 3 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) d286 1 a286 1 error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, d362 1 a362 2 nfsfh_t nfh; fhandle_t *fhp; a373 1 size_t fh_size; d375 1 a375 3 fhp = &nfh.fh_generic; fh_size = NFS_SMALLFH; nfsm_srvmtofh(fhp); d378 1 a378 1 pubflag = nfs_ispublicfh(fhp); d383 1 a383 1 error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, d442 1 a442 1 error = vfs_composefh(vp, fhp, &fh_size); d446 2 a447 1 nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPORFATTR(v3) + NFSX_POSTOPATTR(v3)); d452 1 a452 1 nfsm_srvfhtom(fhp, v3); d490 1 a490 2 nfsfh_t nfh; fhandle_t *fhp; d494 1 a494 2 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); d524 1 a524 1 error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, d589 1 a589 2 nfsfh_t nfh; fhandle_t *fhp; d595 1 a595 2 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); d606 1 a606 1 error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, d819 1 a819 2 nfsfh_t nfh; fhandle_t *fhp; d829 2 a830 3 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); if ((mntp = vfs_getvfs(&fhp->fh_fsid)) == NULL) d883 1 a883 1 error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, d1000 10 d1134 1 a1134 1 wpp = NWDELAYHASH(slp, nfsd->nd_fh.fh_generic.fh_fid.fid_data); d1137 1 a1137 2 while (wp && memcmp(&nfsd->nd_fh, &wp->nd_fh, NFSX_V3FH)) { d1142 1 a1142 1 !memcmp(&nfsd->nd_fh, &wp->nd_fh, NFSX_V3FH)) { d1187 1 a1187 1 error = nfsrv_fhtovp(&nfsd->nd_fh.fh_generic, 1, &vp, cred, slp, d1409 1 a1409 3 nfsfh_t nfh; fhandle_t *fhp; size_t fh_size; d1415 2 a1416 4 fhp = &nfh.fh_generic; fh_size = NFS_SMALLFH; nfsm_srvmtofh(fhp); if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) d1423 1 a1423 1 error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, d1562 1 a1562 1 error = vfs_composefh(vp, fhp, &fh_size); d1583 1 a1583 1 nfsm_reply(NFSX_SRVFH(v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3)); d1586 1 a1586 1 nfsm_srvpostop_fh(fhp); d1591 1 a1591 1 nfsm_srvfhtom(fhp, v3); d1636 1 a1636 3 nfsfh_t nfh; fhandle_t *fhp; size_t fh_size; d1641 2 a1642 4 fhp = &nfh.fh_generic; fh_size = NFS_SMALLFH; nfsm_srvmtofh(fhp); if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) d1649 1 a1649 1 error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, d1724 1 a1724 1 error = vfs_composefh(vp, fhp, &fh_size); d1733 2 a1734 1 nfsm_reply(NFSX_SRVFH(1) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1)); d1736 1 a1736 1 nfsm_srvpostop_fh(fhp); d1780 1 a1780 2 nfsfh_t nfh; fhandle_t *fhp; d1787 2 a1788 3 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) d1795 1 a1795 1 error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, d1871 1 a1871 2 nfsfh_t fnfh, tnfh; fhandle_t *ffhp, *tfhp; a1878 2 ffhp = &fnfh.fh_generic; tfhp = &tnfh.fh_generic; d1881 2 a1882 2 nfsm_srvmtofh(ffhp); if ((mp = vfs_getvfs(&ffhp->fh_fsid)) == NULL) d1894 1 a1894 1 error = nfs_namei(&fromnd, ffhp, len, slp, nam, &md, d1914 1 a1914 1 nfsm_srvmtofh(tfhp); d1928 1 a1928 1 error = nfs_namei(&tond, tfhp, len2, slp, nam, &md, d2087 1 a2087 2 nfsfh_t nfh, dnfh; fhandle_t *fhp, *dfhp; d2091 2 a2092 4 fhp = &nfh.fh_generic; dfhp = &dnfh.fh_generic; nfsm_srvmtofh(fhp); if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) d2095 1 a2095 1 nfsm_srvmtofh(dfhp); d2097 1 a2097 1 error = nfsrv_fhtovp(fhp, FALSE, &vp, cred, slp, nam, d2112 1 a2112 1 error = nfs_namei(&nd, dfhp, len, slp, nam, &md, &dpos, d2192 1 a2192 3 nfsfh_t nfh; fhandle_t *fhp; size_t fh_size; d2197 2 a2198 4 fhp = &nfh.fh_generic; fh_size = NFS_SMALLFH; nfsm_srvmtofh(fhp); if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) d2205 1 a2205 1 error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, d2265 1 a2265 1 error = vfs_composefh(nd.ni_vp, fhp, &fh_size); d2280 2 a2281 1 nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); d2284 1 a2284 1 nfsm_srvpostop_fh(fhp); d2333 1 a2333 3 nfsfh_t nfh; fhandle_t *fhp; size_t fh_size; d2337 2 a2338 4 fhp = &nfh.fh_generic; fh_size = NFS_SMALLFH; nfsm_srvmtofh(fhp); if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) d2345 1 a2345 1 error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, d2387 1 a2387 1 error = vfs_composefh(vp, fhp, &fh_size); d2397 2 a2398 1 nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); d2401 1 a2401 1 nfsm_srvpostop_fh(fhp); d2406 1 a2406 1 nfsm_srvfhtom(fhp, v3); d2449 1 a2449 2 nfsfh_t nfh; fhandle_t *fhp; d2454 2 a2455 3 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) d2462 1 a2462 1 error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, a2563 1 u_int32_t fl_nfh[NFSX_V3FH / sizeof (u_int32_t)]; d2588 1 a2588 2 nfsfh_t nfh; fhandle_t *fhp; d2598 1 a2598 2 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); d2616 1 a2616 1 error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, d2849 1 a2849 3 nfsfh_t nfh; fhandle_t *fhp, *nfhp = (fhandle_t *)fl.fl_nfh; size_t fh_size = sizeof(fl.fl_nfh); d2859 1 a2859 2 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); d2873 1 a2873 1 error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, d3011 2 d3022 1 a3022 1 if (vfs_composefh(nvp, nfhp, &fh_size)) { d3092 1 a3092 1 xfer = sizeof (struct flrep); d3106 18 d3167 1 a3167 2 nfsfh_t nfh; fhandle_t *fhp; d3178 2 a3179 3 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) d3187 1 a3187 1 error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, d3243 1 a3243 2 nfsfh_t nfh; fhandle_t *fhp; d3246 2 a3247 3 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, d3316 1 a3316 2 nfsfh_t nfh; fhandle_t *fhp; d3320 2 a3321 3 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, d3390 1 a3390 2 nfsfh_t nfh; fhandle_t *fhp; d3393 2 a3394 3 fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, @ 1.115 log @When there are too many empty entries in a row, and we need to try to read the next block, free the cookie buffer before doing so to avoid a memory leak. Reported by Mark Davies. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.114 2006/07/13 12:00:26 martin Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.114 2006/07/13 12:00:26 martin Exp $"); d3520 1 @ 1.114 log @Fix alignement problems for fhandle_t, exposed by gcc4.1. While touching all vptofh/fhtovp functions, get rid of VFS_MAXFIDSIZ, version the getfh(2) syscall and explicitly pass the size available in the filehandle from userland. Discussed on tech-kern, with lots of help from yamt (thanks!). @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.113 2006/06/30 09:56:03 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.113 2006/06/30 09:56:03 yamt Exp $"); d2757 1 d3029 1 @ 1.113 log @wrap long lines and fix indents after kauth merge. @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); d380 1 d383 1 d451 1 a451 1 error = vfs_composefh(vp, fhp); d1138 1 a1138 1 wpp = NWDELAYHASH(slp, nfsd->nd_fh.fh_fid.fid_data); d1192 1 a1192 1 error = nfsrv_fhtovp(&nfsd->nd_fh, 1, &vp, cred, slp, d1416 1 d1423 1 d1571 1 a1571 1 error = vfs_composefh(vp, fhp); d1647 1 d1653 1 d1737 1 a1737 1 error = vfs_composefh(vp, fhp); d2214 1 d2220 1 d2289 1 a2289 1 error = vfs_composefh(nd.ni_vp, fhp); d2358 1 d2363 1 d2414 1 a2414 1 error = vfs_composefh(vp, fhp); d2881 1 d3052 1 a3052 1 if (vfs_composefh(nvp, nfhp)) { @ 1.112 log @- introduce vfs_composefh() and use it where appropriate. - fix lock/unlock mismatch in sys_getfh. @ text @d1518 1 a1518 1 KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1712 2 a1713 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1814 2 a1815 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d2121 1 a2121 1 KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) @ 1.111 log @stack police: don't allocate statvfs on the stack. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.110 2006/06/07 22:34:17 kardel Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.110 2006/06/07 22:34:17 kardel Exp $"); d449 1 a449 3 memset((caddr_t)fhp, 0, sizeof(nfh)); fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsidx; error = VFS_VPTOFH(vp, &fhp->fh_fid); a452 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d1567 1 a1567 3 memset((caddr_t)fhp, 0, sizeof(nfh)); fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsidx; error = VFS_VPTOFH(vp, &fhp->fh_fid); a1570 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d1731 1 a1731 3 memset((caddr_t)fhp, 0, sizeof(nfh)); fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsidx; error = VFS_VPTOFH(vp, &fhp->fh_fid); a1734 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d2281 1 a2281 3 memset((caddr_t)fhp, 0, sizeof(nfh)); fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsidx; error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid); a2284 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d2404 1 a2404 3 memset((caddr_t)fhp, 0, sizeof(nfh)); fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsidx; error = VFS_VPTOFH(vp, &fhp->fh_fid); a2407 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d3041 1 a3041 4 memset((caddr_t)nfhp, 0, NFSX_V3FH); nfhp->fh_fsid = nvp->v_mount->mnt_stat.f_fsidx; if (VFS_VPTOFH(nvp, &nfhp->fh_fid)) { a3049 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); @ 1.111.2.1 log @Merge from HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.114 2006/07/13 12:00:26 martin Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.114 2006/07/13 12:00:26 martin Exp $"); a379 1 size_t fh_size; a381 1 fh_size = NFS_SMALLFH; d449 3 a451 1 error = vfs_composefh(vp, fhp, &fh_size); d455 1 d1139 1 a1139 1 wpp = NWDELAYHASH(slp, nfsd->nd_fh.fh_generic.fh_fid.fid_data); d1193 1 a1193 1 error = nfsrv_fhtovp(&nfsd->nd_fh.fh_generic, 1, &vp, cred, slp, a1416 1 size_t fh_size; a1422 1 fh_size = NFS_SMALLFH; d1521 1 a1521 1 KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1570 3 a1572 1 error = vfs_composefh(vp, fhp, &fh_size); d1576 1 a1648 1 size_t fh_size; a1653 1 fh_size = NFS_SMALLFH; d1718 2 a1719 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1737 3 a1739 1 error = vfs_composefh(vp, fhp, &fh_size); d1743 1 d1823 2 a1824 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d2130 1 a2130 1 KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) a2216 1 size_t fh_size; a2221 1 fh_size = NFS_SMALLFH; d2290 3 a2292 1 error = vfs_composefh(nd.ni_vp, fhp, &fh_size); d2296 1 a2361 1 size_t fh_size; a2365 1 fh_size = NFS_SMALLFH; d2416 3 a2418 1 error = vfs_composefh(vp, fhp, &fh_size); d2422 1 a2885 1 size_t fh_size = sizeof(fl.fl_nfh); d3056 4 a3059 1 if (vfs_composefh(nvp, nfhp, &fh_size)) { d3068 1 @ 1.110 log @merge FreeBSD timecounters from branch simonb-timecounters - struct timeval time is gone time.tv_sec -> time_second - struct timeval mono_time is gone mono_time.tv_sec -> time_uptime - access to time via {get,}{micro,nano,bin}time() get* versions are fast but less precise - support NTP nanokernel implementation (NTP API 4) - further reading: Timecounter Paper: http://phk.freebsd.dk/pubs/timecounter.pdf NTP Nanokernel: http://www.eecis.udel.edu/~mills/ntp/html/kern.html @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.109 2006/05/14 21:32:21 elad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.109 2006/05/14 21:32:21 elad Exp $"); d3254 1 a3254 1 struct statvfs *sf; a3266 1 struct statvfs statvfs; d3278 1 a3278 1 sf = &statvfs; d3285 2 a3286 1 if (error) d3288 1 d3310 4 a3313 1 nfsm_srvdone; d3343 1 a3343 1 struct statvfs sb; d3356 4 a3359 2 VFS_STATVFS(vp->v_mount, &sb, (struct lwp *)0); maxfsize = (u_quad_t)0x80000000 * sb.f_frsize - 1; @ 1.109 log @integrate kauth. @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); d1029 1 d1063 2 a1064 1 cur_usec = (u_quad_t)time.tv_sec * 1000000 + (u_quad_t)time.tv_usec; d1176 2 a1177 1 cur_usec = (u_quad_t)time.tv_sec * 1000000 + (u_quad_t)time.tv_usec; @ 1.109.2.1 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.112 2006/06/17 07:06:51 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.112 2006/06/17 07:06:51 yamt Exp $"); d449 3 a451 1 error = vfs_composefh(vp, fhp); d455 1 a1028 1 struct timeval now; d1062 1 a1062 2 getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; d1174 1 a1174 2 getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; d1567 3 a1569 1 error = vfs_composefh(vp, fhp); d1573 1 d1734 3 a1736 1 error = vfs_composefh(vp, fhp); d1740 1 d2287 3 a2289 1 error = vfs_composefh(nd.ni_vp, fhp); d2293 1 d2413 3 a2415 1 error = vfs_composefh(vp, fhp); d2419 1 d3053 4 a3056 1 if (vfs_composefh(nvp, nfhp)) { d3065 1 d3251 1 a3251 1 struct statvfs *sf = NULL; d3264 1 d3276 1 a3276 1 sf = malloc(sizeof(*sf), M_TEMP, M_WAITOK); d3283 1 a3283 2 if (error) { free(sf, M_TEMP); a3284 1 } d3306 1 a3306 4 nfsmout: if (sf) free(sf, M_TEMP); return error; d3336 1 a3336 1 struct statvfs *sb; d3349 2 a3350 4 sb = malloc(sizeof(*sb), M_TEMP, M_WAITOK); VFS_STATVFS(vp->v_mount, sb, (struct lwp *)0); maxfsize = (u_quad_t)0x80000000 * sb->f_frsize - 1; free(sb, M_TEMP); @ 1.108 log @quell GCC 4.1 uninitialised variable warnings. XXX: we should audit the tree for which old ones are no longer needed after getting the older compilers out of the tree.. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.107 2006/04/15 01:58:44 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.107 2006/04/15 01:58:44 christos Exp $"); d73 1 d108 1 a108 1 struct ucred *cred = &nfsd->nd_cr; d177 1 a177 1 struct ucred *cred = &nfsd->nd_cr; d223 1 a223 1 struct ucred *cred = &nfsd->nd_cr; d363 1 a363 1 struct ucred *cred = &nfsd->nd_cr; d485 1 a485 1 struct ucred *cred = &nfsd->nd_cr; d586 1 a586 1 struct ucred *cred = &nfsd->nd_cr; d815 1 a815 1 struct ucred *cred = &nfsd->nd_cr; d993 23 d1036 1 a1036 1 struct ucred *cred; d1057 1 a1057 1 cred = &nfsd->nd_cr; d1159 1 a1159 1 if (NFSW_SAMECRED(owp, nfsd)) d1187 1 a1187 1 cred = &nfsd->nd_cr; d1397 1 a1397 1 struct ucred *cred = &nfsd->nd_cr; d1517 2 a1518 1 (error = suser(cred, (u_short *)0))) { d1632 1 a1632 1 struct ucred *cred = &nfsd->nd_cr; d1715 2 a1716 1 (error = suser(cred, (u_short *)0))) { d1781 1 a1781 1 struct ucred *cred = &nfsd->nd_cr; d1820 2 a1821 1 (error = suser(cred, (u_short *)0)) != 0) d1871 1 a1871 1 struct ucred *cred = &nfsd->nd_cr; d1907 1 a1907 1 saved_uid = cred->cr_uid; d1941 1 a1941 1 cred->cr_uid = saved_uid; d2093 1 a2093 1 struct ucred *cred = &nfsd->nd_cr; d2126 2 a2127 1 if (vp->v_type == VDIR && (error = suser(cred, (u_short *)0)) != 0) d2198 1 a2198 1 struct ucred *cred = &nfsd->nd_cr; d2344 1 a2344 1 struct ucred *cred = &nfsd->nd_cr; d2467 1 a2467 1 struct ucred *cred = &nfsd->nd_cr; d2607 1 a2607 1 struct ucred *cred = &nfsd->nd_cr; d2869 1 a2869 1 struct ucred *cred = &nfsd->nd_cr; d3181 1 a3181 1 struct ucred *cred = &nfsd->nd_cr; d3250 1 a3250 1 struct ucred *cred = &nfsd->nd_cr; d3322 1 a3322 1 struct ucred *cred = &nfsd->nd_cr; d3396 1 a3396 1 struct ucred *cred = &nfsd->nd_cr; d3514 1 a3514 1 struct ucred *cred; d3553 1 a3553 1 if (override && error == EACCES && cred->cr_uid == vattr.va_uid) @ 1.107 log @Coverity CID 735: Remove duplicate code. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.106 2006/04/15 01:54:46 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.106 2006/04/15 01:54:46 christos Exp $"); d240 2 @ 1.106 log @Coverity CID 736: Comment out dead code. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.105 2006/04/15 01:39:15 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.105 2006/04/15 01:39:15 christos Exp $"); a1694 3 if (error) { goto out; } @ 1.105 log @Coverity CID 1143: Prevent NULL deref. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.104 2006/04/15 01:37:46 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.104 2006/04/15 01:37:46 christos Exp $"); d2036 1 d2039 1 @ 1.104 log @Coverity CID 1144: Protect against NULL deref. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.103 2006/04/15 00:44:18 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.103 2006/04/15 00:44:18 christos Exp $"); d1559 4 a1562 2 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); @ 1.103 log @Coverity CID 2510-2514: Always initialize cache. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.102 2006/03/27 20:20:46 martin Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.102 2006/03/27 20:20:46 martin Exp $"); d1715 4 a1718 2 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); @ 1.102 log @KASSERT that the returned file id length from VPTOFH is <= the maximum allowed value (_VFS_MAXFIDSZ). @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.101 2006/03/01 12:38:32 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.101 2006/03/01 12:38:32 yamt Exp $"); d185 1 a185 1 int error = 0, rdonly, cache; d232 1 a232 1 int error = 0, rdonly, cache, preat_ret = 1, postat_ret = 1; d370 1 a370 1 int error = 0, cache, dirattr_ret = 1; d489 1 a489 1 int error = 0, rdonly, cache, i, padlen, getret; d590 1 a590 1 int error = 0, rdonly, cache, getret; d822 1 a822 1 int error = 0, rdonly, cache, len, forat_ret = 1; d1015 1 a1015 1 int error = 0, rdonly, cache, len = 0, forat_ret = 1; d1380 1 a1380 1 int error = 0, cache, len, tsize, dirfor_ret = 1, diraft_ret = 1; d1609 1 a1609 1 int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1; d1757 1 a1757 1 int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1; d1845 1 a1845 1 int error = 0, cache, fdirfor_ret = 1, fdiraft_ret = 1; d2066 1 a2066 1 int error = 0, rdonly, cache, len, dirfor_ret = 1, diraft_ret = 1; d2174 1 a2174 1 int error = 0, cache, dirfor_ret = 1, diraft_ret = 1; d2319 1 a2319 1 int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1; d2438 1 a2438 1 int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1; d2591 1 a2591 1 int siz, cnt, fullsiz, eofflag, rdonly, cache, ncookies; d2855 1 a2855 1 int siz, cnt, fullsiz, eofflag, rdonly, cache, dirlen, ncookies; d3156 1 a3156 1 int error = 0, rdonly, for_ret = 1, aft_ret = 1, cache; a3162 3 #ifndef nolint cache = 0; #endif d3223 1 a3223 1 int error = 0, rdonly, cache, getret = 1; a3233 3 #ifndef nolint cache = 0; #endif d3294 1 a3294 1 int error = 0, rdonly, cache, getret = 1; a3304 3 #ifndef nolint cache = 0; #endif d3368 1 a3368 1 int error = 0, rdonly, cache, getret = 1; a3377 3 #ifndef nolint cache = 0; #endif @ 1.101 log @merge yamt-uio_vmspace branch. - use vmspace rather than proc or lwp where appropriate. the latter is more natural to specify an address space. (and less likely to be abused for random purposes.) - fix a swdmover race. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.100 2006/01/03 11:41:50 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.100 2006/01/03 11:41:50 yamt Exp $"); d452 1 d1546 1 d1713 1 d2260 1 d2386 1 d3032 1 @ 1.101.2.1 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.101 2006/03/01 12:38:32 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.101 2006/03/01 12:38:32 yamt Exp $"); a451 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); a1544 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); a1710 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); a2256 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); a2381 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); a3026 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); @ 1.101.2.2 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.101.2.1 2006/04/01 12:07:50 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.101.2.1 2006/04/01 12:07:50 yamt Exp $"); a72 1 #include d107 1 a107 1 kauth_cred_t cred = nfsd->nd_cr; d176 1 a176 1 kauth_cred_t cred = nfsd->nd_cr; d185 1 a185 1 int error = 0, rdonly, cache = 0; d222 1 a222 1 kauth_cred_t cred = nfsd->nd_cr; d232 1 a232 1 int error = 0, rdonly, cache = 0, preat_ret = 1, postat_ret = 1; a239 2 memset(&guard, 0, sizeof guard); /* XXX gcc */ d360 1 a360 1 kauth_cred_t cred = nfsd->nd_cr; d370 1 a370 1 int error = 0, cache = 0, dirattr_ret = 1; d482 1 a482 1 kauth_cred_t cred = nfsd->nd_cr; d489 1 a489 1 int error = 0, rdonly, cache = 0, i, padlen, getret; d583 1 a583 1 kauth_cred_t cred = nfsd->nd_cr; d590 1 a590 1 int error = 0, rdonly, cache = 0, getret; d812 1 a812 1 kauth_cred_t cred = nfsd->nd_cr; d822 1 a822 1 int error = 0, rdonly, cache = 0, len, forat_ret = 1; a989 23 * XXX elad: the original NFSW_SAMECRED() macro also made sure the * two nd_flag fields of the descriptors contained * ND_KERBAUTH. */ static int nfsrv_samecred(kauth_cred_t cred1, kauth_cred_t cred2) { int i, do_ngroups; if (kauth_cred_geteuid(cred1) != kauth_cred_geteuid(cred2)) return (0); if (kauth_cred_ngroups(cred1) != kauth_cred_ngroups(cred2)) return (0); do_ngroups = kauth_cred_ngroups(cred1); for (i = 0; i < do_ngroups; i++) if (kauth_cred_group(cred1, i) != kauth_cred_group(cred2, i)) return (0); return (1); } /* d1010 1 a1010 1 kauth_cred_t cred; d1015 1 a1015 1 int error = 0, rdonly, cache = 0, len = 0, forat_ret = 1; d1031 1 a1031 1 cred = nfsd->nd_cr; d1133 1 a1133 1 if (nfsrv_samecred(owp->nd_cr, nfsd->nd_cr)) d1161 1 a1161 1 cred = nfsd->nd_cr; d1371 1 a1371 1 kauth_cred_t cred = nfsd->nd_cr; d1380 1 a1380 1 int error = 0, cache = 0, len, tsize, dirfor_ret = 1, diraft_ret = 1; d1491 1 a1491 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1559 2 a1560 4 if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); } d1603 1 a1603 1 kauth_cred_t cred = nfsd->nd_cr; d1609 1 a1609 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d1686 1 a1686 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1693 3 d1715 2 a1716 4 if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); } d1752 1 a1752 1 kauth_cred_t cred = nfsd->nd_cr; d1757 1 a1757 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d1791 1 a1791 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d1841 1 a1841 1 kauth_cred_t cred = nfsd->nd_cr; d1845 1 a1845 1 int error = 0, cache = 0, fdirfor_ret = 1, fdiraft_ret = 1; d1877 1 a1877 1 saved_uid = kauth_cred_geteuid(cred); d1911 1 a1911 1 kauth_cred_seteuid(cred, saved_uid); a2031 1 #ifdef notdef a2033 1 #endif d2061 1 a2061 1 kauth_cred_t cred = nfsd->nd_cr; d2066 1 a2066 1 int error = 0, rdonly, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2094 1 a2094 2 if (vp->v_type == VDIR && (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d2165 1 a2165 1 kauth_cred_t cred = nfsd->nd_cr; d2174 1 a2174 1 int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1; d2311 1 a2311 1 kauth_cred_t cred = nfsd->nd_cr; d2319 1 a2319 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2434 1 a2434 1 kauth_cred_t cred = nfsd->nd_cr; d2438 1 a2438 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2574 1 a2574 1 kauth_cred_t cred = nfsd->nd_cr; d2591 1 a2591 1 int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, ncookies; d2836 1 a2836 1 kauth_cred_t cred = nfsd->nd_cr; d2855 1 a2855 1 int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, dirlen, ncookies; d3148 1 a3148 1 kauth_cred_t cred = nfsd->nd_cr; d3156 1 a3156 1 int error = 0, rdonly, for_ret = 1, aft_ret = 1, cache = 0; d3163 3 d3220 1 a3220 1 kauth_cred_t cred = nfsd->nd_cr; d3226 1 a3226 1 int error = 0, rdonly, cache = 0, getret = 1; d3237 3 d3295 1 a3295 1 kauth_cred_t cred = nfsd->nd_cr; d3300 1 a3300 1 int error = 0, rdonly, cache = 0, getret = 1; d3311 3 d3372 1 a3372 1 kauth_cred_t cred = nfsd->nd_cr; d3377 1 a3377 1 int error = 0, rdonly, cache = 0, getret = 1; d3387 3 d3493 1 a3493 1 kauth_cred_t cred; d3532 1 a3532 1 if (override && error == EACCES && kauth_cred_geteuid(cred) == vattr.va_uid) @ 1.101.2.3 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.101.2.2 2006/05/24 10:59:15 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.101.2.2 2006/05/24 10:59:15 yamt Exp $"); d449 3 a451 1 error = vfs_composefh(vp, fhp); d455 1 a1028 1 struct timeval now; d1062 1 a1062 2 getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; d1174 1 a1174 2 getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; d1567 3 a1569 1 error = vfs_composefh(vp, fhp); d1573 1 d1734 3 a1736 1 error = vfs_composefh(vp, fhp); d1740 1 d2287 3 a2289 1 error = vfs_composefh(nd.ni_vp, fhp); d2293 1 d2413 3 a2415 1 error = vfs_composefh(vp, fhp); d2419 1 d3053 4 a3056 1 if (vfs_composefh(nvp, nfhp)) { d3065 1 d3251 1 a3251 1 struct statvfs *sf = NULL; d3264 1 d3276 1 a3276 1 sf = malloc(sizeof(*sf), M_TEMP, M_WAITOK); d3283 1 a3283 2 if (error) { free(sf, M_TEMP); a3284 1 } d3306 1 a3306 4 nfsmout: if (sf) free(sf, M_TEMP); return error; d3336 1 a3336 1 struct statvfs *sb; d3349 2 a3350 4 sb = malloc(sizeof(*sb), M_TEMP, M_WAITOK); VFS_STATVFS(vp->v_mount, sb, (struct lwp *)0); maxfsize = (u_quad_t)0x80000000 * sb->f_frsize - 1; free(sb, M_TEMP); @ 1.101.2.4 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.101.2.3 2006/06/26 12:54:28 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.101.2.3 2006/06/26 12:54:28 yamt Exp $"); a379 1 size_t fh_size; a381 1 fh_size = NFS_SMALLFH; d449 1 a449 1 error = vfs_composefh(vp, fhp, &fh_size); d1136 1 a1136 1 wpp = NWDELAYHASH(slp, nfsd->nd_fh.fh_generic.fh_fid.fid_data); d1190 1 a1190 1 error = nfsrv_fhtovp(&nfsd->nd_fh.fh_generic, 1, &vp, cred, slp, a1413 1 size_t fh_size; a1419 1 fh_size = NFS_SMALLFH; d1518 1 a1518 1 KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1567 1 a1567 1 error = vfs_composefh(vp, fhp, &fh_size); a1642 1 size_t fh_size; a1647 1 fh_size = NFS_SMALLFH; d1712 2 a1713 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1731 1 a1731 1 error = vfs_composefh(vp, fhp, &fh_size); d1814 2 a1815 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d2121 1 a2121 1 KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) a2207 1 size_t fh_size; a2212 1 fh_size = NFS_SMALLFH; d2281 1 a2281 1 error = vfs_composefh(nd.ni_vp, fhp, &fh_size); a2349 1 size_t fh_size; a2353 1 fh_size = NFS_SMALLFH; d2404 1 a2404 1 error = vfs_composefh(vp, fhp, &fh_size); a2746 1 free(cookies, M_TEMP); a2870 1 size_t fh_size = sizeof(fl.fl_nfh); a3016 1 free(cookies, M_TEMP); d3041 1 a3041 1 if (vfs_composefh(nvp, nfhp, &fh_size)) { @ 1.101.2.5 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.101.2.4 2006/08/11 15:47:05 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.101.2.4 2006/08/11 15:47:05 yamt Exp $"); a72 1 #include d110 2 a111 1 nfsrvfh_t nsfh; d122 2 a123 1 nfsm_srvmtofh(&nsfh); d125 1 a125 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, d181 2 a182 1 nfsrvfh_t nsfh; d191 3 a193 2 nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, d228 2 a229 1 nfsrvfh_t nsfh; d243 3 a245 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d291 1 a291 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, d367 2 a368 1 nfsrvfh_t nsfh; d380 1 d382 3 a384 1 nfsm_srvmtofh(&nsfh); d387 1 a387 1 pubflag = nfs_ispublicfh(&nsfh); d392 1 a392 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d451 1 a451 1 error = nfsrv_composefh(vp, &nsfh, v3); d455 1 a455 2 nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPORFATTR(v3) + NFSX_POSTOPATTR(v3)); d460 1 a460 1 nfsm_srvfhtom(&nsfh, v3); d498 2 a499 1 nfsrvfh_t nsfh; d503 2 a504 1 nfsm_srvmtofh(&nsfh); d534 1 a534 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d599 2 a600 1 nfsrvfh_t nsfh; d606 2 a607 1 nfsm_srvmtofh(&nsfh); d618 1 a618 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d831 2 a832 1 nfsrvfh_t nsfh; d842 3 a844 2 nfsm_srvmtofh(&nsfh); if ((mntp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d897 1 a897 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, a1013 10 static struct nfsrvw_delayhash * nfsrv_nwdelayhash(struct nfssvc_sock *slp, const nfsrvfh_t *nsfh) { uint32_t hash; hash = hash32_buf(NFSRVFH_DATA(nsfh), NFSRVFH_SIZE(nsfh), HASH32_BUF_INIT); return &slp->ns_wdelayhashtbl[hash % NFS_WDELAYHASHSIZ]; } d1138 1 a1138 1 wpp = nfsrv_nwdelayhash(slp, &nfsd->nd_fh); d1141 2 a1142 1 while (wp && nfsrv_comparefh(&nfsd->nd_fh, &wp->nd_fh)) { d1147 1 a1147 1 !nfsrv_comparefh(&nfsd->nd_fh, &wp->nd_fh)) { d1192 1 a1192 1 error = nfsrv_fhtovp(&nfsd->nd_fh, 1, &vp, cred, slp, d1414 3 a1416 1 nfsrvfh_t nsfh; d1422 4 a1425 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d1432 1 a1432 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d1571 1 a1571 1 error = nfsrv_composefh(vp, &nsfh, v3); d1592 1 a1592 1 nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3)); d1595 1 a1595 1 nfsm_srvpostop_fh(&nsfh); d1600 1 a1600 1 nfsm_srvfhtom(&nsfh, v3); d1645 3 a1647 1 nfsrvfh_t nsfh; d1652 4 a1655 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d1662 1 a1662 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d1737 1 a1737 1 error = nfsrv_composefh(vp, &nsfh, TRUE); d1746 1 a1746 2 nfsm_reply(NFSX_SRVFH(&nsfh, TRUE) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1)); d1748 1 a1748 1 nfsm_srvpostop_fh(&nsfh); d1792 2 a1793 1 nfsrvfh_t nsfh; d1800 3 a1802 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d1809 1 a1809 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d1885 2 a1886 1 nfsrvfh_t fnsfh, tnsfh; d1894 2 d1898 2 a1899 2 nfsm_srvmtofh(&fnsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&fnsfh)->fh_fsid)) == NULL) d1911 1 a1911 1 error = nfs_namei(&fromnd, &fnsfh, len, slp, nam, &md, d1931 1 a1931 1 nfsm_srvmtofh(&tnsfh); d1945 1 a1945 1 error = nfs_namei(&tond, &tnsfh, len2, slp, nam, &md, d2104 2 a2105 1 nfsrvfh_t nsfh, dnsfh; d2109 4 a2112 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d2115 1 a2115 1 nfsm_srvmtofh(&dnsfh); d2117 1 a2117 1 error = nfsrv_fhtovp(&nsfh, FALSE, &vp, cred, slp, nam, d2132 1 a2132 1 error = nfs_namei(&nd, &dnsfh, len, slp, nam, &md, &dpos, d2212 3 a2214 1 nfsrvfh_t nsfh; d2219 4 a2222 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d2229 1 a2229 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d2289 1 a2289 1 error = nfsrv_composefh(nd.ni_vp, &nsfh, v3); d2304 1 a2304 2 nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); d2307 1 a2307 1 nfsm_srvpostop_fh(&nsfh); d2356 3 a2358 1 nfsrvfh_t nsfh; d2362 4 a2365 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d2372 1 a2372 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d2414 1 a2414 1 error = nfsrv_composefh(vp, &nsfh, v3); d2424 1 a2424 2 nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); d2427 1 a2427 1 nfsm_srvpostop_fh(&nsfh); d2432 1 a2432 1 nfsm_srvfhtom(&nsfh, v3); d2475 2 a2476 1 nfsrvfh_t nsfh; d2481 3 a2483 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d2490 1 a2490 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d2592 1 d2617 2 a2618 1 nfsrvfh_t nsfh; d2628 2 a2629 1 nfsm_srvmtofh(&nsfh); d2647 1 a2647 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d2880 3 a2882 1 nfsrvfh_t nsfh; d2892 2 a2893 1 nfsm_srvmtofh(&nsfh); d2907 1 a2907 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, a3044 2 nfsrvfh_t nnsfh; d3054 1 a3054 1 if (nfsrv_composefh(nvp, &nnsfh, TRUE)) { d3124 1 a3124 1 xfer = sizeof(struct flrep); a3137 18 /* * ... and filehandle. */ xfer = NFSRVFH_SIZE(&nnsfh); cp = NFSRVFH_DATA(&nnsfh); while (xfer > 0) { nfsm_clget; if ((bp + xfer) > be) tsiz = be - bp; else tsiz = xfer; memcpy(bp, cp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } d3181 2 a3182 1 nfsrvfh_t nsfh; d3193 3 a3195 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d3203 1 a3203 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d3259 2 a3260 1 nfsrvfh_t nsfh; d3263 3 a3265 2 nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d3334 2 a3335 1 nfsrvfh_t nsfh; d3339 3 a3341 2 nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d3410 2 a3411 1 nfsrvfh_t nsfh; d3414 3 a3416 2 nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, a3519 1 int override; @ 1.101.6.1 log @Merge 2006-03-28 NetBSD-current into the "peter-altq" branch. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.102 2006/03/27 20:20:46 martin Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.102 2006/03/27 20:20:46 martin Exp $"); a451 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); a1544 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); a1710 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); a2256 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); a2381 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); a3026 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); @ 1.101.6.2 log @Merge 2006-05-24 NetBSD-current into the "peter-altq" branch. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.109 2006/05/14 21:32:21 elad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.109 2006/05/14 21:32:21 elad Exp $"); a72 1 #include d107 1 a107 1 kauth_cred_t cred = nfsd->nd_cr; d176 1 a176 1 kauth_cred_t cred = nfsd->nd_cr; d185 1 a185 1 int error = 0, rdonly, cache = 0; d222 1 a222 1 kauth_cred_t cred = nfsd->nd_cr; d232 1 a232 1 int error = 0, rdonly, cache = 0, preat_ret = 1, postat_ret = 1; a239 2 memset(&guard, 0, sizeof guard); /* XXX gcc */ d360 1 a360 1 kauth_cred_t cred = nfsd->nd_cr; d370 1 a370 1 int error = 0, cache = 0, dirattr_ret = 1; d482 1 a482 1 kauth_cred_t cred = nfsd->nd_cr; d489 1 a489 1 int error = 0, rdonly, cache = 0, i, padlen, getret; d583 1 a583 1 kauth_cred_t cred = nfsd->nd_cr; d590 1 a590 1 int error = 0, rdonly, cache = 0, getret; d812 1 a812 1 kauth_cred_t cred = nfsd->nd_cr; d822 1 a822 1 int error = 0, rdonly, cache = 0, len, forat_ret = 1; a989 23 * XXX elad: the original NFSW_SAMECRED() macro also made sure the * two nd_flag fields of the descriptors contained * ND_KERBAUTH. */ static int nfsrv_samecred(kauth_cred_t cred1, kauth_cred_t cred2) { int i, do_ngroups; if (kauth_cred_geteuid(cred1) != kauth_cred_geteuid(cred2)) return (0); if (kauth_cred_ngroups(cred1) != kauth_cred_ngroups(cred2)) return (0); do_ngroups = kauth_cred_ngroups(cred1); for (i = 0; i < do_ngroups; i++) if (kauth_cred_group(cred1, i) != kauth_cred_group(cred2, i)) return (0); return (1); } /* d1010 1 a1010 1 kauth_cred_t cred; d1015 1 a1015 1 int error = 0, rdonly, cache = 0, len = 0, forat_ret = 1; d1031 1 a1031 1 cred = nfsd->nd_cr; d1133 1 a1133 1 if (nfsrv_samecred(owp->nd_cr, nfsd->nd_cr)) d1161 1 a1161 1 cred = nfsd->nd_cr; d1371 1 a1371 1 kauth_cred_t cred = nfsd->nd_cr; d1380 1 a1380 1 int error = 0, cache = 0, len, tsize, dirfor_ret = 1, diraft_ret = 1; d1491 1 a1491 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1559 2 a1560 4 if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); } d1603 1 a1603 1 kauth_cred_t cred = nfsd->nd_cr; d1609 1 a1609 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d1686 1 a1686 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1693 3 d1715 2 a1716 4 if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); } d1752 1 a1752 1 kauth_cred_t cred = nfsd->nd_cr; d1757 1 a1757 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d1791 1 a1791 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d1841 1 a1841 1 kauth_cred_t cred = nfsd->nd_cr; d1845 1 a1845 1 int error = 0, cache = 0, fdirfor_ret = 1, fdiraft_ret = 1; d1877 1 a1877 1 saved_uid = kauth_cred_geteuid(cred); d1911 1 a1911 1 kauth_cred_seteuid(cred, saved_uid); a2031 1 #ifdef notdef a2033 1 #endif d2061 1 a2061 1 kauth_cred_t cred = nfsd->nd_cr; d2066 1 a2066 1 int error = 0, rdonly, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2094 1 a2094 2 if (vp->v_type == VDIR && (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d2165 1 a2165 1 kauth_cred_t cred = nfsd->nd_cr; d2174 1 a2174 1 int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1; d2311 1 a2311 1 kauth_cred_t cred = nfsd->nd_cr; d2319 1 a2319 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2434 1 a2434 1 kauth_cred_t cred = nfsd->nd_cr; d2438 1 a2438 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2574 1 a2574 1 kauth_cred_t cred = nfsd->nd_cr; d2591 1 a2591 1 int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, ncookies; d2836 1 a2836 1 kauth_cred_t cred = nfsd->nd_cr; d2855 1 a2855 1 int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, dirlen, ncookies; d3148 1 a3148 1 kauth_cred_t cred = nfsd->nd_cr; d3156 1 a3156 1 int error = 0, rdonly, for_ret = 1, aft_ret = 1, cache = 0; d3163 3 d3220 1 a3220 1 kauth_cred_t cred = nfsd->nd_cr; d3226 1 a3226 1 int error = 0, rdonly, cache = 0, getret = 1; d3237 3 d3295 1 a3295 1 kauth_cred_t cred = nfsd->nd_cr; d3300 1 a3300 1 int error = 0, rdonly, cache = 0, getret = 1; d3311 3 d3372 1 a3372 1 kauth_cred_t cred = nfsd->nd_cr; d3377 1 a3377 1 int error = 0, rdonly, cache = 0, getret = 1; d3387 3 d3493 1 a3493 1 kauth_cred_t cred; d3532 1 a3532 1 if (override && error == EACCES && kauth_cred_geteuid(cred) == vattr.va_uid) @ 1.101.4.1 log @Adapt to kernel authorization KPI. This could use some testing... @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.101 2006/03/01 12:38:32 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.101 2006/03/01 12:38:32 yamt Exp $"); d107 1 a107 1 kauth_cred_t cred = nfsd->nd_cr; d176 1 a176 1 kauth_cred_t cred = nfsd->nd_cr; d222 1 a222 1 kauth_cred_t cred = nfsd->nd_cr; d360 1 a360 1 kauth_cred_t cred = nfsd->nd_cr; d481 1 a481 1 kauth_cred_t cred = nfsd->nd_cr; d582 1 a582 1 kauth_cred_t cred = nfsd->nd_cr; d811 1 a811 1 kauth_cred_t cred = nfsd->nd_cr; d1009 1 a1009 1 kauth_cred_t cred; d1030 1 a1030 1 cred = nfsd->nd_cr; d1160 1 a1160 1 cred = nfsd->nd_cr; d1370 1 a1370 1 kauth_cred_t cred = nfsd->nd_cr; d1490 1 a1490 2 (error = generic_authorize(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1601 1 a1601 1 kauth_cred_t cred = nfsd->nd_cr; d1684 1 a1684 2 (error = generic_authorize(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1749 1 a1749 1 kauth_cred_t cred = nfsd->nd_cr; d1788 1 a1788 2 (error = generic_authorize(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d1838 1 a1838 1 kauth_cred_t cred = nfsd->nd_cr; d1874 1 a1874 1 saved_uid = kauth_cred_geteuid(cred); d1908 1 a1908 1 kauth_cred_seteuid(cred, saved_uid); d2058 1 a2058 1 kauth_cred_t cred = nfsd->nd_cr; d2091 1 a2091 2 if (vp->v_type == VDIR && (error = generic_authorize(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d2162 1 a2162 1 kauth_cred_t cred = nfsd->nd_cr; d2307 1 a2307 1 kauth_cred_t cred = nfsd->nd_cr; d2429 1 a2429 1 kauth_cred_t cred = nfsd->nd_cr; d2569 1 a2569 1 kauth_cred_t cred = nfsd->nd_cr; d2831 1 a2831 1 kauth_cred_t cred = nfsd->nd_cr; d3142 1 a3142 1 kauth_cred_t cred = nfsd->nd_cr; d3214 1 a3214 1 kauth_cred_t cred = nfsd->nd_cr; d3289 1 a3289 1 kauth_cred_t cred = nfsd->nd_cr; d3366 1 a3366 1 kauth_cred_t cred = nfsd->nd_cr; d3487 1 a3487 1 kauth_cred_t cred; d3526 1 a3526 1 if (override && error == EACCES && kauth_cred_geteuid(cred) == vattr.va_uid) @ 1.101.4.2 log @generic_authorize() -> kauth_authorize_generic(). @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.101.4.1 2006/03/08 01:06:28 elad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.101.4.1 2006/03/08 01:06:28 elad Exp $"); d1490 1 a1490 1 (error = kauth_authorize_generic(cred, d1685 1 a1685 1 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, d1790 1 a1790 1 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, d2094 1 a2094 1 if (vp->v_type == VDIR && (error = kauth_authorize_generic(cred, @ 1.101.4.3 log @Get rid of NFSW_SAMECRED() that uses memcmp() to compare two credentials, and use a new nfsrv_samecred(), using kauth(9). Note that the NFSW_SAMECRED() macro used to check nd_flag of both descriptors for NB_KERBAUTH too; we don't do that. [documented] Based on code in FreeBSD, thanks to Jeff Roberson. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.101.4.2 2006/03/10 13:37:46 elad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.101.4.2 2006/03/10 13:37:46 elad Exp $"); a988 23 * XXX elad: the original NFSW_SAMECRED() macro also made sure the * two nd_flag fields of the descriptors contained * ND_KERBAUTH. */ static int nfsrv_samecred(kauth_cred_t cred1, kauth_cred_t cred2) { int i, do_ngroups; if (kauth_cred_geteuid(cred1) != kauth_cred_geteuid(cred2)) return (0); if (kauth_cred_ngroups(cred1) != kauth_cred_ngroups(cred2)) return (0); do_ngroups = kauth_cred_ngroups(cred1); for (i = 0; i < do_ngroups; i++) if (kauth_cred_group(cred1, i) != kauth_cred_group(cred2, i)) return (0); return (1); } /* d1132 1 a1132 1 if (nfsrv_samecred(owp->nd_cr, nfsd->nd_cr)) @ 1.101.4.4 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.101.4.3 2006/03/12 00:07:42 elad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.101.4.3 2006/03/12 00:07:42 elad Exp $"); d185 1 a185 1 int error = 0, rdonly, cache = 0; d232 1 a232 1 int error = 0, rdonly, cache = 0, preat_ret = 1, postat_ret = 1; d370 1 a370 1 int error = 0, cache = 0, dirattr_ret = 1; a451 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d488 1 a488 1 int error = 0, rdonly, cache = 0, i, padlen, getret; d589 1 a589 1 int error = 0, rdonly, cache = 0, getret; d821 1 a821 1 int error = 0, rdonly, cache = 0, len, forat_ret = 1; d1037 1 a1037 1 int error = 0, rdonly, cache = 0, len = 0, forat_ret = 1; d1402 1 a1402 1 int error = 0, cache = 0, len, tsize, dirfor_ret = 1, diraft_ret = 1; a1568 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d1581 2 a1582 4 if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); } d1631 1 a1631 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d1716 3 a1735 5 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); } if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); d1737 2 d1779 1 a1779 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d1868 1 a1868 1 int error = 0, cache = 0, fdirfor_ret = 1, fdiraft_ret = 1; a2054 1 #ifdef notdef a2056 1 #endif d2089 1 a2089 1 int error = 0, rdonly, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2198 1 a2198 1 int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1; a2283 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d2342 1 a2342 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; a2408 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d2460 1 a2460 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2613 1 a2613 1 int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, ncookies; d2877 1 a2877 1 int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, dirlen, ncookies; a3053 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d3177 1 a3177 1 int error = 0, rdonly, for_ret = 1, aft_ret = 1, cache = 0; d3184 3 d3247 1 a3247 1 int error = 0, rdonly, cache = 0, getret = 1; d3258 3 d3321 1 a3321 1 int error = 0, rdonly, cache = 0, getret = 1; d3332 3 d3398 1 a3398 1 int error = 0, rdonly, cache = 0, getret = 1; d3408 3 @ 1.101.4.5 log @- Move kauth_cred_t declaration to - Cleanup struct ucred; forward declarations that are unused. - Don't include in any header, but include it in the c files that need it. Approved by core. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.101.4.4 2006/04/19 05:06:37 elad Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.101.4.4 2006/04/19 05:06:37 elad Exp $"); a72 1 #include @ 1.101.4.6 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.101.4.5 2006/05/06 23:32:11 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.101.4.5 2006/05/06 23:32:11 christos Exp $"); a240 2 memset(&guard, 0, sizeof guard); /* XXX gcc */ @ 1.100 log @remove a few unnecessary caddr_t casts. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.99 2005/12/11 12:25:16 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.99 2005/12/11 12:25:16 christos Exp $"); d530 1 a530 2 uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_lwp = NULL; d762 1 a762 1 uiop->uio_segflg = UIO_SYSSPACE; a950 2 uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_lwp = NULL; d952 1 a1188 2 uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_lwp = NULL; d1191 1 a2226 1 io.uio_segflg = UIO_SYSSPACE; d2228 1 a2228 1 io.uio_lwp = NULL; a2649 1 io.uio_segflg = UIO_SYSSPACE; d2651 1 a2651 1 io.uio_lwp = NULL; a2907 1 io.uio_segflg = UIO_SYSSPACE; d2909 1 a2909 1 io.uio_lwp = NULL; @ 1.100.2.1 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.117 2006/09/02 12:40:36 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.117 2006/09/02 12:40:36 yamt Exp $"); a72 2 #include #include d107 1 a107 1 kauth_cred_t cred = nfsd->nd_cr; d109 2 a110 1 nfsrvfh_t nsfh; d121 2 a122 1 nfsm_srvmtofh(&nsfh); d124 1 a124 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, d176 1 a176 1 kauth_cred_t cred = nfsd->nd_cr; d180 2 a181 1 nfsrvfh_t nsfh; d185 1 a185 1 int error = 0, rdonly, cache = 0; d190 3 a192 2 nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, d222 1 a222 1 kauth_cred_t cred = nfsd->nd_cr; d227 2 a228 1 nfsrvfh_t nsfh; d232 1 a232 1 int error = 0, rdonly, cache = 0, preat_ret = 1, postat_ret = 1; d240 3 a242 4 memset(&guard, 0, sizeof guard); /* XXX gcc */ nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d288 1 a288 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, d360 1 a360 1 kauth_cred_t cred = nfsd->nd_cr; d364 2 a365 1 nfsrvfh_t nsfh; d370 1 a370 1 int error = 0, cache = 0, dirattr_ret = 1; d378 2 a379 1 nfsm_srvmtofh(&nsfh); d382 1 a382 1 pubflag = nfs_ispublicfh(&nsfh); d387 1 a387 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d446 3 a448 1 error = nfsrv_composefh(vp, &nsfh, v3); d452 1 a452 2 nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPORFATTR(v3) + NFSX_POSTOPATTR(v3)); d457 1 a457 1 nfsm_srvfhtom(&nsfh, v3); d481 1 a481 1 kauth_cred_t cred = nfsd->nd_cr; d488 1 a488 1 int error = 0, rdonly, cache = 0, i, padlen, getret; d495 2 a496 1 nfsrvfh_t nsfh; d500 2 a501 1 nfsm_srvmtofh(&nsfh); d530 3 a532 2 UIO_SETUP_SYSSPACE(uiop); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d583 1 a583 1 kauth_cred_t cred = nfsd->nd_cr; d590 1 a590 1 int error = 0, rdonly, cache = 0, getret; d597 2 a598 1 nfsrvfh_t nsfh; d604 2 a605 1 nfsm_srvmtofh(&nsfh); d616 1 a616 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d763 1 a763 1 UIO_SETUP_SYSSPACE(uiop); d812 1 a812 1 kauth_cred_t cred = nfsd->nd_cr; d822 1 a822 1 int error = 0, rdonly, cache = 0, len, forat_ret = 1; d829 2 a830 1 nfsrvfh_t nsfh; d840 3 a842 2 nfsm_srvmtofh(&nsfh); if ((mntp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d895 1 a895 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d952 2 a954 1 UIO_SETUP_SYSSPACE(uiop); a990 33 * XXX elad: the original NFSW_SAMECRED() macro also made sure the * two nd_flag fields of the descriptors contained * ND_KERBAUTH. */ static int nfsrv_samecred(kauth_cred_t cred1, kauth_cred_t cred2) { int i, do_ngroups; if (kauth_cred_geteuid(cred1) != kauth_cred_geteuid(cred2)) return (0); if (kauth_cred_ngroups(cred1) != kauth_cred_ngroups(cred2)) return (0); do_ngroups = kauth_cred_ngroups(cred1); for (i = 0; i < do_ngroups; i++) if (kauth_cred_group(cred1, i) != kauth_cred_group(cred2, i)) return (0); return (1); } static struct nfsrvw_delayhash * nfsrv_nwdelayhash(struct nfssvc_sock *slp, const nfsrvfh_t *nsfh) { uint32_t hash; hash = hash32_buf(NFSRVFH_DATA(nsfh), NFSRVFH_SIZE(nsfh), HASH32_BUF_INIT); return &slp->ns_wdelayhashtbl[hash % NFS_WDELAYHASHSIZ]; } /* a1003 1 struct timeval now; d1011 1 a1011 1 kauth_cred_t cred; d1016 1 a1016 1 int error = 0, rdonly, cache = 0, len = 0, forat_ret = 1; d1032 1 a1032 1 cred = nfsd->nd_cr; d1037 1 a1037 2 getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; d1112 1 a1112 1 wpp = nfsrv_nwdelayhash(slp, &nfsd->nd_fh); d1115 2 a1116 1 while (wp && nfsrv_comparefh(&nfsd->nd_fh, &wp->nd_fh)) { d1121 1 a1121 1 !nfsrv_comparefh(&nfsd->nd_fh, &wp->nd_fh)) { d1134 1 a1134 1 if (nfsrv_samecred(owp->nd_cr, nfsd->nd_cr)) d1149 1 a1149 2 getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; d1162 1 a1162 1 cred = nfsd->nd_cr; d1191 2 a1194 1 UIO_SETUP_SYSSPACE(uiop); d1373 1 a1373 1 kauth_cred_t cred = nfsd->nd_cr; d1382 1 a1382 1 int error = 0, cache = 0, len, tsize, dirfor_ret = 1, diraft_ret = 1; d1388 2 a1389 1 nfsrvfh_t nsfh; d1395 3 a1397 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d1404 1 a1404 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d1493 1 a1493 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1542 3 a1544 1 error = nfsrv_composefh(vp, &nsfh, v3); d1560 2 a1561 4 if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); } d1563 1 a1563 1 nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3)); d1566 1 a1566 1 nfsm_srvpostop_fh(&nsfh); d1571 1 a1571 1 nfsm_srvfhtom(&nsfh, v3); d1604 1 a1604 1 kauth_cred_t cred = nfsd->nd_cr; d1610 1 a1610 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d1616 2 a1617 1 nfsrvfh_t nsfh; d1622 3 a1624 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d1631 1 a1631 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d1687 1 a1687 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1694 3 d1708 3 a1710 1 error = nfsrv_composefh(vp, &nsfh, TRUE); d1715 3 a1717 6 if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); } nfsm_reply(NFSX_SRVFH(&nsfh, TRUE) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1)); d1719 1 a1719 1 nfsm_srvpostop_fh(&nsfh); d1752 1 a1752 1 kauth_cred_t cred = nfsd->nd_cr; d1757 1 a1757 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d1763 2 a1764 1 nfsrvfh_t nsfh; d1771 3 a1773 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d1780 1 a1780 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d1791 1 a1791 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d1841 1 a1841 1 kauth_cred_t cred = nfsd->nd_cr; d1845 1 a1845 1 int error = 0, cache = 0, fdirfor_ret = 1, fdiraft_ret = 1; d1855 2 a1856 1 nfsrvfh_t fnsfh, tnsfh; d1864 2 d1868 2 a1869 2 nfsm_srvmtofh(&fnsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&fnsfh)->fh_fsid)) == NULL) d1877 1 a1877 1 saved_uid = kauth_cred_geteuid(cred); d1881 1 a1881 1 error = nfs_namei(&fromnd, &fnsfh, len, slp, nam, &md, d1901 1 a1901 1 nfsm_srvmtofh(&tnsfh); d1911 1 a1911 1 kauth_cred_seteuid(cred, saved_uid); d1915 1 a1915 1 error = nfs_namei(&tond, &tnsfh, len2, slp, nam, &md, a2031 1 #ifdef notdef a2033 1 #endif d2061 1 a2061 1 kauth_cred_t cred = nfsd->nd_cr; d2066 1 a2066 1 int error = 0, rdonly, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2072 2 a2073 1 nfsrvfh_t nsfh, dnsfh; d2077 4 a2080 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d2083 1 a2083 1 nfsm_srvmtofh(&dnsfh); d2085 1 a2085 1 error = nfsrv_fhtovp(&nsfh, FALSE, &vp, cred, slp, nam, d2094 1 a2094 2 if (vp->v_type == VDIR && (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d2099 1 a2099 1 error = nfs_namei(&nd, &dnsfh, len, slp, nam, &md, &dpos, d2165 1 a2165 1 kauth_cred_t cred = nfsd->nd_cr; d2174 1 a2174 1 int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1; d2179 2 a2180 1 nfsrvfh_t nsfh; d2185 3 a2187 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d2194 1 a2194 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d2230 1 d2232 1 a2232 1 UIO_SETUP_SYSSPACE(&io); d2255 3 a2257 1 error = nfsrv_composefh(nd.ni_vp, &nsfh, v3); d2272 1 a2272 2 nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); d2275 1 a2275 1 nfsm_srvpostop_fh(&nsfh); d2311 1 a2311 1 kauth_cred_t cred = nfsd->nd_cr; d2319 1 a2319 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2324 2 a2325 1 nfsrvfh_t nsfh; d2329 3 a2331 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d2338 1 a2338 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d2380 3 a2382 1 error = nfsrv_composefh(vp, &nsfh, v3); d2392 1 a2392 2 nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); d2395 1 a2395 1 nfsm_srvpostop_fh(&nsfh); d2400 1 a2400 1 nfsm_srvfhtom(&nsfh, v3); d2433 1 a2433 1 kauth_cred_t cred = nfsd->nd_cr; d2437 1 a2437 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2443 2 a2444 1 nfsrvfh_t nsfh; d2449 3 a2451 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d2458 1 a2458 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d2560 1 d2573 1 a2573 1 kauth_cred_t cred = nfsd->nd_cr; d2585 2 a2586 1 nfsrvfh_t nsfh; d2590 1 a2590 1 int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, ncookies; d2596 2 a2597 1 nfsm_srvmtofh(&nsfh); d2615 1 a2615 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d2654 1 d2656 1 a2656 1 UIO_SETUP_SYSSPACE(&io); a2725 1 free(cookies, M_TEMP); d2836 1 a2836 1 kauth_cred_t cred = nfsd->nd_cr; d2848 2 a2849 1 nfsrvfh_t nsfh; d2855 1 a2855 1 int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, dirlen, ncookies; d2859 2 a2860 1 nfsm_srvmtofh(&nsfh); d2874 1 a2874 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d2913 1 d2915 1 a2915 1 UIO_SETUP_SYSSPACE(&io); a2996 1 free(cookies, M_TEMP); a3011 2 nfsrvfh_t nnsfh; d3021 4 a3024 1 if (nfsrv_composefh(nvp, &nnsfh, TRUE)) { d3094 1 a3094 1 xfer = sizeof(struct flrep); a3107 18 /* * ... and filehandle. */ xfer = NFSRVFH_SIZE(&nnsfh); cp = NFSRVFH_DATA(&nnsfh); while (xfer > 0) { nfsm_clget; if ((bp + xfer) > be) tsiz = be - bp; else tsiz = xfer; memcpy(bp, cp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } d3148 1 a3148 1 kauth_cred_t cred = nfsd->nd_cr; d3151 2 a3152 1 nfsrvfh_t nsfh; d3156 1 a3156 1 int error = 0, rdonly, for_ret = 1, aft_ret = 1, cache = 0; d3163 6 a3168 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d3176 1 a3176 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d3220 2 a3221 2 kauth_cred_t cred = nfsd->nd_cr; struct statvfs *sf = NULL; d3226 1 a3226 1 int error = 0, rdonly, cache = 0, getret = 1; d3232 3 a3234 1 nfsrvfh_t nsfh; d3237 6 a3242 2 nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d3249 1 a3249 1 sf = malloc(sizeof(*sf), M_TEMP, M_WAITOK); d3256 1 a3256 2 if (error) { free(sf, M_TEMP); a3257 1 } d3279 1 a3279 4 nfsmout: if (sf) free(sf, M_TEMP); return error; d3295 1 a3295 1 kauth_cred_t cred = nfsd->nd_cr; d3300 1 a3300 1 int error = 0, rdonly, cache = 0, getret = 1; d3306 2 a3307 1 nfsrvfh_t nsfh; d3309 1 a3309 1 struct statvfs *sb; d3311 6 a3316 2 nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d3325 2 a3326 4 sb = malloc(sizeof(*sb), M_TEMP, M_WAITOK); VFS_STATVFS(vp->v_mount, sb, (struct lwp *)0); maxfsize = (u_quad_t)0x80000000 * sb->f_frsize - 1; free(sb, M_TEMP); d3372 1 a3372 1 kauth_cred_t cred = nfsd->nd_cr; d3377 1 a3377 1 int error = 0, rdonly, cache = 0, getret = 1; d3383 2 a3384 1 nfsrvfh_t nsfh; d3387 6 a3392 2 nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d3493 1 a3493 1 kauth_cred_t cred; a3495 1 int override; d3532 1 a3532 1 if (override && error == EACCES && kauth_cred_geteuid(cred) == vattr.va_uid) @ 1.100.4.1 log @Adapt for timecounters: mostly use get*time() and use "time_second" instead of "time.tv_sec". @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.100 2006/01/03 11:41:50 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.100 2006/01/03 11:41:50 yamt Exp $"); a1003 1 struct timeval now; d1037 1 a1037 2 getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; d1149 1 a1149 2 getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; @ 1.100.4.2 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.107 2006/04/15 01:58:44 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.107 2006/04/15 01:58:44 christos Exp $"); d185 1 a185 1 int error = 0, rdonly, cache = 0; d232 1 a232 1 int error = 0, rdonly, cache = 0, preat_ret = 1, postat_ret = 1; d370 1 a370 1 int error = 0, cache = 0, dirattr_ret = 1; a451 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d488 1 a488 1 int error = 0, rdonly, cache = 0, i, padlen, getret; d530 2 a531 1 UIO_SETUP_SYSSPACE(uiop); d590 1 a590 1 int error = 0, rdonly, cache = 0, getret; d763 1 a763 1 UIO_SETUP_SYSSPACE(uiop); d822 1 a822 1 int error = 0, rdonly, cache = 0, len, forat_ret = 1; d952 2 a954 1 UIO_SETUP_SYSSPACE(uiop); d1017 1 a1017 1 int error = 0, rdonly, cache = 0, len = 0, forat_ret = 1; d1194 2 a1197 1 UIO_SETUP_SYSSPACE(uiop); d1385 1 a1385 1 int error = 0, cache = 0, len, tsize, dirfor_ret = 1, diraft_ret = 1; a1550 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d1563 2 a1564 4 if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); } d1613 1 a1613 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d1697 3 a1716 5 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); } if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); d1718 2 d1760 1 a1760 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d1848 1 a1848 1 int error = 0, cache = 0, fdirfor_ret = 1, fdiraft_ret = 1; a2034 1 #ifdef notdef a2036 1 #endif d2069 1 a2069 1 int error = 0, rdonly, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2177 1 a2177 1 int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1; d2233 1 d2235 1 a2235 1 UIO_SETUP_SYSSPACE(&io); a2263 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d2322 1 a2322 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; a2388 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d2440 1 a2440 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2593 1 a2593 1 int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, ncookies; d2657 1 d2659 1 a2659 1 UIO_SETUP_SYSSPACE(&io); d2858 1 a2858 1 int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, dirlen, ncookies; d2916 1 d2918 1 a2918 1 UIO_SETUP_SYSSPACE(&io); a3035 1 KASSERT(fhp->fh_fid.fid_len <= _VFS_MAXFIDSZ); d3159 1 a3159 1 int error = 0, rdonly, for_ret = 1, aft_ret = 1, cache = 0; d3166 3 d3229 1 a3229 1 int error = 0, rdonly, cache = 0, getret = 1; d3240 3 d3303 1 a3303 1 int error = 0, rdonly, cache = 0, getret = 1; d3314 3 d3380 1 a3380 1 int error = 0, rdonly, cache = 0, getret = 1; d3390 3 @ 1.100.4.3 log @Sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.100.4.2 2006/04/22 11:40:15 simonb Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.100.4.2 2006/04/22 11:40:15 simonb Exp $"); a72 1 #include d107 1 a107 1 kauth_cred_t cred = nfsd->nd_cr; d176 1 a176 1 kauth_cred_t cred = nfsd->nd_cr; d222 1 a222 1 kauth_cred_t cred = nfsd->nd_cr; a239 2 memset(&guard, 0, sizeof guard); /* XXX gcc */ d360 1 a360 1 kauth_cred_t cred = nfsd->nd_cr; d482 1 a482 1 kauth_cred_t cred = nfsd->nd_cr; d583 1 a583 1 kauth_cred_t cred = nfsd->nd_cr; d812 1 a812 1 kauth_cred_t cred = nfsd->nd_cr; a989 23 * XXX elad: the original NFSW_SAMECRED() macro also made sure the * two nd_flag fields of the descriptors contained * ND_KERBAUTH. */ static int nfsrv_samecred(kauth_cred_t cred1, kauth_cred_t cred2) { int i, do_ngroups; if (kauth_cred_geteuid(cred1) != kauth_cred_geteuid(cred2)) return (0); if (kauth_cred_ngroups(cred1) != kauth_cred_ngroups(cred2)) return (0); do_ngroups = kauth_cred_ngroups(cred1); for (i = 0; i < do_ngroups; i++) if (kauth_cred_group(cred1, i) != kauth_cred_group(cred2, i)) return (0); return (1); } /* d1011 1 a1011 1 kauth_cred_t cred; d1032 1 a1032 1 cred = nfsd->nd_cr; d1135 1 a1135 1 if (nfsrv_samecred(owp->nd_cr, nfsd->nd_cr)) d1164 1 a1164 1 cred = nfsd->nd_cr; d1374 1 a1374 1 kauth_cred_t cred = nfsd->nd_cr; d1494 1 a1494 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1608 1 a1608 1 kauth_cred_t cred = nfsd->nd_cr; d1691 1 a1691 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1756 1 a1756 1 kauth_cred_t cred = nfsd->nd_cr; d1795 1 a1795 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d1845 1 a1845 1 kauth_cred_t cred = nfsd->nd_cr; d1881 1 a1881 1 saved_uid = kauth_cred_geteuid(cred); d1915 1 a1915 1 kauth_cred_seteuid(cred, saved_uid); d2067 1 a2067 1 kauth_cred_t cred = nfsd->nd_cr; d2100 1 a2100 2 if (vp->v_type == VDIR && (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d2171 1 a2171 1 kauth_cred_t cred = nfsd->nd_cr; d2317 1 a2317 1 kauth_cred_t cred = nfsd->nd_cr; d2440 1 a2440 1 kauth_cred_t cred = nfsd->nd_cr; d2580 1 a2580 1 kauth_cred_t cred = nfsd->nd_cr; d2842 1 a2842 1 kauth_cred_t cred = nfsd->nd_cr; d3154 1 a3154 1 kauth_cred_t cred = nfsd->nd_cr; d3223 1 a3223 1 kauth_cred_t cred = nfsd->nd_cr; d3295 1 a3295 1 kauth_cred_t cred = nfsd->nd_cr; d3369 1 a3369 1 kauth_cred_t cred = nfsd->nd_cr; d3487 1 a3487 1 kauth_cred_t cred; d3526 1 a3526 1 if (override && error == EACCES && kauth_cred_geteuid(cred) == vattr.va_uid) @ 1.99 log @merge ktrace-lwp. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.79.2.8 2005/11/10 14:11:55 skrll Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.79.2.8 2005/11/10 14:11:55 skrll Exp $"); d1116 1 a1116 1 memcmp((caddr_t)&nfsd->nd_fh, (caddr_t)&wp->nd_fh, NFSX_V3FH)) { d1121 1 a1121 1 !memcmp((caddr_t)&nfsd->nd_fh, (caddr_t)&wp->nd_fh, NFSX_V3FH)) { @ 1.99.2.1 log @- adapt nfs. - nfs_doio_read: #if 0 out "killproc if text is modified" part of the code as it's broken. (a process reading the modified text is not necessarily a process which is using the file as a text.) @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); d530 2 a531 1 UIO_SETUP_SYSSPACE(uiop); d763 1 a763 1 UIO_SETUP_SYSSPACE(uiop); d952 2 a954 1 UIO_SETUP_SYSSPACE(uiop); d1191 2 a1194 1 UIO_SETUP_SYSSPACE(uiop); d2230 1 d2232 1 a2232 1 UIO_SETUP_SYSSPACE(&io); d2654 1 d2656 1 a2656 1 UIO_SETUP_SYSSPACE(&io); d2913 1 d2915 1 a2915 1 UIO_SETUP_SYSSPACE(&io); @ 1.99.2.2 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.99.2.1 2005/12/31 16:29:01 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.99.2.1 2005/12/31 16:29:01 yamt Exp $"); d1114 1 a1114 1 memcmp(&nfsd->nd_fh, &wp->nd_fh, NFSX_V3FH)) { d1119 1 a1119 1 !memcmp(&nfsd->nd_fh, &wp->nd_fh, NFSX_V3FH)) { @ 1.98 log @- remove a ufs dependency. - bump readdir block size to 1024. (the same value as userland DIRBLKSIZ) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.97 2005/09/06 09:36:28 jmmv Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.97 2005/09/06 09:36:28 jmmv Exp $"); d98 1 a98 1 nfsrv3_access(nfsd, slp, procp, mrq) d101 1 a101 1 struct proc *procp; d134 1 a134 1 nfsrv_access(vp, VREAD, cred, rdonly, procp, 0) == 0) d139 1 a139 1 nfsrv_access(vp, VWRITE, cred, rdonly, procp, 0) == 0) d142 1 a142 1 nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0) == 0) d148 1 a148 1 nfsrv_access(vp, VWRITE, cred, rdonly, procp, 0) == 0) d151 1 a151 1 nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0) == 0) d154 1 a154 1 getret = VOP_GETATTR(vp, &va, cred, procp); d167 1 a167 1 nfsrv_getattr(nfsd, slp, procp, mrq) d170 1 a170 1 struct proc *procp; d199 1 a199 1 error = VOP_GETATTR(vp, &va, cred, procp); d213 1 a213 1 nfsrv_setattr(nfsd, slp, procp, mrq) d216 1 a216 1 struct proc *procp; d298 1 a298 1 error = preat_ret = VOP_GETATTR(vp, &preat, cred, procp); d326 1 a326 1 procp, 0)) != 0) d329 2 a330 2 error = VOP_SETATTR(vp, &va, cred, procp); postat_ret = VOP_GETATTR(vp, &va, cred, procp); d351 1 a351 1 nfsrv_lookup(nfsd, slp, procp, mrq) d354 1 a354 1 struct proc *procp; d388 1 a388 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), pubflag); d432 1 a432 2 dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, procp); d450 1 a450 1 error = VOP_GETATTR(vp, &va, cred, procp); d472 1 a472 1 nfsrv_readlink(nfsd, slp, procp, mrq) d475 1 a475 1 struct proc *procp; d531 1 a531 1 uiop->uio_procp = NULL; d550 1 a550 1 getret = VOP_GETATTR(vp, &attr, cred, procp); d574 1 a574 1 nfsrv_read(nfsd, slp, procp, mrq) d577 1 a577 1 struct proc *procp; d631 2 a632 2 if ((error = nfsrv_access(vp, VREAD, cred, rdonly, procp, 1)) != 0) error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 1); d634 1 a634 1 getret = VOP_GETATTR(vp, &va, cred, procp); d768 1 a768 1 if (error || (getret = VOP_GETATTR(vp, &va, cred, procp)) != 0){ d803 1 a803 1 nfsrv_write(nfsd, slp, procp, mrq) d806 1 a806 1 struct proc *procp; d904 1 a904 1 forat_ret = VOP_GETATTR(vp, &forat, cred, procp); d913 1 a913 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1); d953 1 a953 1 uiop->uio_procp = NULL; d959 1 a959 1 aftat_ret = VOP_GETATTR(vp, &va, cred, procp); d998 1 a998 1 nfsrv_writegather(ndp, slp, procp, mrq) d1001 1 a1001 1 struct proc *procp; d1170 1 a1170 1 forat_ret = VOP_GETATTR(vp, &forat, cred, procp); d1181 1 a1181 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1); d1192 1 a1192 1 uiop->uio_procp = NULL; d1231 1 a1231 1 aftat_ret = VOP_GETATTR(vp, &va, cred, procp); d1364 1 a1364 1 nfsrv_create(nfsd, slp, procp, mrq) d1367 1 a1367 1 struct proc *procp; d1405 1 a1405 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1408 1 a1408 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d1485 1 a1485 1 procp); d1529 1 a1529 1 (nd.ni_cnd.cn_flags & RDONLY), procp, 0); d1535 1 a1535 2 error = VOP_SETATTR(vp, &va, cred, procp); d1546 1 a1546 1 error = VOP_GETATTR(vp, &va, cred, procp); d1560 1 a1560 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d1595 1 a1595 1 nfsrv_mknod(nfsd, slp, procp, mrq) d1598 1 a1598 1 struct proc *procp; d1632 1 a1632 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1634 1 a1634 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d1712 1 a1712 1 error = VOP_GETATTR(vp, &va, cred, procp); d1715 1 a1715 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d1743 1 a1743 1 nfsrv_remove(nfsd, slp, procp, mrq) d1746 1 a1746 1 struct proc *procp; d1781 1 a1781 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1784 1 a1784 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d1815 1 a1815 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d1832 1 a1832 1 nfsrv_rename(nfsd, slp, procp, mrq) d1835 1 a1835 1 struct proc *procp; d1882 1 a1882 1 &dpos, &fdirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1885 1 a1885 2 fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, procp); d1916 1 a1916 1 &dpos, &tdirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1919 1 a1919 2 tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, procp); d2012 1 a2012 1 fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, procp); d2016 1 a2016 1 tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, procp); d2052 1 a2052 1 nfsrv_link(nfsd, slp, procp, mrq) d2055 1 a2055 1 struct proc *procp; d2100 1 a2100 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2103 1 a2103 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d2135 1 a2135 1 getret = VOP_GETATTR(vp, &at, cred, procp); d2137 1 a2137 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d2156 1 a2156 1 nfsrv_symlink(nfsd, slp, procp, mrq) d2159 1 a2159 1 struct proc *procp; d2195 1 a2195 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2198 1 a2198 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d2232 1 a2232 1 io.uio_procp = NULL; d2259 1 a2259 2 error = VOP_GETATTR(nd.ni_vp, &va, cred, procp); d2269 1 a2269 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d2302 1 a2302 1 nfsrv_mkdir(nfsd, slp, procp, mrq) d2305 1 a2305 1 struct proc *procp; d2339 1 a2339 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2342 1 a2342 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d2384 1 a2384 1 error = VOP_GETATTR(vp, &va, cred, procp); d2389 1 a2389 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d2424 1 a2424 1 nfsrv_rmdir(nfsd, slp, procp, mrq) d2427 1 a2427 1 struct proc *procp; d2459 1 a2459 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2462 1 a2462 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d2507 1 a2507 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d2564 1 a2564 1 nfsrv_readdir(nfsd, slp, procp, mrq) d2567 1 a2567 1 struct proc *procp; d2628 1 a2628 1 error = getret = VOP_GETATTR(vp, &at, cred, procp); d2638 1 a2638 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); d2656 1 a2656 1 io.uio_procp = NULL; d2666 1 a2666 1 getret = VOP_GETATTR(vp, &at, cred, procp); d2827 1 a2827 1 nfsrv_readdirplus(nfsd, slp, procp, mrq) d2830 1 a2830 1 struct proc *procp; d2885 1 a2885 1 error = getret = VOP_GETATTR(vp, &at, cred, procp); d2895 1 a2895 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); d2915 1 a2915 1 io.uio_procp = NULL; d2923 1 a2923 1 getret = VOP_GETATTR(vp, &at, cred, procp); d3028 1 a3028 1 if (VOP_GETATTR(nvp, vap, cred, procp)) { d3139 1 a3139 1 nfsrv_commit(nfsd, slp, procp, mrq) d3142 1 a3142 1 struct proc *procp; d3184 1 a3184 1 for_ret = VOP_GETATTR(vp, &bfor, cred, procp); d3189 1 a3189 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, procp); d3191 1 a3191 1 aft_ret = VOP_GETATTR(vp, &aft, cred, procp); d3211 1 a3211 1 nfsrv_statfs(nfsd, slp, procp, mrq) d3214 1 a3214 1 struct proc *procp; d3250 2 a3251 2 error = VFS_STATVFS(vp->v_mount, sf, procp); getret = VOP_GETATTR(vp, &at, cred, procp); d3286 1 a3286 1 nfsrv_fsinfo(nfsd, slp, procp, mrq) d3289 1 a3289 1 struct proc *procp; d3325 1 a3325 1 VFS_STATVFS(vp->v_mount, &sb, (struct proc *)0); d3328 1 a3328 1 getret = VOP_GETATTR(vp, &at, cred, procp); d3363 1 a3363 1 nfsrv_pathconf(nfsd, slp, procp, mrq) d3366 1 a3366 1 struct proc *procp; d3406 1 a3406 1 getret = VOP_GETATTR(vp, &at, cred, procp); d3434 1 a3434 1 nfsrv_null(nfsd, slp, procp, mrq) d3437 1 a3437 1 struct proc *procp; d3455 1 a3455 1 nfsrv_noop(nfsd, slp, procp, mrq) d3458 1 a3458 1 struct proc *procp; d3490 1 a3490 1 nfsrv_access(vp, flags, cred, rdonly, p, override) d3495 1 a3495 1 struct proc *p; d3524 1 a3524 1 error = VOP_GETATTR(vp, &vattr, cred, p); d3527 1 a3527 1 error = VOP_ACCESS(vp, flags, cred, p); @ 1.98.6.1 log @adapt ffs, lfs, nfs. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.98 2005/10/06 10:23:01 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.98 2005/10/06 10:23:01 yamt Exp $"); d765 1 a765 1 error = VOP_READ(vp, uiop, NULL, IO_NODELOCKED, cred); @ 1.98.6.2 log @- associate read-ahead context to vnode, rather than file. - revert VOP_READ prototype. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.98.6.1 2005/11/15 03:48:47 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.98.6.1 2005/11/15 03:48:47 yamt Exp $"); d765 1 a765 1 error = VOP_READ(vp, uiop, IO_NODELOCKED, cred); @ 1.97 log @Set va_type to VLNK before calling VOP_SYMLINK to match the change in the vfs_syscalls.c file. Pointed out by yamt@@. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.96 2005/08/19 12:47:23 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.96 2005/08/19 12:47:23 yamt Exp $"); a72 1 #include d2534 1 a2534 1 * count rounded up to a multiple of NFS_DIRBLKSIZ <= NFS_MAXREADDIR d2562 3 d2621 1 a2621 1 siz = ((cnt + DIRBLKSIZ - 1) & ~(DIRBLKSIZ - 1)); d2880 1 a2880 1 siz = ((siz + DIRBLKSIZ - 1) & ~(DIRBLKSIZ - 1)); @ 1.96 log @as we now have 64bit ino_t, no need to truncate nfsv3 fileids. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.95 2005/05/18 12:57:34 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.95 2005/05/18 12:57:34 yamt Exp $"); d2216 1 @ 1.95 log @nfsrv_mknod: reject device numbers which we can't handle. @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); d2769 1 a2769 1 *tl = 0; d3071 1 a3071 1 *tl = 0; @ 1.95.2.1 log @nfsrv_read: defer mbuf mapping. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.95 2005/05/18 12:57:34 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.95 2005/05/18 12:57:34 yamt Exp $"); a701 4 #if defined(__HAVE_LAZY_MBUF) m->m_flags |= M_EXT_LAZY; m->m_ext.ext_flags |= M_EXT_LAZY; #else /* defined(__HAVE_LAZY_MBUF) */ a709 1 #endif /* defined(__HAVE_LAZY_MBUF) */ @ 1.95.2.2 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.95.2.1 2005/07/07 13:03:20 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.95.2.1 2005/07/07 13:03:20 yamt Exp $"); d73 1 a73 1 #include d99 1 a99 1 nfsrv3_access(nfsd, slp, lwp, mrq) d102 1 a102 1 struct lwp *lwp; d108 1 a108 1 kauth_cred_t cred = nfsd->nd_cr; d135 1 a135 1 nfsrv_access(vp, VREAD, cred, rdonly, lwp, 0) == 0) d140 1 a140 1 nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0) == 0) d143 1 a143 1 nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0) == 0) d149 1 a149 1 nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0) == 0) d152 1 a152 1 nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0) == 0) d155 1 a155 1 getret = VOP_GETATTR(vp, &va, cred, lwp); d168 1 a168 1 nfsrv_getattr(nfsd, slp, lwp, mrq) d171 1 a171 1 struct lwp *lwp; d177 1 a177 1 kauth_cred_t cred = nfsd->nd_cr; d186 1 a186 1 int error = 0, rdonly, cache = 0; d200 1 a200 1 error = VOP_GETATTR(vp, &va, cred, lwp); d214 1 a214 1 nfsrv_setattr(nfsd, slp, lwp, mrq) d217 1 a217 1 struct lwp *lwp; d223 1 a223 1 kauth_cred_t cred = nfsd->nd_cr; d233 1 a233 1 int error = 0, rdonly, cache = 0, preat_ret = 1, postat_ret = 1; a240 2 memset(&guard, 0, sizeof guard); /* XXX gcc */ d299 1 a299 1 error = preat_ret = VOP_GETATTR(vp, &preat, cred, lwp); d327 1 a327 1 lwp, 0)) != 0) d330 2 a331 2 error = VOP_SETATTR(vp, &va, cred, lwp); postat_ret = VOP_GETATTR(vp, &va, cred, lwp); d352 1 a352 1 nfsrv_lookup(nfsd, slp, lwp, mrq) d355 1 a355 1 struct lwp *lwp; d361 1 a361 1 kauth_cred_t cred = nfsd->nd_cr; d371 1 a371 1 int error = 0, cache = 0, dirattr_ret = 1; d389 1 a389 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag); d433 2 a434 1 dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, lwp); d448 3 a450 1 error = vfs_composefh(vp, fhp); d452 1 a452 1 error = VOP_GETATTR(vp, &va, cred, lwp); d474 1 a474 1 nfsrv_readlink(nfsd, slp, lwp, mrq) d477 1 a477 1 struct lwp *lwp; d483 1 a483 1 kauth_cred_t cred = nfsd->nd_cr; d490 1 a490 1 int error = 0, rdonly, cache = 0, i, padlen, getret; d532 2 a533 1 UIO_SETUP_SYSSPACE(uiop); d552 1 a552 1 getret = VOP_GETATTR(vp, &attr, cred, lwp); d576 1 a576 1 nfsrv_read(nfsd, slp, lwp, mrq) d579 1 a579 1 struct lwp *lwp; d585 1 a585 1 kauth_cred_t cred = nfsd->nd_cr; d592 1 a592 1 int error = 0, rdonly, cache = 0, getret; d633 2 a634 2 if ((error = nfsrv_access(vp, VREAD, cred, rdonly, lwp, 1)) != 0) error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 1); d636 1 a636 1 getret = VOP_GETATTR(vp, &va, cred, lwp); d770 1 a770 1 UIO_SETUP_SYSSPACE(uiop); d775 1 a775 1 if (error || (getret = VOP_GETATTR(vp, &va, cred, lwp)) != 0){ d810 1 a810 1 nfsrv_write(nfsd, slp, lwp, mrq) d813 1 a813 1 struct lwp *lwp; d819 1 a819 1 kauth_cred_t cred = nfsd->nd_cr; d829 1 a829 1 int error = 0, rdonly, cache = 0, len, forat_ret = 1; d911 1 a911 1 forat_ret = VOP_GETATTR(vp, &forat, cred, lwp); d920 1 a920 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 1); d959 2 a961 1 UIO_SETUP_SYSSPACE(uiop); d966 1 a966 1 aftat_ret = VOP_GETATTR(vp, &va, cred, lwp); a997 23 * XXX elad: the original NFSW_SAMECRED() macro also made sure the * two nd_flag fields of the descriptors contained * ND_KERBAUTH. */ static int nfsrv_samecred(kauth_cred_t cred1, kauth_cred_t cred2) { int i, do_ngroups; if (kauth_cred_geteuid(cred1) != kauth_cred_geteuid(cred2)) return (0); if (kauth_cred_ngroups(cred1) != kauth_cred_ngroups(cred2)) return (0); do_ngroups = kauth_cred_ngroups(cred1); for (i = 0; i < do_ngroups; i++) if (kauth_cred_group(cred1, i) != kauth_cred_group(cred2, i)) return (0); return (1); } /* d1005 1 a1005 1 nfsrv_writegather(ndp, slp, lwp, mrq) d1008 1 a1008 1 struct lwp *lwp; a1010 1 struct timeval now; d1018 1 a1018 1 kauth_cred_t cred; d1023 1 a1023 1 int error = 0, rdonly, cache = 0, len = 0, forat_ret = 1; d1039 1 a1039 1 cred = nfsd->nd_cr; d1044 1 a1044 2 getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; d1123 1 a1123 1 memcmp(&nfsd->nd_fh, &wp->nd_fh, NFSX_V3FH)) { d1128 1 a1128 1 !memcmp(&nfsd->nd_fh, &wp->nd_fh, NFSX_V3FH)) { d1141 1 a1141 1 if (nfsrv_samecred(owp->nd_cr, nfsd->nd_cr)) d1156 1 a1156 2 getmicrotime(&now); cur_usec = (u_quad_t)now.tv_sec * 1000000 + (u_quad_t)now.tv_usec; d1169 1 a1169 1 cred = nfsd->nd_cr; d1177 1 a1177 1 forat_ret = VOP_GETATTR(vp, &forat, cred, lwp); d1188 1 a1188 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 1); d1198 2 a1201 1 UIO_SETUP_SYSSPACE(uiop); d1238 1 a1238 1 aftat_ret = VOP_GETATTR(vp, &va, cred, lwp); d1371 1 a1371 1 nfsrv_create(nfsd, slp, lwp, mrq) d1374 1 a1374 1 struct lwp *lwp; d1380 1 a1380 1 kauth_cred_t cred = nfsd->nd_cr; d1389 1 a1389 1 int error = 0, cache = 0, len, tsize, dirfor_ret = 1, diraft_ret = 1; d1412 1 a1412 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1415 2 a1416 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1493 1 a1493 1 lwp); d1501 1 a1501 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1537 1 a1537 1 (nd.ni_cnd.cn_flags & RDONLY), lwp, 0); d1543 2 a1544 1 error = VOP_SETATTR(vp, &va, cred, lwp); d1551 3 a1553 1 error = vfs_composefh(vp, fhp); d1555 1 a1555 1 error = VOP_GETATTR(vp, &va, cred, lwp); d1569 2 a1570 4 if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); } d1604 1 a1604 1 nfsrv_mknod(nfsd, slp, lwp, mrq) d1607 1 a1607 1 struct lwp *lwp; d1613 1 a1613 1 kauth_cred_t cred = nfsd->nd_cr; d1619 1 a1619 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d1641 1 a1641 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1643 1 a1643 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1696 1 a1696 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1703 3 d1717 3 a1719 1 error = vfs_composefh(vp, fhp); d1721 1 a1721 1 error = VOP_GETATTR(vp, &va, cred, lwp); d1724 2 a1725 4 if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); vrele(dirp); } d1752 1 a1752 1 nfsrv_remove(nfsd, slp, lwp, mrq) d1755 1 a1755 1 struct lwp *lwp; d1761 1 a1761 1 kauth_cred_t cred = nfsd->nd_cr; d1766 1 a1766 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d1790 1 a1790 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1793 2 a1794 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1801 1 a1801 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d1825 1 a1825 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1842 1 a1842 1 nfsrv_rename(nfsd, slp, lwp, mrq) d1845 1 a1845 1 struct lwp *lwp; d1851 1 a1851 1 kauth_cred_t cred = nfsd->nd_cr; d1855 1 a1855 1 int error = 0, cache = 0, fdirfor_ret = 1, fdiraft_ret = 1; d1887 1 a1887 1 saved_uid = kauth_cred_geteuid(cred); d1892 1 a1892 1 &dpos, &fdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1895 2 a1896 1 fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, lwp); d1922 1 a1922 1 kauth_cred_seteuid(cred, saved_uid); d1927 1 a1927 1 &dpos, &tdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1930 2 a1931 1 tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, lwp); d2024 1 a2024 1 fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, lwp); d2028 1 a2028 1 tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, lwp); a2043 1 #ifdef notdef a2045 1 #endif d2064 1 a2064 1 nfsrv_link(nfsd, slp, lwp, mrq) d2067 1 a2067 1 struct lwp *lwp; d2073 1 a2073 1 kauth_cred_t cred = nfsd->nd_cr; d2078 1 a2078 1 int error = 0, rdonly, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2106 1 a2106 2 if (vp->v_type == VDIR && (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d2112 1 a2112 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2115 2 a2116 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2148 1 a2148 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d2150 1 a2150 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2169 1 a2169 1 nfsrv_symlink(nfsd, slp, lwp, mrq) d2172 1 a2172 1 struct lwp *lwp; d2178 1 a2178 1 kauth_cred_t cred = nfsd->nd_cr; d2187 1 a2187 1 int error = 0, cache = 0, dirfor_ret = 1, diraft_ret = 1; d2208 1 a2208 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2211 2 a2212 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); a2220 1 va.va_type = VLNK; d2243 1 d2245 1 a2245 1 UIO_SETUP_SYSSPACE(&io); d2268 3 a2270 1 error = vfs_composefh(nd.ni_vp, fhp); d2272 2 a2273 1 error = VOP_GETATTR(nd.ni_vp, &va, cred, lwp); d2283 1 a2283 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2316 1 a2316 1 nfsrv_mkdir(nfsd, slp, lwp, mrq) d2319 1 a2319 1 struct lwp *lwp; d2325 1 a2325 1 kauth_cred_t cred = nfsd->nd_cr; d2333 1 a2333 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2353 1 a2353 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2356 2 a2357 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2395 3 a2397 1 error = vfs_composefh(vp, fhp); d2399 1 a2399 1 error = VOP_GETATTR(vp, &va, cred, lwp); d2404 1 a2404 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2439 1 a2439 1 nfsrv_rmdir(nfsd, slp, lwp, mrq) d2442 1 a2442 1 struct lwp *lwp; d2448 1 a2448 1 kauth_cred_t cred = nfsd->nd_cr; d2452 1 a2452 1 int error = 0, cache = 0, len, dirfor_ret = 1, diraft_ret = 1; d2474 1 a2474 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2477 2 a2478 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2523 1 a2523 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2539 1 a2539 1 * count rounded up to a multiple of NFS_SRVDIRBLKSIZ <= NFS_MAXREADDIR a2566 3 #define NFS_SRVDIRBLKSIZ 1024 d2577 1 a2577 1 nfsrv_readdir(nfsd, slp, lwp, mrq) d2580 1 a2580 1 struct lwp *lwp; d2586 1 a2586 1 kauth_cred_t cred = nfsd->nd_cr; d2603 1 a2603 1 int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, ncookies; d2623 1 a2623 1 siz = ((cnt + NFS_SRVDIRBLKSIZ - 1) & ~(NFS_SRVDIRBLKSIZ - 1)); d2641 1 a2641 1 error = getret = VOP_GETATTR(vp, &at, cred, lwp); d2651 1 a2651 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0); d2667 1 d2669 1 a2669 1 UIO_SETUP_SYSSPACE(&io); d2679 1 a2679 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d2774 1 a2774 1 *tl = txdr_unsigned(dp->d_fileno >> 32); d2840 1 a2840 1 nfsrv_readdirplus(nfsd, slp, lwp, mrq) d2843 1 a2843 1 struct lwp *lwp; d2849 1 a2849 1 kauth_cred_t cred = nfsd->nd_cr; d2868 1 a2868 1 int siz, cnt, fullsiz, eofflag, rdonly, cache = 0, dirlen, ncookies; d2882 1 a2882 1 siz = ((siz + NFS_SRVDIRBLKSIZ - 1) & ~(NFS_SRVDIRBLKSIZ - 1)); d2898 1 a2898 1 error = getret = VOP_GETATTR(vp, &at, cred, lwp); d2908 1 a2908 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0); d2926 1 d2928 1 a2928 1 UIO_SETUP_SYSSPACE(&io); d2936 1 a2936 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d3034 4 a3037 1 if (vfs_composefh(nvp, nfhp)) { d3041 1 a3041 1 if (VOP_GETATTR(nvp, vap, cred, lwp)) { d3076 1 a3076 1 *tl = txdr_unsigned(dp->d_fileno >> 32); d3152 1 a3152 1 nfsrv_commit(nfsd, slp, lwp, mrq) d3155 1 a3155 1 struct lwp *lwp; d3161 1 a3161 1 kauth_cred_t cred = nfsd->nd_cr; d3169 1 a3169 1 int error = 0, rdonly, for_ret = 1, aft_ret = 1, cache = 0; d3176 3 d3197 1 a3197 1 for_ret = VOP_GETATTR(vp, &bfor, cred, lwp); d3202 1 a3202 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, lwp); d3204 1 a3204 1 aft_ret = VOP_GETATTR(vp, &aft, cred, lwp); d3224 1 a3224 1 nfsrv_statfs(nfsd, slp, lwp, mrq) d3227 1 a3227 1 struct lwp *lwp; d3233 2 a3234 2 kauth_cred_t cred = nfsd->nd_cr; struct statvfs *sf = NULL; d3239 1 a3239 1 int error = 0, rdonly, cache = 0, getret = 1; d3247 1 d3250 3 d3262 3 a3264 3 sf = malloc(sizeof(*sf), M_TEMP, M_WAITOK); error = VFS_STATVFS(vp->v_mount, sf, lwp); getret = VOP_GETATTR(vp, &at, cred, lwp); d3269 1 a3269 2 if (error) { free(sf, M_TEMP); a3270 1 } d3292 1 a3292 4 nfsmout: if (sf) free(sf, M_TEMP); return error; d3299 1 a3299 1 nfsrv_fsinfo(nfsd, slp, lwp, mrq) d3302 1 a3302 1 struct lwp *lwp; d3308 1 a3308 1 kauth_cred_t cred = nfsd->nd_cr; d3313 1 a3313 1 int error = 0, rdonly, cache = 0, getret = 1; d3322 1 a3322 1 struct statvfs *sb; d3324 3 d3338 2 a3339 4 sb = malloc(sizeof(*sb), M_TEMP, M_WAITOK); VFS_STATVFS(vp->v_mount, sb, (struct lwp *)0); maxfsize = (u_quad_t)0x80000000 * sb->f_frsize - 1; free(sb, M_TEMP); d3341 1 a3341 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d3376 1 a3376 1 nfsrv_pathconf(nfsd, slp, lwp, mrq) d3379 1 a3379 1 struct lwp *lwp; d3385 1 a3385 1 kauth_cred_t cred = nfsd->nd_cr; d3390 1 a3390 1 int error = 0, rdonly, cache = 0, getret = 1; d3400 3 d3419 1 a3419 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d3447 1 a3447 1 nfsrv_null(nfsd, slp, lwp, mrq) d3450 1 a3450 1 struct lwp *lwp; d3468 1 a3468 1 nfsrv_noop(nfsd, slp, lwp, mrq) d3471 1 a3471 1 struct lwp *lwp; d3503 1 a3503 1 nfsrv_access(vp, flags, cred, rdonly, lwp, override) d3506 1 a3506 1 kauth_cred_t cred; d3508 1 a3508 1 struct lwp *lwp; d3537 1 a3537 1 error = VOP_GETATTR(vp, &vattr, cred, lwp); d3540 1 a3540 1 error = VOP_ACCESS(vp, flags, cred, lwp); d3545 1 a3545 1 if (override && error == EACCES && kauth_cred_geteuid(cred) == vattr.va_uid) @ 1.95.2.3 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.95.2.2 2006/06/21 15:11:58 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.95.2.2 2006/06/21 15:11:58 yamt Exp $"); a72 1 #include d82 1 a94 2 #define nqsrv_getl(vp, rw) /* nothing */ d110 2 a111 1 nfsrvfh_t nsfh; d122 2 a123 1 nfsm_srvmtofh(&nsfh); d125 1 a125 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, d181 2 a182 1 nfsrvfh_t nsfh; d191 3 a193 2 nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, d228 2 a229 1 nfsrvfh_t nsfh; d243 3 a245 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d291 1 a291 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, &rdonly, d367 2 a368 1 nfsrvfh_t nsfh; d381 2 a382 1 nfsm_srvmtofh(&nsfh); d385 1 a385 1 pubflag = nfs_ispublicfh(&nsfh); d390 1 a390 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d446 1 d449 1 a449 1 error = nfsrv_composefh(vp, &nsfh, v3); d453 1 a453 3 vrele(ndp->ni_startdir); nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPORFATTR(v3) + NFSX_POSTOPATTR(v3)); d458 1 a458 1 nfsm_srvfhtom(&nsfh, v3); d496 2 a497 1 nfsrvfh_t nsfh; d501 2 a502 1 nfsm_srvmtofh(&nsfh); d532 1 a532 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d597 2 a598 1 nfsrvfh_t nsfh; d604 2 a605 1 nfsm_srvmtofh(&nsfh); d616 1 a616 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d834 2 a835 1 nfsrvfh_t nsfh; d845 3 a847 2 nfsm_srvmtofh(&nsfh); if ((mntp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d900 1 a900 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, a1016 10 static struct nfsrvw_delayhash * nfsrv_nwdelayhash(struct nfssvc_sock *slp, const nfsrvfh_t *nsfh) { uint32_t hash; hash = hash32_buf(NFSRVFH_DATA(nsfh), NFSRVFH_SIZE(nsfh), HASH32_BUF_INIT); return &slp->ns_wdelayhashtbl[hash % NFS_WDELAYHASHSIZ]; } d1141 1 a1141 1 wpp = nfsrv_nwdelayhash(slp, &nfsd->nd_fh); d1144 2 a1145 1 while (wp && nfsrv_comparefh(&nfsd->nd_fh, &wp->nd_fh)) { d1150 1 a1150 1 !nfsrv_comparefh(&nfsd->nd_fh, &wp->nd_fh)) { d1417 2 a1418 1 nfsrvfh_t nsfh; d1424 3 a1426 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d1433 1 a1433 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d1435 7 a1441 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1523 1 a1523 1 KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1538 1 a1539 1 vrele(nd.ni_dvp); d1572 1 a1572 1 error = nfsrv_composefh(vp, &nsfh, v3); d1590 1 d1593 1 a1593 4 if (dirp) { vrele(dirp); } nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3)); d1596 1 a1596 1 nfsm_srvpostop_fh(&nsfh); d1601 1 a1601 1 nfsm_srvfhtom(&nsfh, v3); d1646 2 a1647 1 nfsrvfh_t nsfh; d1652 3 a1654 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d1661 1 a1661 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d1717 2 a1718 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0))) { d1736 1 a1736 1 error = nfsrv_composefh(vp, &nsfh, TRUE); d1745 1 a1745 2 nfsm_reply(NFSX_SRVFH(&nsfh, TRUE) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1)); d1747 1 a1747 1 nfsm_srvpostop_fh(&nsfh); d1754 2 a1762 2 if (dirp) vrele(dirp); d1791 2 a1792 1 nfsrvfh_t nsfh; d1799 3 a1801 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d1808 1 a1808 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d1810 5 a1814 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1819 2 a1820 2 (error = kauth_authorize_generic(cred, KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d1843 2 a1844 4 if (dirp) { if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d1881 2 a1882 2 struct vnode *fvp, *tvp, *tdvp; struct vnode *fdirp = NULL, *tdirp = NULL; d1884 2 a1885 1 nfsrvfh_t fnsfh, tnsfh; d1893 2 d1897 2 a1898 2 nfsm_srvmtofh(&fnsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&fnsfh)->fh_fsid)) == NULL) d1909 2 a1910 2 fromnd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART; error = nfs_namei(&fromnd, &fnsfh, len, slp, nam, &md, d1912 7 a1918 2 if (fdirp && v3) { fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, lwp); d1925 1 a1925 1 vput(fdirp); a1928 1 VOP_UNLOCK(fdirp, 0); d1930 1 a1930 1 nfsm_srvmtofh(&tnsfh); d1944 1 a1944 1 error = nfs_namei(&tond, &tnsfh, len2, slp, nam, &md, d1946 7 a1952 2 if (tdirp && v3) { tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, lwp); d2041 1 a2041 3 if (v3) { fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, lwp); } d2045 1 a2045 3 if (v3) { tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, lwp); } d2103 2 a2104 1 nfsrvfh_t nsfh, dnsfh; d2108 4 a2111 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d2114 1 a2114 1 nfsm_srvmtofh(&dnsfh); d2116 1 a2116 1 error = nfsrv_fhtovp(&nsfh, FALSE, &vp, cred, slp, nam, d2126 1 a2126 1 KAUTH_GENERIC_ISSUSER, (u_short *)0)) != 0) d2131 1 a2131 1 error = nfs_namei(&nd, &dnsfh, len, slp, nam, &md, &dpos, d2133 7 a2139 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2169 1 a2169 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d2211 2 a2212 1 nfsrvfh_t nsfh; d2217 3 a2219 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d2226 1 a2226 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d2228 7 a2234 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2286 1 a2286 1 error = nfsrv_composefh(nd.ni_vp, &nsfh, v3); d2298 1 a2298 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d2301 1 a2301 2 nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); d2304 1 a2304 1 nfsm_srvpostop_fh(&nsfh); d2312 2 a2320 2 if (dirp) vrele(dirp); d2353 2 a2354 1 nfsrvfh_t nsfh; d2358 3 a2360 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d2367 1 a2367 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d2369 7 a2375 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2409 1 a2409 1 error = nfsrv_composefh(vp, &nsfh, v3); d2416 1 a2416 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d2419 1 a2419 2 nfsm_reply(NFSX_SRVFH(&nsfh, v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); d2422 1 a2422 1 nfsm_srvpostop_fh(&nsfh); d2427 1 a2427 1 nfsm_srvfhtom(&nsfh, v3); d2434 2 a2442 2 if (dirp) vrele(dirp); d2470 2 a2471 1 nfsrvfh_t nsfh; d2476 3 a2478 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d2485 1 a2485 1 error = nfs_namei(&nd, &nsfh, len, slp, nam, &md, &dpos, d2487 7 a2493 2 if (dirp && v3) { dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2534 1 a2534 3 if (v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); } d2587 1 d2612 2 a2613 1 nfsrvfh_t nsfh; d2623 2 a2624 1 nfsm_srvmtofh(&nsfh); d2642 1 a2642 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, a2751 1 free(cookies, M_TEMP); d2874 2 a2875 1 nfsrvfh_t nsfh; d2885 2 a2886 1 nfsm_srvmtofh(&nsfh); d2900 1 a2900 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, a3021 1 free(cookies, M_TEMP); a3036 2 nfsrvfh_t nnsfh; d3046 1 a3046 1 if (nfsrv_composefh(nvp, &nnsfh, TRUE)) { d3116 1 a3116 1 xfer = sizeof(struct flrep); a3129 18 /* * ... and filehandle. */ xfer = NFSRVFH_SIZE(&nnsfh); cp = NFSRVFH_DATA(&nnsfh); while (xfer > 0) { nfsm_clget; if ((bp + xfer) > be) tsiz = be - bp; else tsiz = xfer; memcpy(bp, cp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } d3173 2 a3174 1 nfsrvfh_t nsfh; d3185 3 a3187 2 nfsm_srvmtofh(&nsfh); if ((mp = vfs_getvfs(&NFSRVFH_FHANDLE(&nsfh)->fh_fsid)) == NULL) d3195 1 a3195 1 error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d3251 2 a3252 1 nfsrvfh_t nsfh; d3255 3 a3257 2 nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d3326 2 a3327 1 nfsrvfh_t nsfh; d3331 3 a3333 2 nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d3402 2 a3403 1 nfsrvfh_t nsfh; d3406 3 a3408 2 nfsm_srvmtofh(&nsfh); error = nfsrv_fhtovp(&nsfh, 1, &vp, cred, slp, nam, d3450 5 a3454 2 nfsrv_null(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) d3471 5 a3475 2 nfsrv_noop(struct nfsrv_descript *nfsd, struct nfssvc_sock *slp, struct lwp *lwp, struct mbuf **mrq) a3511 1 int override; @ 1.95.2.4 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.95.2.3 2006/12/30 20:50:51 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.95.2.3 2006/12/30 20:50:51 yamt Exp $"); d126 1 a126 1 (nfsd->nd_flag & ND_KERBAUTH), false); d192 1 a192 1 (nfsd->nd_flag & ND_KERBAUTH), false); d288 1 a288 1 (nfsd->nd_flag & ND_KERBAUTH), false); d526 1 a526 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d608 1 a608 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d890 1 a890 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d1195 1 a1195 1 false); d1430 1 a1430 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d1514 1 a1514 1 KAUTH_GENERIC_ISSUSER, NULL))) { d1653 1 a1653 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d1709 1 a1709 1 KAUTH_GENERIC_ISSUSER, NULL))) { d1727 1 a1727 1 error = nfsrv_composefh(vp, &nsfh, true); d1736 1 a1736 1 nfsm_reply(NFSX_SRVFH(&nsfh, true) + NFSX_POSTOPATTR(1) + d1799 1 a1799 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d1807 1 a1807 1 KAUTH_GENERIC_ISSUSER, NULL)) != 0) d1897 1 a1897 1 &dpos, &fdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d1906 1 a1906 1 vrele(fdirp); d1910 1 a1910 3 if (fromnd.ni_dvp != fromnd.ni_vp) { VOP_UNLOCK(fromnd.ni_dvp, 0); } d1927 1 a1927 1 &dpos, &tdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d2094 2 a2095 2 error = nfsrv_fhtovp(&nsfh, false, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d2104 1 a2104 1 KAUTH_GENERIC_ISSUSER, NULL)) != 0) d2110 1 a2110 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d2200 1 a2200 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d2337 1 a2337 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d2451 1 a2451 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), false); d2602 1 a2602 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); a2711 1 cookies = NULL; d2859 1 a2859 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); a2980 1 cookies = NULL; d3007 1 a3007 1 if (nfsrv_composefh(nvp, &nnsfh, true)) { d3173 1 a3173 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d3233 1 a3233 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d3307 1 a3307 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); d3380 1 a3380 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), false); @ 1.95.2.5 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.95.2.4 2007/02/26 09:12:05 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.95.2.4 2007/02/26 09:12:05 yamt Exp $"); d109 1 a109 1 char *dpos = nfsd->nd_dpos; d115 1 a115 1 char *bpos; d176 1 a176 1 char *dpos = nfsd->nd_dpos; d184 1 a184 1 char *bpos; d220 1 a220 1 char *dpos = nfsd->nd_dpos; d229 1 a229 1 char *bpos; d236 1 d241 3 d292 1 d306 1 d334 1 d358 1 a358 1 char *dpos = nfsd->nd_dpos; d364 1 a364 1 char *cp; d367 1 a367 1 char *bpos; d476 1 a476 1 char *dpos = nfsd->nd_dpos; d483 1 a483 1 char *bpos; d514 1 a514 1 ivp->iov_base = mtod(mp, void *); d575 1 a575 1 char *dpos = nfsd->nd_dpos; d582 1 a582 1 char *bpos; d745 1 a745 1 iv->iov_base = mtod(m, char *) + d761 1 a761 1 free((void *)iv2, M_TEMP); d807 1 a807 1 char *dpos = nfsd->nd_dpos; d817 1 a817 1 char *bpos; d829 1 d836 3 d863 1 a863 1 adjust = dpos - mtod(mp, char *); d886 1 d894 1 d913 1 d924 1 a924 1 ivp->iov_base = mtod(mp, void *); d954 1 d1042 1 a1042 1 char *bpos, *dpos; d1050 1 d1096 1 a1096 1 adjust = dpos - mtod(mp, char *); d1236 1 a1236 1 ivp->iov_base = mtod(mp, void *); d1243 10 a1252 2 error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; d1254 1 a1254 1 free((void *)iov, M_TEMP); a1318 1 nfs_timer_start(); d1399 1 a1399 1 char *dpos = nfsd->nd_dpos; d1406 1 a1406 1 char *cp; d1408 1 a1408 1 char *bpos; d1418 1 d1422 3 d1439 1 d1457 1 a1457 1 nfsm_dissect(cp, void *, NFSX_V3CREATEVERF); d1518 1 d1598 1 d1610 1 d1626 1 a1626 1 char *dpos = nfsd->nd_dpos; d1632 1 a1632 1 char *bpos; d1641 1 d1645 3 d1661 1 d1743 1 d1755 1 d1771 1 a1771 1 char *dpos = nfsd->nd_dpos; d1776 1 a1776 1 char *bpos; d1785 1 d1791 3 d1839 1 d1842 1 d1858 1 a1858 1 char *dpos = nfsd->nd_dpos; d1862 1 a1862 1 char *bpos; d1876 1 d1884 3 d1907 1 d2038 1 d2074 1 a2074 1 char *dpos = nfsd->nd_dpos; d2079 1 a2079 1 char *bpos; d2088 1 d2091 3 d2102 1 d2154 1 d2157 1 d2173 1 a2173 1 char *dpos = nfsd->nd_dpos; d2190 1 d2194 3 d2282 1 d2296 1 d2312 1 a2312 1 char *dpos = nfsd->nd_dpos; d2317 1 a2317 1 char *cp; d2320 1 a2320 1 char *bpos; d2328 1 d2331 3 d2348 1 d2400 1 d2412 1 d2428 1 a2428 1 char *dpos = nfsd->nd_dpos; d2432 1 a2432 1 char *bpos; d2442 1 d2445 3 d2462 1 d2504 1 d2507 1 d2562 1 a2562 1 char *dpos = nfsd->nd_dpos; d2567 1 a2567 1 char *cp; d2570 1 a2570 1 char *bpos; d2661 1 a2661 1 free((void *)rbuf, M_TEMP); d2663 1 a2663 1 free((void *)cookies, M_TEMP); d2688 2 a2689 2 free((void *)rbuf, M_TEMP); free((void *)cookies, M_TEMP); d2807 1 a2807 1 mp->m_len = bp - mtod(mp, char *); d2810 2 a2811 2 free((void *)rbuf, M_TEMP); free((void *)cookies, M_TEMP); d2824 1 a2824 1 char *dpos = nfsd->nd_dpos; d2829 1 a2829 1 char *cp; d2832 1 a2832 1 char *bpos; d2935 2 a2936 2 free((void *)cookies, M_TEMP); free((void *)rbuf, M_TEMP); d2958 2 a2959 2 free((void *)cookies, M_TEMP); free((void *)rbuf, M_TEMP); d3082 1 a3082 1 cp = (void *)&fl; d3132 1 a3132 1 mp->m_len = bp - mtod(mp, char *); d3135 2 a3136 2 free((void *)cookies, M_TEMP); free((void *)rbuf, M_TEMP); d3152 1 a3152 1 char *dpos = nfsd->nd_dpos; d3159 1 a3159 1 char *bpos; d3165 1 d3168 3 d3181 1 d3200 1 d3203 1 d3219 1 a3219 1 char *dpos = nfsd->nd_dpos; d3225 1 a3225 1 char *bpos; d3293 1 a3293 1 char *dpos = nfsd->nd_dpos; d3298 1 a3298 1 char *bpos; d3367 1 a3367 1 char *dpos = nfsd->nd_dpos; d3372 1 a3372 1 char *bpos; d3429 1 a3429 1 char *bpos; d3447 1 a3447 1 char *bpos; @ 1.95.2.6 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.95.2.5 2007/09/03 14:44:18 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.95.2.5 2007/09/03 14:44:18 yamt Exp $"); d1770 1 a1770 1 if (vp->v_vflag & VV_ROOT) { d2405 1 a2405 1 if (vp->v_vflag & VV_ROOT) d3423 1 a3423 1 if (vp->v_iflag & VI_TEXT) @ 1.95.2.7 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.95.2.6 2007/10/27 11:36:16 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.95.2.6 2007/10/27 11:36:16 yamt Exp $"); d155 1 a155 1 getret = VOP_GETATTR(vp, &va, cred); d198 1 a198 1 error = VOP_GETATTR(vp, &va, cred); d292 1 a292 1 error = preat_ret = VOP_GETATTR(vp, &preat, cred); d322 2 a323 2 error = VOP_SETATTR(vp, &va, cred); postat_ret = VOP_GETATTR(vp, &va, cred); d422 1 a422 1 dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred); d437 1 a437 1 error = VOP_GETATTR(vp, &va, cred); d536 1 a536 1 getret = VOP_GETATTR(vp, &attr, cred); d618 1 a618 1 getret = VOP_GETATTR(vp, &va, cred); d757 1 a757 1 if (error || (getret = VOP_GETATTR(vp, &va, cred)) != 0){ d885 1 a885 1 forat_ret = VOP_GETATTR(vp, &forat, cred); d938 1 a938 1 aftat_ret = VOP_GETATTR(vp, &va, cred); d1029 1 a1029 1 int ioflags, aftat_ret = 1, adjust, v3, zeroing; d1111 1 a1112 1 mutex_enter(&nfsd_lock); d1152 1 a1152 1 mutex_exit(&nfsd_lock); d1162 1 a1162 1 mutex_enter(&nfsd_lock); d1171 1 a1171 2 mutex_exit(&nfsd_lock); d1182 1 a1182 1 forat_ret = VOP_GETATTR(vp, &forat, cred); d1234 1 a1234 1 aftat_ret = VOP_GETATTR(vp, &va, cred); d1278 1 a1278 1 mutex_enter(&nfsd_lock); d1287 1 a1287 1 mutex_exit(&nfsd_lock); d1289 1 a1290 2 mutex_enter(&nfsd_lock); d1292 1 a1292 1 mutex_exit(&nfsd_lock); a1294 1 mutex_exit(&nfsd_lock); d1296 1 d1301 1 a1301 1 mutex_enter(&nfsd_lock); d1310 1 a1310 1 mutex_exit(&nfsd_lock); a1330 2 KASSERT(mutex_owned(&nfsd_lock)); d1405 1 a1405 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d1476 2 a1477 2 error = VOP_SETATTR(nd.ni_vp, &va, cred); d1527 1 a1527 1 error = VOP_SETATTR(vp, &va, cred); d1536 1 a1536 1 error = VOP_GETATTR(vp, &va, cred); d1551 1 a1551 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d1620 1 a1620 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d1693 1 a1693 1 error = VOP_GETATTR(vp, &va, cred); d1697 1 a1697 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d1759 1 a1759 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d1790 1 a1790 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d1851 1 a1851 1 fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred); d1882 1 a1882 1 tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred); d1972 1 a1972 1 fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred); d1978 1 a1978 1 tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred); d2059 1 a2059 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2087 1 a2087 1 getret = VOP_GETATTR(vp, &at, cred); d2090 1 a2090 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2143 1 a2143 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2197 1 a2197 1 error = VOP_GETATTR(nd.ni_vp, &va, cred); d2208 1 a2208 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2274 1 a2274 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2309 1 a2309 1 error = VOP_GETATTR(vp, &va, cred); d2315 1 a2315 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2381 1 a2381 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred); d2422 1 a2422 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred); d2539 1 a2539 1 error = getret = VOP_GETATTR(vp, &at, cred); d2576 1 a2576 1 getret = VOP_GETATTR(vp, &at, cred); d2795 1 a2795 1 error = getret = VOP_GETATTR(vp, &at, cred); d2832 1 a2832 1 getret = VOP_GETATTR(vp, &at, cred); d2938 1 a2938 1 if (VOP_GETATTR(nvp, vap, cred)) { d3102 1 a3102 1 for_ret = VOP_GETATTR(vp, &bfor, cred); d3107 1 a3107 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end); d3109 1 a3109 1 aft_ret = VOP_GETATTR(vp, &aft, cred); d3160 2 a3161 2 error = VFS_STATVFS(vp->v_mount, sf); getret = VOP_GETATTR(vp, &at, cred); d3236 1 a3236 1 VFS_STATVFS(vp->v_mount, sb); d3240 1 a3240 1 getret = VOP_GETATTR(vp, &at, cred); d3313 1 a3313 1 getret = VOP_GETATTR(vp, &at, cred); d3426 1 a3426 1 error = VOP_GETATTR(vp, &vattr, cred); d3429 1 a3429 1 error = VOP_ACCESS(vp, flags, cred); @ 1.95.2.8 log @sync with head @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.95.2.7 2007/12/07 17:34:43 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.95.2.7 2007/12/07 17:34:43 yamt Exp $"); a1516 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d1522 1 @ 1.95.2.9 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.95.2.8 2008/01/21 09:47:33 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.95.2.8 2008/01/21 09:47:33 yamt Exp $"); a1831 1 struct mount *localfs = NULL; a1835 1 uint32_t saveflag; a1868 29 localfs = fvp->v_mount; error = VFS_RENAMELOCK_ENTER(localfs); if (error) { VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); vrele(fvp); goto out1; } /* Copied, regrettably, from vfs_syscalls.c (q.v.) */ vrele(fvp); saveflag = fromnd.ni_cnd.cn_flags & SAVESTART; fromnd.ni_cnd.cn_flags &= ~SAVESTART; vn_lock(fromnd.ni_dvp, LK_EXCLUSIVE | LK_RETRY); error = relookup(fromnd.ni_dvp, &fromnd.ni_vp, &fromnd.ni_cnd); fromnd.ni_cnd.cn_flags |= saveflag; if (error) { VOP_UNLOCK(fromnd.ni_dvp, 0); VFS_RENAMELOCK_EXIT(localfs); VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); vrele(fromnd.ni_dvp); goto out1; } VOP_UNLOCK(fromnd.ni_vp, 0); if (fromnd.ni_dvp != fromnd.ni_vp) VOP_UNLOCK(fromnd.ni_dvp, 0); fvp = fromnd.ni_vp; a1888 1 VFS_RENAMELOCK_EXIT(localfs); a1956 1 VFS_RENAMELOCK_EXIT(localfs); a1964 1 VFS_RENAMELOCK_EXIT(localfs); a2005 3 if (localfs) { VFS_RENAMELOCK_EXIT(localfs); } @ 1.95.2.10 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.95.2.9 2008/02/04 09:24:44 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.95.2.9 2008/02/04 09:24:44 yamt Exp $"); d88 1 a88 1 extern const enum vtype nv3tov_type[8]; @ 1.95.2.11 log @drop lazy mapping of mbuf external storage for now, because: - it's currently broken wrt asm code. (cpu_in_cksum) - there are other approaches worth to consider. eg. sf_buf @ text @d1 1 a1 1 /* $NetBSD$ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD$"); d684 4 d696 1 @ 1.95.2.12 log @sync with head. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.95.2.11 2008/02/27 09:24:06 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.95.2.11 2008/02/27 09:24:06 yamt Exp $"); d1484 2 a1485 2 (error = kauth_authorize_system(cred, KAUTH_SYSTEM_MKNOD, 0, NULL, NULL, NULL))) { d1671 2 a1672 2 (error = kauth_authorize_system(cred, KAUTH_SYSTEM_MKNOD, 0, NULL, NULL, NULL))) { d1762 3 a1764 2 if (vp->v_type == VDIR) { error = EPERM; a1765 1 } d1771 1 d2086 2 a2087 2 if (vp->v_type == VDIR) { error = EPERM; a2088 1 } @ 1.94 log @nuke trailing whitespace @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.93 2004/12/09 02:18:45 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.93 2004/12/09 02:18:45 yamt Exp $"); d1651 1 a1651 8 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); goto out; d1657 2 d1662 6 a1667 1 va.va_rdev = makedev(major, minor); d1675 1 d1681 2 a1682 1 vput(nd.ni_vp); @ 1.93 log @nfsrv_commit: make cnt unsigned so that very large commit requests can be handled properly. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.92 2004/12/09 01:48:22 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.92 2004/12/09 01:48:22 yamt Exp $"); d411 1 a411 1 if (dirp) d1041 1 a1041 1 d1059 1 a1059 1 d1097 1 a1097 1 d1145 1 a1145 1 d1167 1 a1167 1 error = nfsrv_fhtovp(&nfsd->nd_fh, 1, &vp, cred, slp, d1185 1 a1185 1 d2776 1 a2776 1 d2796 1 a2796 1 d3020 1 a3020 1 d3077 1 a3077 1 d3096 1 a3096 1 d3527 1 a3527 1 if (vp->v_flag & VTEXT) @ 1.93.2.1 log @sync with -current @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.94 2005/02/26 22:39:50 perry Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.94 2005/02/26 22:39:50 perry Exp $"); d411 1 a411 1 if (dirp) d1041 1 a1041 1 d1059 1 a1059 1 d1097 1 a1097 1 d1145 1 a1145 1 d1167 1 a1167 1 error = nfsrv_fhtovp(&nfsd->nd_fh, 1, &vp, cred, slp, d1185 1 a1185 1 d2776 1 a2776 1 d2796 1 a2796 1 d3020 1 a3020 1 d3077 1 a3077 1 d3096 1 a3096 1 d3527 1 a3527 1 if (vp->v_flag & VTEXT) @ 1.93.4.1 log @sync with head. xen and whitespace. xen part is not finished. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.93 2004/12/09 02:18:45 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.93 2004/12/09 02:18:45 yamt Exp $"); d411 1 a411 1 if (dirp) d1041 1 a1041 1 d1059 1 a1059 1 d1097 1 a1097 1 d1145 1 a1145 1 d1167 1 a1167 1 error = nfsrv_fhtovp(&nfsd->nd_fh, 1, &vp, cred, slp, d1185 1 a1185 1 d2776 1 a2776 1 d2796 1 a2796 1 d3020 1 a3020 1 d3077 1 a3077 1 d3096 1 a3096 1 d3527 1 a3527 1 if (vp->v_flag & VTEXT) @ 1.92 log @when calling create-type VOP, make sure that va_mode is set even when a client doesn't specify it. (most filesystems get confused if va_mode is VNOVAL.) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.91 2004/12/04 08:07:52 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.91 2004/12/04 08:07:52 yamt Exp $"); d3162 2 a3163 1 int error = 0, rdonly, for_ret = 1, aft_ret = 1, cnt, cache; d3181 1 a3181 1 cnt = fxdr_unsigned(int, *tl); @ 1.91 log @nfsrv_read: fall back to copying when fail to loan pages. (i forgot to commit this with uvm_loan.c rev.1.51.) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.90 2004/09/17 14:11:25 skrll Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.90 2004/09/17 14:11:25 skrll Exp $"); d1427 1 a1442 2 if (nd.ni_vp == NULL) va.va_mode = 0; d1661 1 d2215 1 d2366 1 @ 1.90 log @There's no need to pass a proc value when using UIO_SYSSPACE with vn_rdwr(9) and uiomove(9). OK'd by Jason Thorpe @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.89 2004/05/31 08:47:08 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.89 2004/05/31 08:47:08 yamt Exp $"); d691 2 @ 1.89 log @nfsrv_create: fix an LP64 problem for exclusive create. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.88 2004/04/21 01:05:42 christos Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.88 2004/04/21 01:05:42 christos Exp $"); d533 1 a533 1 uiop->uio_procp = (struct proc *)0; d953 1 a953 1 uiop->uio_procp = (struct proc *)0; d1192 1 a1192 1 uiop->uio_procp = (struct proc *)0; d2235 1 a2235 1 io.uio_procp = (struct proc *)0; d2658 1 a2658 1 io.uio_procp = (struct proc *)0; d2917 1 a2917 1 io.uio_procp = (struct proc *)0; @ 1.88 log @Replace the statfs() family of system calls with statvfs(). Retain binary compatibility. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.87 2004/01/07 12:17:10 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.87 2004/01/07 12:17:10 yamt Exp $"); d1480 6 a1485 2 memcpy((caddr_t)&va.va_atime, cverf, NFSX_V3CREATEVERF); d1553 10 a1562 3 if (exclusive_flag && !error && memcmp(cverf, (caddr_t)&va.va_atime, NFSX_V3CREATEVERF)) error = EEXIST; @ 1.87 log @- get pages to loan out in uvm_loanuobjpages() rather than having caller (nfsd, in this case) do so. - tweak locking so that nfs loaned READ works on layered filesystems. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.86 2003/11/05 10:18:38 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.86 2003/11/05 10:18:38 hannken Exp $"); d449 1 a449 1 fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; d1542 1 a1542 1 fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; d1698 1 a1698 1 fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; d2248 1 a2248 1 fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid; d2374 1 a2374 1 fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; d3014 1 a3014 1 nvp->v_mount->mnt_stat.f_fsid; d3211 1 a3211 1 struct statfs *sf; d3224 1 a3224 1 struct statfs statfs; d3239 2 a3240 2 sf = &statfs; error = VFS_STATFS(vp->v_mount, sf, procp); d3250 1 a3250 1 tval = (u_quad_t)((quad_t)sf->f_blocks * (quad_t)sf->f_bsize); d3252 1 a3252 1 tval = (u_quad_t)((quad_t)sf->f_bfree * (quad_t)sf->f_bsize); d3254 1 a3254 1 tval = (u_quad_t)((quad_t)sf->f_bavail * (quad_t)sf->f_bsize); d3264 1 a3264 1 sfp->sf_bsize = txdr_unsigned(sf->f_bsize); d3299 1 a3299 1 struct statfs sb; d3315 2 a3316 2 VFS_STATFS(vp->v_mount, &sb, (struct proc *)0); maxfsize = (u_quad_t)0x80000000 * sb.f_bsize - 1; @ 1.87.2.1 log @Pull up revision 1.89 (requested by yamt in ticket #445). nfsrv_create: fix an LP64 problem for exclusive create. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.87 2004/01/07 12:17:10 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.87 2004/01/07 12:17:10 yamt Exp $"); d1480 2 a1481 6 /* * XXX * assuming NFSX_V3CREATEVERF * == sizeof(nfstime3) */ fxdr_nfsv3time(cverf, &va.va_atime); d1549 3 a1551 10 if (exclusive_flag && !error) { /* * XXX assuming NFSX_V3CREATEVERF == sizeof(nfstime3) */ char oldverf[NFSX_V3CREATEVERF]; txdr_nfsv3time(&va.va_atime, oldverf); if (memcmp(cverf, oldverf, NFSX_V3CREATEVERF)) error = EEXIST; } @ 1.86 log @Clean up the usage of vn_start_write(). At least one occurence clobbered previous error conditions. If "(flags & (V_WAIT|V_PCATCH)) == V_WAIT" the return value is always zero. Ignore the return value in these cases. From Darrin B. Jewell. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.85 2003/10/29 21:28:37 mycroft Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.85 2003/10/29 21:28:37 mycroft Exp $"); a572 7 * XXX UBC temp limit * maximum number of pages we can do VOP_GETPAGES and loan-out at once. * should be <= MAX_READ_AHEAD in genfs_vnops.c */ #define NFSD_READ_GETPAGES_CHUNK 16 /* d667 2 a668 2 int orignpages, nleftpages; vaddr_t lva, curlva; d670 2 a671 3 orignpages = (round_page(off + cnt) - pgoff) >> PAGE_SHIFT; KASSERT(orignpages <= M_EXT_MAXPAGES); /* XXX */ d673 2 a674 1 lva = sokvaalloc(orignpages << PAGE_SHIFT, slp->ns_so); d680 1 d682 1 d685 7 a691 48 curlva = lva; nleftpages = orignpages; while (nleftpages > 0) { int npages = nleftpages; if (npages > NFSD_READ_GETPAGES_CHUNK) npages = NFSD_READ_GETPAGES_CHUNK; again: simple_lock(&vp->v_interlock); error = VOP_GETPAGES(vp, pgoff, pgpp, &npages, 0, VM_PROT_READ, 0, PGO_SYNCIO); if (error == EAGAIN) { tsleep(&lbolt, PVM, "nfsread", 0); goto again; } if (error) { uvm_unloan(m->m_ext.ext_pgs, orignpages - nleftpages, UVM_LOAN_TOPAGE); sokvafree(lva, orignpages << PAGE_SHIFT); m_free(m); goto read_error; } /* loan and unbusy pages */ simple_lock(&vp->v_interlock); for (i = 0; i < npages; i++) { if (pgpp[i]->flags & PG_RELEASED) { uvm_lock_pageq(); uvm_page_unbusy(pgpp, npages); uvm_unlock_pageq(); simple_unlock(&vp->v_interlock); continue; } } uvm_loanuobjpages(pgpp, npages); simple_unlock(&vp->v_interlock); /* map pages */ for (i = 0; i < npages; i++) { pmap_kenter_pa(curlva, VM_PAGE_TO_PHYS(pgpp[i]), VM_PROT_READ); curlva += PAGE_SIZE; } nleftpages -= npages; pgpp += npages; pgoff += npages << PAGE_SHIFT; d694 3 a696 5 lva += off & PAGE_MASK; MCLAIM(m, &nfs_mowner); MEXTADD(m, (void *)lva, cnt, M_MBUF, soloanfree, slp->ns_so); d700 7 d708 1 @ 1.85 log @Back out the bogus initializer -- the compiler bug is fixed. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.84 2003/10/28 02:01:46 cl Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.84 2003/10/28 02:01:46 cl Exp $"); d1258 1 a1258 1 error = vn_start_write(NULL, &mntp, V_WAIT); @ 1.84 log @note 'm68k {u,}int64_t used uninitialized' bug. add reference to gcc bug report. mark all (known) occurrences. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.83 2003/10/20 13:53:47 yamt Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.83 2003/10/20 13:53:47 yamt Exp $"); a3289 1 tval = 0; /* XXX: gcc m68k */ @ 1.83 log @set READres EOF flag correctly. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.82 2003/10/15 11:29:01 hannken Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.82 2003/10/15 11:29:01 hannken Exp $"); d3290 1 @ 1.82 log @Add the gating of system calls that cause modifications to the underlying file system. The function vfs_write_suspend stops all new write operations to a file system, allows any file system modifying system calls already in progress to complete, then sync's the file system to disk and returns. The function vfs_write_resume allows the suspended write operations to complete. From FreeBSD with slight modifications. Approved by: Frank van der Linden @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.81 2003/08/07 16:33:51 agc Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.81 2003/08/07 16:33:51 agc Exp $"); a804 1 off = uiop->uio_offset; d827 1 d829 2 a830 1 if (len < reqlen) @ 1.81 log @Move UCB-licensed code from 4-clause to 3-clause licence. Patches provided by Joel Baker in PR 22364, verified by myself. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.80 2003/07/09 21:16:12 bouyer Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.80 2003/07/09 21:16:12 bouyer Exp $"); d239 1 d243 3 d294 1 d308 1 d336 1 d873 1 d881 3 d931 1 d939 1 d958 1 d1000 1 d1062 1 d1255 10 a1264 2 error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; d1431 1 d1436 3 d1459 1 d1534 1 d1606 1 d1618 1 d1650 1 d1655 3 d1671 1 d1751 1 d1763 1 d1794 1 d1801 3 d1850 1 d1853 1 d1888 1 d1898 3 d1927 1 d2057 1 d2106 1 d2111 3 d2122 1 d2177 1 d2180 1 d2214 1 d2219 3 d2312 1 d2326 1 d2359 1 d2363 3 d2386 1 d2436 1 d2448 1 d2479 1 d2483 3 d2506 1 d2546 1 d2549 1 d3190 1 d3197 3 d3210 1 d3228 2 a3229 1 } else d3231 2 @ 1.80 log @nfsrv_commit(): return success and don't do anything for requests which starts past the end of the file. This can happen when two clients are writting to the same file. Close PR 21696 by myself, discussed on tech-net in 2003/05 and 2003/06. Issue raised by Chuck Silvers (commit and truncate ops needs to be serialised) still unadressed. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.79 2003/06/29 22:32:16 fvdl Exp $ */ d18 1 a18 5 * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.79 2003/06/29 22:32:16 fvdl Exp $"); @ 1.79 log @Back out the lwp/ktrace changes. They contained a lot of colateral damage, and need to be examined and discussed more. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.76 2003/06/09 13:10:31 yamt Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.76 2003/06/09 13:10:31 yamt Exp $"); d3138 3 a3140 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, procp); @ 1.79.2.1 log @Apply the aborted ktrace-lwp changes to a specific branch. This is just for others to review, I'm concerned that patch fuziness may have resulted in some errant code being generated but I'll look at that later by comparing the diff from the base to the branch with the file I attempt to apply to it. This will, at the very least, put the changes in a better context for others to review them and attempt to tinker with removing passing of 'struct lwp' through the kernel. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.79 2003/06/29 22:32:16 fvdl Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.79 2003/06/29 22:32:16 fvdl Exp $"); d103 1 a103 1 nfsrv3_access(nfsd, slp, lwp, mrq) d106 1 a106 1 struct lwp *lwp; d130 1 a130 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d139 1 a139 1 nfsrv_access(vp, VREAD, cred, rdonly, lwp, 0) == 0) d144 1 a144 1 nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0) == 0) d147 1 a147 1 nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0) == 0) d153 1 a153 1 nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0) == 0) d156 1 a156 1 nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0) == 0) d159 1 a159 1 getret = VOP_GETATTR(vp, &va, cred, lwp); d172 1 a172 1 nfsrv_getattr(nfsd, slp, lwp, mrq) d175 1 a175 1 struct lwp *lwp; d198 1 a198 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d204 1 a204 1 error = VOP_GETATTR(vp, &va, cred, lwp); d218 1 a218 1 nfsrv_setattr(nfsd, slp, lwp, mrq) d221 1 a221 1 struct lwp *lwp; d290 1 a290 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d298 1 a298 1 error = preat_ret = VOP_GETATTR(vp, &preat, cred, lwp); d325 1 a325 1 lwp, 0)) != 0) d328 2 a329 2 error = VOP_SETATTR(vp, &va, cred, lwp); postat_ret = VOP_GETATTR(vp, &va, cred, lwp); d349 1 a349 1 nfsrv_lookup(nfsd, slp, lwp, mrq) d352 1 a352 1 struct lwp *lwp; d386 1 a386 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag); d430 2 a431 1 dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, lwp); d449 1 a449 1 error = VOP_GETATTR(vp, &va, cred, lwp); d471 1 a471 1 nfsrv_readlink(nfsd, slp, lwp, mrq) d474 1 a474 1 struct lwp *lwp; d530 1 a530 1 uiop->uio_lwp = (struct lwp *)0; d532 1 a532 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d549 1 a549 1 getret = VOP_GETATTR(vp, &attr, cred, lwp); d580 1 a580 1 nfsrv_read(nfsd, slp, lwp, mrq) d583 1 a583 1 struct lwp *lwp; d623 1 a623 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d637 2 a638 2 if ((error = nfsrv_access(vp, VREAD, cred, rdonly, lwp, 1)) != 0) error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 1); d640 1 a640 1 getret = VOP_GETATTR(vp, &va, cred, lwp); d806 1 a806 1 if (error || (getret = VOP_GETATTR(vp, &va, cred, lwp)) != 0){ d839 1 a839 1 nfsrv_write(nfsd, slp, lwp, mrq) d842 1 a842 1 struct lwp *lwp; d927 1 a927 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d934 1 a934 1 forat_ret = VOP_GETATTR(vp, &forat, cred, lwp); d943 1 a943 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 1); d982 1 a982 1 uiop->uio_lwp = (struct lwp *)0; d988 1 a988 1 aftat_ret = VOP_GETATTR(vp, &va, cred, lwp); d1026 1 a1026 1 nfsrv_writegather(ndp, slp, lwp, mrq) d1029 1 a1029 1 struct lwp *lwp; d1194 1 a1194 1 FALSE, lwp); d1197 1 a1197 1 forat_ret = VOP_GETATTR(vp, &forat, cred, lwp); d1208 1 a1208 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 1); d1219 1 a1219 1 uiop->uio_lwp = (struct lwp *)0; d1250 1 a1250 1 aftat_ret = VOP_GETATTR(vp, &va, cred, lwp); d1383 1 a1383 1 nfsrv_create(nfsd, slp, lwp, mrq) d1386 1 a1386 1 struct lwp *lwp; d1420 1 a1420 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1423 2 a1424 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1497 1 a1497 1 lwp); d1540 1 a1540 1 (nd.ni_cnd.cn_flags & RDONLY), lwp, 0); d1546 2 a1547 1 error = VOP_SETATTR(vp, &va, cred, lwp); d1558 1 a1558 1 error = VOP_GETATTR(vp, &va, cred, lwp); d1565 1 a1565 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1598 1 a1598 1 nfsrv_mknod(nfsd, slp, lwp, mrq) d1601 1 a1601 1 struct lwp *lwp; d1631 1 a1631 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1633 1 a1633 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1707 1 a1707 1 error = VOP_GETATTR(vp, &va, cred, lwp); d1710 1 a1710 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1736 1 a1736 1 nfsrv_remove(nfsd, slp, lwp, mrq) d1739 1 a1739 1 struct lwp *lwp; d1770 1 a1770 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1773 2 a1774 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1805 1 a1805 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1820 1 a1820 1 nfsrv_rename(nfsd, slp, lwp, mrq) d1823 1 a1823 1 struct lwp *lwp; d1866 1 a1866 1 &dpos, &fdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1869 2 a1870 1 fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, lwp); d1900 1 a1900 1 &dpos, &tdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1903 2 a1904 1 tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, lwp); d1997 1 a1997 1 fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, lwp); d2001 1 a2001 1 tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, lwp); d2036 1 a2036 1 nfsrv_link(nfsd, slp, lwp, mrq) d2039 1 a2039 1 struct lwp *lwp; d2066 1 a2066 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d2079 1 a2079 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2082 2 a2083 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2115 1 a2115 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d2117 1 a2117 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2134 1 a2134 1 nfsrv_symlink(nfsd, slp, lwp, mrq) d2137 1 a2137 1 struct lwp *lwp; d2169 1 a2169 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2172 2 a2173 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2205 1 a2205 1 io.uio_lwp = (struct lwp *)0; d2232 2 a2233 1 error = VOP_GETATTR(nd.ni_vp, &va, cred, lwp); d2243 1 a2243 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2274 1 a2274 1 nfsrv_mkdir(nfsd, slp, lwp, mrq) d2277 1 a2277 1 struct lwp *lwp; d2307 1 a2307 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2310 2 a2311 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2351 1 a2351 1 error = VOP_GETATTR(vp, &va, cred, lwp); d2356 1 a2356 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2389 1 a2389 1 nfsrv_rmdir(nfsd, slp, lwp, mrq) d2392 1 a2392 1 struct lwp *lwp; d2420 1 a2420 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2423 2 a2424 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2468 1 a2468 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2520 1 a2520 1 nfsrv_readdir(nfsd, slp, lwp, mrq) d2523 1 a2523 1 struct lwp *lwp; d2572 1 a2572 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d2584 1 a2584 1 error = getret = VOP_GETATTR(vp, &at, cred, lwp); d2594 1 a2594 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0); d2612 1 a2612 1 io.uio_lwp = (struct lwp *)0; d2622 1 a2622 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d2783 1 a2783 1 nfsrv_readdirplus(nfsd, slp, lwp, mrq) d2786 1 a2786 1 struct lwp *lwp; d2831 1 a2831 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d2841 1 a2841 1 error = getret = VOP_GETATTR(vp, &at, cred, lwp); d2851 1 a2851 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0); d2871 1 a2871 1 io.uio_lwp = (struct lwp *)0; d2879 1 a2879 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d2891 1 a2891 1 if ((getret = VFS_VGET(vp->v_mount, at.va_fileid, &nvp, lwp))) d2975 1 a2975 1 if (VFS_VGET(vp->v_mount, dp->d_fileno, &nvp, lwp)) d2984 1 a2984 1 if (VOP_GETATTR(nvp, vap, cred, lwp)) { d3095 1 a3095 1 nfsrv_commit(nfsd, slp, lwp, mrq) d3098 1 a3098 1 struct lwp *lwp; d3128 1 a3128 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d3134 1 a3134 1 for_ret = VOP_GETATTR(vp, &bfor, cred, lwp); d3138 2 a3139 2 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, lwp); aft_ret = VOP_GETATTR(vp, &aft, cred, lwp); d3156 1 a3156 1 nfsrv_statfs(nfsd, slp, lwp, mrq) d3159 1 a3159 1 struct lwp *lwp; d3188 1 a3188 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d3195 2 a3196 2 error = VFS_STATFS(vp->v_mount, sf, lwp); getret = VOP_GETATTR(vp, &at, cred, lwp); d3231 1 a3231 1 nfsrv_fsinfo(nfsd, slp, lwp, mrq) d3234 1 a3234 1 struct lwp *lwp; d3262 1 a3262 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d3270 1 a3270 1 VFS_STATFS(vp->v_mount, &sb, (struct lwp *)0); d3273 1 a3273 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d3308 1 a3308 1 nfsrv_pathconf(nfsd, slp, lwp, mrq) d3311 1 a3311 1 struct lwp *lwp; d3338 1 a3338 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d3351 1 a3351 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d3379 1 a3379 1 nfsrv_null(nfsd, slp, lwp, mrq) d3382 1 a3382 1 struct lwp *lwp; d3400 1 a3400 1 nfsrv_noop(nfsd, slp, lwp, mrq) d3403 1 a3403 1 struct lwp *lwp; d3435 1 a3435 1 nfsrv_access(vp, flags, cred, rdonly, lwp, override) d3440 1 a3440 1 struct lwp *lwp; d3469 1 a3469 1 error = VOP_GETATTR(vp, &vattr, cred, lwp); d3472 1 a3472 1 error = VOP_ACCESS(vp, flags, cred, lwp); @ 1.79.2.2 log @Sync with HEAD @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.79.2.1 2003/07/02 15:27:09 darrenr Exp $ */ d18 5 a22 1 * 3. Neither the name of the University nor the names of its contributors d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.79.2.1 2003/07/02 15:27:09 darrenr Exp $"); a242 1 struct mount *mp = NULL; a245 3 if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a293 1 vn_finished_write(mp, 0); a306 1 vn_finished_write(mp, 0); a333 1 vn_finished_write(mp, 0); d445 1 a445 1 fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsidx; d569 7 d670 2 a671 2 int npages; vaddr_t lva; d673 3 a675 2 npages = (round_page(off + cnt) - pgoff) >> PAGE_SHIFT; KASSERT(npages <= M_EXT_MAXPAGES); /* XXX */ d677 1 a677 2 /* allocate kva for mbuf data */ lva = sokvaalloc(npages << PAGE_SHIFT, slp->ns_so); a682 1 /* allocate mbuf */ a683 1 MCLAIM(m, &nfs_mowner); d686 48 a733 7 /* loan pages */ error = uvm_loanuobjpages(&vp->v_uobj, pgoff, npages, pgpp); if (error) { sokvafree(lva, npages << PAGE_SHIFT); m_free(m); goto read_error; d736 5 a740 3 /* associate kva to mbuf */ MEXTADD(m, (void *)(lva + ((vaddr_t)off & PAGE_MASK)), cnt, M_MBUF, soloanfree, slp->ns_so); a743 7 /* map pages */ for (i = 0; i < npages; i++) { pmap_kenter_pa(lva, VM_PAGE_TO_PHYS(pgpp[i]), VM_PROT_READ); lva += PAGE_SIZE; } a744 1 d801 1 a823 1 /* count */ d825 1 a825 2 /* eof */ if (off + len >= va.va_size) a868 1 struct mount *mntp = NULL; a875 3 if ((mntp = vfs_getvfs(&fhp->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mntp, V_WAIT); a922 1 vn_finished_write(mntp, 0); a929 1 vn_finished_write(mntp, 0); a947 1 vn_finished_write(mntp, 0); a988 1 vn_finished_write(mntp, 0); a1049 1 struct mount *mntp = NULL; d1242 2 a1243 10 if (vn_start_write(vp, &mntp, V_NOWAIT) != 0) { VOP_UNLOCK(vp, 0); vn_start_write(NULL, &mntp, V_WAIT); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); } if (!error) { error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; vn_finished_write(mntp, 0); } a1409 1 struct mount *mp = NULL; a1413 3 if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a1432 1 vn_finished_write(mp, 0); d1492 2 a1493 6 /* * XXX * assuming NFSX_V3CREATEVERF * == sizeof(nfstime3) */ fxdr_nfsv3time(cverf, &va.va_atime); a1506 1 vn_finished_write(mp, 0); d1552 1 a1552 1 fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsidx; d1559 3 a1561 10 if (exclusive_flag && !error) { /* * XXX assuming NFSX_V3CREATEVERF == sizeof(nfstime3) */ char oldverf[NFSX_V3CREATEVERF]; txdr_nfsv3time(&va.va_atime, oldverf); if (memcmp(cverf, oldverf, NFSX_V3CREATEVERF)) error = EEXIST; } a1576 1 vn_finished_write(mp, 0); a1587 1 vn_finished_write(mp, 0); a1618 1 struct mount *mp = NULL; a1622 3 if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a1635 1 vn_finished_write(mp, 0); d1701 1 a1701 1 fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsidx; a1714 1 vn_finished_write(mp, 0); a1725 1 vn_finished_write(mp, 0); a1755 1 struct mount *mp = NULL; a1761 3 if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a1806 1 vn_finished_write(mp, 0); a1808 1 vn_finished_write(mp, 0); a1842 1 struct mount *mp = NULL; a1851 3 if ((mp = vfs_getvfs(&ffhp->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a1876 1 vn_finished_write(mp, 0); a2004 1 vn_finished_write(mp, 0); a2052 1 struct mount *mp = NULL; a2056 3 if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a2064 1 vn_finished_write(mp, 0); a2117 1 vn_finished_write(mp, 0); a2119 1 vn_finished_write(mp, 0); a2152 1 struct mount *mp = NULL; a2156 3 if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); d2221 1 a2221 1 fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsidx; a2244 1 vn_finished_write(mp, 0); a2257 1 vn_finished_write(mp, 0); a2289 1 struct mount *mp = NULL; a2292 3 if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a2311 1 vn_finished_write(mp, 0); d2338 1 a2338 1 fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsidx; a2360 1 vn_finished_write(mp, 0); a2371 1 vn_finished_write(mp, 0); a2401 1 struct mount *mp = NULL; a2404 3 if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a2423 1 vn_finished_write(mp, 0); a2462 1 vn_finished_write(mp, 0); a2464 1 vn_finished_write(mp, 0); d2968 1 a2968 1 nvp->v_mount->mnt_stat.f_fsidx; a3104 1 struct mount *mp = NULL; a3110 3 if ((mp = vfs_getvfs(&fhp->fh_fsid)) == NULL) return (ESTALE); vn_start_write(NULL, &mp, V_WAIT); a3120 1 vn_finished_write(mp, 0); d3127 1 a3127 3 if (off < vp->v_size) error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, lwp); /* else error == 0, from nfsrv_fhtovp() */ d3136 1 a3136 2 } else { vn_finished_write(mp, 0); a3137 2 } vn_finished_write(mp, 0); d3155 1 a3155 1 struct statvfs *sf; d3168 1 a3168 1 struct statvfs statvfs; d3183 2 a3184 2 sf = &statvfs; error = VFS_STATVFS(vp->v_mount, sf, lwp); d3194 1 a3194 1 tval = (u_quad_t)((quad_t)sf->f_blocks * (quad_t)sf->f_frsize); d3196 1 a3196 1 tval = (u_quad_t)((quad_t)sf->f_bfree * (quad_t)sf->f_frsize); d3198 1 a3198 1 tval = (u_quad_t)((quad_t)sf->f_bavail * (quad_t)sf->f_frsize); d3208 1 a3208 1 sfp->sf_bsize = txdr_unsigned(sf->f_frsize); d3243 1 a3243 1 struct statvfs sb; d3259 2 a3260 2 VFS_STATVFS(vp->v_mount, &sb, (struct lwp *)0); maxfsize = (u_quad_t)0x80000000 * sb.f_frsize - 1; @ 1.79.2.3 log @Undo part of the ktrace/lwp changes. In particular: * Remove the "lwp *" argument that was added to vget(). Turns out that nothing actually used it! * Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(), and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted above, didn't use it). * Remove all of the "lwp *" arguments to internal functions that were added just to appease the above. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.79.2.2 2004/08/03 10:56:17 skrll Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.79.2.2 2004/08/03 10:56:17 skrll Exp $"); d126 1 a126 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE); d194 1 a194 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE); d290 1 a290 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE); d534 1 a534 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d618 1 a618 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d895 1 a895 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1166 1 a1166 1 FALSE); d2083 1 a2083 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2607 1 a2607 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2866 1 a2866 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2926 1 a2926 1 if ((getret = VFS_VGET(vp->v_mount, at.va_fileid, &nvp))) d3010 1 a3010 1 if (VFS_VGET(vp->v_mount, dp->d_fileno, &nvp)) d3167 1 a3167 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d3233 1 a3233 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d3307 1 a3307 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d3383 1 a3383 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); @ 1.79.2.4 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.90 2004/09/17 14:11:25 skrll Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.90 2004/09/17 14:11:25 skrll Exp $"); d99 1 a99 1 nfsrv3_access(nfsd, slp, procp, mrq) d102 1 a102 1 struct proc *procp; d135 1 a135 1 nfsrv_access(vp, VREAD, cred, rdonly, procp, 0) == 0) d140 1 a140 1 nfsrv_access(vp, VWRITE, cred, rdonly, procp, 0) == 0) d143 1 a143 1 nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0) == 0) d149 1 a149 1 nfsrv_access(vp, VWRITE, cred, rdonly, procp, 0) == 0) d152 1 a152 1 nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0) == 0) d155 1 a155 1 getret = VOP_GETATTR(vp, &va, cred, procp); d168 1 a168 1 nfsrv_getattr(nfsd, slp, procp, mrq) d171 1 a171 1 struct proc *procp; d200 1 a200 1 error = VOP_GETATTR(vp, &va, cred, procp); d214 1 a214 1 nfsrv_setattr(nfsd, slp, procp, mrq) d217 1 a217 1 struct proc *procp; d299 1 a299 1 error = preat_ret = VOP_GETATTR(vp, &preat, cred, procp); d327 1 a327 1 procp, 0)) != 0) d330 2 a331 2 error = VOP_SETATTR(vp, &va, cred, procp); postat_ret = VOP_GETATTR(vp, &va, cred, procp); d352 1 a352 1 nfsrv_lookup(nfsd, slp, procp, mrq) d355 1 a355 1 struct proc *procp; d389 1 a389 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), pubflag); d433 1 a433 2 dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, procp); d451 1 a451 1 error = VOP_GETATTR(vp, &va, cred, procp); d473 1 a473 1 nfsrv_readlink(nfsd, slp, procp, mrq) d476 1 a476 1 struct proc *procp; d532 1 a532 1 uiop->uio_procp = NULL; d551 1 a551 1 getret = VOP_GETATTR(vp, &attr, cred, procp); d575 1 a575 1 nfsrv_read(nfsd, slp, procp, mrq) d578 1 a578 1 struct proc *procp; d632 2 a633 2 if ((error = nfsrv_access(vp, VREAD, cred, rdonly, procp, 1)) != 0) error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 1); d635 1 a635 1 getret = VOP_GETATTR(vp, &va, cred, procp); d767 1 a767 1 if (error || (getret = VOP_GETATTR(vp, &va, cred, procp)) != 0){ d802 1 a802 1 nfsrv_write(nfsd, slp, procp, mrq) d805 1 a805 1 struct proc *procp; d903 1 a903 1 forat_ret = VOP_GETATTR(vp, &forat, cred, procp); d912 1 a912 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1); d952 1 a952 1 uiop->uio_procp = NULL; d958 1 a958 1 aftat_ret = VOP_GETATTR(vp, &va, cred, procp); d997 1 a997 1 nfsrv_writegather(ndp, slp, procp, mrq) d1000 1 a1000 1 struct proc *procp; d1169 1 a1169 1 forat_ret = VOP_GETATTR(vp, &forat, cred, procp); d1180 1 a1180 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1); d1191 1 a1191 1 uiop->uio_procp = NULL; d1230 1 a1230 1 aftat_ret = VOP_GETATTR(vp, &va, cred, procp); d1363 1 a1363 1 nfsrv_create(nfsd, slp, procp, mrq) d1366 1 a1366 1 struct proc *procp; d1404 1 a1404 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1407 1 a1407 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d1485 1 a1485 1 procp); d1529 1 a1529 1 (nd.ni_cnd.cn_flags & RDONLY), procp, 0); d1535 1 a1535 2 error = VOP_SETATTR(vp, &va, cred, procp); d1546 1 a1546 1 error = VOP_GETATTR(vp, &va, cred, procp); d1560 1 a1560 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d1595 1 a1595 1 nfsrv_mknod(nfsd, slp, procp, mrq) d1598 1 a1598 1 struct proc *procp; d1632 1 a1632 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1634 1 a1634 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d1709 1 a1709 1 error = VOP_GETATTR(vp, &va, cred, procp); d1712 1 a1712 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d1740 1 a1740 1 nfsrv_remove(nfsd, slp, procp, mrq) d1743 1 a1743 1 struct proc *procp; d1778 1 a1778 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1781 1 a1781 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d1812 1 a1812 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d1829 1 a1829 1 nfsrv_rename(nfsd, slp, procp, mrq) d1832 1 a1832 1 struct proc *procp; d1879 1 a1879 1 &dpos, &fdirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1882 1 a1882 2 fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, procp); d1913 1 a1913 1 &dpos, &tdirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1916 1 a1916 2 tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, procp); d2009 1 a2009 1 fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, procp); d2013 1 a2013 1 tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, procp); d2049 1 a2049 1 nfsrv_link(nfsd, slp, procp, mrq) d2052 1 a2052 1 struct proc *procp; d2097 1 a2097 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2100 1 a2100 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d2132 1 a2132 1 getret = VOP_GETATTR(vp, &at, cred, procp); d2134 1 a2134 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d2153 1 a2153 1 nfsrv_symlink(nfsd, slp, procp, mrq) d2156 1 a2156 1 struct proc *procp; d2192 1 a2192 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2195 1 a2195 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d2227 1 a2227 1 io.uio_procp = NULL; d2254 1 a2254 2 error = VOP_GETATTR(nd.ni_vp, &va, cred, procp); d2264 1 a2264 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d2297 1 a2297 1 nfsrv_mkdir(nfsd, slp, procp, mrq) d2300 1 a2300 1 struct proc *procp; d2334 1 a2334 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2337 1 a2337 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d2378 1 a2378 1 error = VOP_GETATTR(vp, &va, cred, procp); d2383 1 a2383 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d2418 1 a2418 1 nfsrv_rmdir(nfsd, slp, procp, mrq) d2421 1 a2421 1 struct proc *procp; d2453 1 a2453 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2456 1 a2456 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d2501 1 a2501 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d2555 1 a2555 1 nfsrv_readdir(nfsd, slp, procp, mrq) d2558 1 a2558 1 struct proc *procp; d2619 1 a2619 1 error = getret = VOP_GETATTR(vp, &at, cred, procp); d2629 1 a2629 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); d2647 1 a2647 1 io.uio_procp = NULL; d2657 1 a2657 1 getret = VOP_GETATTR(vp, &at, cred, procp); d2818 1 a2818 1 nfsrv_readdirplus(nfsd, slp, procp, mrq) d2821 1 a2821 1 struct proc *procp; d2876 1 a2876 1 error = getret = VOP_GETATTR(vp, &at, cred, procp); d2886 1 a2886 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); d2906 1 a2906 1 io.uio_procp = NULL; d2914 1 a2914 1 getret = VOP_GETATTR(vp, &at, cred, procp); d3019 1 a3019 1 if (VOP_GETATTR(nvp, vap, cred, procp)) { d3130 1 a3130 1 nfsrv_commit(nfsd, slp, procp, mrq) d3133 1 a3133 1 struct proc *procp; d3174 1 a3174 1 for_ret = VOP_GETATTR(vp, &bfor, cred, procp); d3179 1 a3179 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, procp); d3181 1 a3181 1 aft_ret = VOP_GETATTR(vp, &aft, cred, procp); d3201 1 a3201 1 nfsrv_statfs(nfsd, slp, procp, mrq) d3204 1 a3204 1 struct proc *procp; d3240 2 a3241 2 error = VFS_STATVFS(vp->v_mount, sf, procp); getret = VOP_GETATTR(vp, &at, cred, procp); d3276 1 a3276 1 nfsrv_fsinfo(nfsd, slp, procp, mrq) d3279 1 a3279 1 struct proc *procp; d3315 1 a3315 1 VFS_STATVFS(vp->v_mount, &sb, (struct proc *)0); d3318 1 a3318 1 getret = VOP_GETATTR(vp, &at, cred, procp); d3353 1 a3353 1 nfsrv_pathconf(nfsd, slp, procp, mrq) d3356 1 a3356 1 struct proc *procp; d3396 1 a3396 1 getret = VOP_GETATTR(vp, &at, cred, procp); d3424 1 a3424 1 nfsrv_null(nfsd, slp, procp, mrq) d3427 1 a3427 1 struct proc *procp; d3445 1 a3445 1 nfsrv_noop(nfsd, slp, procp, mrq) d3448 1 a3448 1 struct proc *procp; d3480 1 a3480 1 nfsrv_access(vp, flags, cred, rdonly, p, override) d3485 1 a3485 1 struct proc *p; d3514 1 a3514 1 error = VOP_GETATTR(vp, &vattr, cred, p); d3517 1 a3517 1 error = VOP_ACCESS(vp, flags, cred, p); @ 1.79.2.5 log @Fix the sync with head I botched. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.79.2.3 2004/08/24 17:57:41 skrll Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.79.2.3 2004/08/24 17:57:41 skrll Exp $"); d99 1 a99 1 nfsrv3_access(nfsd, slp, lwp, mrq) d102 1 a102 1 struct lwp *lwp; d135 1 a135 1 nfsrv_access(vp, VREAD, cred, rdonly, lwp, 0) == 0) d140 1 a140 1 nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0) == 0) d143 1 a143 1 nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0) == 0) d149 1 a149 1 nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0) == 0) d152 1 a152 1 nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0) == 0) d155 1 a155 1 getret = VOP_GETATTR(vp, &va, cred, lwp); d168 1 a168 1 nfsrv_getattr(nfsd, slp, lwp, mrq) d171 1 a171 1 struct lwp *lwp; d200 1 a200 1 error = VOP_GETATTR(vp, &va, cred, lwp); d214 1 a214 1 nfsrv_setattr(nfsd, slp, lwp, mrq) d217 1 a217 1 struct lwp *lwp; d299 1 a299 1 error = preat_ret = VOP_GETATTR(vp, &preat, cred, lwp); d327 1 a327 1 lwp, 0)) != 0) d330 2 a331 2 error = VOP_SETATTR(vp, &va, cred, lwp); postat_ret = VOP_GETATTR(vp, &va, cred, lwp); d352 1 a352 1 nfsrv_lookup(nfsd, slp, lwp, mrq) d355 1 a355 1 struct lwp *lwp; d389 1 a389 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag); d433 2 a434 1 dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, lwp); d452 1 a452 1 error = VOP_GETATTR(vp, &va, cred, lwp); d474 1 a474 1 nfsrv_readlink(nfsd, slp, lwp, mrq) d477 1 a477 1 struct lwp *lwp; d533 1 a533 1 uiop->uio_lwp = NULL; d552 1 a552 1 getret = VOP_GETATTR(vp, &attr, cred, lwp); d576 1 a576 1 nfsrv_read(nfsd, slp, lwp, mrq) d579 1 a579 1 struct lwp *lwp; d633 2 a634 2 if ((error = nfsrv_access(vp, VREAD, cred, rdonly, lwp, 1)) != 0) error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 1); d636 1 a636 1 getret = VOP_GETATTR(vp, &va, cred, lwp); d768 1 a768 1 if (error || (getret = VOP_GETATTR(vp, &va, cred, lwp)) != 0){ d803 1 a803 1 nfsrv_write(nfsd, slp, lwp, mrq) d806 1 a806 1 struct lwp *lwp; d904 1 a904 1 forat_ret = VOP_GETATTR(vp, &forat, cred, lwp); d913 1 a913 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 1); d953 1 a953 1 uiop->uio_lwp = NULL; d959 1 a959 1 aftat_ret = VOP_GETATTR(vp, &va, cred, lwp); d998 1 a998 1 nfsrv_writegather(ndp, slp, lwp, mrq) d1001 1 a1001 1 struct lwp *lwp; d1170 1 a1170 1 forat_ret = VOP_GETATTR(vp, &forat, cred, lwp); d1181 1 a1181 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 1); d1192 1 a1192 1 uiop->uio_lwp = NULL; d1231 1 a1231 1 aftat_ret = VOP_GETATTR(vp, &va, cred, lwp); d1364 1 a1364 1 nfsrv_create(nfsd, slp, lwp, mrq) d1367 1 a1367 1 struct lwp *lwp; d1405 1 a1405 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1408 2 a1409 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1487 1 a1487 1 lwp); d1531 1 a1531 1 (nd.ni_cnd.cn_flags & RDONLY), lwp, 0); d1537 2 a1538 1 error = VOP_SETATTR(vp, &va, cred, lwp); d1549 1 a1549 1 error = VOP_GETATTR(vp, &va, cred, lwp); d1563 1 a1563 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1598 1 a1598 1 nfsrv_mknod(nfsd, slp, lwp, mrq) d1601 1 a1601 1 struct lwp *lwp; d1635 1 a1635 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1637 1 a1637 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1712 1 a1712 1 error = VOP_GETATTR(vp, &va, cred, lwp); d1715 1 a1715 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1743 1 a1743 1 nfsrv_remove(nfsd, slp, lwp, mrq) d1746 1 a1746 1 struct lwp *lwp; d1781 1 a1781 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1784 2 a1785 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1816 1 a1816 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1833 1 a1833 1 nfsrv_rename(nfsd, slp, lwp, mrq) d1836 1 a1836 1 struct lwp *lwp; d1883 1 a1883 1 &dpos, &fdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1886 2 a1887 1 fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, lwp); d1918 1 a1918 1 &dpos, &tdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1921 2 a1922 1 tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, lwp); d2015 1 a2015 1 fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, lwp); d2019 1 a2019 1 tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, lwp); d2055 1 a2055 1 nfsrv_link(nfsd, slp, lwp, mrq) d2058 1 a2058 1 struct lwp *lwp; d2103 1 a2103 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2106 2 a2107 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2139 1 a2139 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d2141 1 a2141 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2160 1 a2160 1 nfsrv_symlink(nfsd, slp, lwp, mrq) d2163 1 a2163 1 struct lwp *lwp; d2199 1 a2199 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2202 2 a2203 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2235 1 a2235 1 io.uio_lwp = NULL; d2262 2 a2263 1 error = VOP_GETATTR(nd.ni_vp, &va, cred, lwp); d2273 1 a2273 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2306 1 a2306 1 nfsrv_mkdir(nfsd, slp, lwp, mrq) d2309 1 a2309 1 struct lwp *lwp; d2343 1 a2343 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2346 2 a2347 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2388 1 a2388 1 error = VOP_GETATTR(vp, &va, cred, lwp); d2393 1 a2393 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2428 1 a2428 1 nfsrv_rmdir(nfsd, slp, lwp, mrq) d2431 1 a2431 1 struct lwp *lwp; d2463 1 a2463 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2466 2 a2467 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2512 1 a2512 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2566 1 a2566 1 nfsrv_readdir(nfsd, slp, lwp, mrq) d2569 1 a2569 1 struct lwp *lwp; d2630 1 a2630 1 error = getret = VOP_GETATTR(vp, &at, cred, lwp); d2640 1 a2640 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0); d2658 1 a2658 1 io.uio_lwp = NULL; d2668 1 a2668 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d2829 1 a2829 1 nfsrv_readdirplus(nfsd, slp, lwp, mrq) d2832 1 a2832 1 struct lwp *lwp; d2887 1 a2887 1 error = getret = VOP_GETATTR(vp, &at, cred, lwp); d2897 1 a2897 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0); d2917 1 a2917 1 io.uio_lwp = NULL; d2925 1 a2925 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d3030 1 a3030 1 if (VOP_GETATTR(nvp, vap, cred, lwp)) { d3141 1 a3141 1 nfsrv_commit(nfsd, slp, lwp, mrq) d3144 1 a3144 1 struct lwp *lwp; d3185 1 a3185 1 for_ret = VOP_GETATTR(vp, &bfor, cred, lwp); d3190 1 a3190 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, lwp); d3192 1 a3192 1 aft_ret = VOP_GETATTR(vp, &aft, cred, lwp); d3212 1 a3212 1 nfsrv_statfs(nfsd, slp, lwp, mrq) d3215 1 a3215 1 struct lwp *lwp; d3251 2 a3252 2 error = VFS_STATVFS(vp->v_mount, sf, lwp); getret = VOP_GETATTR(vp, &at, cred, lwp); d3287 1 a3287 1 nfsrv_fsinfo(nfsd, slp, lwp, mrq) d3290 1 a3290 1 struct lwp *lwp; d3326 1 a3326 1 VFS_STATVFS(vp->v_mount, &sb, (struct lwp *)0); d3329 1 a3329 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d3364 1 a3364 1 nfsrv_pathconf(nfsd, slp, lwp, mrq) d3367 1 a3367 1 struct lwp *lwp; d3407 1 a3407 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d3435 1 a3435 1 nfsrv_null(nfsd, slp, lwp, mrq) d3438 1 a3438 1 struct lwp *lwp; d3456 1 a3456 1 nfsrv_noop(nfsd, slp, lwp, mrq) d3459 1 a3459 1 struct lwp *lwp; d3491 1 a3491 1 nfsrv_access(vp, flags, cred, rdonly, lwp, override) d3496 1 a3496 1 struct lwp *lwp; d3525 1 a3525 1 error = VOP_GETATTR(vp, &vattr, cred, lwp); d3528 1 a3528 1 error = VOP_ACCESS(vp, flags, cred, lwp); @ 1.79.2.6 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.79.2.5 2004/09/21 13:38:38 skrll Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.79.2.5 2004/09/21 13:38:38 skrll Exp $"); a689 2 if (error == EBUSY) goto loan_fail; a1422 1 va.va_mode = 0; d1438 2 a1656 1 va.va_mode = 0; a2204 1 va.va_mode = 0; a2352 1 va.va_mode = 0; d3147 1 a3147 2 int error = 0, rdonly, for_ret = 1, aft_ret = 1, cache; uint32_t cnt; d3165 1 a3165 1 cnt = fxdr_unsigned(uint32_t, *tl); @ 1.79.2.7 log @Sync with HEAD. Hi Perry! @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.79.2.6 2004/12/18 09:33:17 skrll Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.79.2.6 2004/12/18 09:33:17 skrll Exp $"); d411 1 a411 1 if (dirp) d1040 1 a1040 1 d1058 1 a1058 1 d1096 1 a1096 1 d1144 1 a1144 1 d1166 1 a1166 1 error = nfsrv_fhtovp(&nfsd->nd_fh, 1, &vp, cred, slp, d1184 1 a1184 1 d2765 1 a2765 1 d2785 1 a2785 1 d3009 1 a3009 1 d3066 1 a3066 1 d3085 1 a3085 1 d3516 1 a3516 1 if (vp->v_flag & VTEXT) @ 1.79.2.8 log @Sync with HEAD. Here we go again... @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.79.2.7 2005/03/04 16:54:20 skrll Exp $ */ d58 1 a58 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.79.2.7 2005/03/04 16:54:20 skrll Exp $"); d73 1 d1648 8 a1655 1 goto abort; a1660 2 dev_t rdev; d1664 1 a1664 6 rdev = makedev(major, minor); if (major(rdev) != major || minor(rdev) != minor) { error = EINVAL; goto abort; } va.va_rdev = rdev; a1671 1 abort: d1677 1 a1677 2 if (nd.ni_vp) vput(nd.ni_vp); a2205 1 va.va_type = VLNK; d2521 1 a2521 1 * count rounded up to a multiple of NFS_SRVDIRBLKSIZ <= NFS_MAXREADDIR a2548 3 #define NFS_SRVDIRBLKSIZ 1024 d2605 1 a2605 1 siz = ((cnt + NFS_SRVDIRBLKSIZ - 1) & ~(NFS_SRVDIRBLKSIZ - 1)); d2756 1 a2756 1 *tl = txdr_unsigned(dp->d_fileno >> 32); d2864 1 a2864 1 siz = ((siz + NFS_SRVDIRBLKSIZ - 1) & ~(NFS_SRVDIRBLKSIZ - 1)); d3058 1 a3058 1 *tl = txdr_unsigned(dp->d_fileno >> 32); @ 1.78 log @Undo part of the ktrace/lwp changes. In particular: * Remove the "lwp *" argument that was added to vget(). Turns out that nothing actually used it! * Remove the "lwp *" arguments that were added to VFS_ROOT(), VFS_VGET(), and VFS_FHTOVP(); all they did was pass it to vget() (which, as noted above, didn't use it). * Remove all of the "lwp *" arguments to internal functions that were added just to appease the above. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.77 2003/06/28 14:22:17 darrenr Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.77 2003/06/28 14:22:17 darrenr Exp $"); d103 1 a103 1 nfsrv3_access(nfsd, slp, lwp, mrq) d106 1 a106 1 struct lwp *lwp; d139 1 a139 1 nfsrv_access(vp, VREAD, cred, rdonly, lwp, 0) == 0) d144 1 a144 1 nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0) == 0) d147 1 a147 1 nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0) == 0) d153 1 a153 1 nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 0) == 0) d156 1 a156 1 nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0) == 0) d159 1 a159 1 getret = VOP_GETATTR(vp, &va, cred, lwp); d172 1 a172 1 nfsrv_getattr(nfsd, slp, lwp, mrq) d175 1 a175 1 struct lwp *lwp; d204 1 a204 1 error = VOP_GETATTR(vp, &va, cred, lwp); d218 1 a218 1 nfsrv_setattr(nfsd, slp, lwp, mrq) d221 1 a221 1 struct lwp *lwp; d298 1 a298 1 error = preat_ret = VOP_GETATTR(vp, &preat, cred, lwp); d325 1 a325 1 lwp, 0)) != 0) d328 2 a329 2 error = VOP_SETATTR(vp, &va, cred, lwp); postat_ret = VOP_GETATTR(vp, &va, cred, lwp); d349 1 a349 1 nfsrv_lookup(nfsd, slp, lwp, mrq) d352 1 a352 1 struct lwp *lwp; d386 1 a386 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag); d430 2 a431 1 dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, lwp); d449 1 a449 1 error = VOP_GETATTR(vp, &va, cred, lwp); d471 1 a471 1 nfsrv_readlink(nfsd, slp, lwp, mrq) d474 1 a474 1 struct lwp *lwp; d530 1 a530 1 uiop->uio_lwp = (struct lwp *)0; d549 1 a549 1 getret = VOP_GETATTR(vp, &attr, cred, lwp); d580 1 a580 1 nfsrv_read(nfsd, slp, lwp, mrq) d583 1 a583 1 struct lwp *lwp; d637 2 a638 2 if ((error = nfsrv_access(vp, VREAD, cred, rdonly, lwp, 1)) != 0) error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 1); d640 1 a640 1 getret = VOP_GETATTR(vp, &va, cred, lwp); d806 1 a806 1 if (error || (getret = VOP_GETATTR(vp, &va, cred, lwp)) != 0){ d839 1 a839 1 nfsrv_write(nfsd, slp, lwp, mrq) d842 1 a842 1 struct lwp *lwp; d934 1 a934 1 forat_ret = VOP_GETATTR(vp, &forat, cred, lwp); d943 1 a943 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 1); d982 1 a982 1 uiop->uio_lwp = (struct lwp *)0; d988 1 a988 1 aftat_ret = VOP_GETATTR(vp, &va, cred, lwp); d1026 1 a1026 1 nfsrv_writegather(ndp, slp, lwp, mrq) d1029 1 a1029 1 struct lwp *lwp; d1197 1 a1197 1 forat_ret = VOP_GETATTR(vp, &forat, cred, lwp); d1208 1 a1208 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, lwp, 1); d1219 1 a1219 1 uiop->uio_lwp = (struct lwp *)0; d1250 1 a1250 1 aftat_ret = VOP_GETATTR(vp, &va, cred, lwp); d1383 1 a1383 1 nfsrv_create(nfsd, slp, lwp, mrq) d1386 1 a1386 1 struct lwp *lwp; d1420 1 a1420 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1423 2 a1424 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1497 1 a1497 1 lwp); d1540 1 a1540 1 (nd.ni_cnd.cn_flags & RDONLY), lwp, 0); d1546 2 a1547 1 error = VOP_SETATTR(vp, &va, cred, lwp); d1558 1 a1558 1 error = VOP_GETATTR(vp, &va, cred, lwp); d1565 1 a1565 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1598 1 a1598 1 nfsrv_mknod(nfsd, slp, lwp, mrq) d1601 1 a1601 1 struct lwp *lwp; d1631 1 a1631 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1633 1 a1633 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1707 1 a1707 1 error = VOP_GETATTR(vp, &va, cred, lwp); d1710 1 a1710 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1736 1 a1736 1 nfsrv_remove(nfsd, slp, lwp, mrq) d1739 1 a1739 1 struct lwp *lwp; d1770 1 a1770 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1773 2 a1774 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d1805 1 a1805 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d1820 1 a1820 1 nfsrv_rename(nfsd, slp, lwp, mrq) d1823 1 a1823 1 struct lwp *lwp; d1866 1 a1866 1 &dpos, &fdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1869 2 a1870 1 fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, lwp); d1900 1 a1900 1 &dpos, &tdirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1903 2 a1904 1 tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, lwp); d1997 1 a1997 1 fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, lwp); d2001 1 a2001 1 tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, lwp); d2036 1 a2036 1 nfsrv_link(nfsd, slp, lwp, mrq) d2039 1 a2039 1 struct lwp *lwp; d2079 1 a2079 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2082 2 a2083 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2115 1 a2115 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d2117 1 a2117 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2134 1 a2134 1 nfsrv_symlink(nfsd, slp, lwp, mrq) d2137 1 a2137 1 struct lwp *lwp; d2169 1 a2169 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2172 2 a2173 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2205 1 a2205 1 io.uio_lwp = (struct lwp *)0; d2232 2 a2233 1 error = VOP_GETATTR(nd.ni_vp, &va, cred, lwp); d2243 1 a2243 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2274 1 a2274 1 nfsrv_mkdir(nfsd, slp, lwp, mrq) d2277 1 a2277 1 struct lwp *lwp; d2307 1 a2307 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2310 2 a2311 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2351 1 a2351 1 error = VOP_GETATTR(vp, &va, cred, lwp); d2356 1 a2356 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2389 1 a2389 1 nfsrv_rmdir(nfsd, slp, lwp, mrq) d2392 1 a2392 1 struct lwp *lwp; d2420 1 a2420 1 &dirp, lwp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2423 2 a2424 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, lwp); d2468 1 a2468 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, lwp); d2520 1 a2520 1 nfsrv_readdir(nfsd, slp, lwp, mrq) d2523 1 a2523 1 struct lwp *lwp; d2584 1 a2584 1 error = getret = VOP_GETATTR(vp, &at, cred, lwp); d2594 1 a2594 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0); d2612 1 a2612 1 io.uio_lwp = (struct lwp *)0; d2622 1 a2622 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d2783 1 a2783 1 nfsrv_readdirplus(nfsd, slp, lwp, mrq) d2786 1 a2786 1 struct lwp *lwp; d2841 1 a2841 1 error = getret = VOP_GETATTR(vp, &at, cred, lwp); d2851 1 a2851 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, lwp, 0); d2871 1 a2871 1 io.uio_lwp = (struct lwp *)0; d2879 1 a2879 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d2984 1 a2984 1 if (VOP_GETATTR(nvp, vap, cred, lwp)) { d3095 1 a3095 1 nfsrv_commit(nfsd, slp, lwp, mrq) d3098 1 a3098 1 struct lwp *lwp; d3134 1 a3134 1 for_ret = VOP_GETATTR(vp, &bfor, cred, lwp); d3138 2 a3139 2 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, lwp); aft_ret = VOP_GETATTR(vp, &aft, cred, lwp); d3156 1 a3156 1 nfsrv_statfs(nfsd, slp, lwp, mrq) d3159 1 a3159 1 struct lwp *lwp; d3195 2 a3196 2 error = VFS_STATFS(vp->v_mount, sf, lwp); getret = VOP_GETATTR(vp, &at, cred, lwp); d3231 1 a3231 1 nfsrv_fsinfo(nfsd, slp, lwp, mrq) d3234 1 a3234 1 struct lwp *lwp; d3270 1 a3270 1 VFS_STATFS(vp->v_mount, &sb, (struct lwp *)0); d3273 1 a3273 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d3308 1 a3308 1 nfsrv_pathconf(nfsd, slp, lwp, mrq) d3311 1 a3311 1 struct lwp *lwp; d3351 1 a3351 1 getret = VOP_GETATTR(vp, &at, cred, lwp); d3379 1 a3379 1 nfsrv_null(nfsd, slp, lwp, mrq) d3382 1 a3382 1 struct lwp *lwp; d3400 1 a3400 1 nfsrv_noop(nfsd, slp, lwp, mrq) d3403 1 a3403 1 struct lwp *lwp; d3435 1 a3435 1 nfsrv_access(vp, flags, cred, rdonly, lwp, override) d3440 1 a3440 1 struct lwp *lwp; d3469 1 a3469 1 error = VOP_GETATTR(vp, &vattr, cred, lwp); d3472 1 a3472 1 error = VOP_ACCESS(vp, flags, cred, lwp); @ 1.77 log @Pass lwp pointers throughtout the kernel, as required, so that the lwpid can be inserted into ktrace records. The general change has been to replace "struct proc *" with "struct lwp *" in various function prototypes, pass the lwp through and use l_proc to get the process pointer when needed. Bump the kernel rev up to 1.6V @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.76 2003/06/09 13:10:31 yamt Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.76 2003/06/09 13:10:31 yamt Exp $"); d130 1 a130 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d198 1 a198 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d290 1 a290 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d531 1 a531 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d622 1 a622 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d926 1 a926 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d1193 1 a1193 1 FALSE, lwp); d2060 1 a2060 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d2561 1 a2561 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d2820 1 a2820 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d2880 1 a2880 1 if ((getret = VFS_VGET(vp->v_mount, at.va_fileid, &nvp, lwp))) d2964 1 a2964 1 if (VFS_VGET(vp->v_mount, dp->d_fileno, &nvp, lwp)) d3117 1 a3117 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d3177 1 a3177 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d3251 1 a3251 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); d3327 1 a3327 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE, lwp); @ 1.76 log @rework zero padding of rpc reply. - for READ procedure, don't send back more bytes than requested. - don't have doubtful assumptions on mbuf chain structure. - rename a function (nfsm_adj -> nfs_zeropad) to avoid confusion as the semantics of the function was changed. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.75 2003/05/29 15:18:14 yamt Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.75 2003/05/29 15:18:14 yamt Exp $"); d103 1 a103 1 nfsrv3_access(nfsd, slp, procp, mrq) d106 1 a106 1 struct proc *procp; d130 1 a130 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE); d139 1 a139 1 nfsrv_access(vp, VREAD, cred, rdonly, procp, 0) == 0) d144 1 a144 1 nfsrv_access(vp, VWRITE, cred, rdonly, procp, 0) == 0) d147 1 a147 1 nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0) == 0) d153 1 a153 1 nfsrv_access(vp, VWRITE, cred, rdonly, procp, 0) == 0) d156 1 a156 1 nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0) == 0) d159 1 a159 1 getret = VOP_GETATTR(vp, &va, cred, procp); d172 1 a172 1 nfsrv_getattr(nfsd, slp, procp, mrq) d175 1 a175 1 struct proc *procp; d198 1 a198 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE); d204 1 a204 1 error = VOP_GETATTR(vp, &va, cred, procp); d218 1 a218 1 nfsrv_setattr(nfsd, slp, procp, mrq) d221 1 a221 1 struct proc *procp; d290 1 a290 1 (nfsd->nd_flag & ND_KERBAUTH), FALSE); d298 1 a298 1 error = preat_ret = VOP_GETATTR(vp, &preat, cred, procp); d325 1 a325 1 procp, 0)) != 0) d328 2 a329 2 error = VOP_SETATTR(vp, &va, cred, procp); postat_ret = VOP_GETATTR(vp, &va, cred, procp); d349 1 a349 1 nfsrv_lookup(nfsd, slp, procp, mrq) d352 1 a352 1 struct proc *procp; d386 1 a386 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), pubflag); d430 1 a430 2 dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, procp); d448 1 a448 1 error = VOP_GETATTR(vp, &va, cred, procp); d470 1 a470 1 nfsrv_readlink(nfsd, slp, procp, mrq) d473 1 a473 1 struct proc *procp; d529 1 a529 1 uiop->uio_procp = (struct proc *)0; d531 1 a531 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d548 1 a548 1 getret = VOP_GETATTR(vp, &attr, cred, procp); d579 1 a579 1 nfsrv_read(nfsd, slp, procp, mrq) d582 1 a582 1 struct proc *procp; d622 1 a622 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d636 2 a637 2 if ((error = nfsrv_access(vp, VREAD, cred, rdonly, procp, 1)) != 0) error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 1); d639 1 a639 1 getret = VOP_GETATTR(vp, &va, cred, procp); d805 1 a805 1 if (error || (getret = VOP_GETATTR(vp, &va, cred, procp)) != 0){ d838 1 a838 1 nfsrv_write(nfsd, slp, procp, mrq) d841 1 a841 1 struct proc *procp; d926 1 a926 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d933 1 a933 1 forat_ret = VOP_GETATTR(vp, &forat, cred, procp); d942 1 a942 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1); d981 1 a981 1 uiop->uio_procp = (struct proc *)0; d987 1 a987 1 aftat_ret = VOP_GETATTR(vp, &va, cred, procp); d1025 1 a1025 1 nfsrv_writegather(ndp, slp, procp, mrq) d1028 1 a1028 1 struct proc *procp; d1193 1 a1193 1 FALSE); d1196 1 a1196 1 forat_ret = VOP_GETATTR(vp, &forat, cred, procp); d1207 1 a1207 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, procp, 1); d1218 1 a1218 1 uiop->uio_procp = (struct proc *)0; d1249 1 a1249 1 aftat_ret = VOP_GETATTR(vp, &va, cred, procp); d1382 1 a1382 1 nfsrv_create(nfsd, slp, procp, mrq) d1385 1 a1385 1 struct proc *procp; d1419 1 a1419 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1422 1 a1422 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d1495 1 a1495 1 procp); d1538 1 a1538 1 (nd.ni_cnd.cn_flags & RDONLY), procp, 0); d1544 1 a1544 2 error = VOP_SETATTR(vp, &va, cred, procp); d1555 1 a1555 1 error = VOP_GETATTR(vp, &va, cred, procp); d1562 1 a1562 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d1595 1 a1595 1 nfsrv_mknod(nfsd, slp, procp, mrq) d1598 1 a1598 1 struct proc *procp; d1628 1 a1628 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1630 1 a1630 1 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d1704 1 a1704 1 error = VOP_GETATTR(vp, &va, cred, procp); d1707 1 a1707 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d1733 1 a1733 1 nfsrv_remove(nfsd, slp, procp, mrq) d1736 1 a1736 1 struct proc *procp; d1767 1 a1767 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1770 1 a1770 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d1801 1 a1801 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d1816 1 a1816 1 nfsrv_rename(nfsd, slp, procp, mrq) d1819 1 a1819 1 struct proc *procp; d1862 1 a1862 1 &dpos, &fdirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1865 1 a1865 2 fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, procp); d1895 1 a1895 1 &dpos, &tdirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d1898 1 a1898 2 tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, procp); d1991 1 a1991 1 fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, procp); d1995 1 a1995 1 tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, procp); d2030 1 a2030 1 nfsrv_link(nfsd, slp, procp, mrq) d2033 1 a2033 1 struct proc *procp; d2060 1 a2060 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2073 1 a2073 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2076 1 a2076 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d2108 1 a2108 1 getret = VOP_GETATTR(vp, &at, cred, procp); d2110 1 a2110 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d2127 1 a2127 1 nfsrv_symlink(nfsd, slp, procp, mrq) d2130 1 a2130 1 struct proc *procp; d2162 1 a2162 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2165 1 a2165 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d2197 1 a2197 1 io.uio_procp = (struct proc *)0; d2224 1 a2224 2 error = VOP_GETATTR(nd.ni_vp, &va, cred, procp); d2234 1 a2234 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d2265 1 a2265 1 nfsrv_mkdir(nfsd, slp, procp, mrq) d2268 1 a2268 1 struct proc *procp; d2298 1 a2298 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2301 1 a2301 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d2341 1 a2341 1 error = VOP_GETATTR(vp, &va, cred, procp); d2346 1 a2346 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d2379 1 a2379 1 nfsrv_rmdir(nfsd, slp, procp, mrq) d2382 1 a2382 1 struct proc *procp; d2410 1 a2410 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2413 1 a2413 2 dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); d2457 1 a2457 1 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); d2509 1 a2509 1 nfsrv_readdir(nfsd, slp, procp, mrq) d2512 1 a2512 1 struct proc *procp; d2561 1 a2561 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2573 1 a2573 1 error = getret = VOP_GETATTR(vp, &at, cred, procp); d2583 1 a2583 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); d2601 1 a2601 1 io.uio_procp = (struct proc *)0; d2611 1 a2611 1 getret = VOP_GETATTR(vp, &at, cred, procp); d2772 1 a2772 1 nfsrv_readdirplus(nfsd, slp, procp, mrq) d2775 1 a2775 1 struct proc *procp; d2820 1 a2820 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d2830 1 a2830 1 error = getret = VOP_GETATTR(vp, &at, cred, procp); d2840 1 a2840 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); d2860 1 a2860 1 io.uio_procp = (struct proc *)0; d2868 1 a2868 1 getret = VOP_GETATTR(vp, &at, cred, procp); d2880 1 a2880 1 if ((getret = VFS_VGET(vp->v_mount, at.va_fileid, &nvp))) d2964 1 a2964 1 if (VFS_VGET(vp->v_mount, dp->d_fileno, &nvp)) d2973 1 a2973 1 if (VOP_GETATTR(nvp, vap, cred, procp)) { d3084 1 a3084 1 nfsrv_commit(nfsd, slp, procp, mrq) d3087 1 a3087 1 struct proc *procp; d3117 1 a3117 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d3123 1 a3123 1 for_ret = VOP_GETATTR(vp, &bfor, cred, procp); d3127 2 a3128 2 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, procp); aft_ret = VOP_GETATTR(vp, &aft, cred, procp); d3145 1 a3145 1 nfsrv_statfs(nfsd, slp, procp, mrq) d3148 1 a3148 1 struct proc *procp; d3177 1 a3177 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d3184 2 a3185 2 error = VFS_STATFS(vp->v_mount, sf, procp); getret = VOP_GETATTR(vp, &at, cred, procp); d3220 1 a3220 1 nfsrv_fsinfo(nfsd, slp, procp, mrq) d3223 1 a3223 1 struct proc *procp; d3251 1 a3251 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d3259 1 a3259 1 VFS_STATFS(vp->v_mount, &sb, (struct proc *)0); d3262 1 a3262 1 getret = VOP_GETATTR(vp, &at, cred, procp); d3297 1 a3297 1 nfsrv_pathconf(nfsd, slp, procp, mrq) d3300 1 a3300 1 struct proc *procp; d3327 1 a3327 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH), FALSE); d3340 1 a3340 1 getret = VOP_GETATTR(vp, &at, cred, procp); d3368 1 a3368 1 nfsrv_null(nfsd, slp, procp, mrq) d3371 1 a3371 1 struct proc *procp; d3389 1 a3389 1 nfsrv_noop(nfsd, slp, procp, mrq) d3392 1 a3392 1 struct proc *procp; d3424 1 a3424 1 nfsrv_access(vp, flags, cred, rdonly, p, override) d3429 1 a3429 1 struct proc *p; d3458 1 a3458 1 error = VOP_GETATTR(vp, &vattr, cred, p); d3461 1 a3461 1 error = VOP_ACCESS(vp, flags, cred, p); @ 1.75 log @workaround for UBC limit. while our nfsd announces MAXBSIZE as wtmax for tcp, VOP_GETPAGES of filesystems that uses genfs_getpages can't handle >= MAX_READ_AHEAD(16) pages at once. therefore, depending on PAGE_SIZE of the machine and file offset of a read request, we can't VOP_GETPAGES the range at once. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.74 2003/05/07 13:10:44 yamt Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.74 2003/05/07 13:10:44 yamt Exp $"); d487 2 a488 1 int error = 0, rdonly, cache, i, tlen, len, getret; d559 4 a562 5 if (uiop->uio_resid > 0) { len -= uiop->uio_resid; tlen = nfsm_rndup(len); nfsm_adj(mp3, NFS_MAXPATHLEN-tlen, tlen-len); } d598 2 a599 1 uint32_t reqlen, len, cnt, left, tlen; d652 1 a652 1 cnt = nfsm_rndup(va.va_size - off); d821 3 a823 3 tlen = nfsm_rndup(len); if (cnt != tlen || tlen != len) nfsm_adj(mb, (int)cnt - tlen, tlen - len); @ 1.74 log @- indent. - fix a comment typo (mus -> must) - remove an unneeded caddr_t cast. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.73 2003/05/04 11:40:22 yamt Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.73 2003/05/04 11:40:22 yamt Exp $"); d570 7 d670 2 a671 2 int orignpages, npages; vaddr_t lva; d673 1 a673 1 npages = orignpages = (round_page(off + cnt) - pgoff) d675 1 a675 1 KASSERT(npages <= M_EXT_MAXPAGES); /* XXX */ d677 1 a677 1 lva = sokvaalloc(npages << PAGE_SHIFT, slp->ns_so); d685 7 d693 27 a719 23 simple_lock(&vp->v_interlock); again_locked: error = VOP_GETPAGES(vp, pgoff, pgpp, &npages, 0, VM_PROT_READ, 0, PGO_SYNCIO); if (error == EAGAIN) { tsleep(&lbolt, PVM, "nfsread", 0); goto again; } if (error) { sokvafree(lva, orignpages << PAGE_SHIFT); m_free(m); goto read_error; } KASSERT(npages == orignpages); /* loan and unbusy pages */ simple_lock(&vp->v_interlock); for (i = 0; i < npages; i++) { if (pgpp[i]->flags & PG_RELEASED) { uvm_lock_pageq(); uvm_page_unbusy(pgpp, npages); uvm_unlock_pageq(); goto again_locked; d721 2 a722 3 } uvm_loanuobjpages(pgpp, npages); simple_unlock(&vp->v_interlock); d724 10 a733 4 /* map pages */ for (i = 0; i < npages; i++) { pmap_kenter_pa(lva + (i << PAGE_SHIFT), VM_PAGE_TO_PHYS(pgpp[i]), VM_PROT_READ); @ 1.73 log @fix handling of the case that readsize == 0. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.72 2003/05/03 18:36:26 yamt Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.72 2003/05/03 18:36:26 yamt Exp $"); d872 9 a880 17 zeroing = 1; mp = mrep; while (mp) { if (mp == md) { zeroing = 0; adjust = dpos - mtod(mp, caddr_t); mp->m_len -= adjust; if (mp->m_len > 0 && adjust > 0) NFSMADV(mp, adjust); } if (zeroing) mp->m_len = 0; else if (mp->m_len > 0) { i += mp->m_len; if (i > len) { mp->m_len -= (i - len); zeroing = 1; d882 12 a893 2 if (mp->m_len > 0) cnt++; a894 2 mp = mp->m_next; } d929 34 a962 34 ivp = malloc(cnt * sizeof (struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = iv = ivp; uiop->uio_iovcnt = cnt; mp = mrep; while (mp) { if (mp->m_len > 0) { ivp->iov_base = mtod(mp, caddr_t); ivp->iov_len = mp->m_len; ivp++; } mp = mp->m_next; } /* * XXX * The IO_METASYNC flag indicates that all metadata (and not just * enough to ensure data integrity) mus be written to stable storage * synchronously. * (IO_METASYNC is not yet implemented in 4.4BSD-Lite.) */ if (stable == NFSV3WRITE_UNSTABLE) ioflags = IO_NODELOCKED; else if (stable == NFSV3WRITE_DATASYNC) ioflags = (IO_SYNC | IO_NODELOCKED); else ioflags = (IO_METASYNC | IO_SYNC | IO_NODELOCKED); uiop->uio_resid = len; uiop->uio_rw = UIO_WRITE; uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_procp = (struct proc *)0; uiop->uio_offset = off; error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; free((caddr_t)iv, M_TEMP); @ 1.72 log @use uvm page loanout mechanism for nfsd READ procedure processing. reviewed by Frank van der Linden and Chuck Silvers. tested by Wojciech Puchar. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.71 2003/04/03 15:19:12 yamt Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.71 2003/04/03 15:19:12 yamt Exp $"); d659 1 a659 1 if (cnt >= 0) { @ 1.71 log @return rtmax bytes if we get READ requests larger than rtmax. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.70 2003/04/02 15:14:20 yamt Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.70 2003/04/02 15:14:20 yamt Exp $"); d79 1 a79 1 #include d97 1 a582 2 struct iovec *iv; struct iovec *iv2; d589 1 a589 1 int error = 0, rdonly, cache, cnt, len, left, siz, tlen, getret; d591 1 a591 1 uint32_t reqlen; a593 1 struct mbuf *m2; d659 44 a702 11 if (cnt > 0) { /* * Generate the mbuf list with the uio_iov ref. to it. */ i = 0; m = m2 = mb; while (left > 0) { siz = min(M_TRAILINGSPACE(m), left); if (siz > 0) { left -= siz; i++; d704 7 a710 7 if (left > 0) { m = m_get(M_WAIT, MT_DATA); MCLAIM(m, &nfs_mowner); m_clget(m, M_WAIT); m->m_len = 0; m2->m_next = m; m2 = m; d712 59 a770 17 } iv = malloc(i * sizeof (struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = iv2 = iv; m = mb; left = cnt; i = 0; while (left > 0) { if (m == NULL) panic("nfsrv_read iov"); siz = min(M_TRAILINGSPACE(m), left); if (siz > 0) { iv->iov_base = mtod(m, caddr_t) + m->m_len; iv->iov_len = siz; m->m_len += siz; left -= siz; iv++; i++; d772 8 a779 1 m = m->m_next; d781 1 a781 8 uiop->uio_iovcnt = i; uiop->uio_offset = off; uiop->uio_resid = cnt; uiop->uio_rw = UIO_READ; uiop->uio_segflg = UIO_SYSSPACE; error = VOP_READ(vp, uiop, IO_NODELOCKED, cred); off = uiop->uio_offset; free((caddr_t)iv2, M_TEMP); d791 1 a791 1 } else d793 1 d799 1 a799 1 nfsm_adj(mb, cnt - tlen, tlen - len); @ 1.70 log @use queue manipulation macros. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.69 2003/03/28 15:24:58 yamt Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.69 2003/03/28 15:24:58 yamt Exp $"); d613 3 a615 1 nfsm_srvstrsiz(reqlen, NFS_SRVMAXDATA(nfsd)); @ 1.69 log @reply FSINFO rtmax and wtmax for DGRAM properly. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.68 2003/03/28 13:05:47 yamt Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.68 2003/03/28 13:05:47 yamt Exp $"); d1028 1 a1028 1 wp = slp->ns_tq.lh_first; d1031 1 a1031 1 wp = wp->nd_tq.le_next; d1041 1 a1041 1 wp = wpp->lh_first; d1045 1 a1045 1 wp = wp->nd_hash.le_next; d1050 1 a1050 1 wp = wp->nd_hash.le_next; d1060 1 a1060 1 wp = nfsd->nd_hash.le_next; d1078 2 a1079 2 for (nfsd = slp->ns_tq.lh_first; nfsd; nfsd = owp) { owp = nfsd->nd_tq.le_next; d1199 1 a1199 1 nfsd = swp->nd_coalesce.lh_first; d1217 1 a1217 1 for (nfsd = slp->ns_tq.lh_first; nfsd; nfsd = nfsd->nd_tq.le_next) d1224 1 d1244 1 d1272 4 a1275 10 if (nfsd->nd_coalesce.lh_first) { struct nfsrv_descript *m; while ((m = nfsd->nd_coalesce.lh_first)) { LIST_REMOVE(m, nd_tq); LIST_INSERT_HEAD(&owp->nd_coalesce, m, nd_tq); } } @ 1.68 log @reply ENAMETOOLONG properly instead of discarding request as BADRPC. my own PR20791. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.67 2003/02/26 06:31:18 matt Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.67 2003/02/26 06:31:18 matt Exp $"); d3149 2 a3150 1 int error = 0, rdonly, cache, getret = 1, pref; d3189 1 a3189 1 pref = NFS_MAXDGRAMDATA; d3191 3 a3193 3 pref = NFS_MAXDATA; sip->fs_rtmax = txdr_unsigned(NFS_MAXDATA); sip->fs_rtpref = txdr_unsigned(pref); d3195 2 a3196 2 sip->fs_wtmax = txdr_unsigned(NFS_MAXDATA); sip->fs_wtpref = txdr_unsigned(pref); d3198 1 a3198 1 sip->fs_dtpref = txdr_unsigned(pref); @ 1.67 log @Add MBUFTRACE kernel option. Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *) to m_get*(M_WAIT, *). These are not performance critical and making them call m_get saves considerable space. Add m_clget analogue of MCLGET and make corresponding change for M_WAIT uses. Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE. Begin to change netstat to use sysctl. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.66 2002/12/01 23:02:10 matt Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.66 2002/12/01 23:02:10 matt Exp $"); d367 2 a368 1 int error = 0, cache, len, dirattr_ret = 1; d591 2 a592 1 int v3 = (nfsd->nd_flag & ND_NFSV3), reqlen; d1737 2 a1738 1 int error = 0, cache, len, len2, fdirfor_ret = 1, fdiraft_ret = 1; d1790 9 a1798 1 nfsm_strsiz(len2, NFS_MAXNAMLEN); d2056 2 a2057 1 int error = 0, cache, len, len2, dirfor_ret = 1, diraft_ret = 1; d2086 1 a2086 1 if (v3) d2088 12 a2099 1 nfsm_strsiz(len2, NFS_MAXPATHLEN); d2117 2 d2124 2 a2125 2 vrele(nd.ni_vp); error = EEXIST; @ 1.66 log @Make sure these all agree on the same definitons of various variables. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.65 2002/09/27 19:30:46 bouyer Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.65 2002/09/27 19:30:46 bouyer Exp $"); d120 1 a120 1 struct mbuf *mb, *mreq, *mb2; d191 1 a191 1 struct mbuf *mb, *mb2, *mreq; d239 1 a239 1 struct mbuf *mb, *mb2, *mreq; d370 1 a370 1 struct mbuf *mb, *mb2, *mreq; d488 1 a488 1 struct mbuf *mb, *mb2, *mp2 = NULL, *mp3 = NULL, *mreq; d501 3 a503 2 MGET(mp, M_WAIT, MT_DATA); MCLGET(mp, M_WAIT); d592 1 a592 1 struct mbuf *mb, *mb2, *mreq; d670 3 a672 2 MGET(m, M_WAIT, MT_DATA); MCLGET(m, M_WAIT); d761 1 a761 1 struct mbuf *mb, *mb2, *mreq; d945 1 a945 1 struct mbuf *mb, *mb2, *mreq, *mrep, *md; d1307 1 a1307 1 struct mbuf *mb, *mb2, *mreq; d1519 1 a1519 1 struct mbuf *mb, *mb2, *mreq; d2047 1 a2047 1 struct mbuf *mb, *mreq, *mb2; d2173 1 a2173 1 struct mbuf *mb, *mb2, *mreq; d2416 1 a2416 1 struct mbuf *mb, *mb2, *mreq, *mp2; d2679 1 a2679 1 struct mbuf *mb, *mb2, *mreq, *mp2; d2993 1 a2993 1 struct mbuf *mb, *mb2, *mreq; d3053 1 a3053 1 struct mbuf *mb, *mb2, *mreq; d3126 1 a3126 1 struct mbuf *mb, *mb2, *mreq; d3203 1 a3203 1 struct mbuf *mb, *mb2, *mreq; @ 1.65 log @In nfs_commit(), sanity-check what we get from network: if we try to fluch past end of file, or if off + cnt overflows a quad_t, flush to end of file. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.64 2002/09/26 20:41:25 bouyer Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.64 2002/09/26 20:41:25 bouyer Exp $"); d94 2 a95 2 extern nfstype nfsv2_type[9]; extern nfstype nfsv3_type[9]; @ 1.64 log @In nfsrv_create(), kill an extra PNBUF_PUT() in the NFSv2 mknod case. The pnbuf has already been freed by VOP_MKNOD. This should have been removed in rev 1.60. Should fix PR 18013, OK'd by fvdl. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.63 2002/09/26 20:38:04 bouyer Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.63 2002/09/26 20:38:04 bouyer Exp $"); d2992 1 a2992 1 u_quad_t frev, off; d3012 4 a3015 4 if (cnt > 0) error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, off + cnt, procp); else error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, vp->v_size, procp); @ 1.63 log @nfsrv_commit(): Properly handle the case cnt == 0, which means "flush to end of file". Calling VOP_FSYNC with start == end triggers a DIAGNOSTIC check. Noticed with NFSv3 Linux clients. OK'd by fvdl. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.62 2001/11/10 10:59:09 lukem Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.62 2001/11/10 10:59:09 lukem Exp $"); a1417 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); @ 1.62 log @add RCSIDs @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.61 2001/09/23 01:37:03 chs Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD$"); d3013 4 a3016 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, off + cnt, procp); @ 1.62.10.1 log @Pull up revision 1.64 (requested by bouyer in ticket #879): In nfsrv_create(), kill an extra PNBUF_PUT() in the NFSv2 mknod case. The pnbuf has already been freed by VOP_MKNOD. This should have been removed in rev 1.60. Should fix PR 18013, OK'd by fvdl. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.62 2001/11/10 10:59:09 lukem Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.62 2001/11/10 10:59:09 lukem Exp $"); d1418 1 @ 1.62.10.2 log @Pull up revision 1.63 (requested by bouyer in ticket #880): nfsrv_commit(): Properly handle the case cnt == 0, which means "flush to end of file". Calling VOP_FSYNC with start == end triggers a DIAGNOSTIC check. Noticed with NFSv3 Linux clients. OK'd by fvdl. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.62.10.1 2002/09/30 13:47:00 lukem Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.62.10.1 2002/09/30 13:47:00 lukem Exp $"); d3012 1 a3012 4 if (cnt > 0) error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, off + cnt, procp); else error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, vp->v_size, procp); @ 1.62.10.3 log @Pull up revision 1.65 (requested by bouyer in ticket #880): In nfs_commit(), sanity-check what we get from network: if we try to fluch past end of file, or if off + cnt overflows a quad_t, flush to end of file. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.62.10.2 2002/09/30 13:49:53 lukem Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.62.10.2 2002/09/30 13:49:53 lukem Exp $"); d2992 1 a2992 1 u_quad_t frev, off, end; d3012 4 a3015 4 end = (cnt > 0) ? off + cnt : vp->v_size; if (end < off || end > vp->v_size) end = vp->v_size; error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, procp); @ 1.62.10.4 log @Pull up revision 1.80 (requested by bouyer in ticket #1373): nfsrv_commit(): return success and don't do anything for requests which starts past the end of the file. This can happen when two clients are writting to the same file. Close PR 21696 by myself, discussed on tech-net in 2003/05 and 2003/06. Issue raised by Chuck Silvers (commit and truncate ops needs to be serialised) still unadressed. @ text @d1 1 a1 1 /* $NetBSD$ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD$"); d3015 1 a3015 3 if (off < vp->v_size) error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, procp); /* else error == 0, from nfsrv_fhtovp() */ @ 1.62.10.5 log @Pull up revision 1.89 (requested by yamt in ticket #1706). nfsrv_create: fix an LP64 problem for exclusive create. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.62.10.4 2003/07/10 15:30:18 tron Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.62.10.4 2003/07/10 15:30:18 tron Exp $"); d1394 2 a1395 6 /* * XXX * assuming NFSX_V3CREATEVERF * == sizeof(nfstime3) */ fxdr_nfsv3time(cverf, &va.va_atime); d1462 3 a1464 10 if (exclusive_flag && !error) { /* * XXX assuming NFSX_V3CREATEVERF == sizeof(nfstime3) */ char oldverf[NFSX_V3CREATEVERF]; txdr_nfsv3time(&va.va_atime, oldverf); if (memcmp(cverf, oldverf, NFSX_V3CREATEVERF)) error = EEXIST; } @ 1.61 log @remove SAVESTART from the symlink, mknod and create operations. it was unnecessary, and removing it also fixes a v_usecount leak that was introduced in the previous revision. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.60 2001/07/24 15:39:33 assar Exp $ */ d60 3 @ 1.61.2.1 log @Sync the thorpej-mips-cache branch with -current. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.62 2001/11/10 10:59:09 lukem Exp $ */ a59 3 #include __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.62 2001/11/10 10:59:09 lukem Exp $"); @ 1.60 log @change vop_symlink and vop_mknod to return vpp (the created node) refed, so that the caller can actually use it. update callers and file systems that implement these vnode operations @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.59 2000/11/27 08:39:49 chs Exp $ */ d1315 1 a1315 1 nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART; a1384 1 vrele(nd.ni_startdir); a1387 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); a1402 2 vrele(nd.ni_startdir); PNBUF_PUT(nd.ni_cnd.cn_pnbuf); a1412 1 vrele(nd.ni_startdir); a1423 2 vrele(nd.ni_startdir); PNBUF_PUT(nd.ni_cnd.cn_pnbuf); a1429 2 vrele(nd.ni_startdir); PNBUF_PUT(nd.ni_cnd.cn_pnbuf); a1481 4 if (nd.ni_cnd.cn_nameiop) { vrele(nd.ni_startdir); PNBUF_PUT(nd.ni_cnd.cn_pnbuf); } d1527 1 a1527 1 nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART; a1541 2 vrele(nd.ni_startdir); PNBUF_PUT(nd.ni_cnd.cn_pnbuf); a1564 2 vrele(nd.ni_startdir); PNBUF_PUT(nd.ni_cnd.cn_pnbuf); a1575 1 vrele(nd.ni_startdir); a1577 2 if (!error) PNBUF_PUT(nd.ni_cnd.cn_pnbuf); a1580 2 vrele(nd.ni_startdir); PNBUF_PUT(nd.ni_cnd.cn_pnbuf); a1587 1 vrele(nd.ni_startdir); a1589 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); a1592 1 vrele(nd.ni_dvp); a1619 4 if (nd.ni_cnd.cn_nameiop) { vrele(nd.ni_startdir); PNBUF_PUT(nd.ni_cnd.cn_pnbuf); } d2055 1 a2055 1 nd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART; a2089 2 vrele(nd.ni_startdir); PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d2101 1 a2101 3 if (error) vrele(nd.ni_startdir); else { a2110 1 vrele(nd.ni_startdir); a2112 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); a2130 4 if (nd.ni_cnd.cn_nameiop) { vrele(nd.ni_startdir); PNBUF_PUT(nd.ni_cnd.cn_pnbuf); } @ 1.60.2.1 log @Catch up with -current. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.61 2001/09/23 01:37:03 chs Exp $ */ d1315 1 a1315 1 nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; d1385 1 d1389 1 d1405 2 d1417 1 d1429 2 d1437 2 d1491 4 d1540 1 a1540 1 nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; d1555 2 d1580 2 d1593 1 d1596 2 d1601 2 d1610 1 d1613 1 d1617 1 d1645 4 d2084 1 a2084 1 nd.ni_cnd.cn_flags = LOCKPARENT; d2119 2 d2132 3 a2134 1 if (!error) { d2144 1 d2147 1 d2166 4 @ 1.59 log @Initial integration of the Unified Buffer Cache project. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.58 2000/09/19 22:05:29 fvdl Exp $ */ a1419 8 nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART); nd.ni_cnd.cn_proc = procp; nd.ni_cnd.cn_cred = cred; if ((error = lookup(&nd)) != 0) { PNBUF_PUT(nd.ni_cnd.cn_pnbuf); nfsm_reply(0); } a1612 5 nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART); nd.ni_cnd.cn_proc = procp; nd.ni_cnd.cn_cred = procp->p_ucred; error = lookup(&nd); d2136 5 a2140 12 nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART | FOLLOW); nd.ni_cnd.cn_flags |= (NOFOLLOW | LOCKLEAF); nd.ni_cnd.cn_proc = procp; nd.ni_cnd.cn_cred = cred; error = lookup(&nd); if (!error) { memset((caddr_t)fhp, 0, sizeof(nfh)); fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid); if (!error) error = VOP_GETATTR(nd.ni_vp, &va, cred, d2142 2 a2143 3 vput(nd.ni_vp); } } else d2145 2 @ 1.59.2.1 log @Catch up with -current. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.59 2000/11/27 08:39:49 chs Exp $ */ d1420 8 d1621 5 d2149 12 a2160 5 memset((caddr_t)fhp, 0, sizeof(nfh)); fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid); if (!error) error = VOP_GETATTR(nd.ni_vp, &va, cred, d2162 3 a2164 2 vput(nd.ni_vp); } else { a2165 2 vput(nd.ni_vp); } @ 1.59.2.2 log @Catch up to -current. Again. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.59.2.1 2001/08/24 00:12:56 nathanw Exp $ */ d1315 1 a1315 1 nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; d1385 1 d1389 1 d1405 2 d1417 1 d1429 2 d1437 2 d1491 4 d1540 1 a1540 1 nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; d1555 2 d1580 2 d1593 1 d1596 2 d1601 2 d1610 1 d1613 1 d1617 1 d1645 4 d2084 1 a2084 1 nd.ni_cnd.cn_flags = LOCKPARENT; d2119 2 d2132 3 a2134 1 if (!error) { d2144 1 d2147 1 d2166 4 @ 1.59.2.3 log @Catch up to -current. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.59.2.2 2001/09/26 19:55:11 nathanw Exp $ */ a59 3 #include __KERNEL_RCSID(0, "$NetBSD$"); @ 1.59.2.4 log @Catch up to -current. @ text @d1 1 a1 1 /* $NetBSD$ */ d1418 1 d2993 1 a2993 1 u_quad_t frev, off, end; d3013 1 a3013 4 end = (cnt > 0) ? off + cnt : vp->v_size; if (end < off || end > vp->v_size) end = vp->v_size; error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, procp); @ 1.59.2.5 log @Sync with HEAD. @ text @d94 2 a95 2 extern const nfstype nfsv2_type[9]; extern const nfstype nfsv3_type[9]; @ 1.59.4.1 log @update to -current @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.60 2001/07/24 15:39:33 assar Exp $ */ d1420 8 d1621 5 d2149 12 a2160 5 memset((caddr_t)fhp, 0, sizeof(nfh)); fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid); if (!error) error = VOP_GETATTR(nd.ni_vp, &va, cred, d2162 3 a2164 2 vput(nd.ni_vp); } else { a2165 2 vput(nd.ni_vp); } @ 1.59.4.2 log @Sync kqueue branch with -current. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.59.4.1 2001/08/03 04:14:02 lukem Exp $ */ a60 3 #include __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.62 2001/11/10 10:59:09 lukem Exp $"); d1315 1 a1315 1 nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; d1385 1 d1389 1 d1405 2 d1417 1 d1429 2 d1437 2 d1491 4 d1540 1 a1540 1 nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; d1555 2 d1580 2 d1593 1 d1596 2 d1601 2 d1610 1 d1613 1 d1617 1 d1645 4 d2084 1 a2084 1 nd.ni_cnd.cn_flags = LOCKPARENT; d2119 2 d2132 3 a2134 1 if (!error) { d2144 1 d2147 1 d2166 4 @ 1.59.4.3 log @sync kqueue with -current; this includes merge of gehenna-devsw branch, merge of i386 MP branch, and part of autoconf rototil work @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.59.4.2 2002/01/10 20:04:23 thorpej Exp $ */ d62 1 a62 1 __KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.59.4.2 2002/01/10 20:04:23 thorpej Exp $"); d1418 1 d2993 1 a2993 1 u_quad_t frev, off, end; d3013 1 a3013 4 end = (cnt > 0) ? off + cnt : vp->v_size; if (end < off || end > vp->v_size) end = vp->v_size; error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, end, procp); @ 1.58 log @Adapt for VOP_FSYNC parameter change. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.57 2000/08/03 20:41:31 thorpej Exp $ */ a1731 1 (void)uvm_vnp_uncache(vp); a1905 1 (void)uvm_vnp_uncache(tvp); d3390 1 d3392 2 a3393 3 * If there's shared text associated with * the inode, try to free it up once. If * we fail, we can't allow writing. d3395 1 a3395 1 if ((vp->v_flag & VTEXT) && !uvm_vnp_uncache(vp)) @ 1.57 log @Convert namei pathname buffer allocation to use the pool allocator. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.56 2000/08/03 06:15:03 thorpej Exp $ */ a3058 4 /* * XXX At this time VOP_FSYNC() does not accept offset and byte * count parameters, so these arguments are useless (someday maybe). */ d3070 1 a3070 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, procp); @ 1.56 log @MALLOC()/FREE() are not to be used for variable size allocations. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.55 2000/06/27 17:52:32 mrg Exp $ */ d438 1 a438 1 FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); d1389 1 a1389 1 FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); d1406 1 a1406 1 free(nd.ni_cnd.cn_pnbuf, M_NAMEI); d1425 1 a1425 1 free(nd.ni_cnd.cn_pnbuf, M_NAMEI); d1428 1 a1428 1 FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); d1438 1 a1438 1 free(nd.ni_cnd.cn_pnbuf, M_NAMEI); d1446 1 a1446 1 free(nd.ni_cnd.cn_pnbuf, M_NAMEI); d1501 1 a1501 1 free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); d1564 1 a1564 1 free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); d1589 1 a1589 1 free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); d1605 1 a1605 1 FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); d1610 1 a1610 1 free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); d1626 1 a1626 1 FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); d1660 1 a1660 1 free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); d1927 1 a1927 1 FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI); d1938 1 a1938 1 FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI); d1953 1 a1953 1 FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI); d1957 1 a1957 1 FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI); d2135 1 a2135 1 free(nd.ni_cnd.cn_pnbuf, M_NAMEI); d2168 1 a2168 1 FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); d2189 1 a2189 1 free(nd.ni_cnd.cn_pnbuf, M_NAMEI); @ 1.55 log @remove include of @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.54 2000/03/30 12:51:15 augustss Exp $ */ d673 1 a673 2 MALLOC(iv, struct iovec *, i * sizeof (struct iovec), M_TEMP, M_WAITOK); d699 1 a699 1 FREE((caddr_t)iv2, M_TEMP); d846 1 a846 2 MALLOC(ivp, struct iovec *, cnt * sizeof (struct iovec), M_TEMP, M_WAITOK); d879 1 a879 1 FREE((caddr_t)iv, M_TEMP); d1124 1 a1124 2 MALLOC(iov, struct iovec *, i * sizeof (struct iovec), M_TEMP, M_WAITOK); d1139 1 a1139 1 FREE((caddr_t)iov, M_TEMP); d2117 1 a2117 1 MALLOC(pathcp, caddr_t, len2 + 1, M_TEMP, M_WAITOK); d2172 1 a2172 1 FREE(pathcp, M_TEMP); d2201 1 a2201 1 FREE(pathcp, M_TEMP); d2537 1 a2537 1 MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK); d2565 1 a2565 1 FREE((caddr_t)rbuf, M_TEMP); d2592 2 a2593 2 FREE((caddr_t)rbuf, M_TEMP); FREE((caddr_t)cookies, M_TEMP); d2712 2 a2713 2 FREE((caddr_t)rbuf, M_TEMP); FREE((caddr_t)cookies, M_TEMP); d2796 1 a2796 1 MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK); d2840 2 a2841 2 FREE((caddr_t)cookies, M_TEMP); FREE((caddr_t)rbuf, M_TEMP); d2863 2 a2864 2 FREE((caddr_t)cookies, M_TEMP); FREE((caddr_t)rbuf, M_TEMP); d3021 2 a3022 2 FREE((caddr_t)cookies, M_TEMP); FREE((caddr_t)rbuf, M_TEMP); @ 1.54 log @Remove register declarations. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.53 2000/03/30 02:42:17 simonb Exp $ */ a74 2 #include @ 1.54.4.1 log @Pull up revision 1.58 (requested by fvdl): Improve NFS performance, possibly with as much as 100% in throughput. Please note: this implies a kernel interface change, VOP_FSYNC gains two arguments. @ text @d1 1 a1 1 /* $NetBSD$ */ d3064 4 d3079 1 a3079 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, off + cnt, procp); @ 1.53 log @Delete redundant decl of nfs_pub - it's in . @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.52 1999/12/05 01:43:06 fvdl Exp $ */ d114 2 a115 2 register u_int32_t *tl; register int32_t t1; d180 1 a180 1 register struct nfs_fattr *fp; d185 2 a186 2 register u_int32_t *tl; register int32_t t1; d227 2 a228 2 register struct nfsv2_sattr *sp; register struct nfs_fattr *fp; d232 2 a233 2 register u_int32_t *tl; register int32_t t1; d357 1 a357 1 register struct nfs_fattr *fp; d362 3 a364 3 register caddr_t cp; register u_int32_t *tl; register int32_t t1; d479 4 a482 4 register struct iovec *ivp = iv; register struct mbuf *mp; register u_int32_t *tl; register int32_t t1; d579 1 a579 1 register struct iovec *iv; d581 5 a585 5 register struct mbuf *m; register struct nfs_fattr *fp; register u_int32_t *tl; register int32_t t1; register int i; d745 4 a748 4 register struct iovec *ivp; register int i, cnt; register struct mbuf *mp; register struct nfs_fattr *fp; d751 2 a752 2 register u_int32_t *tl; register int32_t t1; d929 5 a933 5 register struct iovec *ivp; register struct mbuf *mp; register struct nfsrv_descript *wp, *nfsd, *owp, *swp; register struct nfs_fattr *fp; register int i = 0; d938 2 a939 2 register u_int32_t *tl; register int32_t t1; d1236 2 a1237 2 register struct nfsrv_descript *owp; register struct nfsrv_descript *nfsd; d1239 2 a1240 2 register int overlap; register struct mbuf *mp; d1270 1 a1270 1 register struct nfsrv_descript *m; d1295 1 a1295 1 register struct nfs_fattr *fp; d1297 2 a1298 2 register struct nfsv2_sattr *sp; register u_int32_t *tl; d1300 2 a1301 2 register caddr_t cp; register int32_t t1; d1533 1 a1533 1 register u_int32_t *tl; d1535 1 a1535 1 register int32_t t1; d1692 2 a1693 2 register u_int32_t *tl; register int32_t t1; d1776 2 a1777 2 register u_int32_t *tl; register int32_t t1; d1985 2 a1986 2 register u_int32_t *tl; register int32_t t1; d2084 2 a2085 2 register u_int32_t *tl; register int32_t t1; d2225 1 a2225 1 register struct nfs_fattr *fp; d2227 3 a2229 3 register caddr_t cp; register u_int32_t *tl; register int32_t t1; d2339 2 a2340 2 register u_int32_t *tl; register int32_t t1; d2470 6 a2475 6 register char *bp, *be; register struct mbuf *mp; register struct dirent *dp; register caddr_t cp; register u_int32_t *tl; register int32_t t1; d2733 6 a2738 6 register char *bp, *be; register struct mbuf *mp; register struct dirent *dp; register caddr_t cp; register u_int32_t *tl; register int32_t t1; d3049 2 a3050 2 register u_int32_t *tl; register int32_t t1; d3107 4 a3110 4 register struct statfs *sf; register struct nfs_statfs *sfp; register u_int32_t *tl; register int32_t t1; d3182 3 a3184 3 register u_int32_t *tl; register struct nfsv3_fsinfo *sip; register int32_t t1; d3258 3 a3260 3 register u_int32_t *tl; register struct nfsv3_pathconf *pc; register int32_t t1; d3376 1 a3376 1 register struct vnode *vp; d3378 1 a3378 1 register struct ucred *cred; @ 1.52 log @The length check for readdirplus entries wasn't right, causing troubles with 32k readdir sizes. From FreeBSD. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.51 1999/05/04 16:01:37 sommerfe Exp $ */ a94 1 extern struct nfs_public nfs_pub; @ 1.51 log @Fix vnode lock leak in nfsrv_mknod() if to-be-created vnode already existed. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.50 1999/03/30 12:01:18 mycroft Exp $ */ d2937 1 a2937 1 len += (7 * NFSX_UNSIGNED + nlen + rem + NFSX_V3FH + @ 1.51.2.1 log @Update thorpej_scsipi to -current as of a month ago @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.58 2000/09/19 22:05:29 fvdl Exp $ */ d76 2 d95 1 d115 2 a116 2 u_int32_t *tl; int32_t t1; d181 1 a181 1 struct nfs_fattr *fp; d186 2 a187 2 u_int32_t *tl; int32_t t1; d228 2 a229 2 struct nfsv2_sattr *sp; struct nfs_fattr *fp; d233 2 a234 2 u_int32_t *tl; int32_t t1; d358 1 a358 1 struct nfs_fattr *fp; d363 3 a365 3 caddr_t cp; u_int32_t *tl; int32_t t1; d441 1 a441 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d480 4 a483 4 struct iovec *ivp = iv; struct mbuf *mp; u_int32_t *tl; int32_t t1; d580 1 a580 1 struct iovec *iv; d582 5 a586 5 struct mbuf *m; struct nfs_fattr *fp; u_int32_t *tl; int32_t t1; int i; d676 2 a677 1 iv = malloc(i * sizeof (struct iovec), M_TEMP, M_WAITOK); d703 1 a703 1 free((caddr_t)iv2, M_TEMP); d746 4 a749 4 struct iovec *ivp; int i, cnt; struct mbuf *mp; struct nfs_fattr *fp; d752 2 a753 2 u_int32_t *tl; int32_t t1; d850 2 a851 1 ivp = malloc(cnt * sizeof (struct iovec), M_TEMP, M_WAITOK); d884 1 a884 1 free((caddr_t)iv, M_TEMP); d930 5 a934 5 struct iovec *ivp; struct mbuf *mp; struct nfsrv_descript *wp, *nfsd, *owp, *swp; struct nfs_fattr *fp; int i = 0; d939 2 a940 2 u_int32_t *tl; int32_t t1; d1129 2 a1130 1 iov = malloc(i * sizeof (struct iovec), M_TEMP, M_WAITOK); d1145 1 a1145 1 free((caddr_t)iov, M_TEMP); d1237 2 a1238 2 struct nfsrv_descript *owp; struct nfsrv_descript *nfsd; d1240 2 a1241 2 int overlap; struct mbuf *mp; d1271 1 a1271 1 struct nfsrv_descript *m; d1296 1 a1296 1 struct nfs_fattr *fp; d1298 2 a1299 2 struct nfsv2_sattr *sp; u_int32_t *tl; d1301 2 a1302 2 caddr_t cp; int32_t t1; d1395 1 a1395 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1412 1 a1412 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1431 1 a1431 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1434 1 a1434 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1444 1 a1444 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1452 1 a1452 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1507 1 a1507 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1534 1 a1534 1 u_int32_t *tl; d1536 1 a1536 1 int32_t t1; d1570 1 a1570 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1595 1 a1595 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1611 1 a1611 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1616 1 a1616 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1632 1 a1632 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1666 1 a1666 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d1693 2 a1694 2 u_int32_t *tl; int32_t t1; d1777 2 a1778 2 u_int32_t *tl; int32_t t1; d1933 1 a1933 1 PNBUF_PUT(tond.ni_cnd.cn_pnbuf); d1944 1 a1944 1 PNBUF_PUT(fromnd.ni_cnd.cn_pnbuf); d1959 1 a1959 1 PNBUF_PUT(tond.ni_cnd.cn_pnbuf); d1963 1 a1963 1 PNBUF_PUT(fromnd.ni_cnd.cn_pnbuf); d1986 2 a1987 2 u_int32_t *tl; int32_t t1; d2085 2 a2086 2 u_int32_t *tl; int32_t t1; d2123 1 a2123 1 pathcp = malloc(len2 + 1, M_TEMP, M_WAITOK); d2141 1 a2141 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d2174 1 a2174 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d2178 1 a2178 1 free(pathcp, M_TEMP); d2195 1 a2195 1 PNBUF_PUT(nd.ni_cnd.cn_pnbuf); d2207 1 a2207 1 free(pathcp, M_TEMP); d2226 1 a2226 1 struct nfs_fattr *fp; d2228 3 a2230 3 caddr_t cp; u_int32_t *tl; int32_t t1; d2340 2 a2341 2 u_int32_t *tl; int32_t t1; d2471 6 a2476 6 char *bp, *be; struct mbuf *mp; struct dirent *dp; caddr_t cp; u_int32_t *tl; int32_t t1; d2543 1 a2543 1 rbuf = malloc(siz, M_TEMP, M_WAITOK); d2571 1 a2571 1 free((caddr_t)rbuf, M_TEMP); d2598 2 a2599 2 free((caddr_t)rbuf, M_TEMP); free((caddr_t)cookies, M_TEMP); d2718 2 a2719 2 free((caddr_t)rbuf, M_TEMP); free((caddr_t)cookies, M_TEMP); d2734 6 a2739 6 char *bp, *be; struct mbuf *mp; struct dirent *dp; caddr_t cp; u_int32_t *tl; int32_t t1; d2802 1 a2802 1 rbuf = malloc(siz, M_TEMP, M_WAITOK); d2846 2 a2847 2 free((caddr_t)cookies, M_TEMP); free((caddr_t)rbuf, M_TEMP); d2869 2 a2870 2 free((caddr_t)cookies, M_TEMP); free((caddr_t)rbuf, M_TEMP); d2937 1 a2937 1 len += (8 * NFSX_UNSIGNED + nlen + rem + NFSX_V3FH + d3027 2 a3028 2 free((caddr_t)cookies, M_TEMP); free((caddr_t)rbuf, M_TEMP); d3050 2 a3051 2 u_int32_t *tl; int32_t t1; d3065 4 d3080 1 a3080 1 error = VOP_FSYNC(vp, cred, FSYNC_WAIT, off, off + cnt, procp); d3108 4 a3111 4 struct statfs *sf; struct nfs_statfs *sfp; u_int32_t *tl; int32_t t1; d3183 3 a3185 3 u_int32_t *tl; struct nfsv3_fsinfo *sip; int32_t t1; d3259 3 a3261 3 u_int32_t *tl; struct nfsv3_pathconf *pc; int32_t t1; d3377 1 a3377 1 struct vnode *vp; d3379 1 a3379 1 struct ucred *cred; @ 1.51.2.2 log @Sync with HEAD. @ text @d1 1 a1 1 /* $NetBSD$ */ d1732 1 d1907 1 a3391 1 d3393 3 a3395 2 * If the vnode is in use as a process's text, * we can't allow writing. d3397 1 a3397 1 if (vp->v_flag & VTEXT) @ 1.51.8.1 log @Pull up to last week's -current. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.52 1999/12/05 01:43:06 fvdl Exp $ */ d2937 1 a2937 1 len += (8 * NFSX_UNSIGNED + nlen + rem + NFSX_V3FH + @ 1.50 log @Fix two problems with NFSV3CREATE_GUARDED: * We shouldn't truncate the file. * We were leaving the vnode locked (unless the truncate happened to fail). Solaris clients may cause this under some conditions. Problem reported by chopps, analysis and fix by me. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.49 1999/03/24 05:51:28 mrg Exp $ */ d1573 6 a1578 1 vput(nd.ni_dvp); d1598 5 a1602 1 vput(nd.ni_dvp); @ 1.50.2.1 log @pullup 1.50->1.51 (sommerfeld) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.51 1999/05/04 16:01:37 sommerfe Exp $ */ d1573 1 a1573 6 if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); d1593 1 a1593 5 if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); vput(nd.ni_vp); @ 1.50.2.2 log @Pull up revision 1.52 (requested by fvdl): Correct length check in readdirplus, making 32k readdir sizes work. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.50.2.1 1999/05/04 17:10:00 perry Exp $ */ d2937 1 a2937 1 len += (8 * NFSX_UNSIGNED + nlen + rem + NFSX_V3FH + @ 1.50.2.1.2.1 log @Sync w/ -current. @ text @@ 1.50.2.1.2.2 log @remove uvm_vnp_uncache(), it's no longer needed. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.50.2.1.2.1 1999/06/21 01:28:55 thorpej Exp $ */ d1738 1 d1913 1 a3401 1 d3404 2 a3405 1 * the inode, we can't allow writing. d3407 1 a3407 1 if (vp->v_flag & VTEXT) @ 1.49 log @completely remove Mach VM support. all that is left is the all the header files as UVM still uses (most of) these. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.48 1999/03/06 05:34:41 fair Exp $ */ d1459 1 a1459 1 if (va.va_size != -1) { a1469 2 if (error) vput(vp); d1471 2 @ 1.48 log @Snatch a patch from OpenBSD to fix PRs 6529 and 7074. Adjust fxdr_hyper() and txdr_hyper() macros. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.47 1999/03/05 07:27:58 mycroft Exp $ */ a60 2 #include "opt_uvm.h" a77 1 #if defined(UVM) a78 1 #endif a1728 1 #if defined(UVM) a1729 3 #else (void)vnode_pager_uncache(vp); #endif a1903 1 #if defined(UVM) a1904 3 #else (void)vnode_pager_uncache(tvp); #endif a3397 1 #if defined(UVM) a3399 4 #else if ((vp->v_flag & VTEXT) && !vnode_pager_uncache(vp)) return (ETXTBSY); #endif @ 1.47 log @Clean up some sign extension bogosity in statfs, so negative numbers are actually negative on a LP64 client. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.46 1999/01/31 09:24:10 mrg Exp $ */ d609 1 a609 1 fxdr_hyper(tl, &off); d780 1 a780 1 fxdr_hyper(tl, &off); d975 1 a975 1 fxdr_hyper(tl, &nfsd->nd_off); d2500 1 a2500 1 fxdr_hyper(tl, &toff); d2502 1 a2502 1 fxdr_hyper(tl, &verf); d2595 1 a2595 1 txdr_hyper(&at.va_filerev, tl); d2634 1 a2634 1 txdr_hyper(&at.va_filerev, tl); d2692 1 a2692 1 txdr_hyper(cookiep, &jar); d2762 1 a2762 1 fxdr_hyper(tl, &toff); d2764 1 a2764 1 fxdr_hyper(tl, &verf); d2868 1 a2868 1 txdr_hyper(&at.va_filerev, tl); d2904 1 a2904 1 txdr_hyper(&at.va_filerev, tl); d2957 1 a2957 1 txdr_hyper(cookiep, fl.fl_off.nfsuquad); d3072 1 a3072 1 fxdr_hyper(tl, &off); d3151 1 a3151 1 txdr_hyper(&tval, &sfp->sf_tbytes); d3153 1 a3153 1 txdr_hyper(&tval, &sfp->sf_fbytes); d3155 1 a3155 1 txdr_hyper(&tval, &sfp->sf_abytes); d3157 1 a3157 1 txdr_hyper(&tval, &sfp->sf_tfiles); d3159 2 a3160 2 txdr_hyper(&tval, &sfp->sf_ffiles); txdr_hyper(&tval, &sfp->sf_afiles); d3239 1 a3239 1 txdr_hyper(&maxfsize, &sip->fs_maxfilesize); @ 1.46 log @non-root users can mkfifo over NFS. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.45 1998/08/18 06:45:04 thorpej Exp $ */ d3150 1 a3150 2 tval = (u_quad_t)sf->f_blocks; tval *= (u_quad_t)sf->f_bsize; d3152 1 a3152 2 tval = (u_quad_t)sf->f_bfree; tval *= (u_quad_t)sf->f_bsize; d3154 1 a3154 2 tval = (u_quad_t)sf->f_bavail; tval *= (u_quad_t)sf->f_bsize; d3156 5 a3160 6 sfp->sf_tfiles.nfsuquad[0] = 0; sfp->sf_tfiles.nfsuquad[1] = txdr_unsigned(sf->f_files); sfp->sf_ffiles.nfsuquad[0] = 0; sfp->sf_ffiles.nfsuquad[1] = txdr_unsigned(sf->f_ffree); sfp->sf_afiles.nfsuquad[0] = 0; sfp->sf_afiles.nfsuquad[1] = txdr_unsigned(sf->f_ffree); @ 1.45 log @Add some braces to make egcs happy (ambiguous else warning). @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.44 1998/08/09 21:19:51 perry Exp $ */ d1413 2 a1414 2 error = suser(cred, (u_short *)0); if (error) { d1608 2 a1609 2 error = suser(cred, (u_short *)0); if (error) { @ 1.44 log @bzero->memset, bcopy->memcpy, bcmp->memcmp @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.43 1998/06/05 19:53:01 kleink Exp $ */ d1891 1 a1891 1 if (fvp == tdvp) d1896 1 @ 1.43 log @Convert fsync vnode operator implementations and usage from the old `waitfor' argument and MNT_WAIT/MNT_NOWAIT to `flags' and FSYNC_WAIT. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.42 1998/03/01 02:24:28 fvdl Exp $ */ d447 1 a447 1 bzero((caddr_t)fhp, sizeof(nfh)); d1045 1 a1045 1 bcmp((caddr_t)&nfsd->nd_fh,(caddr_t)&wp->nd_fh,NFSX_V3FH)) { d1050 1 a1050 1 !bcmp((caddr_t)&nfsd->nd_fh,(caddr_t)&wp->nd_fh,NFSX_V3FH)) { d1359 1 a1359 1 bcopy(cp, cverf, NFSX_V3CREATEVERF); d1403 1 a1403 1 bcopy(cverf, (caddr_t)&va.va_atime, d1479 1 a1479 1 bzero((caddr_t)fhp, sizeof(nfh)); d1488 1 a1488 1 bcmp(cverf, (caddr_t)&va.va_atime, NFSX_V3CREATEVERF)) d1640 1 a1640 1 bzero((caddr_t)fhp, sizeof(nfh)); d1903 1 a1903 1 !bcmp(fromnd.ni_cnd.cn_nameptr, tond.ni_cnd.cn_nameptr, d2166 1 a2166 1 bzero((caddr_t)fhp, sizeof(nfh)); d2290 1 a2290 1 bzero((caddr_t)fhp, sizeof(nfh)); d2679 1 a2679 1 bcopy(cp, bp, tsiz); d2920 1 a2920 1 bzero((caddr_t)nfhp, NFSX_V3FH); d2980 1 a2980 1 bcopy(cp, bp, tsiz); d3001 1 a3001 1 bcopy(cp, bp, tsiz); @ 1.42 log @Merge with Lite2 + local changes @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.41 1998/02/10 14:10:12 mrg Exp $ */ d3082 1 a3082 1 error = VOP_FSYNC(vp, cred, MNT_WAIT, procp); @ 1.41 log @- add defopt's for UVM, UVMHIST and PMAP_NEW. - remove unnecessary UVMHIST_DECL's. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.40 1998/02/05 08:00:21 mrg Exp $ */ d38 1 a38 1 * @@(#)nfs_serv.c 8.7 (Berkeley) 5/14/95 d398 1 a398 1 VOP_UNLOCK(nd.ni_vp); d2544 1 a2544 5 #ifdef Lite2_integrated VOP_UNLOCK(vp, 0, procp); #else VOP_UNLOCK(vp); #endif a2545 3 ncookies = siz / (5 * NFSX_UNSIGNED); /*7 for V3, but it's an est. so*/ MALLOC(cookies, off_t *, ncookies * sizeof (off_t), M_TEMP, M_WAITOK); d2557 1 a2557 5 #ifdef Lite2_integrated VOP_LOCK(vp, 0, procp); #else VOP_LOCK(vp); #endif d2559 1 a2559 1 error = VOP_READDIR(vp, &io, cred, &eofflag, cookies, ncookies); d2570 1 a2570 5 #ifdef Lite2_integrated VOP_UNLOCK(vp, 0, procp); #else VOP_UNLOCK(vp); #endif d2573 1 a2573 1 free((caddr_t)rbuf, M_TEMP); d2802 1 a2802 5 #ifdef Lite2_integrated VOP_UNLOCK(vp, 0, procp); #else VOP_UNLOCK(vp); #endif a2804 3 ncookies = siz / (7 * NFSX_UNSIGNED); MALLOC(cookies, off_t *, ncookies * sizeof (off_t), M_TEMP, M_WAITOK); d2817 3 a2819 6 #ifdef Lite2_integrated VOP_LOCK(vp, 0, procp); #else VOP_LOCK(vp); #endif error = VOP_READDIR(vp, &io, cred, &eofflag, cookies, ncookies); d2824 1 a2824 5 #ifdef Lite2_integrated VOP_UNLOCK(vp, 0, procp); #else VOP_UNLOCK(vp); #endif d2848 2 a2849 2 free((caddr_t)cookies, M_TEMP); free((caddr_t)rbuf, M_TEMP); @ 1.40 log @initial import of the new virtual memory system, UVM, into -current. UVM was written by chuck cranor , with some minor portions derived from the old Mach code. i provided some help getting swap and paging working, and other bug fixes/ideas. chuck silvers also provided some other fixes. this is the rest of the MI portion changes. this will be KNF'd shortly. :-) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.39 1997/12/22 00:09:02 fvdl Exp $ */ d60 2 @ 1.39 log @Check vnode for VDIR type before doing anything with it in the NFS readdir service. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.38 1997/10/10 01:53:22 fvdl Exp $ */ d78 4 d1731 3 d1735 1 d1909 3 d1913 1 d3440 4 d3446 1 @ 1.38 log @* New directory entry caching system. Provides full caching of any directory cookie that may be thrown back at us from userspace, up to a size limit. Fixes double entry problem. * Split flags for internal and external use in the NFS mount structure. * Fix some buffer structure fields that weren're being used correctly. * Fix missing directory cache inval call in nfs_open. * Limit on NFS_DIRBLKSIZ no longer needed, bumped to the more reasonable value of 8k. * Various other things that I forget, all related to the dir caching somehow, though. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.37 1997/07/17 23:54:29 fvdl Exp $ */ d2502 4 d2776 4 @ 1.38.2.1 log @pullup a fix to a critical NFS bug (fvdl) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.39 1997/12/22 00:09:02 fvdl Exp $ */ a2501 4 if (!error && vp->v_type != VDIR) { error = ENOTDIR; vput(vp); } a2771 4 if (!error && vp->v_type != VDIR) { error = ENOTDIR; vput(vp); } @ 1.38.2.2 log @pull up rev 1.46 from trunk (mrg) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.38.2.1 1997/12/22 01:25:18 perry Exp $ */ d1407 2 a1408 2 if (va.va_type != VFIFO && (error = suser(cred, (u_short *)0))) { d1602 2 a1603 2 if (va.va_type != VFIFO && (error = suser(cred, (u_short *)0))) { @ 1.37 log @* Deal with servers that don't give complete FSINFO (like NT) From Olaf Seibert (PR 3687) * Make an attempt to check the maximum filesize before attempting a write to the server, as write RPCs will typically happen asynchronously, and the process will not see the error. Fixes problems with unexpectly truncated files at 4G * Pass up errors in nfs_writerpc correctly @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.36 1997/07/15 01:07:47 fvdl Exp $ */ d2478 2 a2479 1 u_long *cookies = NULL, *cookiep; d2533 1 a2533 1 MALLOC(cookies, u_long *, ncookies * sizeof (u_long *), M_TEMP, d2688 1 d2690 1 a2690 1 *tl = 0; d2694 1 a2694 1 *tl = txdr_unsigned(*cookiep); d2753 1 a2753 1 u_long *cookies = NULL, *cookiep; d2803 1 a2803 1 MALLOC(cookies, u_long *, ncookies * sizeof (u_long *), M_TEMP, d2963 1 a2963 2 fl.fl_off.nfsuquad[0] = 0; fl.fl_off.nfsuquad[1] = txdr_unsigned(*cookiep); @ 1.37.2.1 log @Update marc-pcmcia branch from trunk. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.38 1997/10/10 01:53:22 fvdl Exp $ */ d2478 1 a2478 2 off_t *cookies = NULL, *cookiep; nfsuint64 jar; d2532 1 a2532 1 MALLOC(cookies, off_t *, ncookies * sizeof (off_t), M_TEMP, a2686 1 txdr_hyper(cookiep, &jar); d2688 1 a2688 1 *tl = jar.nfsuquad[0]; d2692 1 a2692 1 *tl = jar.nfsuquad[1]; d2751 1 a2751 1 off_t *cookies = NULL, *cookiep; d2801 1 a2801 1 MALLOC(cookies, off_t *, ncookies * sizeof (off_t), M_TEMP, d2961 2 a2962 1 txdr_hyper(cookiep, fl.fl_off.nfsuquad); @ 1.36 log @A filesystem may not support VFS_VGET (like msdosfs). If it doesn't, the server code would always skip all dir entries for a readdirplus operation. To avoid endlessly retrying clients, try VFS_VGET first, and it it fails, return NFSERR_NOTSUPP so that client will fall back to normal readdir operations. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.35 1997/06/24 23:32:45 fvdl Exp $ */ d3206 2 a3207 1 u_quad_t frev; d3221 5 d3248 1 a3248 2 sip->fs_maxfilesize.nfsuquad[0] = 0xffffffff; sip->fs_maxfilesize.nfsuquad[1] = 0xffffffff; @ 1.35 log @Provide the extra arg to nfsrv_fhtovp, signalling if we're dealing with a request on the public filehandle. Extend the lookup operation to support WebNFS, including index file support (URL style). Yucky, it's optional in the spec, but Solaris 2.6 will support it, so.. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.34 1997/05/12 23:37:12 fvdl Exp $ */ d2830 16 @ 1.34 log @In nfsrvw_coalesce, make sure the coalesce list from the nfsd is moved as well. This fixes client hangs. (from Naofumi Honda / NetBSD-pc98) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.33 1997/05/08 16:20:32 mycroft Exp $ */ d93 1 d127 1 a127 1 (nfsd->nd_flag & ND_KERBAUTH)); d195 1 a195 1 (nfsd->nd_flag & ND_KERBAUTH)); d287 1 a287 1 (nfsd->nd_flag & ND_KERBAUTH)); d357 1 a357 1 struct nameidata nd; d366 1 a366 1 int v3 = (nfsd->nd_flag & ND_NFSV3); d375 3 d382 42 a423 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); d430 1 d436 3 a438 2 nqsrv_getl(nd.ni_startdir, ND_READ); vrele(nd.ni_startdir); d440 1 a440 1 vp = nd.ni_vp; d526 1 a526 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); d610 1 a610 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); d822 1 a822 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); d1089 2 a1090 1 nfsd->nd_nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); d1321 1 a1321 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); d1554 1 a1554 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); d1705 1 a1705 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); d1801 1 a1801 1 &dpos, &fdirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); d1827 1 a1827 1 &dpos, &tdirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); d1993 1 a1993 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); d2006 1 a2006 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); d2095 1 a2095 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); d2236 1 a2236 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); d2349 1 a2349 1 &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); d2500 1 a2500 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); d2769 1 a2769 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); d3065 1 a3065 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); d3122 1 a3122 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); d3198 1 a3198 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); d3270 1 a3270 1 &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); @ 1.33 log @Pass the vnode type to vaccess(), and use it when checking VEXEC. Make sure that the mode bits passed to vaccess() and returned by foo_getattr() contain only permission bits. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.32 1997/05/08 10:57:41 mycroft Exp $ */ d1215 14 @ 1.32 log @VEXEC -> VLOOKUP, as appropriate. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.31 1997/02/22 02:56:01 fvdl Exp $ */ d152 1 a152 1 nfsrv_access(vp, VLOOKUP, cred, rdonly, procp, 0) == 0) d2456 1 a2456 1 error = nfsrv_access(vp, VLOOKUP, cred, rdonly, procp, 0); d2723 1 a2723 1 error = nfsrv_access(vp, VLOOKUP, cred, rdonly, procp, 0); @ 1.31 log @Fixes from BSDI (thanks go to Keith Bostic). Original RCS message: date: 1996/11/20 20:02:54; author: pjd; state: Exp; lines: +7 -4 In nfsrv_access(), if VOP_ACCESS() returns an error and the error == EPERM or its not the owner doing the access, return the error. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.30 1997/02/10 12:20:49 fvdl Exp $ */ d119 1 a119 1 u_long testmode, nfsmode; d132 23 a154 19 nfsmode = fxdr_unsigned(u_int32_t, *tl); if ((nfsmode & NFSV3ACCESS_READ) && nfsrv_access(vp, VREAD, cred, rdonly, procp, 0)) nfsmode &= ~NFSV3ACCESS_READ; if (vp->v_type == VDIR) testmode = (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND | NFSV3ACCESS_DELETE); else testmode = (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND); if ((nfsmode & testmode) && nfsrv_access(vp, VWRITE, cred, rdonly, procp, 0)) nfsmode &= ~testmode; if (vp->v_type == VDIR) testmode = NFSV3ACCESS_LOOKUP; else testmode = NFSV3ACCESS_EXECUTE; if ((nfsmode & testmode) && nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0)) nfsmode &= ~testmode; d160 1 a160 1 *tl = txdr_unsigned(nfsmode); d2456 1 a2456 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); d2723 1 a2723 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, procp, 0); @ 1.30 log @Move vnode_pager_uncache to a better spot in nfsrv_remove. Also use it in nfsrv_rename, if the 2nd argument is an existing file and will thus be removed. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.29 1997/01/31 16:12:26 fvdl Exp $ */ d3296 3 d3343 1 a3343 2 if (override && (error == EPERM || error == EACCES) && cred->cr_uid == vattr.va_uid) @ 1.29 log @nfsrv_readdirplus also suffered from the off-by-one loop problem; fix it too. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.28 1997/01/31 09:09:43 fvdl Exp $ */ a1658 1 (void) vnode_pager_uncache(vp); d1661 1 d1834 2 a1835 1 if (tvp) d1837 1 @ 1.29.2.1 log @Merge in changes from Trunk @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.31 1997/02/22 02:56:01 fvdl Exp $ */ d1659 1 a1661 1 (void)vnode_pager_uncache(vp); d1834 1 a1834 2 if (tvp) { (void)vnode_pager_uncache(tvp); a1835 1 } a3293 3 * * The exception to rule 2 is EPERM. If a file is IMMUTABLE, VOP_ACCESS() * will return EPERM instead of EACCESS. EPERM is always an error. d3338 2 a3339 1 if (override && error == EACCES && cred->cr_uid == vattr.va_uid) @ 1.28 log @Fix order error in loop condition which could cause a crash in nfsrv_readdir(). Fixes PR #3170 @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.27 1996/12/11 00:01:56 fvdl Exp $ */ d2807 2 a2808 2 while ((dp->d_fileno == 0 || dp->d_type == DT_WHT) && cpos < cend && ncookies > 0) { @ 1.27 log @Give permission to the owner of the file to preserve semantics only in the relevant cases (read, write). Fixes PR 3017. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.26 1996/07/01 11:16:03 fvdl Exp $ */ d2543 2 a2544 2 while ((dp->d_fileno == 0 || dp->d_type == DT_WHT) && cpos < cend && ncookies > 0) { @ 1.26 log @Always call vnode_pager_uncache when removing a file in the server (same as in sys_unlink()). @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.25 1996/03/02 15:55:52 jtk Exp $ */ d134 1 a134 1 nfsrv_access(vp, VREAD, cred, rdonly, procp)) d142 1 a142 1 nfsrv_access(vp, VWRITE, cred, rdonly, procp)) d149 1 a149 1 nfsrv_access(vp, VEXEC, cred, rdonly, procp)) d317 1 a317 1 procp)) != 0) d573 2 a574 2 if ((error = nfsrv_access(vp, VREAD, cred, rdonly, procp)) != 0) error = nfsrv_access(vp, VEXEC, cred, rdonly, procp); d787 1 a787 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, procp); d1052 1 a1052 1 error = nfsrv_access(vp, VWRITE, cred, rdonly, procp); d1393 1 a1393 1 (nd.ni_cnd.cn_flags & RDONLY), procp); d2450 1 a2450 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, procp); d2717 1 a2717 1 error = nfsrv_access(vp, VEXEC, cred, rdonly, procp); d3289 5 a3293 4 * 2 - The owner is to be given access irrespective of mode bits so that * processes that chmod after opening a file don't break. I don't like * this because it opens a security hole, but since the nfs server opens * a security hole the size of a barn door anyhow, what the heck. d3296 1 a3296 1 nfsrv_access(vp, flags, cred, rdonly, p) d3333 9 a3341 4 if ((error = VOP_ACCESS(vp, flags, cred, p)) != 0 && cred->cr_uid != vattr.va_uid) return (error); return (0); @ 1.25 log @Do not return whiteout directory entries in NFS readdir replies. (The NFS protocol doesn't know how to deal with them properly, yet.) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.24 1996/02/20 23:45:10 cgd Exp $ */ d1659 1 a1659 2 if (vp->v_flag & VTEXT) (void) vnode_pager_uncache(vp); @ 1.25.4.1 log @From trunk: Always call vnode_pager_uncache() when removing a file. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.26 1996/07/01 11:16:03 fvdl Exp $ */ d1659 2 a1660 1 (void) vnode_pager_uncache(vp); @ 1.25.4.2 log @Pull up bug fixes from -current, per fvdl. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.25.4.1 1996/12/11 10:02:54 mycroft Exp $ */ d2543 2 a2544 2 while (cpos < cend && ncookies > 0 && (dp->d_fileno == 0 || dp->d_type == DT_WHT)) { d2807 2 a2808 2 while (cpos < cend && ncookies > 0 && (dp->d_fileno == 0 || dp->d_type == DT_WHT)) { @ 1.24 log @Third argument to VOP_PATHCONF is a register_t *, and register_t may be different than 'int'. Do the right thing when declaring variables which are used this way. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.23 1996/02/18 11:53:45 fvdl Exp $ */ d2357 2 d2544 2 a2545 1 while (dp->d_fileno == 0 && cpos < cend && ncookies > 0) { d2570 1 a2570 1 if (dp->d_fileno != 0) { d2808 2 a2809 1 while (dp->d_fileno == 0 && cpos < cend && ncookies > 0) { d2832 1 a2832 1 if (dp->d_fileno != 0) { @ 1.23 log @Bring in a merge of Rick Macklem's NFSv3 code from Lite2 @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.22 1996/02/09 21:48:27 christos Exp $ */ d3183 2 a3184 2 int error = 0, rdonly, cache, getret = 1, linkmax, namemax; int chownres, notrunc; @ 1.22 log @nfs prototype changes @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.21 1996/02/09 15:47:11 mycroft Exp $ */ d38 1 a38 1 * @@(#)nfs_serv.c 8.4 (Berkeley) 6/4/94 d42 1 a42 1 * nfs version 2 server calls to vnode ops d57 2 d68 2 d73 2 d78 1 a78 1 #include a85 4 /* Defs */ #define TRUE 1 #define FALSE 0 a86 1 extern u_long nfs_procids[NFS_NPROCS]; d89 5 a93 2 nfstype nfs_type[9] = { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFNON, NFCHR, NFNON }; d96 1 a96 1 * nqnfs access service d99 5 a103 6 nqnfsrv_access(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d105 4 d110 1 a110 1 nfsv2fh_t nfh; d115 1 a115 1 int error = 0, rdonly, cache = 0, mode = 0; d117 3 a119 1 struct mbuf *mb, *mreq; d124 28 a151 11 nfsm_dissect(tl, u_int32_t *, 3 * NFSX_UNSIGNED); error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly); if (error) nfsm_reply(0); if (*tl++ == nfs_true) mode |= VREAD; if (*tl++ == nfs_true) mode |= VWRITE; if (*tl == nfs_true) mode |= VEXEC; error = nfsrv_access(vp, mode, cred, rdonly, nfsd->nd_procp); d153 4 a156 1 nfsm_reply(0); d164 5 a168 6 nfsrv_getattr(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d170 5 a174 1 register struct nfsv2_fattr *fp; d177 1 a177 1 nfsv2fh_t nfh; d189 3 a191 2 error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly); if (error) d193 4 a196 2 nqsrv_getl(vp, NQL_READ); error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp); d198 5 a202 3 nfsm_reply(NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_srvfillattr; d210 5 a214 6 nfsrv_setattr(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d216 5 a220 1 struct vattr va; d222 1 a222 1 register struct nfsv2_fattr *fp; d224 1 a224 1 nfsv2fh_t nfh; d229 2 a230 1 int error = 0, rdonly, cache; d233 2 a234 1 u_quad_t frev, frev2; a237 6 nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_SATTR(nfsd->nd_nqlflag != NQL_NOVAL)); error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly); if (error) nfsm_reply(0); nqsrv_getl(vp, NQL_WRITE); d239 26 a264 17 /* * Nah nah nah nah na nah * There is a bug in the Sun client that puts 0xffff in the mode * field of sattr when it should put in 0xffffffff. The u_short * doesn't sign extend. * --> check the low order 2 bytes for 0xffff */ if ((fxdr_unsigned(int, sp->sa_mode) & 0xffff) != 0xffff) va.va_mode = nfstov_mode(sp->sa_mode); if (sp->sa_uid != nfs_xdrneg1) va.va_uid = fxdr_unsigned(uid_t, sp->sa_uid); if (sp->sa_gid != nfs_xdrneg1) va.va_gid = fxdr_unsigned(gid_t, sp->sa_gid); if (nfsd->nd_nqlflag == NQL_NOVAL) { if (sp->sa_nfssize != nfs_xdrneg1) va.va_size = fxdr_unsigned(u_quad_t, sp->sa_nfssize); if (sp->sa_nfsatime.nfs_sec != nfs_xdrneg1) { d266 1 a266 1 fxdr_nfstime(&sp->sa_nfsatime, &va.va_atime); d269 1 a269 1 fxdr_unsigned(int32_t, sp->sa_nfsatime.nfs_sec); d273 28 a300 7 if (sp->sa_nfsmtime.nfs_sec != nfs_xdrneg1) fxdr_nfstime(&sp->sa_nfsmtime, &va.va_mtime); } else { fxdr_hyper(&sp->sa_nqsize, &va.va_size); fxdr_nqtime(&sp->sa_nqatime, &va.va_atime); fxdr_nqtime(&sp->sa_nqmtime, &va.va_mtime); va.va_flags = fxdr_unsigned(u_int32_t, sp->sa_nqflags); d317 1 a317 1 nfsd->nd_procp)) != 0) d320 4 a323 5 if ((error = VOP_SETATTR(vp, &va, cred, nfsd->nd_procp)) != 0) { vput(vp); nfsm_reply(0); } error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp); d326 7 a332 6 nfsm_reply(NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL) + 2*NFSX_UNSIGNED); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_srvfillattr; if (nfsd->nd_nqlflag != NQL_NOVAL) { nfsm_build(tl, u_int32_t *, 2*NFSX_UNSIGNED); txdr_hyper(&frev2, tl); d341 5 a345 6 nfsrv_lookup(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d347 5 a351 1 register struct nfsv2_fattr *fp; d353 2 a354 2 struct vnode *vp; nfsv2fh_t nfh; d360 2 a361 1 int error = 0, cache, duration2, cache2, len; d364 2 a365 2 struct vattr va; u_quad_t frev, frev2; a367 5 duration2 = 0; if (nfsd->nd_nqlflag != NQL_NOVAL) { nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); duration2 = fxdr_unsigned(int, *tl); } d369 1 a369 1 nfsm_srvstrsiz(len, NFS_MAXNAMLEN); d373 14 a386 4 if ((error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) != 0) nfsm_reply(0); nqsrv_getl(nd.ni_startdir, NQL_READ); d392 8 a399 3 if ((error = VFS_VPTOFH(vp, &fhp->fh_fid)) != 0) { vput(vp); nfsm_reply(0); d401 7 a407 17 if (duration2) (void) nqsrv_getlease(vp, &duration2, NQL_READ, nfsd, nam, &cache2, &frev2, cred); error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp); vput(vp); nfsm_reply(NFSX_FH + NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL) + 5*NFSX_UNSIGNED); if (nfsd->nd_nqlflag != NQL_NOVAL) { if (duration2) { nfsm_build(tl, u_int32_t *, 5*NFSX_UNSIGNED); *tl++ = txdr_unsigned(NQL_READ); *tl++ = txdr_unsigned(cache2); *tl++ = txdr_unsigned(duration2); txdr_hyper(&frev2, tl); } else { nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); *tl = 0; } a408 3 nfsm_srvfhtom(fhp); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_srvfillattr; d416 5 a420 6 nfsrv_readlink(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d422 4 d432 2 a433 1 int error = 0, rdonly, cache, i, tlen, len; d437 2 a438 1 nfsv2fh_t nfh; d474 2 a475 1 error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly); d478 3 a480 1 nfsm_reply(0); d483 4 a486 1 error = EINVAL; d489 1 a489 1 nqsrv_getl(vp, NQL_READ); d492 1 d496 6 a501 1 nfsm_reply(NFSX_UNSIGNED); d517 5 a521 6 nfsrv_read(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d523 4 d530 1 a530 1 register struct nfsv2_fattr *fp; d533 1 d535 2 a536 1 int error = 0, rdonly, cache, i, cnt, len, left, siz, tlen; d541 1 a541 1 nfsv2fh_t nfh; d550 4 a553 1 if (nfsd->nd_nqlflag == NQL_NOVAL) { a555 3 } else { nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); fxdr_hyper(tl, &off); d557 8 a564 4 nfsm_srvstrsiz(cnt, NFS_MAXDATA); error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly); if (error) nfsm_reply(0); d566 4 a569 3 error = (vp->v_type == VDIR) ? EISDIR : EACCES; vput(vp); nfsm_reply(0); d571 8 a578 9 nqsrv_getl(vp, NQL_READ); error = nfsrv_access(vp, VREAD, cred, rdonly, nfsd->nd_procp); if (error) goto out; error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp); if (error) goto out; error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp); a579 1 out: d581 3 a583 1 nfsm_reply(0); d587 1 a587 1 else if ((off + cnt) > va.va_size) d589 13 a601 3 nfsm_reply(NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)+NFSX_UNSIGNED+nfsm_rndup(cnt)); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_build(tl, u_int32_t *, NFSX_UNSIGNED); a608 4 MALLOC(iv, struct iovec *, ((NFS_MAXDATA+MLEN-1)/MLEN) * sizeof (struct iovec), M_TEMP, M_WAITOK); iv2 = iv; d612 1 a612 4 m->m_len += siz; iv->iov_base = bpos; iv->iov_len = siz; iv++; a613 1 left -= siz; a620 1 bpos = mtod(m, caddr_t); d623 20 a642 1 uiop->uio_iov = iv2; d651 3 a653 1 if (error || (error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp))) { d656 3 a658 1 nfsm_reply(0); d663 1 a663 1 nfsm_srvfillattr; d667 8 a674 1 nfsm_adj(mb, cnt-tlen, tlen-len); d683 5 a687 6 nfsrv_write(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d689 4 d694 1 d696 3 a698 3 register struct nfsv2_fattr *fp; struct iovec iv[NFS_MAXIOVEC]; struct vattr va; d702 4 a705 2 int error = 0, rdonly, cache, siz, len, xfer; int ioflags = IO_SYNC | IO_NODELOCKED; d709 1 a709 1 nfsv2fh_t nfh; d715 4 d721 7 a727 2 nfsm_dissect(tl, u_int32_t *, 4 * NFSX_UNSIGNED); if (nfsd->nd_nqlflag == NQL_NOVAL) { a729 5 } else { fxdr_hyper(tl, &off); tl += 2; if (fxdr_unsigned(u_int32_t, *tl++)) ioflags |= IO_APPEND; d731 38 a768 4 len = fxdr_unsigned(int32_t, *tl); if (len > NFS_MAXDATA || len <= 0) { error = EBADRPC; nfsm_reply(0); d770 6 a775 11 if (dpos == (mtod(md, caddr_t)+md->m_len)) { mp = md->m_next; if (mp == NULL) { error = EBADRPC; nfsm_reply(0); } } else { mp = md; siz = dpos-mtod(mp, caddr_t); mp->m_len -= siz; NFSMADV(mp, siz); d777 2 a778 3 error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly); if (error) nfsm_reply(0); d780 8 a787 3 error = (vp->v_type == VDIR) ? EISDIR : EACCES; vput(vp); nfsm_reply(0); a788 2 nqsrv_getl(vp, NQL_WRITE); error = nfsrv_access(vp, VWRITE, cred, rdonly, nfsd->nd_procp); d791 223 a1013 1 nfsm_reply(0); d1015 1 a1015 4 uiop->uio_resid = 0; uiop->uio_rw = UIO_WRITE; uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_procp = (struct proc *)0; d1017 2 a1018 2 * Do up to NFS_MAXIOVEC mbufs of write each iteration of the * loop until done. d1020 25 a1044 10 while (len > 0 && uiop->uio_resid == 0) { ivp = iv; siz = 0; uiop->uio_iov = ivp; uiop->uio_iovcnt = 0; uiop->uio_offset = off; while (len > 0 && uiop->uio_iovcnt < NFS_MAXIOVEC && mp != NULL) { ivp->iov_base = mtod(mp, caddr_t); if (len < mp->m_len) ivp->iov_len = xfer = len; d1046 39 a1084 12 ivp->iov_len = xfer = mp->m_len; #ifdef notdef /* Not Yet .. */ if (M_HASCL(mp) && (((u_long)ivp->iov_base) & CLOFSET) == 0) ivp->iov_op = NULL; /* what should it be ?? */ else ivp->iov_op = NULL; #endif uiop->uio_iovcnt++; ivp++; len -= xfer; siz += xfer; d1086 6 d1093 4 a1096 4 if (len > 0 && mp == NULL) { error = EBADRPC; vput(vp); nfsm_reply(0); d1098 70 a1167 4 uiop->uio_resid = siz; if ((error = VOP_WRITE(vp, uiop, ioflags, cred)) != 0) { vput(vp); nfsm_reply(0); d1169 42 a1210 12 off = uiop->uio_offset; } error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp); vput(vp); nfsm_reply(NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_srvfillattr; if (nfsd->nd_nqlflag != NQL_NOVAL) { nfsm_build(tl, u_int32_t *, 2*NFSX_UNSIGNED); txdr_hyper(&va.va_filerev, tl); } nfsm_srvdone; d1218 5 a1222 6 nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d1224 6 a1229 2 register struct nfsv2_fattr *fp; struct vattr va; d1236 3 a1238 1 int error = 0, rdev, cache, len, tsize; d1241 2 a1242 2 struct vnode *vp = NULL; nfsv2fh_t nfh; d1244 2 a1245 1 u_quad_t frev; d1250 1 a1250 1 nfsm_srvstrsiz(len, NFS_MAXNAMLEN); d1254 18 a1271 4 error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp); if (error) nfsm_reply(0); d1273 43 a1315 1 nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_SATTR(nfsd->nd_nqlflag != NQL_NOVAL)); a1321 8 va.va_type = IFTOVT(fxdr_unsigned(u_int32_t, sp->sa_mode)); if (va.va_type == VNON) va.va_type = VREG; va.va_mode = nfstov_mode(sp->sa_mode); if (nfsd->nd_nqlflag == NQL_NOVAL) rdev = fxdr_unsigned(int32_t, sp->sa_nfssize); else rdev = fxdr_unsigned(int32_t, sp->sa_nqrdev); d1324 13 a1336 6 nqsrv_getl(nd.ni_dvp, NQL_WRITE); error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va); if (error) nfsm_reply(0); FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); d1341 4 a1344 2 if (va.va_type == VFIFO) { #ifndef FIFO d1347 2 a1348 7 error = ENXIO; goto out; #endif /* FIFO */ } else if ((error = suser(cred, (u_short *)0)) != 0) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); goto out; d1351 1 a1351 1 nqsrv_getl(nd.ni_dvp, NQL_WRITE); d1353 1 a1353 1 &va); d1360 2 a1361 2 nd.ni_cnd.cn_proc = nfsd->nd_procp; nd.ni_cnd.cn_cred = nfsd->nd_procp->p_ucred; d1375 2 a1379 1 goto out; a1390 8 if (nfsd->nd_nqlflag == NQL_NOVAL) { tsize = fxdr_unsigned(int32_t, sp->sa_nfssize); if (tsize != -1) va.va_size = (u_quad_t)tsize; else va.va_size = -1; } else fxdr_hyper(&sp->sa_nqsize, &va.va_size); d1393 8 a1400 5 (nd.ni_cnd.cn_flags & RDONLY), nfsd->nd_procp); if (error) { vput(vp); nfsm_reply(0); d1402 1 a1402 3 nqsrv_getl(vp, NQL_WRITE); error = VOP_SETATTR(vp, &va, cred, nfsd->nd_procp); if (error) { a1403 2 nfsm_reply(0); } d1406 6 a1411 3 bzero((caddr_t)fhp, sizeof(nfh)); fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; if ((error = VFS_VPTOFH(vp, &fhp->fh_fid)) != 0) { a1412 1 nfsm_reply(0); d1414 20 a1433 7 error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp); vput(vp); nfsm_reply(NFSX_FH+NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_srvfhtom(fhp); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_srvfillattr; return (error); d1435 3 a1437 1 if (nd.ni_cnd.cn_nameiop || nd.ni_cnd.cn_flags) d1439 2 d1449 67 d1517 48 d1566 33 a1598 4 vrele(nd.ni_startdir); free(nd.ni_cnd.cn_pnbuf, M_NAMEI); nfsm_reply(0); return 0; d1605 5 a1609 6 nfsrv_remove(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d1611 4 d1619 2 a1620 1 int error = 0, cache, len; d1623 3 a1625 2 struct vnode *vp; nfsv2fh_t nfh; d1629 3 d1634 1 a1634 1 nfsm_srvstrsiz(len, NFS_MAXNAMLEN); d1638 6 a1643 12 error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp); if (error) nfsm_reply(0); vp = nd.ni_vp; /* * The root of a mounted filesystem cannot be deleted. */ if (vp->v_flag & VROOT) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == vp) vrele(nd.ni_dvp); d1645 1 a1645 4 vput(nd.ni_dvp); vput(vp); error = EBUSY; goto out; d1647 14 a1660 5 if (vp->v_flag & VTEXT) (void) vnode_pager_uncache(vp); nqsrv_getl(nd.ni_dvp, NQL_WRITE); nqsrv_getl(vp, NQL_WRITE); error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); d1662 22 a1683 1 nfsm_reply(0); d1691 5 a1695 6 nfsrv_rename(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d1697 4 d1704 3 a1706 1 int error = 0, cache, len, len2; d1710 4 a1713 2 struct vnode *fvp = NULL, *tvp, *tdvp; nfsv2fh_t fnfh, tnfh; d1718 3 d1726 1 a1726 1 nfsm_srvstrsiz(len, NFS_MAXNAMLEN); d1735 19 a1753 4 error = nfs_namei(&fromnd, ffhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp); if (error) nfsm_reply(0); d1761 11 a1771 2 error = nfs_namei(&tond, tfhp, len2, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp); d1782 4 a1785 1 error = EISDIR; d1788 4 a1791 1 error = ENOTDIR; d1795 4 a1798 1 error = EXDEV; d1803 4 a1806 1 error = EBUSY; d1810 4 a1813 1 error = EXDEV; d1817 4 a1820 1 error = EINVAL; d1833 2 a1834 2 nqsrv_getl(fromnd.ni_dvp, NQL_WRITE); nqsrv_getl(tdvp, NQL_WRITE); d1836 1 a1836 1 nqsrv_getl(tvp, NQL_WRITE); d1850 2 d1856 8 d1866 6 a1871 2 nfsm_reply(0); return (error); d1874 5 a1878 1 if (tond.ni_cnd.cn_nameiop || tond.ni_cnd.cn_flags) { d1882 1 a1882 1 if (fromnd.ni_cnd.cn_nameiop || fromnd.ni_cnd.cn_flags) { d1896 5 a1900 6 nfsrv_link(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d1902 4 d1910 2 a1911 1 int error = 0, rdonly, cache, len; d1914 3 a1916 2 struct vnode *vp; nfsv2fh_t nfh, dnfh; d1924 11 a1934 4 nfsm_srvstrsiz(len, NFS_MAXNAMLEN); error = nfsrv_fhtovp(fhp, FALSE, &vp, cred, nfsd->nd_slp, nam, &rdonly); if (error) nfsm_reply(0); d1938 11 a1948 2 error = nfs_namei(&nd, dfhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp); d1950 4 d1955 10 a1964 1 if (nd.ni_vp) { d1970 9 a1978 3 vrele(nd.ni_vp); error = EEXIST; goto out; a1979 4 nqsrv_getl(nd.ni_dvp, NQL_WRITE); nqsrv_getl(vp, NQL_WRITE); error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); out: d1981 6 a1986 1 nfsm_reply(0); d1994 5 a1998 6 nfsrv_symlink(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d2000 5 a2004 1 struct vattr va; d2009 1 a2009 1 caddr_t bpos; d2012 5 a2016 4 int error = 0, cache, len, len2; char *pathcp, *cp2; struct mbuf *mb, *mreq; nfsv2fh_t nfh; d2020 1 a2020 1 pathcp = (char *)0; d2023 1 a2023 1 nfsm_srvstrsiz(len, NFS_MAXNAMLEN); d2026 12 a2037 3 nd.ni_cnd.cn_flags = LOCKPARENT; error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp); d2040 3 d2055 4 a2058 1 nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_SATTR(nfsd->nd_nqlflag != NQL_NOVAL)); d2061 2 d2072 25 a2096 4 VATTR_NULL(&va); va.va_mode = fxdr_unsigned(u_int16_t, sp->sa_mode); nqsrv_getl(nd.ni_dvp, NQL_WRITE); error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va, pathcp); d2100 13 a2112 2 nfsm_reply(0); return (error); d2114 6 d2136 5 a2140 6 nfsrv_mkdir(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d2142 6 a2147 2 struct vattr va; register struct nfsv2_fattr *fp; d2153 2 a2154 1 int error = 0, cache, len; d2157 2 a2158 2 struct vnode *vp; nfsv2fh_t nfh; d2164 1 a2164 1 nfsm_srvstrsiz(len, NFS_MAXNAMLEN); d2168 18 a2185 5 error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp); if (error) nfsm_reply(0); nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); d2187 6 a2193 1 va.va_mode = nfstov_mode(*tl++); d2203 1 a2203 1 nfsm_reply(0); d2205 9 a2213 7 nqsrv_getl(nd.ni_dvp, NQL_WRITE); if ((error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va)) != 0) nfsm_reply(0); vp = nd.ni_vp; bzero((caddr_t)fhp, sizeof(nfh)); fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; if ((error = VFS_VPTOFH(vp, &fhp->fh_fid)) != 0) { a2214 1 nfsm_reply(0); d2216 18 a2233 7 error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp); vput(vp); nfsm_reply(NFSX_FH+NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_srvfhtom(fhp); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_srvfillattr; return (error); d2235 2 d2251 5 a2255 6 nfsrv_rmdir(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d2257 4 d2264 2 a2265 1 int error = 0, cache, len; d2268 3 a2270 2 struct vnode *vp; nfsv2fh_t nfh; d2277 1 a2277 1 nfsm_srvstrsiz(len, NFS_MAXNAMLEN); d2281 18 a2298 4 error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp); if (error) nfsm_reply(0); d2318 2 a2319 2 nqsrv_getl(nd.ni_dvp, NQL_WRITE); nqsrv_getl(vp, NQL_WRITE); d2329 9 a2337 1 nfsm_reply(0); d2361 1 a2361 1 * The alternate call nqnfsrv_readdirlook() does lookups as well. d2371 6 a2376 5 u_int32_t fl_cachable; u_int32_t fl_duration; u_int32_t fl_frev[2]; nfsv2fh_t fl_nfh; u_int32_t fl_fattr[NFSX_NQFATTR / sizeof (u_int32_t)]; d2380 5 a2384 6 nfsrv_readdir(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d2386 4 d2392 1 a2392 1 register struct dirent *dp = NULL; d2400 2 a2401 1 nfsv2fh_t nfh; d2405 5 a2409 5 int len, nlen, rem, xfer, tsiz, i, error = 0; int siz, cnt, fullsiz, eofflag, rdonly, cache; u_quad_t frev; u_long off, *cookiebuf, *cookie; int ncookies; d2413 11 a2423 2 nfsm_dissect(tl, u_int32_t *, 2*NFSX_UNSIGNED); off = fxdr_unsigned(u_int32_t, *tl++); d2425 4 a2428 3 siz = ((cnt+NFS_DIRBLKSIZ-1) & ~(NFS_DIRBLKSIZ-1)); if (cnt > NFS_MAXREADDIR) siz = NFS_MAXREADDIR; d2430 20 a2449 6 ncookies = siz / 16; /* Guess at the number of cookies needed. */ error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly); if (error) nfsm_reply(0); nqsrv_getl(vp, NQL_READ); error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp); d2452 3 a2454 1 nfsm_reply(0); d2456 3 d2460 1 d2462 3 a2464 2 MALLOC(cookiebuf, u_long *, ncookies * sizeof(*cookiebuf), M_TEMP, M_WAITOK); d2475 9 a2483 2 error = VOP_READDIR(vp, &io, cred, &eofflag, cookiebuf, ncookies); cookie = cookiebuf; d2485 13 a2499 1 free((caddr_t)cookiebuf, M_TEMP); d2501 5 a2505 1 nfsm_reply(0); d2516 9 a2524 2 nfsm_reply(2*NFSX_UNSIGNED); nfsm_build(tl, u_int32_t *, 2*NFSX_UNSIGNED); a2526 1 FREE((caddr_t)cookiebuf, M_TEMP); d2528 1 d2539 5 a2543 1 while (cpos < cend) { d2545 2 a2546 5 if (dp->d_fileno == 0) { cpos += dp->d_reclen; cookie++; } else break; d2548 2 a2549 1 if (cpos >= cend) { d2554 7 a2560 2 len = 3*NFSX_UNSIGNED; /* paranoia, probably can be 0 */ nfsm_reply(siz); d2566 1 a2566 1 while (cpos < cend) { d2570 3 a2572 1 len += (4*NFSX_UNSIGNED + nlen + rem); d2584 5 d2611 1 a2611 1 /* And null pad to a int32_t boundary */ d2617 6 a2622 1 *tl = txdr_unsigned(*cookie); d2627 2 a2628 1 cookie++; d2645 2 a2646 2 FREE(cookiebuf, M_TEMP); FREE(rbuf, M_TEMP); d2651 5 a2655 6 nqnfsrv_readdirlook(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d2657 4 d2663 1 a2663 1 register struct dirent *dp = NULL; d2672 2 a2673 2 nfsv2fh_t nfh; fhandle_t *fhp; d2676 6 a2681 7 struct vattr va; struct nfsv2_fattr *fp; int len, nlen, rem, xfer, tsiz, i, error = 0, duration2, cache2; int siz, cnt, fullsiz, eofflag, rdonly, cache; u_quad_t frev, frev2; u_long off, *cookiebuf, *cookie; int ncookies; d2685 12 a2696 7 nfsm_dissect(tl, u_int32_t *, 3*NFSX_UNSIGNED); off = fxdr_unsigned(u_int32_t, *tl++); cnt = fxdr_unsigned(int, *tl++); duration2 = fxdr_unsigned(int, *tl); siz = ((cnt+NFS_DIRBLKSIZ-1) & ~(NFS_DIRBLKSIZ-1)); if (cnt > NFS_MAXREADDIR) siz = NFS_MAXREADDIR; d2698 19 a2716 6 ncookies = siz / 16; /* Guess at the number of cookies needed. */ error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly); if (error) nfsm_reply(0); nqsrv_getl(vp, NQL_READ); error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp); d2719 3 a2721 1 nfsm_reply(0); d2723 3 d2727 2 d2730 3 a2732 2 MALLOC(cookiebuf, u_long *, ncookies * sizeof(*cookiebuf), M_TEMP, M_WAITOK); d2743 21 a2763 3 error = VOP_READDIR(vp, &io, cred, &eofflag, cookiebuf, ncookies); cookie = cookiebuf; off = (u_long)io.uio_offset; d2766 2 a2767 1 free((caddr_t)cookiebuf, M_TEMP); d2769 3 a2771 1 nfsm_reply(0); d2782 6 a2787 2 nfsm_reply(2 * NFSX_UNSIGNED); nfsm_build(tl, u_int32_t *, 2 * NFSX_UNSIGNED); d2790 1 a2790 1 FREE((caddr_t)cookiebuf, M_TEMP); d2802 5 a2806 1 while (cpos < cend) { d2808 2 a2809 5 if (dp->d_fileno == 0) { cpos += dp->d_reclen; cookie++; } else break; d2811 2 a2812 1 if (cpos >= cend) { d2817 5 a2821 2 len = 3 * NFSX_UNSIGNED; /* paranoia, probably can be 0 */ nfsm_reply(siz); d2827 1 a2827 1 while (cpos < cend) { d2838 2 a2839 2 bzero((caddr_t)&fl.fl_nfh, sizeof (nfsv2fh_t)); fl.fl_nfh.fh_generic.fh_fsid = d2841 1 a2841 1 if (VFS_VPTOFH(nvp, &fl.fl_nfh.fh_generic.fh_fid)) { d2845 1 a2845 9 if (duration2) { (void) nqsrv_getlease(nvp, &duration2, NQL_READ, nfsd, nam, &cache2, &frev2, cred); fl.fl_duration = txdr_unsigned(duration2); fl.fl_cachable = txdr_unsigned(cache2); txdr_hyper(&frev2, fl.fl_frev); } else fl.fl_duration = 0; if (VOP_GETATTR(nvp, &va, cred, nfsd->nd_procp)) { d2850 11 a2860 5 fp = (struct nfsv2_fattr *)&fl.fl_fattr; nfsm_srvfillattr; len += (4*NFSX_UNSIGNED + nlen + rem + NFSX_FH + NFSX_NQFATTR); if (len > cnt) { d2864 1 d2869 8 d2880 3 a2882 18 /* * For readdir_and_lookup copy the stuff out. */ xfer = sizeof (struct flrep); cp = (caddr_t)&fl; while (xfer > 0) { nfsm_clget; if ((bp+xfer) > be) tsiz = be-bp; else tsiz = xfer; bcopy(cp, bp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } d2895 2 a2896 2 if ((bp+xfer) > be) tsiz = be-bp; d2905 1 a2905 1 /* And null pad to a int32_t boundary */ a2907 1 nfsm_clget; d2909 17 a2925 3 /* Finish off the record */ *tl = txdr_unsigned(*cookie); bp += NFSX_UNSIGNED; d2930 2 a2931 1 cookie++; d2948 64 a3011 2 FREE(cookiebuf, M_TEMP); FREE(rbuf, M_TEMP); d3019 5 a3023 6 nfsrv_statfs(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d3025 4 d3030 1 a3030 1 register struct nfsv2_statfs *sfp; d3034 2 a3035 1 int error = 0, rdonly, cache = 0, isnq; d3039 2 a3040 1 nfsv2fh_t nfh; d3043 1 a3043 1 u_quad_t frev; d3045 3 a3048 1 isnq = (nfsd->nd_nqlflag != NQL_NOVAL); d3050 7 a3056 3 error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly); if (error) nfsm_reply(0); d3058 2 a3059 1 error = VFS_STATFS(vp->v_mount, sf, nfsd->nd_procp); d3061 71 a3131 10 nfsm_reply(NFSX_STATFS(isnq)); nfsm_build(sfp, struct nfsv2_statfs *, NFSX_STATFS(isnq)); sfp->sf_tsize = txdr_unsigned(NFS_MAXDGRAMDATA); sfp->sf_bsize = txdr_unsigned(sf->f_bsize); sfp->sf_blocks = txdr_unsigned(sf->f_blocks); sfp->sf_bfree = txdr_unsigned(sf->f_bfree); sfp->sf_bavail = txdr_unsigned(sf->f_bavail); if (isnq) { sfp->sf_files = txdr_unsigned(sf->f_files); sfp->sf_ffree = txdr_unsigned(sf->f_ffree); d3133 99 d3240 5 a3244 6 nfsrv_null(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d3246 1 d3248 1 a3248 1 int error = VNOVAL, cache = 0; d3253 1 a3253 1 return (error); d3261 5 a3265 6 nfsrv_noop(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; d3267 1 d3278 1 a3278 1 return (error); d3310 3 a3312 1 case VREG: case VDIR: case VLNK: d3314 1 a3314 6 case VNON: case VBLK: case VCHR: case VSOCK: case VFIFO: case VBAD: d3326 2 a3327 1 if ((error = VOP_GETATTR(vp, &vattr, cred, p)) != 0) d3329 1 a3329 1 if ((error = VOP_ACCESS(vp, flags, cred, p)) && @ 1.21 log @Fix vop_link, vop_symlink, and vop_remove semantics in several ways: * Change the argument names to vop_link so they actually make sense. * Implement vop_link and vop_symlink for all file systems, so they do proper cleanup. * Require the file system to decide whether or not linking and unlinking of directories is allowed, and disable it for all current file systems. (Also, remove the cross-device link check, that was moved into the file systems some time ago.) @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.20 1996/02/01 00:40:13 jtc Exp $ */ d78 1 d94 1 d108 1 a108 1 int error = 0, rdonly, cache, mode = 0; d116 2 a117 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d134 1 d157 2 a158 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d172 1 d196 4 a199 2 nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_SATTR(nfsd->nd_nqlflag != NQL_NOVAL)); if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d250 2 a251 2 } else if (error = nfsrv_access(vp, VWRITE, cred, rdonly, nfsd->nd_procp)) d254 1 a254 1 if (error = VOP_SETATTR(vp, &va, cred, nfsd->nd_procp)) { d274 1 d308 2 a309 2 if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d317 1 a317 1 if (error = VFS_VPTOFH(vp, &fhp->fh_fid)) { d348 1 d364 1 a364 1 struct mbuf *mb, *mb2, *mp2, *mp3, *mreq; d402 2 a403 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) { d432 1 d469 2 a470 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d478 10 a487 6 if ((error = nfsrv_access(vp, VREAD, cred, rdonly, nfsd->nd_procp)) && (error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp))) { vput(vp); nfsm_reply(0); } if (error = VOP_GETATTR(vp, &va, cred, nfsd->nd_procp)) { d557 1 d613 2 a614 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d622 2 a623 1 if (error = nfsrv_access(vp, VWRITE, cred, rdonly, nfsd->nd_procp)) { d666 1 a666 1 if (error = VOP_WRITE(vp, uiop, ioflags, cred)) { d688 1 d707 1 a707 1 struct vnode *vp; d719 3 a721 2 if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d742 3 a744 1 if (error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va)) d758 1 a758 1 } else if (error = suser(cred, (u_short *)0)) { d765 3 a767 1 if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va)) { d775 1 a775 1 if (error = lookup(&nd)) { d812 4 a815 2 if (error = nfsrv_access(vp, VWRITE, cred, (nd.ni_cnd.cn_flags & RDONLY), nfsd->nd_procp)) { d820 2 a821 1 if (error = VOP_SETATTR(vp, &va, cred, nfsd->nd_procp)) { d829 1 a829 1 if (error = VFS_VPTOFH(vp, &fhp->fh_fid)) { d856 1 d862 1 d888 3 a890 2 if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d919 1 d934 1 a934 1 struct vnode *fvp, *tvp, *tdvp; d954 3 a956 2 if (error = nfs_namei(&fromnd, ffhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d965 3 a967 2 if (error = nfs_namei(&tond, tfhp, len2, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) { d1054 1 d1079 2 a1080 1 if (error = nfsrv_fhtovp(fhp, FALSE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d1085 3 a1087 2 if (error = nfs_namei(&nd, dfhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d1111 1 d1141 3 a1143 2 if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d1194 1 d1223 3 a1225 2 if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d1243 1 a1243 1 if (error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, &va)) d1248 1 a1248 1 if (error = VFS_VPTOFH(vp, &fhp->fh_fid)) { d1273 1 d1299 3 a1301 2 if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d1374 1 d1384 1 a1384 1 register struct dirent *dp; d1412 2 a1413 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d1416 2 a1417 1 if (error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp)) { d1560 1 d1570 1 a1570 1 register struct dirent *dp; d1602 2 a1603 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d1606 2 a1607 1 if (error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp)) { d1802 1 d1815 1 a1815 1 int error = 0, rdonly, cache, isnq; d1827 2 a1828 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d1851 1 d1860 1 a1860 1 int error = VNOVAL, cache; d1872 1 d1881 1 a1881 1 int error, cache; d1903 1 d1924 7 d1941 1 a1941 1 if (error = VOP_GETATTR(vp, &vattr, cred, p)) @ 1.20 log @Rename struct timespec fields to conform to POSIX.1b @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.19 1995/12/19 23:07:32 cgd Exp $ */ a860 3 if (vp->v_type == VDIR && (error = suser(cred, (u_short *)0))) goto out; a864 11 error = EBUSY; goto out; } if (vp->v_flag & VTEXT) (void) vnode_pager_uncache(vp); out: if (!error) { nqsrv_getl(nd.ni_dvp, NQL_WRITE); nqsrv_getl(vp, NQL_WRITE); error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); } else { d871 2 d874 6 d1033 1 a1033 1 struct vnode *vp, *xp; a1044 2 if (vp->v_type == VDIR && (error = suser(cred, (u_short *)0))) goto out1; a1049 4 goto out1; xp = nd.ni_vp; if (xp != NULL) { error = EEXIST; d1051 1 a1051 10 } xp = nd.ni_dvp; if (vp->v_mount != xp->v_mount) error = EXDEV; out: if (!error) { nqsrv_getl(vp, NQL_WRITE); nqsrv_getl(xp, NQL_WRITE); error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); } else { d1057 3 a1059 2 if (nd.ni_vp) vrele(nd.ni_vp); d1061 4 a1064 1 out1: @ 1.19 log @changes to make this work on systems where pointers & longs are 64 bits. This is mostly just changes to make the stuff that goes over the wire use fixed-size types. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.18 1995/05/23 06:22:47 mycroft Exp $ */ d215 1 a215 1 va.va_atime.ts_sec = d217 1 a217 1 va.va_atime.ts_nsec = 0; @ 1.18 log @Remove gratuitous extra indirections. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.17 1994/12/13 17:17:01 mycroft Exp $ */ d85 2 a86 2 extern u_long nfs_xdrneg1; extern u_long nfs_false, nfs_true; d103 2 a104 2 register u_long *tl; register long t1; d113 1 a113 1 nfsm_dissect(tl, u_long *, 3 * NFSX_UNSIGNED); d143 2 a144 2 register u_long *tl; register long t1; d180 2 a181 2 register u_long *tl; register long t1; d216 1 a216 1 fxdr_unsigned(long, sp->sa_nfsatime.nfs_sec); d226 1 a226 1 va.va_flags = fxdr_unsigned(u_long, sp->sa_nqflags); d257 1 a257 1 nfsm_build(tl, u_long *, 2*NFSX_UNSIGNED); d279 2 a280 2 register u_long *tl; register long t1; d291 1 a291 1 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); d320 1 a320 1 nfsm_build(tl, u_long *, 5*NFSX_UNSIGNED); d326 1 a326 1 nfsm_build(tl, u_long *, NFSX_UNSIGNED); d349 2 a350 2 register u_long *tl; register long t1; d412 1 a412 1 nfsm_build(tl, u_long *, NFSX_UNSIGNED); d432 2 a433 2 register u_long *tl; register long t1; d450 2 a451 2 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); off = (off_t)fxdr_unsigned(u_long, *tl); d453 1 a453 1 nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); d480 1 a480 1 nfsm_build(tl, u_long *, NFSX_UNSIGNED); d552 2 a553 2 register u_long *tl; register long t1; d568 1 a568 1 nfsm_dissect(tl, u_long *, 4 * NFSX_UNSIGNED); d570 1 a570 1 off = (off_t)fxdr_unsigned(u_long, *++tl); d575 1 a575 1 if (fxdr_unsigned(u_long, *tl++)) d578 1 a578 1 len = fxdr_unsigned(long, *tl); d658 1 a658 1 nfsm_build(tl, u_long *, 2*NFSX_UNSIGNED); d678 1 a678 1 register u_long *tl; d681 1 a681 1 register long t1; d709 1 a709 1 va.va_type = IFTOVT(fxdr_unsigned(u_long, sp->sa_mode)); d714 1 a714 1 rdev = fxdr_unsigned(long, sp->sa_nfssize); d716 1 a716 1 rdev = fxdr_unsigned(long, sp->sa_nqrdev); d778 1 a778 1 tsize = fxdr_unsigned(long, sp->sa_nfssize); d840 2 a841 2 register u_long *tl; register long t1; d900 2 a901 2 register u_long *tl; register long t1; d1033 2 a1034 2 register u_long *tl; register long t1; d1099 2 a1100 2 register u_long *tl; register long t1; d1147 1 a1147 1 va.va_mode = fxdr_unsigned(u_short, sp->sa_mode); d1182 2 a1183 2 register u_long *tl; register long t1; d1202 1 a1202 1 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); d1255 2 a1256 2 register u_long *tl; register long t1; d1340 3 a1342 3 u_long fl_cachable; u_long fl_duration; u_long fl_frev[2]; d1344 1 a1344 1 u_long fl_fattr[NFSX_NQFATTR / sizeof (u_long)]; d1358 2 a1359 2 register u_long *tl; register long t1; d1376 2 a1377 2 nfsm_dissect(tl, u_long *, 2*NFSX_UNSIGNED); off = fxdr_unsigned(u_long, *tl++); d1424 1 a1424 1 nfsm_build(tl, u_long *, 2*NFSX_UNSIGNED); d1497 1 a1497 1 /* And null pad to a long boundary */ d1541 2 a1542 2 register u_long *tl; register long t1; d1562 2 a1563 2 nfsm_dissect(tl, u_long *, 3*NFSX_UNSIGNED); off = fxdr_unsigned(u_long, *tl++); d1611 1 a1611 1 nfsm_build(tl, u_long *, 2 * NFSX_UNSIGNED); d1732 1 a1732 1 /* And null pad to a long boundary */ d1778 2 a1779 2 register u_long *tl; register long t1; @ 1.17 log @Sync with CSRG. @ text @d1 1 a1 1 /* $NetBSD: nfs_serv.c,v 1.16 1994/06/29 06:42:13 cgd Exp $ */ a139 1 register struct vattr *vap = &va; d156 1 a156 1 error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp); a174 1 register struct vattr *vap = &va; d194 1 a194 1 VATTR_NULL(vap); d203 1 a203 1 vap->va_mode = nfstov_mode(sp->sa_mode); d205 1 a205 1 vap->va_uid = fxdr_unsigned(uid_t, sp->sa_uid); d207 1 a207 1 vap->va_gid = fxdr_unsigned(gid_t, sp->sa_gid); d210 1 a210 1 vap->va_size = fxdr_unsigned(u_quad_t, sp->sa_nfssize); d213 1 a213 1 fxdr_nfstime(&sp->sa_nfsatime, &vap->va_atime); d215 1 a215 1 vap->va_atime.ts_sec = d217 1 a217 1 vap->va_atime.ts_nsec = 0; d221 1 a221 1 fxdr_nfstime(&sp->sa_nfsmtime, &vap->va_mtime); d223 4 a226 4 fxdr_hyper(&sp->sa_nqsize, &vap->va_size); fxdr_nqtime(&sp->sa_nqatime, &vap->va_atime); fxdr_nqtime(&sp->sa_nqmtime, &vap->va_mtime); vap->va_flags = fxdr_unsigned(u_long, sp->sa_nqflags); d233 1 a233 1 if (vap->va_size == ((u_quad_t)((quad_t) -1))) { d246 1 a246 1 if (error = VOP_SETATTR(vp, vap, cred, nfsd->nd_procp)) { d250 1 a250 1 error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp); d285 1 a285 1 struct vattr va, *vap = &va; d315 1 a315 1 error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp); d443 1 a443 1 struct vattr va, *vap = &va; d470 1 a470 1 if (error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp)) { d474 1 a474 1 if (off >= vap->va_size) d476 2 a477 2 else if ((off + cnt) > vap->va_size) cnt = nfsm_rndup(vap->va_size - off); d520 1 a520 1 if (error || (error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp))) { a551 1 register struct vattr *vap = &va; d652 1 a652 1 error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp); d659 1 a659 1 txdr_hyper(&vap->va_filerev, tl); a676 1 register struct vattr *vap = &va; d701 1 a701 1 VATTR_NULL(vap); d709 4 a712 4 vap->va_type = IFTOVT(fxdr_unsigned(u_long, sp->sa_mode)); if (vap->va_type == VNON) vap->va_type = VREG; vap->va_mode = nfstov_mode(sp->sa_mode); d717 1 a717 1 if (vap->va_type == VREG || vap->va_type == VSOCK) { d720 1 a720 1 if (error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) d723 5 a727 5 } else if (vap->va_type == VCHR || vap->va_type == VBLK || vap->va_type == VFIFO) { if (vap->va_type == VCHR && rdev == 0xffffffff) vap->va_type = VFIFO; if (vap->va_type == VFIFO) { d739 1 a739 1 vap->va_rdev = (dev_t)rdev; d741 1 a741 1 if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) { d780 1 a780 1 vap->va_size = (u_quad_t)tsize; d782 1 a782 1 vap->va_size = -1; d784 2 a785 2 fxdr_hyper(&sp->sa_nqsize, &vap->va_size); if (vap->va_size != -1) { d792 1 a792 1 if (error = VOP_SETATTR(vp, vap, cred, nfsd->nd_procp)) { d804 1 a804 1 error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp); a1098 1 register struct vattr *vap = &va; d1146 2 a1147 2 VATTR_NULL(vap); vap->va_mode = fxdr_unsigned(u_short, sp->sa_mode); d1149 1 a1149 1 error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap, pathcp); a1178 1 register struct vattr *vap = &va; d1203 3 a1205 3 VATTR_NULL(vap); vap->va_type = VDIR; vap->va_mode = nfstov_mode(*tl++); d1218 1 a1218 1 if (error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) d1227 1 a1227 1 error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp); d1552 1 a1552 1 struct vattr va, *vap = &va; d1672 1 a1672 1 if (VOP_GETATTR(nvp, vap, cred, nfsd->nd_procp)) { @ 1.16 log @New RCS ID's, take two. they're more aesthecially pleasant, and use 'NetBSD' @ text @d1 1 a1 1 /* $NetBSD$ */ d38 1 a38 1 * @@(#)nfs_serv.c 8.3 (Berkeley) 1/12/94 @ 1.15 log @Update to 4.4-Lite fs code, with local changes. @ text @d1 2 d38 1 a38 2 * from: @@(#)nfs_serv.c 8.3 (Berkeley) 1/12/94 * $Id: $ @ 1.14 log @Convert mount, vnode, and buf structs to use . Also, some knf and structure frobbing to do along with it. @ text @d2 2 a3 2 * Copyright (c) 1989 The Regents of the University of California. * All rights reserved. d36 2 a37 2 * from: @@(#)nfs_serv.c 7.40 (Berkeley) 5/15/91 * $Id: nfs_serv.c,v 1.13 1994/04/10 06:45:56 cgd Exp $ d66 2 a67 1 #include d69 1 a69 2 #include #include /* for IFTOVT */ d72 1 d76 1 d86 1 a86 1 nfstype nfs_type[9]={ NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFNON, d89 38 a126 38 int nfsrv_null(), nfsrv_getattr(), nfsrv_setattr(), nfsrv_lookup(), nfsrv_readlink(), nfsrv_read(), nfsrv_write(), nfsrv_create(), nfsrv_remove(), nfsrv_rename(), nfsrv_link(), nfsrv_symlink(), nfsrv_mkdir(), nfsrv_rmdir(), nfsrv_readdir(), nfsrv_statfs(), nfsrv_noop(); int (*nfsrv_procs[NFS_NPROCS])() = { nfsrv_null, nfsrv_getattr, nfsrv_setattr, nfsrv_noop, nfsrv_lookup, nfsrv_readlink, nfsrv_read, nfsrv_noop, nfsrv_write, nfsrv_create, nfsrv_remove, nfsrv_rename, nfsrv_link, nfsrv_symlink, nfsrv_mkdir, nfsrv_rmdir, nfsrv_readdir, nfsrv_statfs, }; d130 2 a131 2 nfsrv_getattr(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf **mrq; d135 1 a135 3 u_long xid; int *repstat; struct proc *p; d146 1 a146 1 int error = 0; d149 1 d153 1 a153 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred)) d155 2 a156 1 error = VOP_GETATTR(vp, vap, cred, p); d158 2 a159 2 nfsm_reply(NFSX_FATTR); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR); d167 2 a168 2 nfsrv_setattr(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf **mrq; d172 1 a172 3 u_long xid; int *repstat; struct proc *p; d184 1 a184 1 int error = 0; d187 1 d191 2 a192 2 nfsm_disect(sp, struct nfsv2_sattr *, NFSX_SATTR); if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred)) d194 1 a194 2 if (error = nfsrv_access(vp, VWRITE, cred, p)) goto out; d209 21 a229 2 if (sp->sa_size != nfs_xdrneg1) vap->va_size = fxdr_unsigned(u_long, sp->sa_size); d231 2 a232 7 * The usec field of sa_atime is overloaded with the va_flags field * for 4.4BSD clients. Hopefully other clients always set both the * sec and usec fields to -1 when not setting the atime. * * jfw@@ksr.com (6/2/93): Suns certainly don't set the usec field to * -1 when *setting* the atime, resulting in * va_flags acquiring random contents. d234 12 a245 4 #if 0 /* bad assumption, NFS is too fragile to extend. */ if (sp->sa_atime.tv_sec != nfs_xdrneg1) { vap->va_atime.tv_sec = fxdr_unsigned(long, sp->sa_atime.tv_sec); vap->va_atime.tv_usec = 0; d247 1 a247 9 if (sp->sa_atime.tv_usec != nfs_xdrneg1) vap->va_flags = fxdr_unsigned(u_long, sp->sa_atime.tv_usec); #else if (sp->sa_atime.tv_sec != nfs_xdrneg1) fxdr_time(&sp->sa_atime, &vap->va_atime); #endif if (sp->sa_mtime.tv_sec != nfs_xdrneg1) fxdr_time(&sp->sa_mtime, &vap->va_mtime); if (error = VOP_SETATTR(vp, vap, cred, p)) { d251 1 a251 1 error = VOP_GETATTR(vp, vap, cred, p); d254 2 a255 2 nfsm_reply(NFSX_FATTR); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR); d257 4 d267 2 a268 2 nfsrv_lookup(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf **mrq; d272 1 a272 3 u_long xid; int *repstat; struct proc *p; d283 1 a283 1 int error = 0; a285 1 long len; d287 1 d290 5 d297 5 a301 3 nd.ni_cred = cred; nd.ni_nameiop = LOOKUP | LOCKLEAF; if (error = nfs_namei(&nd, fhp, len, &md, &dpos, p)) d303 3 d313 4 a316 1 error = VOP_GETATTR(vp, vap, cred, p); d318 13 a330 1 nfsm_reply(NFSX_FH+NFSX_FATTR); d332 1 a332 1 nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR); d340 2 a341 2 nfsrv_readlink(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf **mrq; d345 1 a345 3 u_long xid; int *repstat; struct proc *p; d353 1 a353 1 int error = 0; d360 1 a360 1 int i, tlen, len; d393 1 a393 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred)) { d401 1 d422 2 a423 2 nfsrv_read(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf **mrq; d427 1 a427 3 u_long xid; int *repstat; struct proc *p; d436 1 a436 1 int error = 0; d439 1 a439 1 struct mbuf *m2, *m3; a444 1 int i, cnt, len, left, siz, tlen; d446 1 d450 7 a456 2 nfsm_disect(tl, u_long *, NFSX_UNSIGNED); off = fxdr_unsigned(off_t, *tl); d458 1 a458 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred)) d460 2 a461 2 if ((error = nfsrv_access(vp, VREAD, cred, p)) && (error = nfsrv_access(vp, VEXEC, cred, p))) { d465 5 a469 30 len = left = cnt; /* * Generate the mbuf list with the uio_iov ref. to it. */ i = 0; m3 = (struct mbuf *)0; #ifdef lint m2 = (struct mbuf *)0; #endif /* lint */ MALLOC(iv, struct iovec *, ((NFS_MAXDATA+MLEN-1)/MLEN) * sizeof (struct iovec), M_TEMP, M_WAITOK); iv2 = iv; while (left > 0) { MGET(m, M_WAIT, MT_DATA); if (left > MINCLSIZE) MCLGET(m, M_WAIT); m->m_len = 0; siz = min(M_TRAILINGSPACE(m), left); m->m_len = siz; iv->iov_base = mtod(m, caddr_t); iv->iov_len = siz; iv++; i++; left -= siz; if (m3) { m2->m_next = m; m2 = m; } else m3 = m2 = m; d471 1 a471 12 uiop->uio_iov = iv2; uiop->uio_iovcnt = i; uiop->uio_offset = off; uiop->uio_resid = cnt; uiop->uio_rw = UIO_READ; uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_procp = (struct proc *)0; error = VOP_READ(vp, uiop, IO_NODELOCKED, cred); off = uiop->uio_offset; FREE((caddr_t)iv2, M_TEMP); if (error) { m_freem(m3); d475 53 a527 2 if (error = VOP_GETATTR(vp, vap, cred, p)) m_freem(m3); a528 2 nfsm_reply(NFSX_FATTR+NFSX_UNSIGNED); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR); d531 3 a533 9 if (len > 0) { tlen = nfsm_rndup(len); if (cnt != tlen || tlen != len) nfsm_adj(m3, cnt-tlen, tlen-len); } else { m_freem(m3); m3 = (struct mbuf *)0; } nfsm_build(tl, u_long *, NFSX_UNSIGNED); a534 1 mb->m_next = m3; d541 3 a543 2 nfsrv_write(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf *mrep, *md, **mrq; d546 1 a546 3 u_long xid; int *repstat; struct proc *p; d557 2 a558 1 int error = 0; d566 1 a566 1 long siz, len, xfer; d570 10 a579 3 nfsm_disect(tl, u_long *, 4*NFSX_UNSIGNED); off = fxdr_unsigned(off_t, *++tl); tl += 2; d597 1 a597 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred)) d599 7 a605 1 if (error = nfsrv_access(vp, VWRITE, cred, p)) { d648 1 a648 2 if (error = VOP_WRITE(vp, uiop, IO_SYNC | IO_NODELOCKED, cred)) { d654 1 a654 1 error = VOP_GETATTR(vp, vap, cred, p); d656 2 a657 2 nfsm_reply(NFSX_FATTR); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR); d659 4 d668 1 a668 2 * if it already exists, just set length * do NOT truncate unconditionally ! d670 3 a672 2 nfsrv_create(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf *mrep, *md, **mrq; d675 1 a675 3 u_long xid; int *repstat; struct proc *p; d680 2 a683 1 register u_long *tl; d686 1 a686 2 long rdev; int error = 0; d692 1 a692 1 long len; d694 1 a694 1 nd.ni_nameiop = 0; d698 5 a702 3 nd.ni_cred = cred; nd.ni_nameiop = CREATE | LOCKPARENT | LOCKLEAF | SAVESTART; if (error = nfs_namei(&nd, fhp, len, &md, &dpos, p)) d705 1 a705 1 nfsm_disect(tl, u_long *, NFSX_SATTR); d707 2 a708 2 * If it doesn't exist, create it * otherwise just set length from attributes d712 1 a712 1 vap->va_type = IFTOVT(fxdr_unsigned(u_long, *tl)); d715 5 a719 2 vap->va_mode = nfstov_mode(*tl); rdev = fxdr_unsigned(long, *(tl+3)); d722 2 a723 1 if (error = VOP_CREATE(&nd, vap, p)) d725 1 a725 1 FREE(nd.ni_pnbuf, M_NAMEI); d732 1 a732 1 VOP_ABORTOP(&nd); d738 1 a738 1 VOP_ABORTOP(&nd); d743 2 a744 1 if (error = VOP_MKNOD(&nd, vap, cred, p)) { d748 6 a753 4 nd.ni_nameiop &= ~(OPMASK | LOCKPARENT | SAVESTART); nd.ni_nameiop |= LOOKUP; if (error = lookup(&nd, p)) { free(nd.ni_pnbuf, M_NAMEI); d756 2 a757 2 FREE(nd.ni_pnbuf, M_NAMEI); if (nd.ni_more) { d760 1 a760 1 VOP_ABORTOP(&nd); d765 1 a765 1 VOP_ABORTOP(&nd); d773 1 a773 1 free(nd.ni_pnbuf, M_NAMEI); d779 20 a798 6 VOP_ABORTOP(&nd); vap->va_size = fxdr_unsigned(long, *(tl+3)); if (vap->va_size != -1 && (error = VOP_SETATTR(vp, vap, cred, p))) { vput(vp); nfsm_reply(0); d807 1 a807 1 error = VOP_GETATTR(vp, vap, cred, p); d809 1 a809 1 nfsm_reply(NFSX_FH+NFSX_FATTR); d811 1 a811 1 nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR); d815 1 a815 1 if (nd.ni_nameiop) d817 1 a817 1 VOP_ABORTOP(&nd); d828 1 a828 1 free(nd.ni_pnbuf, M_NAMEI); d835 3 a837 2 nfsrv_remove(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf *mrep, *md, **mrq; d840 1 a840 3 u_long xid; int *repstat; struct proc *p; d846 1 a846 1 int error = 0; d852 1 a852 1 long len; d857 5 a861 3 nd.ni_cred = cred; nd.ni_nameiop = DELETE | LOCKPARENT | LOCKLEAF; if (error = nfs_namei(&nd, fhp, len, &md, &dpos, p)) d878 3 a880 1 error = VOP_REMOVE(&nd, p); d882 1 a882 1 VOP_ABORTOP(&nd); d896 3 a898 2 nfsrv_rename(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf *mrep, *md, **mrq; d901 1 a901 3 u_long xid; int *repstat; struct proc *p; d906 1 a906 1 int error = 0; d913 2 a914 2 long len, len2; int rootflg = 0; d918 2 a919 2 fromnd.ni_nameiop = 0; tond.ni_nameiop = 0; d923 2 a924 2 * Remember if we are root so that we can reset cr_uid before * the second nfs_namei() call d926 6 a931 5 if (cred->cr_uid == 0) rootflg++; fromnd.ni_cred = cred; fromnd.ni_nameiop = DELETE | WANTPARENT | SAVESTART; if (error = nfs_namei(&fromnd, ffhp, len, &md, &dpos, p)) d936 7 a942 7 if (rootflg) cred->cr_uid = 0; tond.ni_cred = cred; tond.ni_nameiop = RENAME | LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART; if (error = nfs_namei(&tond, tfhp, len2, &md, &dpos, p)) { VOP_ABORTOP(&fromnd); d957 8 d978 3 a980 2 fromnd.ni_namelen == tond.ni_namelen && !bcmp(fromnd.ni_ptr, tond.ni_ptr, fromnd.ni_namelen)) d984 6 a989 1 error = VOP_RENAME(&fromnd, &tond, p); d991 1 a991 1 VOP_ABORTOP(&tond); d998 1 a998 1 VOP_ABORTOP(&fromnd); d1003 1 a1003 1 FREE(tond.ni_pnbuf, M_NAMEI); d1006 1 a1006 1 FREE(fromnd.ni_pnbuf, M_NAMEI); d1011 1 a1011 1 if (tond.ni_nameiop) { d1013 1 a1013 1 FREE(tond.ni_pnbuf, M_NAMEI); d1015 1 a1015 1 if (fromnd.ni_nameiop) { d1017 2 a1018 2 FREE(fromnd.ni_pnbuf, M_NAMEI); VOP_ABORTOP(&fromnd); d1028 3 a1030 2 nfsrv_link(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf *mrep, *md, **mrq; d1033 1 a1033 3 u_long xid; int *repstat; struct proc *p; d1039 1 a1039 1 int error = 0; d1045 1 a1045 1 long len; d1052 1 a1052 1 if (error = nfsrv_fhtovp(fhp, FALSE, &vp, cred)) d1054 1 a1054 1 if (vp->v_type == VDIR && (error = suser(cred, NULL))) d1056 5 a1060 3 nd.ni_cred = cred; nd.ni_nameiop = CREATE | LOCKPARENT; if (error = nfs_namei(&nd, dfhp, len, &md, &dpos, p)) d1072 3 a1074 1 error = VOP_LINK(vp, &nd, p); d1076 1 a1076 1 VOP_ABORTOP(&nd); d1093 3 a1095 2 nfsrv_symlink(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf *mrep, *md, **mrq; d1098 1 a1098 3 u_long xid; int *repstat; struct proc *p; d1109 1 a1109 1 int error = 0; d1114 1 a1114 1 long len, len2; d1120 5 a1124 3 nd.ni_cred = cred; nd.ni_nameiop = CREATE | LOCKPARENT; if (error = nfs_namei(&nd, fhp, len, &md, &dpos, p)) d1138 1 a1138 1 nfsm_disect(sp, struct nfsv2_sattr *, NFSX_SATTR); d1141 1 a1141 1 VOP_ABORTOP(&nd); d1152 2 a1153 1 error = VOP_SYMLINK(&nd, vap, pathcp, p); d1160 1 a1160 1 VOP_ABORTOP(&nd); d1175 3 a1177 2 nfsrv_mkdir(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf *mrep, *md, **mrq; d1180 1 a1180 3 u_long xid; int *repstat; struct proc *p; d1190 1 a1190 1 int error = 0; d1196 1 a1196 1 long len; d1201 5 a1205 3 nd.ni_cred = cred; nd.ni_nameiop = CREATE | LOCKPARENT; if (error = nfs_namei(&nd, fhp, len, &md, &dpos, p)) d1207 1 a1207 1 nfsm_disect(tl, u_long *, NFSX_UNSIGNED); d1213 1 a1213 1 VOP_ABORTOP(&nd); d1222 2 a1223 1 if (error = VOP_MKDIR(&nd, vap, p)) d1232 1 a1232 1 error = VOP_GETATTR(vp, vap, cred, p); d1234 1 a1234 1 nfsm_reply(NFSX_FH+NFSX_FATTR); d1236 1 a1236 1 nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR); d1240 1 a1240 1 VOP_ABORTOP(&nd); d1253 3 a1255 2 nfsrv_rmdir(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf *mrep, *md, **mrq; d1258 1 a1258 3 u_long xid; int *repstat; struct proc *p; d1263 1 a1263 1 int error = 0; a1268 1 long len; d1270 1 d1275 5 a1279 3 nd.ni_cred = cred; nd.ni_nameiop = DELETE | LOCKPARENT | LOCKLEAF; if (error = nfs_namei(&nd, fhp, len, &md, &dpos, p)) d1300 3 a1302 1 error = VOP_RMDIR(&nd, p); d1304 1 a1304 1 VOP_ABORTOP(&nd); d1335 1 d1344 10 a1353 2 nfsrv_readdir(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf **mrq; d1357 1 a1357 3 u_long xid; int *repstat; struct proc *p; d1366 2 a1367 5 int error = 0; char *cp2; struct mbuf *mb, *mb2, *mreq; char *cpos, *cend; int len, nlen, rem, xfer, tsiz, i; a1368 1 struct mbuf *mp2, *mp3; d1373 4 a1376 4 int siz, cnt, fullsiz, eofflag; char *rbuf; off_t off; u_int *cookiebuf, *cookie; d1378 1 a1378 1 d1381 2 a1382 2 nfsm_disect(tl, u_long *, 2*NFSX_UNSIGNED); off = fxdr_unsigned(off_t, *tl++); d1388 2 a1389 2 ncookies = siz / 16; /* guess on the number of cookies needed */ if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred)) d1391 2 a1392 1 if (error = nfsrv_access(vp, VEXEC, cred, p)) { d1398 2 a1399 1 MALLOC(cookiebuf, u_int *, ncookies * sizeof(u_int), M_TEMP, M_WAITOK); d1405 1 a1405 1 io.uio_offset = off; a1409 1 d1412 1 a1412 1 off = io.uio_offset; d1415 1 a1416 1 free(cookiebuf,M_TEMP); d1446 1 a1446 1 if (cpos < rbuf || dp->d_fileno == 0) { d1457 58 d1516 129 a1644 3 len = 3*NFSX_UNSIGNED; /* paranoia, probably can be 0 */ bp = be = (caddr_t)0; mp3 = (struct mbuf *)0; d1646 3 d1657 2 a1658 3 * As noted above, the NFS spec. is not clear about what * should be included in "count" as totalled up here in * "len". d1660 26 a1685 1 len += (4*NFSX_UNSIGNED+nlen+rem); d1690 4 a1693 2 /* Build the directory record xdr from the dirent entry */ d1697 18 d1722 1 a1722 1 /* And loop arround copying the name */ d1746 1 d1751 1 d1761 5 a1765 3 if (bp < be) mp->m_len = bp-mtod(mp, caddr_t); mb->m_next = mp3; d1774 2 a1775 2 nfsrv_statfs(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf **mrq; d1779 1 a1779 3 u_long xid; int *repstat; struct proc *p; d1786 1 a1786 1 int error = 0; d1793 1 d1796 1 d1798 1 a1798 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred)) d1801 1 a1801 1 error = VFS_STATFS(vp->v_mount, sf, p); d1803 2 a1804 2 nfsm_reply(NFSX_STATFS); nfsm_build(sfp, struct nfsv2_statfs *, NFSX_STATFS); d1810 4 d1821 2 a1822 2 nfsrv_null(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf **mrq; d1826 1 a1826 3 u_long xid; int *repstat; struct proc *p; d1829 1 a1829 1 int error = 0; d1831 1 a1832 1 error = VNOVAL; d1841 2 a1842 2 nfsrv_noop(mrep, md, dpos, cred, xid, mrq, repstat, p) struct mbuf **mrq; d1846 1 a1846 3 u_long xid; int *repstat; struct proc *p; d1849 1 a1849 1 int error; d1851 1 d1853 2 a1854 2 if (*repstat) error = *repstat; d1865 1 a1865 1 * 1 - You must check for MNT_EXRDONLY as well as MNT_RDONLY for the write case d1871 1 a1871 1 nfsrv_access(vp, flags, cred, p) d1875 1 d1881 1 a1881 1 /* Just vn_writechk() changed to check MNT_EXRDONLY */ d1887 1 a1887 1 if (vp->v_mount->mnt_flag & (MNT_RDONLY | MNT_EXRDONLY)) { @ 1.13 log @patchkit date deletions! @ text @d37 1 a37 1 * $Id: nfs_serv.c,v 1.12 1994/03/12 01:31:32 cgd Exp $ d1454 1 a1454 1 sfp->sf_bsize = txdr_unsigned(sf->f_fsize); @ 1.12 log @fix rcs id @ text @d37 1 a37 1 * $Id$ d603 1 a603 1 * if it already exists, just set length * 28 Aug 92* d642 1 a642 1 * If it doesn't exist, create it * 28 Aug 92* d708 3 a710 2 vap->va_size = fxdr_unsigned(long, *(tl+3)); /* 28 Aug 92*/ /* 08 Sep 92*/ if (vap->va_size != -1 && (error = VOP_SETATTR(vp, vap, cred, p))) { d1497 1 a1497 1 int error; /* 08 Sep 92*/ d1500 1 a1500 1 if (*repstat) /* 08 Sep 92*/ @ 1.11 log @Make FFS optional @ text @d37 1 a37 1 * nfs_serv.c,v 1.7 1993/09/03 23:57:25 jtc Exp @ 1.10 log @Canonicalize all #includes. @ text @d66 1 d69 1 a69 2 #include #include d1214 1 a1214 1 * - it trims out records with d_ino == 0 d1240 1 a1240 1 register struct direct *dp; d1327 2 a1328 2 dp = (struct direct *)cpos; if (cpos < rbuf || dp->d_ino == 0) { d1347 1 a1347 1 if (dp->d_ino != 0) { d1362 1 a1362 1 /* Build the directory record xdr from the direct entry */ d1367 1 a1367 1 *tl = txdr_unsigned(dp->d_ino); d1398 1 a1398 1 dp = (struct direct *)cpos; @ 1.9 log @Bug fixes to ISOFS @ text @d58 8 a65 8 #include "param.h" #include "systm.h" #include "proc.h" #include "file.h" #include "namei.h" #include "vnode.h" #include "mount.h" #include "mbuf.h" d67 3 a69 3 #include "../ufs/quota.h" #include "../ufs/inode.h" #include "../ufs/dir.h" d71 4 a74 4 #include "nfsv2.h" #include "nfs.h" #include "xdr_subs.h" #include "nfsm_subs.h" @ 1.8 log @Changes to VFS readdir semantics NFS changes for better cookie support ISOFS changes for better Rockridge support and support for generation numbers @ text @a1256 1 u_long on; a1265 2 on = off & (NFS_DIRBLKSIZ-1); off &= ~(NFS_DIRBLKSIZ-1); d1328 1 a1328 1 if (cpos < rbuf + on || dp->d_ino == 0) { a1335 1 on = 0; @ 1.8.2.1 log @Make all files using spl*() #include cpu.h. Changes from trunk. nfs_vfsops.c, nfsmount.h: Make nfs_quotactl() take an int rather than a uid_t, as it might be -1. nfs_vnops.c: va_size and va_bytes are now quads. @ text @a66 2 #include "machine/cpu.h" @ 1.8.2.2 log @Canonicalize all #includes. @ text @d58 8 a65 8 #include #include #include #include #include #include #include #include d67 1 a67 3 #include #include #include d69 3 a71 1 #include d73 4 a76 4 #include #include #include #include @ 1.8.2.3 log @Merge changes from trunk. @ text @d1259 1 d1269 2 d1333 1 a1333 1 if (cpos < rbuf || dp->d_ino == 0) { d1341 1 @ 1.7 log @Include systm.h to get prototypes (and possibly inlines) of *max functions. @ text @d37 1 a37 1 * $Id: nfs_serv.c,v 1.6 1993/07/16 00:52:50 cgd Exp $ d1259 4 a1262 2 off_t off, toff; d1266 3 a1268 3 toff = fxdr_unsigned(off_t, *tl++); off = (toff & ~(NFS_DIRBLKSIZ-1)); on = (toff & (NFS_DIRBLKSIZ-1)); d1274 1 d1283 1 d1294 3 a1296 1 error = VOP_READDIR(vp, &io, cred, &eofflag); d1301 1 d1317 1 d1327 1 a1327 1 cpos = rbuf + on; d1329 1 a1329 3 dp = (struct direct *)cpos; while (cpos < cend && dp->d_ino == 0) { cpos += dp->d_reclen; d1331 5 a1337 1 toff = off; a1342 3 cpos = rbuf + on; cend = rbuf + siz; dp = (struct direct *)cpos; d1398 1 a1398 2 toff += dp->d_reclen; *tl = txdr_unsigned(toff); d1400 1 a1400 2 } else toff += dp->d_reclen; d1403 1 d1417 1 @ 1.6 log @ANSI mods. (originally committed by andrew on 1993/06/27 06:58:35) @ text @d37 1 a37 1 * $Id: nfs_serv.c,v 1.6 1993/06/27 06:58:35 andrew Exp $ d59 1 @ 1.5 log @fix for macklem's bogus use of the va_flags field, supplied by John Woods, jfwfrom: @@ksr.com. also, fixes the following problems: the va_gen field is in a similar position (Suns are going to be reporting the change-date microseconds as their "generation"), I've supplied my own set of diffs below for your inspection. Note these aren't even compiled, but they're pretty similar to what I had to do to our older version of OSF/1 here. (There's also an unrelated change supplied for xdr_subs.h; the pointer types supplied to the fxdr_time() and txdr_time() macros are not, in fact, both struct timevals. That turns out to be one of many tips-of-the-iceberg facing those porting the (old) Berkeley NFS code to 64-bit machines...) (originally committed by cgd on 1993/06/03 01:12:42) @ text @d37 1 a37 1 * $Id: nfs_serv.c,v 1.5 1993/06/03 01:12:42 cgd Exp $ d667 1 a667 1 } else if (error = suser(cred, (short *)0)) { d776 1 a776 1 (error = suser(cred, (short *)0))) @ 1.4 log @more rcs id adding and header cleanup. i like vi macros! (originally committed by cgd on 1993/05/20 03:18:44) @ text @d37 1 a37 1 * $Id: nfs_serv.c,v 1.4 1993/05/20 03:18:44 cgd Exp $ d214 4 d219 1 d226 4 @ 1.3 log @migrated code to make split possible @ text @d36 2 a37 10 * @@(#)nfs_serv.c 7.40 (Berkeley) 5/15/91 * * PATCHES MAGIC LEVEL PATCH THAT GOT US HERE * -------------------- ----- ---------------------- * CURRENT PATCH LEVEL: 3 00090 * -------------------- ----- ---------------------- * * 08 Sep 92 Rick "gopher I" Fix "truncate" (conflicting?) * 28 Aug 92 Arne Henrik Juul Fixed NFS "create" bug * 02 Mar 92 Greg Hackney Make NFS POSIX compliant (anon fix) @ 1.2 log @after 0.2.2 "stable" patches applied @ text @d94 38 @ 1.1 log @Initial revision @ text @d37 9 d377 2 a378 1 if (error = nfsrv_access(vp, VREAD | VEXEC, cred, p)) { d563 2 a564 1 * now does a truncate to 0 length via. setattr if it already exists d602 2 a603 2 * Iff doesn't exist, create it * otherwise just truncate to 0 length d668 2 a669 2 vap->va_size = 0; if (error = VOP_SETATTR(vp, vap, cred, p)) { d1453 1 a1453 1 int error = 0; d1456 4 a1459 1 error = EPROCUNAVAIL; @ 1.1.1.1 log @initial import of 386bsd-0.1 sources @ text @@ 1.1.1.2 log @Import 4.4BSD-Lite for reference @ text @d2 2 a3 2 * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. d36 1 a36 1 * @@(#)nfs_serv.c 8.3 (Berkeley) 1/12/94 d57 16 a72 19 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include d82 1 a82 1 nfstype nfs_type[9] = { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFNON, a85 38 * nqnfs access service */ nqnfsrv_access(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; { struct vnode *vp; nfsv2fh_t nfh; fhandle_t *fhp; register u_long *tl; register long t1; caddr_t bpos; int error = 0, rdonly, cache, mode = 0; char *cp2; struct mbuf *mb, *mreq; u_quad_t frev; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); nfsm_dissect(tl, u_long *, 3 * NFSX_UNSIGNED); if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) nfsm_reply(0); if (*tl++ == nfs_true) mode |= VREAD; if (*tl++ == nfs_true) mode |= VWRITE; if (*tl == nfs_true) mode |= VEXEC; error = nfsrv_access(vp, mode, cred, rdonly, nfsd->nd_procp); vput(vp); nfsm_reply(0); nfsm_srvdone; } /* d88 2 a89 2 nfsrv_getattr(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; d93 3 a95 1 struct mbuf *nam, **mrq; d106 1 a106 1 int error = 0, rdonly, cache; a108 1 u_quad_t frev; d112 1 a112 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d114 1 a114 2 nqsrv_getl(vp, NQL_READ); error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp); d116 2 a117 2 nfsm_reply(NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); d125 2 a126 2 nfsrv_setattr(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; d130 3 a132 1 struct mbuf *nam, **mrq; d144 1 a144 1 int error = 0, rdonly, cache; a146 1 u_quad_t frev, frev2; d150 2 a151 2 nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_SATTR(nfsd->nd_nqlflag != NQL_NOVAL)); if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d153 2 a154 1 nqsrv_getl(vp, NQL_WRITE); d169 2 a170 21 if (nfsd->nd_nqlflag == NQL_NOVAL) { if (sp->sa_nfssize != nfs_xdrneg1) vap->va_size = fxdr_unsigned(u_quad_t, sp->sa_nfssize); if (sp->sa_nfsatime.nfs_sec != nfs_xdrneg1) { #ifdef notyet fxdr_nfstime(&sp->sa_nfsatime, &vap->va_atime); #else vap->va_atime.ts_sec = fxdr_unsigned(long, sp->sa_nfsatime.nfs_sec); vap->va_atime.ts_nsec = 0; #endif } if (sp->sa_nfsmtime.nfs_sec != nfs_xdrneg1) fxdr_nfstime(&sp->sa_nfsmtime, &vap->va_mtime); } else { fxdr_hyper(&sp->sa_nqsize, &vap->va_size); fxdr_nqtime(&sp->sa_nqatime, &vap->va_atime); fxdr_nqtime(&sp->sa_nqmtime, &vap->va_mtime); vap->va_flags = fxdr_unsigned(u_long, sp->sa_nqflags); } d172 3 a174 2 * If the size is being changed write acces is required, otherwise * just check for a read only file system. d176 9 a184 14 if (vap->va_size == ((u_quad_t)((quad_t) -1))) { if (rdonly || (vp->v_mount->mnt_flag & MNT_RDONLY)) { error = EROFS; goto out; } } else { if (vp->v_type == VDIR) { error = EISDIR; goto out; } else if (error = nfsrv_access(vp, VWRITE, cred, rdonly, nfsd->nd_procp)) goto out; } if (error = VOP_SETATTR(vp, vap, cred, nfsd->nd_procp)) { d188 1 a188 1 error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp); d191 2 a192 2 nfsm_reply(NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL) + 2*NFSX_UNSIGNED); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); a193 4 if (nfsd->nd_nqlflag != NQL_NOVAL) { nfsm_build(tl, u_long *, 2*NFSX_UNSIGNED); txdr_hyper(&frev2, tl); } d200 2 a201 2 nfsrv_lookup(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; d205 3 a207 1 struct mbuf *nam, **mrq; d218 1 a218 1 int error = 0, cache, duration2, cache2, len; d221 1 a222 1 u_quad_t frev, frev2; a224 5 duration2 = 0; if (nfsd->nd_nqlflag != NQL_NOVAL) { nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); duration2 = fxdr_unsigned(int, *tl); } d227 3 a229 5 nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags = LOCKLEAF | SAVESTART; if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) a230 3 nqsrv_getl(nd.ni_startdir, NQL_READ); vrele(nd.ni_startdir); FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); d238 1 a238 4 if (duration2) (void) nqsrv_getlease(vp, &duration2, NQL_READ, nfsd, nam, &cache2, &frev2, cred); error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp); d240 1 a240 13 nfsm_reply(NFSX_FH + NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL) + 5*NFSX_UNSIGNED); if (nfsd->nd_nqlflag != NQL_NOVAL) { if (duration2) { nfsm_build(tl, u_long *, 5*NFSX_UNSIGNED); *tl++ = txdr_unsigned(NQL_READ); *tl++ = txdr_unsigned(cache2); *tl++ = txdr_unsigned(duration2); txdr_hyper(&frev2, tl); } else { nfsm_build(tl, u_long *, NFSX_UNSIGNED); *tl = 0; } } d242 1 a242 1 nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); d250 2 a251 2 nfsrv_readlink(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; d255 3 a257 1 struct mbuf *nam, **mrq; d265 1 a265 1 int error = 0, rdonly, cache, i, tlen, len; d272 1 a272 1 u_quad_t frev; d305 1 a305 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) { a312 1 nqsrv_getl(vp, NQL_READ); d333 2 a334 2 nfsrv_read(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; d338 3 a340 1 struct mbuf *nam, **mrq; d349 1 a349 1 int error = 0, rdonly, cache, i, cnt, len, left, siz, tlen; d352 1 a352 1 struct mbuf *m2; d358 1 a359 1 u_quad_t frev; d363 2 a364 7 if (nfsd->nd_nqlflag == NQL_NOVAL) { nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); off = (off_t)fxdr_unsigned(u_long, *tl); } else { nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); fxdr_hyper(tl, &off); } d366 1 a366 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d368 1 a368 2 if (vp->v_type != VREG) { error = (vp->v_type == VDIR) ? EISDIR : EACCES; d372 30 a401 5 nqsrv_getl(vp, NQL_READ); if ((error = nfsrv_access(vp, VREAD, cred, rdonly, nfsd->nd_procp)) && (error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp))) { vput(vp); nfsm_reply(0); d403 12 a414 1 if (error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp)) { d418 2 a419 53 if (off >= vap->va_size) cnt = 0; else if ((off + cnt) > vap->va_size) cnt = nfsm_rndup(vap->va_size - off); nfsm_reply(NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)+NFSX_UNSIGNED+nfsm_rndup(cnt)); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_build(tl, u_long *, NFSX_UNSIGNED); len = left = cnt; if (cnt > 0) { /* * Generate the mbuf list with the uio_iov ref. to it. */ i = 0; m = m2 = mb; MALLOC(iv, struct iovec *, ((NFS_MAXDATA+MLEN-1)/MLEN) * sizeof (struct iovec), M_TEMP, M_WAITOK); iv2 = iv; while (left > 0) { siz = min(M_TRAILINGSPACE(m), left); if (siz > 0) { m->m_len += siz; iv->iov_base = bpos; iv->iov_len = siz; iv++; i++; left -= siz; } if (left > 0) { MGET(m, M_WAIT, MT_DATA); MCLGET(m, M_WAIT); m->m_len = 0; m2->m_next = m; m2 = m; bpos = mtod(m, caddr_t); } } uiop->uio_iov = iv2; uiop->uio_iovcnt = i; uiop->uio_offset = off; uiop->uio_resid = cnt; uiop->uio_rw = UIO_READ; uiop->uio_segflg = UIO_SYSSPACE; error = VOP_READ(vp, uiop, IO_NODELOCKED, cred); off = uiop->uio_offset; FREE((caddr_t)iv2, M_TEMP); if (error || (error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp))) { m_freem(mreq); vput(vp); nfsm_reply(0); } } else uiop->uio_resid = 0; d421 2 d425 9 a433 3 tlen = nfsm_rndup(len); if (cnt != tlen || tlen != len) nfsm_adj(mb, cnt-tlen, tlen-len); d435 1 d442 2 a443 3 nfsrv_write(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; d446 3 a448 1 struct mbuf *nam, **mrq; d459 1 a459 2 int error = 0, rdonly, cache, siz, len, xfer; int ioflags = IO_SYNC | IO_NODELOCKED; d467 1 a467 1 u_quad_t frev; d471 3 a473 10 nfsm_dissect(tl, u_long *, 4 * NFSX_UNSIGNED); if (nfsd->nd_nqlflag == NQL_NOVAL) { off = (off_t)fxdr_unsigned(u_long, *++tl); tl += 2; } else { fxdr_hyper(tl, &off); tl += 2; if (fxdr_unsigned(u_long, *tl++)) ioflags |= IO_APPEND; } d491 1 a491 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d493 1 a493 7 if (vp->v_type != VREG) { error = (vp->v_type == VDIR) ? EISDIR : EACCES; vput(vp); nfsm_reply(0); } nqsrv_getl(vp, NQL_WRITE); if (error = nfsrv_access(vp, VWRITE, cred, rdonly, nfsd->nd_procp)) { d536 2 a537 1 if (error = VOP_WRITE(vp, uiop, ioflags, cred)) { d543 1 a543 1 error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp); d545 2 a546 2 nfsm_reply(NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); a547 4 if (nfsd->nd_nqlflag != NQL_NOVAL) { nfsm_build(tl, u_long *, 2*NFSX_UNSIGNED); txdr_hyper(&vap->va_filerev, tl); } d555 2 a556 3 nfsrv_create(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; d559 3 a561 1 struct mbuf *nam, **mrq; a565 2 register struct nfsv2_sattr *sp; register u_long *tl; d568 1 d571 2 a572 1 int error = 0, rdev, cache, len, tsize; d578 1 a578 1 u_quad_t frev; d580 1 a580 1 nd.ni_cnd.cn_nameiop = 0; d584 3 a586 5 nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART; if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d589 1 a589 1 nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_SATTR(nfsd->nd_nqlflag != NQL_NOVAL)); d596 1 a596 1 vap->va_type = IFTOVT(fxdr_unsigned(u_long, sp->sa_mode)); d599 2 a600 5 vap->va_mode = nfstov_mode(sp->sa_mode); if (nfsd->nd_nqlflag == NQL_NOVAL) rdev = fxdr_unsigned(long, sp->sa_nfssize); else rdev = fxdr_unsigned(long, sp->sa_nqrdev); d603 1 a603 2 nqsrv_getl(nd.ni_dvp, NQL_WRITE); if (error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) d605 1 a605 1 FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); d612 1 a612 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d617 2 a618 2 } else if (error = suser(cred, (u_short *)0)) { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d623 1 a623 2 nqsrv_getl(nd.ni_dvp, NQL_WRITE); if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) { d627 4 a630 6 nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART); nd.ni_cnd.cn_proc = nfsd->nd_procp; nd.ni_cnd.cn_cred = nfsd->nd_procp->p_ucred; if (error = lookup(&nd)) { free(nd.ni_cnd.cn_pnbuf, M_NAMEI); d633 2 a634 2 FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); if (nd.ni_cnd.cn_flags & ISSYMLINK) { d637 1 a637 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d642 1 a642 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d650 1 a650 1 free(nd.ni_cnd.cn_pnbuf, M_NAMEI); d656 5 a660 20 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nfsd->nd_nqlflag == NQL_NOVAL) { tsize = fxdr_unsigned(long, sp->sa_nfssize); if (tsize != -1) vap->va_size = (u_quad_t)tsize; else vap->va_size = -1; } else fxdr_hyper(&sp->sa_nqsize, &vap->va_size); if (vap->va_size != -1) { if (error = nfsrv_access(vp, VWRITE, cred, (nd.ni_cnd.cn_flags & RDONLY), nfsd->nd_procp)) { vput(vp); nfsm_reply(0); } nqsrv_getl(vp, NQL_WRITE); if (error = VOP_SETATTR(vp, vap, cred, nfsd->nd_procp)) { vput(vp); nfsm_reply(0); } d669 1 a669 1 error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp); d671 1 a671 1 nfsm_reply(NFSX_FH+NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); d673 1 a673 1 nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); d677 1 a677 1 if (nd.ni_cnd.cn_nameiop || nd.ni_cnd.cn_flags) d679 1 a679 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d690 1 a690 1 free(nd.ni_cnd.cn_pnbuf, M_NAMEI); d697 2 a698 3 nfsrv_remove(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; d701 3 a703 1 struct mbuf *nam, **mrq; d709 1 a709 1 int error = 0, cache, len; d715 1 a715 1 u_quad_t frev; d720 3 a722 5 nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = DELETE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d726 1 a726 1 (error = suser(cred, (u_short *)0))) d739 1 a739 3 nqsrv_getl(nd.ni_dvp, NQL_WRITE); nqsrv_getl(vp, NQL_WRITE); error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); d741 1 a741 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d755 2 a756 3 nfsrv_rename(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; d759 3 a761 1 struct mbuf *nam, **mrq; d766 1 a766 1 int error = 0, cache, len, len2; d773 2 a774 2 u_quad_t frev; uid_t saved_uid; d778 2 a779 2 fromnd.ni_cnd.cn_nameiop = 0; tond.ni_cnd.cn_nameiop = 0; d783 2 a784 2 * Remember our original uid so that we can reset cr_uid before * the second nfs_namei() call, in case it is remapped. d786 5 a790 6 saved_uid = cred->cr_uid; fromnd.ni_cnd.cn_cred = cred; fromnd.ni_cnd.cn_nameiop = DELETE; fromnd.ni_cnd.cn_flags = WANTPARENT | SAVESTART; if (error = nfs_namei(&fromnd, ffhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d795 7 a801 7 cred->cr_uid = saved_uid; tond.ni_cnd.cn_cred = cred; tond.ni_cnd.cn_nameiop = RENAME; tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART; if (error = nfs_namei(&tond, tfhp, len2, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) { VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); a815 8 if (tvp->v_type == VDIR && tvp->v_mountedhere) { error = EXDEV; goto out; } } if (fvp->v_type == VDIR && fvp->v_mountedhere) { error = EBUSY; goto out; d829 2 a830 3 fromnd.ni_cnd.cn_namelen == tond.ni_cnd.cn_namelen && !bcmp(fromnd.ni_cnd.cn_nameptr, tond.ni_cnd.cn_nameptr, fromnd.ni_cnd.cn_namelen)) d834 1 a834 6 nqsrv_getl(fromnd.ni_dvp, NQL_WRITE); nqsrv_getl(tdvp, NQL_WRITE); if (tvp) nqsrv_getl(tvp, NQL_WRITE); error = VOP_RENAME(fromnd.ni_dvp, fromnd.ni_vp, &fromnd.ni_cnd, tond.ni_dvp, tond.ni_vp, &tond.ni_cnd); d836 1 a836 1 VOP_ABORTOP(tond.ni_dvp, &tond.ni_cnd); d843 1 a843 1 VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); d848 1 a848 1 FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI); d851 1 a851 1 FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI); d856 1 a856 1 if (tond.ni_cnd.cn_nameiop || tond.ni_cnd.cn_flags) { d858 1 a858 1 FREE(tond.ni_cnd.cn_pnbuf, M_NAMEI); d860 1 a860 1 if (fromnd.ni_cnd.cn_nameiop || fromnd.ni_cnd.cn_flags) { d862 2 a863 2 FREE(fromnd.ni_cnd.cn_pnbuf, M_NAMEI); VOP_ABORTOP(fromnd.ni_dvp, &fromnd.ni_cnd); d873 2 a874 3 nfsrv_link(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; d877 3 a879 1 struct mbuf *nam, **mrq; d885 1 a885 1 int error = 0, rdonly, cache, len; d891 1 a891 1 u_quad_t frev; d898 1 a898 1 if (error = nfsrv_fhtovp(fhp, FALSE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d900 1 a900 1 if (vp->v_type == VDIR && (error = suser(cred, (u_short *)0))) d902 3 a904 5 nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT; if (error = nfs_namei(&nd, dfhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d916 1 a916 3 nqsrv_getl(vp, NQL_WRITE); nqsrv_getl(xp, NQL_WRITE); error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); d918 1 a918 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d935 2 a936 3 nfsrv_symlink(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; d939 3 a941 1 struct mbuf *nam, **mrq; d952 1 a952 1 int error = 0, cache, len, len2; d957 1 a957 1 u_quad_t frev; d963 3 a965 5 nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT; if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d979 1 a979 1 nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_SATTR(nfsd->nd_nqlflag != NQL_NOVAL)); d982 1 a982 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d993 1 a993 2 nqsrv_getl(nd.ni_dvp, NQL_WRITE); error = VOP_SYMLINK(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap, pathcp); d1000 1 a1000 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d1015 2 a1016 3 nfsrv_mkdir(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; d1019 3 a1021 1 struct mbuf *nam, **mrq; d1031 1 a1031 1 int error = 0, cache, len; d1037 1 a1037 1 u_quad_t frev; d1042 3 a1044 5 nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT; if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d1046 1 a1046 1 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); d1052 1 a1052 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d1061 1 a1061 2 nqsrv_getl(nd.ni_dvp, NQL_WRITE); if (error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) d1070 1 a1070 1 error = VOP_GETATTR(vp, vap, cred, nfsd->nd_procp); d1072 1 a1072 1 nfsm_reply(NFSX_FH+NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); d1074 1 a1074 1 nfsm_build(fp, struct nfsv2_fattr *, NFSX_FATTR(nfsd->nd_nqlflag != NQL_NOVAL)); d1078 1 a1078 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d1091 2 a1092 3 nfsrv_rmdir(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; d1095 3 a1097 1 struct mbuf *nam, **mrq; d1102 1 a1102 1 int error = 0, cache, len; d1108 1 a1109 1 u_quad_t frev; d1114 3 a1116 5 nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = DELETE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; if (error = nfs_namei(&nd, fhp, len, nfsd->nd_slp, nam, &md, &dpos, nfsd->nd_procp)) d1137 1 a1137 3 nqsrv_getl(nd.ni_dvp, NQL_WRITE); nqsrv_getl(vp, NQL_WRITE); error = VOP_RMDIR(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); d1139 1 a1139 1 VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); d1163 1 a1163 1 * - it trims out records with d_fileno == 0 a1169 1 * The alternate call nqnfsrv_readdirlook() does lookups as well. d1178 2 a1179 10 struct flrep { u_long fl_cachable; u_long fl_duration; u_long fl_frev[2]; nfsv2fh_t fl_nfh; u_long fl_fattr[NFSX_NQFATTR / sizeof (u_long)]; }; nfsrv_readdir(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; d1183 3 a1185 1 struct mbuf *nam, **mrq; d1189 1 a1189 1 register struct dirent *dp; d1194 5 a1198 2 struct mbuf *mb, *mb2, *mreq, *mp2; char *cpos, *cend, *cp2, *rbuf; d1200 1 d1205 4 a1208 4 int len, nlen, rem, xfer, tsiz, i, error = 0; int siz, cnt, fullsiz, eofflag, rdonly, cache; u_quad_t frev; u_long on, off, toff; d1212 2 a1213 2 nfsm_dissect(tl, u_long *, 2*NFSX_UNSIGNED); toff = fxdr_unsigned(u_long, *tl++); d1221 1 a1221 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d1223 1 a1223 2 nqsrv_getl(vp, NQL_READ); if (error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp)) { d1234 1 a1234 1 io.uio_offset = (off_t)off; d1239 2 a1240 2 error = VOP_READDIR(vp, &io, cred); off = (off_t)io.uio_offset; a1245 4 if (io.uio_resid < fullsiz) eofflag = 0; else eofflag = 1; d1270 2 a1271 2 dp = (struct dirent *)cpos; while (cpos < cend && dp->d_fileno == 0) { d1273 1 a1273 1 dp = (struct dirent *)cpos; d1284 2 a1285 1 dp = (struct dirent *)cpos; d1287 2 a1289 3 mp = mp2 = mb; bp = bpos; be = bp + M_TRAILINGSPACE(mp); d1293 1 a1293 189 if (dp->d_fileno != 0) { nlen = dp->d_namlen; rem = nfsm_rndup(nlen)-nlen; len += (4*NFSX_UNSIGNED + nlen + rem); if (len > cnt) { eofflag = 0; break; } /* * Build the directory record xdr from * the dirent entry. */ nfsm_clget; *tl = nfs_true; bp += NFSX_UNSIGNED; nfsm_clget; *tl = txdr_unsigned(dp->d_fileno); bp += NFSX_UNSIGNED; nfsm_clget; *tl = txdr_unsigned(nlen); bp += NFSX_UNSIGNED; /* And loop around copying the name */ xfer = nlen; cp = dp->d_name; while (xfer > 0) { nfsm_clget; if ((bp+xfer) > be) tsiz = be-bp; else tsiz = xfer; bcopy(cp, bp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } /* And null pad to a long boundary */ for (i = 0; i < rem; i++) *bp++ = '\0'; nfsm_clget; /* Finish off the record */ toff += dp->d_reclen; *tl = txdr_unsigned(toff); bp += NFSX_UNSIGNED; } else toff += dp->d_reclen; cpos += dp->d_reclen; dp = (struct dirent *)cpos; } vrele(vp); nfsm_clget; *tl = nfs_false; bp += NFSX_UNSIGNED; nfsm_clget; if (eofflag) *tl = nfs_true; else *tl = nfs_false; bp += NFSX_UNSIGNED; if (mp != mb) { if (bp < be) mp->m_len = bp - mtod(mp, caddr_t); } else mp->m_len += bp - bpos; FREE(rbuf, M_TEMP); nfsm_srvdone; } nqnfsrv_readdirlook(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; struct mbuf *mrep, *md; caddr_t dpos; struct ucred *cred; struct mbuf *nam, **mrq; { register char *bp, *be; register struct mbuf *mp; register struct dirent *dp; register caddr_t cp; register u_long *tl; register long t1; caddr_t bpos; struct mbuf *mb, *mb2, *mreq, *mp2; char *cpos, *cend, *cp2, *rbuf; struct vnode *vp, *nvp; struct flrep fl; nfsv2fh_t nfh; fhandle_t *fhp; struct uio io; struct iovec iv; struct vattr va, *vap = &va; struct nfsv2_fattr *fp; int len, nlen, rem, xfer, tsiz, i, error = 0, duration2, cache2; int siz, cnt, fullsiz, eofflag, rdonly, cache; u_quad_t frev, frev2; u_long on, off, toff; fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); nfsm_dissect(tl, u_long *, 3*NFSX_UNSIGNED); toff = fxdr_unsigned(u_long, *tl++); off = (toff & ~(NFS_DIRBLKSIZ-1)); on = (toff & (NFS_DIRBLKSIZ-1)); cnt = fxdr_unsigned(int, *tl++); duration2 = fxdr_unsigned(int, *tl); siz = ((cnt+NFS_DIRBLKSIZ-1) & ~(NFS_DIRBLKSIZ-1)); if (cnt > NFS_MAXREADDIR) siz = NFS_MAXREADDIR; fullsiz = siz; if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) nfsm_reply(0); nqsrv_getl(vp, NQL_READ); if (error = nfsrv_access(vp, VEXEC, cred, rdonly, nfsd->nd_procp)) { vput(vp); nfsm_reply(0); } VOP_UNLOCK(vp); MALLOC(rbuf, caddr_t, siz, M_TEMP, M_WAITOK); again: iv.iov_base = rbuf; iv.iov_len = fullsiz; io.uio_iov = &iv; io.uio_iovcnt = 1; io.uio_offset = (off_t)off; io.uio_resid = fullsiz; io.uio_segflg = UIO_SYSSPACE; io.uio_rw = UIO_READ; io.uio_procp = (struct proc *)0; error = VOP_READDIR(vp, &io, cred); off = (u_long)io.uio_offset; if (error) { vrele(vp); free((caddr_t)rbuf, M_TEMP); nfsm_reply(0); } if (io.uio_resid < fullsiz) eofflag = 0; else eofflag = 1; if (io.uio_resid) { siz -= io.uio_resid; /* * If nothing read, return eof * rpc reply */ if (siz == 0) { vrele(vp); nfsm_reply(2 * NFSX_UNSIGNED); nfsm_build(tl, u_long *, 2 * NFSX_UNSIGNED); *tl++ = nfs_false; *tl = nfs_true; FREE((caddr_t)rbuf, M_TEMP); return (0); } } /* * Check for degenerate cases of nothing useful read. * If so go try again */ cpos = rbuf + on; cend = rbuf + siz; dp = (struct dirent *)cpos; while (cpos < cend && dp->d_fileno == 0) { cpos += dp->d_reclen; dp = (struct dirent *)cpos; } if (cpos >= cend) { toff = off; siz = fullsiz; on = 0; goto again; } cpos = rbuf + on; cend = rbuf + siz; dp = (struct dirent *)cpos; len = 3 * NFSX_UNSIGNED; /* paranoia, probably can be 0 */ nfsm_reply(siz); mp = mp2 = mb; bp = bpos; be = bp + M_TRAILINGSPACE(mp); /* Loop through the records and build reply */ while (cpos < cend) { if (dp->d_fileno != 0) { d1298 3 a1300 2 * For readdir_and_lookup get the vnode using * the file number. d1302 1 a1302 26 if (VFS_VGET(vp->v_mount, dp->d_fileno, &nvp)) goto invalid; bzero((caddr_t)&fl.fl_nfh, sizeof (nfsv2fh_t)); fl.fl_nfh.fh_generic.fh_fsid = nvp->v_mount->mnt_stat.f_fsid; if (VFS_VPTOFH(nvp, &fl.fl_nfh.fh_generic.fh_fid)) { vput(nvp); goto invalid; } if (duration2) { (void) nqsrv_getlease(nvp, &duration2, NQL_READ, nfsd, nam, &cache2, &frev2, cred); fl.fl_duration = txdr_unsigned(duration2); fl.fl_cachable = txdr_unsigned(cache2); txdr_hyper(&frev2, fl.fl_frev); } else fl.fl_duration = 0; if (VOP_GETATTR(nvp, vap, cred, nfsd->nd_procp)) { vput(nvp); goto invalid; } vput(nvp); fp = (struct nfsv2_fattr *)&fl.fl_fattr; nfsm_srvfillattr; len += (4*NFSX_UNSIGNED + nlen + rem + NFSX_FH + NFSX_NQFATTR); d1307 2 a1308 4 /* * Build the directory record xdr from * the dirent entry. */ a1311 18 /* * For readdir_and_lookup copy the stuff out. */ xfer = sizeof (struct flrep); cp = (caddr_t)&fl; while (xfer > 0) { nfsm_clget; if ((bp+xfer) > be) tsiz = be-bp; else tsiz = xfer; bcopy(cp, bp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } d1313 1 a1313 1 *tl = txdr_unsigned(dp->d_fileno); d1319 1 a1319 1 /* And loop around copying the name */ a1343 1 invalid: d1346 1 a1346 1 dp = (struct dirent *)cpos; a1347 1 vrele(vp); d1357 3 a1359 5 if (mp != mb) { if (bp < be) mp->m_len = bp - mtod(mp, caddr_t); } else mp->m_len += bp - bpos; d1367 2 a1368 2 nfsrv_statfs(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; d1372 3 a1374 1 struct mbuf *nam, **mrq; d1381 1 a1381 1 int error = 0, rdonly, cache, isnq; a1387 1 u_quad_t frev; a1389 1 isnq = (nfsd->nd_nqlflag != NQL_NOVAL); d1391 1 a1391 1 if (error = nfsrv_fhtovp(fhp, TRUE, &vp, cred, nfsd->nd_slp, nam, &rdonly)) d1394 1 a1394 1 error = VFS_STATFS(vp->v_mount, sf, nfsd->nd_procp); d1396 2 a1397 2 nfsm_reply(NFSX_STATFS(isnq)); nfsm_build(sfp, struct nfsv2_statfs *, NFSX_STATFS(isnq)); d1399 1 a1399 1 sfp->sf_bsize = txdr_unsigned(sf->f_bsize); a1402 4 if (isnq) { sfp->sf_files = txdr_unsigned(sf->f_files); sfp->sf_ffree = txdr_unsigned(sf->f_ffree); } d1410 2 a1411 2 nfsrv_null(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; d1415 3 a1417 1 struct mbuf *nam, **mrq; d1420 1 a1420 1 int error = VNOVAL, cache; a1421 1 u_quad_t frev; d1423 1 d1432 2 a1433 2 nfsrv_noop(nfsd, mrep, md, dpos, cred, nam, mrq) struct nfsd *nfsd; d1437 3 a1439 1 struct mbuf *nam, **mrq; d1442 1 a1442 1 int error, cache; a1443 1 u_quad_t frev; d1445 1 a1445 4 if (nfsd->nd_repstat) error = nfsd->nd_repstat; else error = EPROCUNAVAIL; d1454 1 a1454 1 * 1 - You must check for exported rdonly as well as MNT_RDONLY for the write case d1460 1 a1460 1 nfsrv_access(vp, flags, cred, rdonly, p) a1463 1 int rdonly; d1469 1 a1469 1 /* Just vn_writechk() changed to check rdonly */ d1475 1 a1475 1 if (rdonly || (vp->v_mount->mnt_flag & MNT_RDONLY)) { @ 1.1.1.3 log @Import 4.4BSD-Lite2 @ text @d36 1 a36 1 * @@(#)nfs_serv.c 8.7 (Berkeley) 5/14/95 d40 1 a40 1 * nfs version 2 and 3 server calls to vnode ops a54 2 * For Version 3, nfsm_reply() does not return for the error case, since * most version 3 rpcs return more than the status for error cases. a63 2 #include #include a66 2 #include #include d70 1 a70 1 #include d77 4 d82 1 d85 1 a85 3 extern enum vtype nv3tov_type[8]; extern struct nfsstats nfsstats; nfstype nfsv2_type[9] = { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFNON, a86 3 nfstype nfsv3_type[9] = { NFNON, NFREG, NFDIR, NFBLK, NFCHR, NFLNK, NFSOCK, NFFIFO, NFNON }; int nfsrvw_procrastinate = NFS_GATHERDELAY * 1000; d89 1 a89 1 * nfs v3 access service d91 6 a96 6 int nfsrv3_access(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; a97 4 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; d99 1 a99 1 nfsfh_t nfh; d104 1 a104 1 int error = 0, rdonly, cache, getret; d106 1 a106 3 struct mbuf *mb, *mreq, *mb2; struct vattr vattr, *vap = &vattr; u_long testmode, nfsmode; a108 3 #ifndef nolint cache = 0; #endif d111 10 a120 27 nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); if (error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH))) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(1, (struct vattr *)0); return (0); } nfsmode = fxdr_unsigned(u_long, *tl); if ((nfsmode & NFSV3ACCESS_READ) && nfsrv_access(vp, VREAD, cred, rdonly, procp)) nfsmode &= ~NFSV3ACCESS_READ; if (vp->v_type == VDIR) testmode = (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND | NFSV3ACCESS_DELETE); else testmode = (NFSV3ACCESS_MODIFY | NFSV3ACCESS_EXTEND); if ((nfsmode & testmode) && nfsrv_access(vp, VWRITE, cred, rdonly, procp)) nfsmode &= ~testmode; if (vp->v_type == VDIR) testmode = NFSV3ACCESS_LOOKUP; else testmode = NFSV3ACCESS_EXECUTE; if ((nfsmode & testmode) && nfsrv_access(vp, VEXEC, cred, rdonly, procp)) nfsmode &= ~testmode; getret = VOP_GETATTR(vp, vap, cred, procp); d122 1 a122 4 nfsm_reply(NFSX_POSTOPATTR(1) + NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, vap); nfsm_build(tl, u_long *, NFSX_UNSIGNED); *tl = txdr_unsigned(nfsmode); d129 6 a134 6 int nfsrv_getattr(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; d136 1 a136 5 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; register struct nfs_fattr *fp; d140 1 a140 1 nfsfh_t nfh; d152 1 a152 2 if (error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH))) { d154 2 a155 4 return (0); } nqsrv_getl(vp, ND_READ); error = VOP_GETATTR(vp, vap, cred, procp); d157 3 a159 5 nfsm_reply(NFSX_FATTR(nfsd->nd_flag & ND_NFSV3)); if (error) return (0); nfsm_build(fp, struct nfs_fattr *, NFSX_FATTR(nfsd->nd_flag & ND_NFSV3)); nfsm_srvfillattr(vap, fp); d166 6 a171 6 int nfsrv_setattr(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; d173 1 a173 5 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct vattr va, preat; d176 1 a176 1 register struct nfs_fattr *fp; d178 1 a178 1 nfsfh_t nfh; d183 1 a183 2 int error = 0, rdonly, cache, preat_ret = 1, postat_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3), gcheck = 0; d186 1 a186 2 u_quad_t frev; struct timespec guard; d190 4 d195 17 a211 26 if (v3) { nfsm_srvsattr(vap); nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); gcheck = fxdr_unsigned(int, *tl); if (gcheck) { nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); fxdr_nfsv3time(tl, &guard); } } else { nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); /* * Nah nah nah nah na nah * There is a bug in the Sun client that puts 0xffff in the mode * field of sattr when it should put in 0xffffffff. The u_short * doesn't sign extend. * --> check the low order 2 bytes for 0xffff */ if ((fxdr_unsigned(int, sp->sa_mode) & 0xffff) != 0xffff) vap->va_mode = nfstov_mode(sp->sa_mode); if (sp->sa_uid != nfs_xdrneg1) vap->va_uid = fxdr_unsigned(uid_t, sp->sa_uid); if (sp->sa_gid != nfs_xdrneg1) vap->va_gid = fxdr_unsigned(gid_t, sp->sa_gid); if (sp->sa_size != nfs_xdrneg1) vap->va_size = fxdr_unsigned(u_quad_t, sp->sa_size); if (sp->sa_atime.nfsv2_sec != nfs_xdrneg1) { d213 1 a213 1 fxdr_nfsv2time(&sp->sa_atime, &vap->va_atime); d216 1 a216 1 fxdr_unsigned(long, sp->sa_atime.nfsv2_sec); d220 7 a226 27 if (sp->sa_mtime.nfsv2_sec != nfs_xdrneg1) fxdr_nfsv2time(&sp->sa_mtime, &vap->va_mtime); } /* * Now that we have all the fields, lets do it. */ if (error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH))) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(preat_ret, &preat, postat_ret, vap); return (0); } nqsrv_getl(vp, ND_WRITE); if (v3) { error = preat_ret = VOP_GETATTR(vp, &preat, cred, procp); if (!error && gcheck && (preat.va_ctime.ts_sec != guard.ts_sec || preat.va_ctime.ts_nsec != guard.ts_nsec)) error = NFSERR_NOT_SYNC; if (error) { vput(vp); nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(preat_ret, &preat, postat_ret, vap); return (0); } d243 1 a243 1 procp)) d246 5 a250 4 error = VOP_SETATTR(vp, vap, cred, procp); postat_ret = VOP_GETATTR(vp, vap, cred, procp); if (!error) error = postat_ret; d253 6 a258 7 nfsm_reply(NFSX_WCCORFATTR(v3)); if (v3) { nfsm_srvwcc_data(preat_ret, &preat, postat_ret, vap); return (0); } else { nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(vap, fp); d266 6 a271 6 int nfsrv_lookup(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; d273 1 a273 5 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; register struct nfs_fattr *fp; d275 2 a276 2 struct vnode *vp, *dirp; nfsfh_t nfh; d282 1 a282 2 int error = 0, cache, len, dirattr_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); d285 2 a286 2 struct vattr va, dirattr, *vap = &va; u_quad_t frev; d289 5 d295 1 a295 1 nfsm_srvnamesiz(len); d299 4 a302 14 error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); if (dirp) { if (v3) dirattr_ret = VOP_GETATTR(dirp, &dirattr, cred, procp); vrele(dirp); } if (error) { nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(dirattr_ret, &dirattr); return (0); } nqsrv_getl(nd.ni_startdir, ND_READ); d308 8 a315 3 error = VFS_VPTOFH(vp, &fhp->fh_fid); if (!error) error = VOP_GETATTR(vp, vap, cred, procp); d317 12 a328 12 nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPORFATTR(v3) + NFSX_POSTOPATTR(v3)); if (error) { nfsm_srvpostop_attr(dirattr_ret, &dirattr); return (0); } nfsm_srvfhtom(fhp, v3); if (v3) { nfsm_srvpostop_attr(0, vap); nfsm_srvpostop_attr(dirattr_ret, &dirattr); } else { nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(vap, fp); d330 3 d339 6 a344 6 int nfsrv_readlink(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; a345 4 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; d352 1 a352 2 int error = 0, rdonly, cache, i, tlen, len, getret; int v3 = (nfsd->nd_flag & ND_NFSV3); d356 1 a356 2 struct vattr attr; nfsfh_t nfh; a360 3 #ifndef nolint mp2 = mp3 = (struct mbuf *)0; #endif d392 1 a392 2 if (error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH))) { d394 1 a394 3 nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvpostop_attr(1, (struct vattr *)0); return (0); d397 1 a397 4 if (v3) error = EINVAL; else error = ENXIO; d400 1 a400 1 nqsrv_getl(vp, ND_READ); a402 1 getret = VOP_GETATTR(vp, &attr, cred, procp); d406 1 a406 6 nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_UNSIGNED); if (v3) { nfsm_srvpostop_attr(getret, &attr); if (error) return (0); } d421 6 a426 6 int nfsrv_read(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; a427 4 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; d431 1 a431 1 register struct nfs_fattr *fp; a433 1 register int i; d435 1 a435 2 int error = 0, rdonly, cache, cnt, len, left, siz, tlen, getret; int v3 = (nfsd->nd_flag & ND_NFSV3), reqlen; d440 1 a440 1 nfsfh_t nfh; d449 4 a452 1 if (v3) { a454 3 } else { nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); off = (off_t)fxdr_unsigned(u_long, *tl); d456 7 a462 6 nfsm_srvstrsiz(reqlen, NFS_SRVMAXDATA(nfsd)); if (error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH))) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvpostop_attr(1, (struct vattr *)0); return (0); d464 5 a468 5 if (vp->v_type != VREG) { if (v3) error = EINVAL; else error = (vp->v_type == VDIR) ? EISDIR : EACCES; d470 1 a470 9 if (!error) { nqsrv_getl(vp, ND_READ); if (error = nfsrv_access(vp, VREAD, cred, rdonly, procp)) error = nfsrv_access(vp, VEXEC, cred, rdonly, procp); } getret = VOP_GETATTR(vp, vap, cred, procp); if (!error) error = getret; if (error) { d472 1 a472 3 nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(getret, vap); return (0); d476 1 a476 1 else if ((off + reqlen) > vap->va_size) d478 3 a480 13 else cnt = reqlen; nfsm_reply(NFSX_POSTOPORFATTR(v3) + 3 * NFSX_UNSIGNED+nfsm_rndup(cnt)); if (v3) { nfsm_build(tl, u_long *, NFSX_V3FATTR + 4 * NFSX_UNSIGNED); *tl++ = nfs_true; fp = (struct nfs_fattr *)tl; tl += (NFSX_V3FATTR / sizeof (u_long)); } else { nfsm_build(tl, u_long *, NFSX_V2FATTR + NFSX_UNSIGNED); fp = (struct nfs_fattr *)tl; tl += (NFSX_V2FATTR / sizeof (u_long)); } d488 4 d495 5 a500 1 i++; d508 1 d511 1 a511 20 MALLOC(iv, struct iovec *, i * sizeof (struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = iv2 = iv; m = mb; left = cnt; i = 0; while (left > 0) { if (m == NULL) panic("nfsrv_read iov"); siz = min(M_TRAILINGSPACE(m), left); if (siz > 0) { iv->iov_base = mtod(m, caddr_t) + m->m_len; iv->iov_len = siz; m->m_len += siz; left -= siz; iv++; i++; } m = m->m_next; } d520 1 a520 3 if (error || (getret = VOP_GETATTR(vp, vap, cred, procp))) { if (!error) error = getret; d523 1 a523 3 nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(getret, vap); return (0); d528 1 a528 1 nfsm_srvfillattr(vap, fp); d532 1 a532 8 nfsm_adj(mb, cnt - tlen, tlen - len); if (v3) { *tl++ = txdr_unsigned(len); if (len < reqlen) *tl++ = nfs_true; else *tl++ = nfs_false; } d540 6 a545 6 int nfsrv_write(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; a546 4 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; a547 1 register int i, cnt; d549 3 a551 3 register struct nfs_fattr *fp; struct iovec *iv; struct vattr va, forat; d556 2 a557 4 int error = 0, rdonly, cache, siz, len, xfer, forat_ret = 1; int ioflags, aftat_ret = 1, retlen, zeroing, adjust; int stable = NFSV3WRITE_FILESYNC; int v3 = (nfsd->nd_flag & ND_NFSV3); d561 1 a561 1 nfsfh_t nfh; a566 4 if (mrep == NULL) { *mrq = NULL; return (0); } d569 5 a573 2 if (v3) { nfsm_dissect(tl, u_long *, 5 * NFSX_UNSIGNED); a574 5 tl += 3; stable = fxdr_unsigned(int, *tl++); } else { nfsm_dissect(tl, u_long *, 4 * NFSX_UNSIGNED); off = (off_t)fxdr_unsigned(u_long, *++tl); d576 7 d584 5 a588 18 retlen = len = fxdr_unsigned(long, *tl); cnt = i = 0; /* * For NFS Version 2, it is not obvious what a write of zero length * should do, but I might as well be consistent with Version 3, * which is to return ok so long as there are no permission problems. */ if (len > 0) { zeroing = 1; mp = mrep; while (mp) { if (mp == md) { zeroing = 0; adjust = dpos - mtod(mp, caddr_t); mp->m_len -= adjust; if (mp->m_len > 0 && adjust > 0) NFSMADV(mp, adjust); d590 5 a594 13 if (zeroing) mp->m_len = 0; else if (mp->m_len > 0) { i += mp->m_len; if (i > len) { mp->m_len -= (i - len); zeroing = 1; } if (mp->m_len > 0) cnt++; } mp = mp->m_next; } d596 2 a597 14 if (len > NFS_MAXDATA || len < 0 || i < len) { error = EIO; nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, vap); return (0); } if (error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH))) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, vap); return (0); } if (v3) forat_ret = VOP_GETATTR(vp, &forat, cred, procp); d599 3 a601 8 if (v3) error = EINVAL; else error = (vp->v_type == VDIR) ? EISDIR : EACCES; } if (!error) { nqsrv_getl(vp, ND_WRITE); error = nfsrv_access(vp, VWRITE, cred, rdonly, procp); d603 2 a604 1 if (error) { d606 1 a606 3 nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, vap); return (0); d608 4 a611 226 if (len > 0) { MALLOC(ivp, struct iovec *, cnt * sizeof (struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = iv = ivp; uiop->uio_iovcnt = cnt; mp = mrep; while (mp) { if (mp->m_len > 0) { ivp->iov_base = mtod(mp, caddr_t); ivp->iov_len = mp->m_len; ivp++; } mp = mp->m_next; } /* * XXX * The IO_METASYNC flag indicates that all metadata (and not just * enough to ensure data integrity) mus be written to stable storage * synchronously. * (IO_METASYNC is not yet implemented in 4.4BSD-Lite.) */ if (stable == NFSV3WRITE_UNSTABLE) ioflags = IO_NODELOCKED; else if (stable == NFSV3WRITE_DATASYNC) ioflags = (IO_SYNC | IO_NODELOCKED); else ioflags = (IO_METASYNC | IO_SYNC | IO_NODELOCKED); uiop->uio_resid = len; uiop->uio_rw = UIO_WRITE; uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_procp = (struct proc *)0; uiop->uio_offset = off; error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; FREE((caddr_t)iv, M_TEMP); } aftat_ret = VOP_GETATTR(vp, vap, cred, procp); vput(vp); if (!error) error = aftat_ret; nfsm_reply(NFSX_PREOPATTR(v3) + NFSX_POSTOPORFATTR(v3) + 2 * NFSX_UNSIGNED + NFSX_WRITEVERF(v3)); if (v3) { nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, vap); if (error) return (0); nfsm_build(tl, u_long *, 4 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(retlen); if (stable == NFSV3WRITE_UNSTABLE) *tl++ = txdr_unsigned(stable); else *tl++ = txdr_unsigned(NFSV3WRITE_FILESYNC); /* * Actually, there is no need to txdr these fields, * but it may make the values more human readable, * for debugging purposes. */ *tl++ = txdr_unsigned(boottime.tv_sec); *tl = txdr_unsigned(boottime.tv_usec); } else { nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(vap, fp); } nfsm_srvdone; } /* * NFS write service with write gathering support. Called when * nfsrvw_procrastinate > 0. * See: Chet Juszczak, "Improving the Write Performance of an NFS Server", * in Proc. of the Winter 1994 Usenix Conference, pg. 247-259, San Franscisco, * Jan. 1994. */ int nfsrv_writegather(ndp, slp, procp, mrq) struct nfsrv_descript **ndp; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; { register struct iovec *ivp; register struct mbuf *mp; register struct nfsrv_descript *wp, *nfsd, *owp, *swp; register struct nfs_fattr *fp; register int i; struct iovec *iov; struct nfsrvw_delayhash *wpp; struct ucred *cred; struct vattr va, forat; register u_long *tl; register long t1; caddr_t bpos, dpos; int error = 0, rdonly, cache, len, forat_ret = 1; int ioflags, aftat_ret = 1, s, adjust, v3, zeroing; char *cp2; struct mbuf *mb, *mb2, *mreq, *mrep, *md; struct vnode *vp; struct uio io, *uiop = &io; off_t off; u_quad_t frev, cur_usec; #ifndef nolint i = 0; len = 0; #endif *mrq = NULL; if (*ndp) { nfsd = *ndp; *ndp = NULL; mrep = nfsd->nd_mrep; md = nfsd->nd_md; dpos = nfsd->nd_dpos; cred = &nfsd->nd_cr; v3 = (nfsd->nd_flag & ND_NFSV3); LIST_INIT(&nfsd->nd_coalesce); nfsd->nd_mreq = NULL; nfsd->nd_stable = NFSV3WRITE_FILESYNC; cur_usec = (u_quad_t)time.tv_sec * 1000000 + (u_quad_t)time.tv_usec; nfsd->nd_time = cur_usec + nfsrvw_procrastinate; /* * Now, get the write header.. */ nfsm_srvmtofh(&nfsd->nd_fh); if (v3) { nfsm_dissect(tl, u_long *, 5 * NFSX_UNSIGNED); fxdr_hyper(tl, &nfsd->nd_off); tl += 3; nfsd->nd_stable = fxdr_unsigned(int, *tl++); } else { nfsm_dissect(tl, u_long *, 4 * NFSX_UNSIGNED); nfsd->nd_off = (off_t)fxdr_unsigned(u_long, *++tl); tl += 2; } len = fxdr_unsigned(long, *tl); nfsd->nd_len = len; nfsd->nd_eoff = nfsd->nd_off + len; /* * Trim the header out of the mbuf list and trim off any trailing * junk so that the mbuf list has only the write data. */ zeroing = 1; i = 0; mp = mrep; while (mp) { if (mp == md) { zeroing = 0; adjust = dpos - mtod(mp, caddr_t); mp->m_len -= adjust; if (mp->m_len > 0 && adjust > 0) NFSMADV(mp, adjust); } if (zeroing) mp->m_len = 0; else { i += mp->m_len; if (i > len) { mp->m_len -= (i - len); zeroing = 1; } } mp = mp->m_next; } if (len > NFS_MAXDATA || len < 0 || i < len) { nfsmout: m_freem(mrep); error = EIO; nfsm_writereply(2 * NFSX_UNSIGNED, v3); if (v3) nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); nfsd->nd_mreq = mreq; nfsd->nd_mrep = NULL; nfsd->nd_time = 0; } /* * Add this entry to the hash and time queues. */ s = splsoftclock(); owp = NULL; wp = slp->ns_tq.lh_first; while (wp && wp->nd_time < nfsd->nd_time) { owp = wp; wp = wp->nd_tq.le_next; } if (owp) { LIST_INSERT_AFTER(owp, nfsd, nd_tq); } else { LIST_INSERT_HEAD(&slp->ns_tq, nfsd, nd_tq); } if (nfsd->nd_mrep) { wpp = NWDELAYHASH(slp, nfsd->nd_fh.fh_fid.fid_data); owp = NULL; wp = wpp->lh_first; while (wp && bcmp((caddr_t)&nfsd->nd_fh,(caddr_t)&wp->nd_fh,NFSX_V3FH)) { owp = wp; wp = wp->nd_hash.le_next; } while (wp && wp->nd_off < nfsd->nd_off && !bcmp((caddr_t)&nfsd->nd_fh,(caddr_t)&wp->nd_fh,NFSX_V3FH)) { owp = wp; wp = wp->nd_hash.le_next; } if (owp) { LIST_INSERT_AFTER(owp, nfsd, nd_hash); /* * Search the hash list for overlapping entries and * coalesce. */ for(; nfsd && NFSW_CONTIG(owp, nfsd); nfsd = wp) { wp = nfsd->nd_hash.le_next; if (NFSW_SAMECRED(owp, nfsd)) nfsrvw_coalesce(owp, nfsd); } } else { LIST_INSERT_HEAD(wpp, nfsd, nd_hash); } } splx(s); } d613 2 a614 2 * Now, do VOP_WRITE()s for any one(s) that need to be done now * and generate the associated reply mbuf list(s). d616 16 a631 25 loop1: cur_usec = (u_quad_t)time.tv_sec * 1000000 + (u_quad_t)time.tv_usec; s = splsoftclock(); for (nfsd = slp->ns_tq.lh_first; nfsd; nfsd = owp) { owp = nfsd->nd_tq.le_next; if (nfsd->nd_time > cur_usec) break; if (nfsd->nd_mreq) continue; LIST_REMOVE(nfsd, nd_tq); LIST_REMOVE(nfsd, nd_hash); splx(s); mrep = nfsd->nd_mrep; nfsd->nd_mrep = NULL; cred = &nfsd->nd_cr; v3 = (nfsd->nd_flag & ND_NFSV3); forat_ret = aftat_ret = 1; error = nfsrv_fhtovp(&nfsd->nd_fh, 1, &vp, cred, slp, nfsd->nd_nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH)); if (!error) { if (v3) forat_ret = VOP_GETATTR(vp, &forat, cred, procp); if (vp->v_type != VREG) { if (v3) error = EINVAL; d633 7 a639 7 error = (vp->v_type == VDIR) ? EISDIR : EACCES; } } else vp = NULL; if (!error) { nqsrv_getl(vp, ND_WRITE); error = nfsrv_access(vp, VWRITE, cred, rdonly, procp); d641 4 a644 38 if (nfsd->nd_stable == NFSV3WRITE_UNSTABLE) ioflags = IO_NODELOCKED; else if (nfsd->nd_stable == NFSV3WRITE_DATASYNC) ioflags = (IO_SYNC | IO_NODELOCKED); else ioflags = (IO_METASYNC | IO_SYNC | IO_NODELOCKED); uiop->uio_rw = UIO_WRITE; uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_procp = (struct proc *)0; uiop->uio_offset = nfsd->nd_off; uiop->uio_resid = nfsd->nd_eoff - nfsd->nd_off; if (uiop->uio_resid > 0) { mp = mrep; i = 0; while (mp) { if (mp->m_len > 0) i++; mp = mp->m_next; } uiop->uio_iovcnt = i; MALLOC(iov, struct iovec *, i * sizeof (struct iovec), M_TEMP, M_WAITOK); uiop->uio_iov = ivp = iov; mp = mrep; while (mp) { if (mp->m_len > 0) { ivp->iov_base = mtod(mp, caddr_t); ivp->iov_len = mp->m_len; ivp++; } mp = mp->m_next; } if (!error) { error = VOP_WRITE(vp, uiop, ioflags, cred); nfsstats.srvvop_writes++; } FREE((caddr_t)iov, M_TEMP); d646 4 a649 4 m_freem(mrep); if (vp) { aftat_ret = VOP_GETATTR(vp, &va, cred, procp); vput(vp); d651 1 a651 57 /* * Loop around generating replies for all write rpcs that have * now been completed. */ swp = nfsd; do { if (error) { nfsm_writereply(NFSX_WCCDATA(v3), v3); if (v3) { nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); } } else { nfsm_writereply(NFSX_PREOPATTR(v3) + NFSX_POSTOPORFATTR(v3) + 2 * NFSX_UNSIGNED + NFSX_WRITEVERF(v3), v3); if (v3) { nfsm_srvwcc_data(forat_ret, &forat, aftat_ret, &va); nfsm_build(tl, u_long *, 4 * NFSX_UNSIGNED); *tl++ = txdr_unsigned(nfsd->nd_len); *tl++ = txdr_unsigned(swp->nd_stable); /* * Actually, there is no need to txdr these fields, * but it may make the values more human readable, * for debugging purposes. */ *tl++ = txdr_unsigned(boottime.tv_sec); *tl = txdr_unsigned(boottime.tv_usec); } else { nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(&va, fp); } } nfsd->nd_mreq = mreq; if (nfsd->nd_mrep) panic("nfsrv_write: nd_mrep not free"); /* * Done. Put it at the head of the timer queue so that * the final phase can return the reply. */ s = splsoftclock(); if (nfsd != swp) { nfsd->nd_time = 0; LIST_INSERT_HEAD(&slp->ns_tq, nfsd, nd_tq); } nfsd = swp->nd_coalesce.lh_first; if (nfsd) { LIST_REMOVE(nfsd, nd_tq); } splx(s); } while (nfsd); s = splsoftclock(); swp->nd_time = 0; LIST_INSERT_HEAD(&slp->ns_tq, swp, nd_tq); splx(s); goto loop1; d653 8 a660 77 splx(s); /* * Search for a reply to return. */ s = splsoftclock(); for (nfsd = slp->ns_tq.lh_first; nfsd; nfsd = nfsd->nd_tq.le_next) if (nfsd->nd_mreq) { LIST_REMOVE(nfsd, nd_tq); *mrq = nfsd->nd_mreq; *ndp = nfsd; break; } splx(s); return (0); } /* * Coalesce the write request nfsd into owp. To do this we must: * - remove nfsd from the queues * - merge nfsd->nd_mrep into owp->nd_mrep * - update the nd_eoff and nd_stable for owp * - put nfsd on owp's nd_coalesce list * NB: Must be called at splsoftclock(). */ void nfsrvw_coalesce(owp, nfsd) register struct nfsrv_descript *owp; register struct nfsrv_descript *nfsd; { register int overlap; register struct mbuf *mp; LIST_REMOVE(nfsd, nd_hash); LIST_REMOVE(nfsd, nd_tq); if (owp->nd_eoff < nfsd->nd_eoff) { overlap = owp->nd_eoff - nfsd->nd_off; if (overlap < 0) panic("nfsrv_coalesce: bad off"); if (overlap > 0) m_adj(nfsd->nd_mrep, overlap); mp = owp->nd_mrep; while (mp->m_next) mp = mp->m_next; mp->m_next = nfsd->nd_mrep; owp->nd_eoff = nfsd->nd_eoff; } else m_freem(nfsd->nd_mrep); nfsd->nd_mrep = NULL; if (nfsd->nd_stable == NFSV3WRITE_FILESYNC) owp->nd_stable = NFSV3WRITE_FILESYNC; else if (nfsd->nd_stable == NFSV3WRITE_DATASYNC && owp->nd_stable == NFSV3WRITE_UNSTABLE) owp->nd_stable = NFSV3WRITE_DATASYNC; LIST_INSERT_HEAD(&owp->nd_coalesce, nfsd, nd_tq); } /* * Sort the group list in increasing numerical order. * (Insertion sort by Chris Torek, who was grossed out by the bubble sort * that used to be here.) */ void nfsrvw_sort(list, num) register gid_t *list; register int num; { register int i, j; gid_t v; /* Insertion sort. */ for (i = 1; i < num; i++) { v = list[i]; /* find correct slot for value v, moving others up */ for (j = i; --j >= 0 && v < list[j];) list[j + 1] = list[j]; list[j + 1] = v; d662 1 a662 18 } /* * copy credentials making sure that the result can be compared with bcmp(). */ void nfsrv_setcred(incred, outcred) register struct ucred *incred, *outcred; { register int i; bzero((caddr_t)outcred, sizeof (struct ucred)); outcred->cr_ref = 1; outcred->cr_uid = incred->cr_uid; outcred->cr_ngroups = incred->cr_ngroups; for (i = 0; i < incred->cr_ngroups; i++) outcred->cr_groups[i] = incred->cr_groups[i]; nfsrvw_sort(outcred->cr_groups, outcred->cr_ngroups); d669 6 a674 6 int nfsrv_create(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; d676 2 a677 6 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; register struct nfs_fattr *fp; struct vattr va, dirfor, diraft; d685 1 a685 2 int error = 0, rdev, cache, len, tsize, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3), how, exclusive_flag = 0; d688 2 a689 2 struct vnode *vp, *dirp = (struct vnode *)0; nfsfh_t nfh; d691 1 a691 2 u_quad_t frev, tempsize; u_char cverf[NFSX_V3CREATEVERF]; a692 3 #ifndef nolint rdev = 0; #endif d696 1 a696 1 nfsm_srvnamesiz(len); d700 3 a702 18 error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); if (dirp) { if (v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); else { vrele(dirp); dirp = (struct vnode *)0; } } if (error) { nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); if (dirp) vrele(dirp); return (0); } d704 1 a704 41 if (v3) { nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); how = fxdr_unsigned(int, *tl); switch (how) { case NFSV3CREATE_GUARDED: if (nd.ni_vp) { error = EEXIST; break; } case NFSV3CREATE_UNCHECKED: nfsm_srvsattr(vap); break; case NFSV3CREATE_EXCLUSIVE: nfsm_dissect(cp, caddr_t, NFSX_V3CREATEVERF); bcopy(cp, cverf, NFSX_V3CREATEVERF); exclusive_flag = 1; if (nd.ni_vp == NULL) vap->va_mode = 0; break; }; vap->va_type = VREG; } else { nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); vap->va_type = IFTOVT(fxdr_unsigned(u_long, sp->sa_mode)); if (vap->va_type == VNON) vap->va_type = VREG; vap->va_mode = nfstov_mode(sp->sa_mode); switch (vap->va_type) { case VREG: tsize = fxdr_unsigned(long, sp->sa_size); if (tsize != -1) vap->va_size = (u_quad_t)tsize; break; case VCHR: case VBLK: case VFIFO: rdev = fxdr_unsigned(long, sp->sa_size); break; }; } d711 8 d721 4 a724 13 nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap); if (!error) { FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); if (exclusive_flag) { exclusive_flag = 0; VATTR_NULL(vap); bcopy(cverf, (caddr_t)&vap->va_atime, NFSX_V3CREATEVERF); error = VOP_SETATTR(nd.ni_vp, vap, cred, procp); } } d729 8 a736 3 if (error = suser(cred, (u_short *)0)) { vrele(nd.ni_startdir); free(nd.ni_cnd.cn_pnbuf, M_NAMEI); d739 1 a739 2 nfsm_reply(0); return (error); d742 1 a742 1 nqsrv_getl(nd.ni_dvp, ND_WRITE); d749 2 a750 2 nd.ni_cnd.cn_proc = procp; nd.ni_cnd.cn_cred = cred; a763 2 vrele(nd.ni_startdir); free(nd.ni_cnd.cn_pnbuf, M_NAMEI); d767 1 d779 8 d788 4 a791 9 error = nfsrv_access(vp, VWRITE, cred, (nd.ni_cnd.cn_flags & RDONLY), procp); if (!error) { nqsrv_getl(vp, ND_WRITE); tempsize = vap->va_size; VATTR_NULL(vap); vap->va_size = tempsize; error = VOP_SETATTR(vp, vap, cred, procp); d793 2 a794 1 if (error) d796 2 d800 3 a802 6 if (!error) { bzero((caddr_t)fhp, sizeof(nfh)); fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(vp, &fhp->fh_fid); if (!error) error = VOP_GETATTR(vp, vap, cred, procp); d804 1 d806 7 a812 20 if (v3) { if (exclusive_flag && !error && bcmp(cverf, (caddr_t)&vap->va_atime, NFSX_V3CREATEVERF)) error = EEXIST; diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); vrele(dirp); } nfsm_reply(NFSX_SRVFH(v3) + NFSX_FATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { if (!error) { nfsm_srvpostop_fh(fhp); nfsm_srvpostop_attr(0, vap); } nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); } else { nfsm_srvfhtom(fhp, v3); nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(vap, fp); } return (0); d814 1 a814 3 if (dirp) vrele(dirp); if (nd.ni_cnd.cn_nameiop) { a815 2 free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); } d824 5 d832 1 a832 1 * nfs v3 mknod service d834 6 a839 6 int nfsrv_mknod(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; d841 1 a841 7 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; register struct nfs_fattr *fp; struct vattr va, dirfor, diraft; register struct vattr *vap = &va; a842 2 struct nameidata nd; register caddr_t cp; d845 1 a845 3 int error = 0, cache, len, tsize, dirfor_ret = 1, diraft_ret = 1; u_long major, minor; enum vtype vtyp; d847 3 a849 3 struct mbuf *mb, *mb2, *mreq; struct vnode *vp, *dirp = (struct vnode *)0; nfsfh_t nfh; a852 1 nd.ni_cnd.cn_nameiop = 0; d855 1 a855 1 nfsm_srvnamesiz(len); d857 8 a864 21 nd.ni_cnd.cn_nameiop = CREATE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | SAVESTART; error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); if (dirp) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); if (error) { nfsm_reply(NFSX_WCCDATA(1)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); if (dirp) vrele(dirp); return (0); } nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); vtyp = nfsv3tov_type(*tl); if (vtyp != VCHR && vtyp != VBLK && vtyp != VSOCK && vtyp != VFIFO) { vrele(nd.ni_startdir); free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); error = NFSERR_BADTYPE; VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); a865 10 } VATTR_NULL(vap); nfsm_srvsattr(vap); if (vtyp == VCHR || vtyp == VBLK) { nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); major = fxdr_unsigned(u_long, *tl++); minor = fxdr_unsigned(u_long, *tl); vap->va_rdev = makedev(major, minor); } d867 1 a867 1 * Iff doesn't exist, create it. d869 2 a870 6 if (nd.ni_vp) { vrele(nd.ni_startdir); free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); error = EEXIST; VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); vput(nd.ni_dvp); d873 7 a879 7 vap->va_type = vtyp; if (vtyp == VSOCK) { vrele(nd.ni_startdir); nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_CREATE(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap); if (!error) FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); d881 4 a884 4 if (error = suser(cred, (u_short *)0)) { vrele(nd.ni_startdir); free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); a885 30 goto out; } nqsrv_getl(nd.ni_dvp, ND_WRITE); if (error = VOP_MKNOD(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap)) { vrele(nd.ni_startdir); goto out; } nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART); nd.ni_cnd.cn_proc = procp; nd.ni_cnd.cn_cred = procp->p_ucred; error = lookup(&nd); FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); if (error) goto out; if (nd.ni_cnd.cn_flags & ISSYMLINK) { vrele(nd.ni_dvp); vput(nd.ni_vp); VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); error = EINVAL; } } out: vp = nd.ni_vp; if (!error) { bzero((caddr_t)fhp, sizeof(nfh)); fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(vp, &fhp->fh_fid); if (!error) error = VOP_GETATTR(vp, vap, cred, procp); d888 1 a888 109 diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); vrele(dirp); nfsm_reply(NFSX_SRVFH(1) + NFSX_POSTOPATTR(1) + NFSX_WCCDATA(1)); if (!error) { nfsm_srvpostop_fh(fhp); nfsm_srvpostop_attr(0, vap); } nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); nfsmout: if (dirp) vrele(dirp); if (nd.ni_cnd.cn_nameiop) { vrele(nd.ni_startdir); free((caddr_t)nd.ni_cnd.cn_pnbuf, M_NAMEI); } VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == nd.ni_vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); if (nd.ni_vp) vput(nd.ni_vp); return (error); } /* * nfs remove service */ int nfsrv_remove(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct nameidata nd; register u_long *tl; register long t1; caddr_t bpos; int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); char *cp2; struct mbuf *mb, *mreq, *mb2; struct vnode *vp, *dirp; struct vattr dirfor, diraft; nfsfh_t nfh; fhandle_t *fhp; u_quad_t frev; #ifndef nolint vp = (struct vnode *)0; #endif fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); nfsm_srvnamesiz(len); nd.ni_cnd.cn_cred = cred; nd.ni_cnd.cn_nameiop = DELETE; nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF; error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); if (dirp) { if (v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); else vrele(dirp); } if (!error) { vp = nd.ni_vp; if (vp->v_type == VDIR && (error = suser(cred, (u_short *)0))) goto out; /* * The root of a mounted filesystem cannot be deleted. */ if (vp->v_flag & VROOT) { error = EBUSY; goto out; } if (vp->v_flag & VTEXT) (void) vnode_pager_uncache(vp); out: if (!error) { nqsrv_getl(nd.ni_dvp, ND_WRITE); nqsrv_getl(vp, ND_WRITE); error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd); } else { VOP_ABORTOP(nd.ni_dvp, &nd.ni_cnd); if (nd.ni_dvp == vp) vrele(nd.ni_dvp); else vput(nd.ni_dvp); vput(vp); } } if (dirp && v3) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); vrele(dirp); } nfsm_reply(NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); } d895 6 a900 6 int nfsrv_rename(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; a901 4 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; d905 1 a905 3 int error = 0, cache, len, len2, fdirfor_ret = 1, fdiraft_ret = 1; int tdirfor_ret = 1, tdiraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); d907 1 a907 1 struct mbuf *mb, *mreq, *mb2; d909 2 a910 4 struct vnode *fvp, *tvp, *tdvp, *fdirp = (struct vnode *)0; struct vnode *tdirp = (struct vnode *)0; struct vattr fdirfor, fdiraft, tdirfor, tdiraft; nfsfh_t fnfh, tnfh; a914 3 #ifndef nolint fvp = (struct vnode *)0; #endif d920 1 a920 1 nfsm_srvnamesiz(len); d929 3 a931 19 error = nfs_namei(&fromnd, ffhp, len, slp, nam, &md, &dpos, &fdirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); if (fdirp) { if (v3) fdirfor_ret = VOP_GETATTR(fdirp, &fdirfor, cred, procp); else { vrele(fdirp); fdirp = (struct vnode *)0; } } if (error) { nfsm_reply(2 * NFSX_WCCDATA(v3)); nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft); nfsm_srvwcc_data(tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft); if (fdirp) vrele(fdirp); return (0); } d939 2 a940 12 error = nfs_namei(&tond, tfhp, len2, slp, nam, &md, &dpos, &tdirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); if (tdirp) { if (v3) tdirfor_ret = VOP_GETATTR(tdirp, &tdirfor, cred, procp); else { vrele(tdirp); tdirp = (struct vnode *)0; } } if (error) { d950 1 a950 4 if (v3) error = EEXIST; else error = EISDIR; d953 1 a953 4 if (v3) error = EEXIST; else error = ENOTDIR; d957 1 a957 4 if (v3) error = EXDEV; else error = ENOTEMPTY; d962 1 a962 4 if (v3) error = EXDEV; else error = ENOTEMPTY; d966 1 a966 4 if (v3) error = EXDEV; else error = ENOTEMPTY; d970 1 a970 4 if (v3) error = EINVAL; else error = ENOTEMPTY; d983 2 a984 2 nqsrv_getl(fromnd.ni_dvp, ND_WRITE); nqsrv_getl(tdvp, ND_WRITE); d986 1 a986 1 nqsrv_getl(tvp, ND_WRITE); a999 2 if (error == -1) error = 0; a1003 8 if (fdirp) { fdiraft_ret = VOP_GETATTR(fdirp, &fdiraft, cred, procp); vrele(fdirp); } if (tdirp) { tdiraft_ret = VOP_GETATTR(tdirp, &tdiraft, cred, procp); vrele(tdirp); } d1006 2 a1007 6 nfsm_reply(2 * NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(fdirfor_ret, &fdirfor, fdiraft_ret, &fdiraft); nfsm_srvwcc_data(tdirfor_ret, &tdirfor, tdiraft_ret, &tdiraft); } return (0); d1010 1 a1010 5 if (fdirp) vrele(fdirp); if (tdirp) vrele(tdirp); if (tond.ni_cnd.cn_nameiop) { d1014 1 a1014 1 if (fromnd.ni_cnd.cn_nameiop) { d1027 6 a1032 6 int nfsrv_link(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; a1033 4 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; d1038 1 a1038 2 int error = 0, rdonly, cache, len, dirfor_ret = 1, diraft_ret = 1; int getret = 1, v3 = (nfsd->nd_flag & ND_NFSV3); d1040 3 a1042 4 struct mbuf *mb, *mreq, *mb2; struct vnode *vp, *xp, *dirp = (struct vnode *)0; struct vattr dirfor, diraft, at; nfsfh_t nfh, dnfh; d1050 3 a1052 8 nfsm_srvnamesiz(len); if (error = nfsrv_fhtovp(fhp, FALSE, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH))) { nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); nfsm_srvpostop_attr(getret, &at); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); } d1058 2 a1059 12 error = nfs_namei(&nd, dfhp, len, slp, nam, &md, &dpos, &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); if (dirp) { if (v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); else { vrele(dirp); dirp = (struct vnode *)0; } } if (error) d1071 3 a1073 3 nqsrv_getl(vp, ND_WRITE); nqsrv_getl(xp, ND_WRITE); error = VOP_LINK(vp, nd.ni_dvp, &nd.ni_cnd); a1083 6 if (v3) getret = VOP_GETATTR(vp, &at, cred, procp); if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); vrele(dirp); } d1085 1 a1085 6 nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { nfsm_srvpostop_attr(getret, &at); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); } d1092 6 a1097 6 int nfsrv_symlink(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; d1099 1 a1099 5 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct vattr va, dirfor, diraft; d1105 1 a1105 1 char *bpos, *cp, *pathcp = (char *)0, *cp2; d1108 4 a1111 5 int error = 0, cache, len, len2, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); struct mbuf *mb, *mreq, *mb2; struct vnode *dirp = (struct vnode *)0; nfsfh_t nfh; d1115 1 a1115 1 nd.ni_cnd.cn_nameiop = 0; d1118 1 a1118 1 nfsm_srvnamesiz(len); d1121 3 a1123 13 nd.ni_cnd.cn_flags = LOCKPARENT | SAVESTART; error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); if (dirp) { if (v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); else { vrele(dirp); dirp = (struct vnode *)0; } } if (error) a1124 3 VATTR_NULL(vap); if (v3) nfsm_srvsattr(vap); d1137 1 a1137 4 if (!v3) { nfsm_dissect(sp, struct nfsv2_sattr *, NFSX_V2SATTR); vap->va_mode = fxdr_unsigned(u_short, sp->sa_mode); } a1139 2 vrele(nd.ni_startdir); free(nd.ni_cnd.cn_pnbuf, M_NAMEI); d1149 3 a1151 1 nqsrv_getl(nd.ni_dvp, ND_WRITE); a1152 23 if (error) vrele(nd.ni_startdir); else { if (v3) { nd.ni_cnd.cn_nameiop = LOOKUP; nd.ni_cnd.cn_flags &= ~(LOCKPARENT | SAVESTART | FOLLOW); nd.ni_cnd.cn_flags |= (NOFOLLOW | LOCKLEAF); nd.ni_cnd.cn_proc = procp; nd.ni_cnd.cn_cred = cred; error = lookup(&nd); if (!error) { bzero((caddr_t)fhp, sizeof(nfh)); fhp->fh_fsid = nd.ni_vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(nd.ni_vp, &fhp->fh_fid); if (!error) error = VOP_GETATTR(nd.ni_vp, vap, cred, procp); vput(nd.ni_vp); } } else vrele(nd.ni_startdir); FREE(nd.ni_cnd.cn_pnbuf, M_NAMEI); } d1156 2 a1157 13 if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); vrele(dirp); } nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { if (!error) { nfsm_srvpostop_fh(fhp); nfsm_srvpostop_attr(0, vap); } nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); } return (0); a1158 6 if (nd.ni_cnd.cn_nameiop) { vrele(nd.ni_startdir); free(nd.ni_cnd.cn_pnbuf, M_NAMEI); } if (dirp) vrele(dirp); d1174 6 a1179 6 int nfsrv_mkdir(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; d1181 1 a1181 5 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct vattr va, dirfor, diraft; d1183 1 a1183 1 register struct nfs_fattr *fp; d1189 1 a1189 2 int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); d1192 2 a1193 2 struct vnode *vp, *dirp = (struct vnode *)0; nfsfh_t nfh; d1199 1 a1199 1 nfsm_srvnamesiz(len); d1203 4 a1206 18 error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); if (dirp) { if (v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); else { vrele(dirp); dirp = (struct vnode *)0; } } if (error) { nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); if (dirp) vrele(dirp); return (0); } a1207 6 if (v3) { nfsm_srvsattr(vap); } else { nfsm_dissect(tl, u_long *, NFSX_UNSIGNED); vap->va_mode = nfstov_mode(*tl++); } d1209 1 d1219 1 a1219 1 goto out; d1221 7 a1227 9 nqsrv_getl(nd.ni_dvp, ND_WRITE); error = VOP_MKDIR(nd.ni_dvp, &nd.ni_vp, &nd.ni_cnd, vap); if (!error) { vp = nd.ni_vp; bzero((caddr_t)fhp, sizeof(nfh)); fhp->fh_fsid = vp->v_mount->mnt_stat.f_fsid; error = VFS_VPTOFH(vp, &fhp->fh_fid); if (!error) error = VOP_GETATTR(vp, vap, cred, procp); d1229 1 d1231 7 a1237 18 out: if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); vrele(dirp); } nfsm_reply(NFSX_SRVFH(v3) + NFSX_POSTOPATTR(v3) + NFSX_WCCDATA(v3)); if (v3) { if (!error) { nfsm_srvpostop_fh(fhp); nfsm_srvpostop_attr(0, vap); } nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); } else { nfsm_srvfhtom(fhp, v3); nfsm_build(fp, struct nfs_fattr *, NFSX_V2FATTR); nfsm_srvfillattr(vap, fp); } return (0); a1238 2 if (dirp) vrele(dirp); d1252 6 a1257 6 int nfsrv_rmdir(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; a1258 4 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; d1262 1 a1262 2 int error = 0, cache, len, dirfor_ret = 1, diraft_ret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); d1264 3 a1266 4 struct mbuf *mb, *mreq, *mb2; struct vnode *vp, *dirp = (struct vnode *)0; struct vattr dirfor, diraft; nfsfh_t nfh; d1273 1 a1273 1 nfsm_srvnamesiz(len); d1277 3 a1279 18 error = nfs_namei(&nd, fhp, len, slp, nam, &md, &dpos, &dirp, procp, (nfsd->nd_flag & ND_KERBAUTH)); if (dirp) { if (v3) dirfor_ret = VOP_GETATTR(dirp, &dirfor, cred, procp); else { vrele(dirp); dirp = (struct vnode *)0; } } if (error) { nfsm_reply(NFSX_WCCDATA(v3)); nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); if (dirp) vrele(dirp); return (0); } d1299 2 a1300 2 nqsrv_getl(nd.ni_dvp, ND_WRITE); nqsrv_getl(vp, ND_WRITE); d1310 1 a1310 9 if (dirp) { diraft_ret = VOP_GETATTR(dirp, &diraft, cred, procp); vrele(dirp); } nfsm_reply(NFSX_WCCDATA(v3)); if (v3) { nfsm_srvwcc_data(dirfor_ret, &dirfor, diraft_ret, &diraft); return (0); } d1334 1 a1334 1 * The alternate call nfsrv_readdirplus() does lookups as well. d1344 5 a1348 6 nfsuint64 fl_off; u_long fl_postopok; u_long fl_fattr[NFSX_V3FATTR / sizeof (u_long)]; u_long fl_fhok; u_long fl_fhsize; u_long fl_nfh[NFSX_V3FH / sizeof (u_long)]; d1351 6 a1356 6 int nfsrv_readdir(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; a1357 4 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; d1368 1 a1368 2 struct vattr at; nfsfh_t nfh; d1372 4 a1375 5 int len, nlen, rem, xfer, tsiz, i, error = 0, getret = 1; int siz, cnt, fullsiz, eofflag, rdonly, cache, ncookies; int v3 = (nfsd->nd_flag & ND_NFSV3); u_quad_t frev, off, toff, verf; u_long *cookies = NULL, *cookiep; d1379 4 a1382 11 if (v3) { nfsm_dissect(tl, u_long *, 5 * NFSX_UNSIGNED); fxdr_hyper(tl, &toff); tl += 2; fxdr_hyper(tl, &verf); tl += 2; } else { nfsm_dissect(tl, u_long *, 2 * NFSX_UNSIGNED); toff = fxdr_unsigned(u_quad_t, *tl++); } off = toff; d1384 3 a1386 4 siz = ((cnt + DIRBLKSIZ - 1) & ~(DIRBLKSIZ - 1)); xfer = NFS_SRVMAXDATA(nfsd); if (siz > xfer) siz = xfer; d1388 4 a1391 15 if (error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH))) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } nqsrv_getl(vp, ND_READ); if (v3) { error = getret = VOP_GETATTR(vp, &at, cred, procp); if (!error && toff && verf != at.va_filerev) error = NFSERR_BAD_COOKIE; } if (!error) error = nfsrv_access(vp, VEXEC, cred, rdonly, procp); if (error) { d1393 1 a1393 3 nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(getret, &at); return (0); d1395 1 a1395 1 VOP_UNLOCK(vp, 0, procp); d1407 1 a1407 6 eofflag = 0; if (cookies) { free((caddr_t)cookies, M_TEMP); cookies = NULL; } error = VOP_READDIR(vp, &io, cred, &eofflag, &ncookies, &cookies); a1408 7 if (!cookies && !error) error = NFSERR_PERM; if (v3) { getret = VOP_GETATTR(vp, &at, cred, procp); if (!error) error = getret; } d1412 1 a1412 5 if (cookies) free((caddr_t)cookies, M_TEMP); nfsm_reply(NFSX_POSTOPATTR(v3)); nfsm_srvpostop_attr(getret, &at); return (0); d1414 4 d1427 2 a1428 9 nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_COOKIEVERF(v3) + 2 * NFSX_UNSIGNED); if (v3) { nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_long *, 4 * NFSX_UNSIGNED); txdr_hyper(&at.va_filerev, tl); tl += 2; } else nfsm_build(tl, u_long *, 2 * NFSX_UNSIGNED); a1431 1 FREE((caddr_t)cookies, M_TEMP); d1440 1 a1440 1 cpos = rbuf; d1443 1 a1443 2 cookiep = cookies; while (dp->d_fileno == 0 && cpos < cend && ncookies > 0) { a1445 2 cookiep++; ncookies--; d1447 1 a1447 1 if (cpos >= cend || ncookies == 0) { d1450 1 d1454 5 a1458 7 len = 3 * NFSX_UNSIGNED; /* paranoia, probably can be 0 */ nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_COOKIEVERF(v3) + siz); if (v3) { nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_long *, 2 * NFSX_UNSIGNED); txdr_hyper(&at.va_filerev, tl); } d1464 1 a1464 1 while (cpos < cend && ncookies > 0) { d1468 1 a1468 3 len += (4 * NFSX_UNSIGNED + nlen + rem); if (v3) len += 2 * NFSX_UNSIGNED; a1479 5 if (v3) { nfsm_clget; *tl = 0; bp += NFSX_UNSIGNED; } d1508 2 a1509 6 if (v3) { *tl = 0; bp += NFSX_UNSIGNED; nfsm_clget; } *tl = txdr_unsigned(*cookiep); d1511 2 a1512 1 } a1514 2 cookiep++; ncookies--; d1531 1 a1531 2 FREE((caddr_t)rbuf, M_TEMP); FREE((caddr_t)cookies, M_TEMP); d1535 6 a1540 6 int nfsrv_readdirplus(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; a1541 4 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; d1553 2 a1554 2 nfsfh_t nfh; fhandle_t *fhp, *nfhp = (fhandle_t *)fl.fl_nfh; d1557 6 a1562 6 struct vattr va, at, *vap = &va; struct nfs_fattr *fp; int len, nlen, rem, xfer, tsiz, i, error = 0, getret = 1; int siz, cnt, fullsiz, eofflag, rdonly, cache, dirlen, ncookies; u_quad_t frev, off, toff, verf; u_long *cookies = NULL, *cookiep; d1566 9 a1574 12 nfsm_dissect(tl, u_long *, 6 * NFSX_UNSIGNED); fxdr_hyper(tl, &toff); tl += 2; fxdr_hyper(tl, &verf); tl += 2; siz = fxdr_unsigned(int, *tl++); cnt = fxdr_unsigned(int, *tl); off = toff; siz = ((siz + DIRBLKSIZ - 1) & ~(DIRBLKSIZ - 1)); xfer = NFS_SRVMAXDATA(nfsd); if (siz > xfer) siz = xfer; d1576 4 a1579 14 if (error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH))) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } error = getret = VOP_GETATTR(vp, &at, cred, procp); if (!error && toff && verf != at.va_filerev) error = NFSERR_BAD_COOKIE; if (!error) { nqsrv_getl(vp, ND_READ); error = nfsrv_access(vp, VEXEC, cred, rdonly, procp); } if (error) { d1581 1 a1581 3 nfsm_reply(NFSX_V3POSTOPATTR); nfsm_srvpostop_attr(getret, &at); return (0); d1583 1 a1583 1 VOP_UNLOCK(vp, 0, procp); d1595 2 a1596 12 eofflag = 0; if (cookies) { free((caddr_t)cookies, M_TEMP); cookies = NULL; } error = VOP_READDIR(vp, &io, cred, &eofflag, &ncookies, &cookies); off = (u_quad_t)io.uio_offset; getret = VOP_GETATTR(vp, &at, cred, procp); if (!cookies && !error) error = NFSERR_PERM; if (!error) error = getret; a1598 2 if (cookies) free((caddr_t)cookies, M_TEMP); d1600 1 a1600 3 nfsm_reply(NFSX_V3POSTOPATTR); nfsm_srvpostop_attr(getret, &at); return (0); d1602 4 d1615 2 a1616 6 nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF + 2 * NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_long *, 4 * NFSX_UNSIGNED); txdr_hyper(&at.va_filerev, tl); tl += 2; a1618 1 FREE((caddr_t)cookies, M_TEMP); d1628 1 a1628 1 cpos = rbuf; d1631 1 a1631 2 cookiep = cookies; while (dp->d_fileno == 0 && cpos < cend && ncookies > 0) { a1633 2 cookiep++; ncookies--; d1635 1 a1635 1 if (cpos >= cend || ncookies == 0) { d1638 1 d1642 5 a1646 5 dirlen = len = NFSX_V3POSTOPATTR + NFSX_V3COOKIEVERF + 2 * NFSX_UNSIGNED; nfsm_reply(cnt); nfsm_srvpostop_attr(getret, &at); nfsm_build(tl, u_long *, 2 * NFSX_UNSIGNED); txdr_hyper(&at.va_filerev, tl); d1652 1 a1652 1 while (cpos < cend && ncookies > 0) { d1663 2 a1664 2 bzero((caddr_t)nfhp, NFSX_V3FH); nfhp->fh_fsid = d1666 1 a1666 1 if (VFS_VPTOFH(nvp, &nfhp->fh_fid)) { d1670 9 a1678 1 if (VOP_GETATTR(nvp, vap, cred, procp)) { d1683 5 a1687 11 /* * If either the dircount or maxcount will be * exceeded, get out now. Both of these lengths * are calculated conservatively, including all * XDR overheads. */ len += (7 * NFSX_UNSIGNED + nlen + rem + NFSX_V3FH + NFSX_V3POSTOPATTR); dirlen += (6 * NFSX_UNSIGNED + nlen + rem); if (len > cnt || dirlen > fullsiz) { a1690 1 a1694 8 fp = (struct nfs_fattr *)&fl.fl_fattr; nfsm_srvfillattr(vap, fp); fl.fl_fhsize = txdr_unsigned(NFSX_V3FH); fl.fl_fhok = nfs_true; fl.fl_postopok = nfs_true; fl.fl_off.nfsuquad[0] = 0; fl.fl_off.nfsuquad[1] = txdr_unsigned(*cookiep); d1698 18 a1715 3 nfsm_clget; *tl = 0; bp += NFSX_UNSIGNED; d1728 2 a1729 2 if ((bp + xfer) > be) tsiz = be - bp; d1741 1 d1743 5 a1747 18 /* * Now copy the flrep structure out. */ xfer = sizeof (struct flrep); cp = (caddr_t)&fl; while (xfer > 0) { nfsm_clget; if ((bp + xfer) > be) tsiz = be - bp; else tsiz = xfer; bcopy(cp, bp, tsiz); bp += tsiz; xfer -= tsiz; if (xfer > 0) cp += tsiz; } } d1749 1 a1751 2 cookiep++; ncookies--; d1768 1 a1768 63 FREE((caddr_t)cookies, M_TEMP); FREE((caddr_t)rbuf, M_TEMP); nfsm_srvdone; } /* * nfs commit service */ int nfsrv_commit(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; struct vattr bfor, aft; struct vnode *vp; nfsfh_t nfh; fhandle_t *fhp; register u_long *tl; register long t1; caddr_t bpos; int error = 0, rdonly, for_ret = 1, aft_ret = 1, cnt, cache; char *cp2; struct mbuf *mb, *mb2, *mreq; u_quad_t frev, off; #ifndef nolint cache = 0; #endif fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); nfsm_dissect(tl, u_long *, 3 * NFSX_UNSIGNED); /* * XXX At this time VOP_FSYNC() does not accept offset and byte * count parameters, so these arguments are useless (someday maybe). */ fxdr_hyper(tl, &off); tl += 2; cnt = fxdr_unsigned(int, *tl); if (error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH))) { nfsm_reply(2 * NFSX_UNSIGNED); nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft); return (0); } for_ret = VOP_GETATTR(vp, &bfor, cred, procp); error = VOP_FSYNC(vp, cred, MNT_WAIT, procp); aft_ret = VOP_GETATTR(vp, &aft, cred, procp); vput(vp); nfsm_reply(NFSX_V3WCCDATA + NFSX_V3WRITEVERF); nfsm_srvwcc_data(for_ret, &bfor, aft_ret, &aft); if (!error) { nfsm_build(tl, u_long *, NFSX_V3WRITEVERF); *tl++ = txdr_unsigned(boottime.tv_sec); *tl = txdr_unsigned(boottime.tv_usec); } else return (0); d1775 6 a1780 6 int nfsrv_statfs(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; a1781 4 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; d1783 1 a1783 1 register struct nfs_statfs *sfp; d1787 1 a1787 2 int error = 0, rdonly, cache, getret = 1; int v3 = (nfsd->nd_flag & ND_NFSV3); d1791 1 a1791 2 struct vattr at; nfsfh_t nfh; d1794 1 a1794 1 u_quad_t frev, tval; a1795 3 #ifndef nolint cache = 0; #endif d1797 1 d1799 2 a1800 6 if (error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH))) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } d1802 1 a1802 2 error = VFS_STATFS(vp->v_mount, sf, procp); getret = VOP_GETATTR(vp, &at, cred, procp); d1804 10 a1813 70 nfsm_reply(NFSX_POSTOPATTR(v3) + NFSX_STATFS(v3)); if (v3) nfsm_srvpostop_attr(getret, &at); if (error) return (0); nfsm_build(sfp, struct nfs_statfs *, NFSX_STATFS(v3)); if (v3) { tval = (u_quad_t)sf->f_blocks; tval *= (u_quad_t)sf->f_bsize; txdr_hyper(&tval, &sfp->sf_tbytes); tval = (u_quad_t)sf->f_bfree; tval *= (u_quad_t)sf->f_bsize; txdr_hyper(&tval, &sfp->sf_fbytes); tval = (u_quad_t)sf->f_bavail; tval *= (u_quad_t)sf->f_bsize; txdr_hyper(&tval, &sfp->sf_abytes); sfp->sf_tfiles.nfsuquad[0] = 0; sfp->sf_tfiles.nfsuquad[1] = txdr_unsigned(sf->f_files); sfp->sf_ffiles.nfsuquad[0] = 0; sfp->sf_ffiles.nfsuquad[1] = txdr_unsigned(sf->f_ffree); sfp->sf_afiles.nfsuquad[0] = 0; sfp->sf_afiles.nfsuquad[1] = txdr_unsigned(sf->f_ffree); sfp->sf_invarsec = 0; } else { sfp->sf_tsize = txdr_unsigned(NFS_MAXDGRAMDATA); sfp->sf_bsize = txdr_unsigned(sf->f_bsize); sfp->sf_blocks = txdr_unsigned(sf->f_blocks); sfp->sf_bfree = txdr_unsigned(sf->f_bfree); sfp->sf_bavail = txdr_unsigned(sf->f_bavail); } nfsm_srvdone; } /* * nfs fsinfo service */ int nfsrv_fsinfo(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; register u_long *tl; register struct nfsv3_fsinfo *sip; register long t1; caddr_t bpos; int error = 0, rdonly, cache, getret = 1, pref; char *cp2; struct mbuf *mb, *mb2, *mreq; struct vnode *vp; struct vattr at; nfsfh_t nfh; fhandle_t *fhp; u_quad_t frev; #ifndef nolint cache = 0; #endif fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); if (error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH))) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); a1814 98 getret = VOP_GETATTR(vp, &at, cred, procp); vput(vp); nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3FSINFO); nfsm_srvpostop_attr(getret, &at); nfsm_build(sip, struct nfsv3_fsinfo *, NFSX_V3FSINFO); /* * XXX * There should be file system VFS OP(s) to get this information. * For now, assume ufs. */ if (slp->ns_so->so_type == SOCK_DGRAM) pref = NFS_MAXDGRAMDATA; else pref = NFS_MAXDATA; sip->fs_rtmax = txdr_unsigned(NFS_MAXDATA); sip->fs_rtpref = txdr_unsigned(pref); sip->fs_rtmult = txdr_unsigned(NFS_FABLKSIZE); sip->fs_wtmax = txdr_unsigned(NFS_MAXDATA); sip->fs_wtpref = txdr_unsigned(pref); sip->fs_wtmult = txdr_unsigned(NFS_FABLKSIZE); sip->fs_dtpref = txdr_unsigned(pref); sip->fs_maxfilesize.nfsuquad[0] = 0xffffffff; sip->fs_maxfilesize.nfsuquad[1] = 0xffffffff; sip->fs_timedelta.nfsv3_sec = 0; sip->fs_timedelta.nfsv3_nsec = txdr_unsigned(1); sip->fs_properties = txdr_unsigned(NFSV3FSINFO_LINK | NFSV3FSINFO_SYMLINK | NFSV3FSINFO_HOMOGENEOUS | NFSV3FSINFO_CANSETTIME); nfsm_srvdone; } /* * nfs pathconf service */ int nfsrv_pathconf(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; { struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; register u_long *tl; register struct nfsv3_pathconf *pc; register long t1; caddr_t bpos; int error = 0, rdonly, cache, getret = 1, linkmax, namemax; int chownres, notrunc; char *cp2; struct mbuf *mb, *mb2, *mreq; struct vnode *vp; struct vattr at; nfsfh_t nfh; fhandle_t *fhp; u_quad_t frev; #ifndef nolint cache = 0; #endif fhp = &nfh.fh_generic; nfsm_srvmtofh(fhp); if (error = nfsrv_fhtovp(fhp, 1, &vp, cred, slp, nam, &rdonly, (nfsd->nd_flag & ND_KERBAUTH))) { nfsm_reply(NFSX_UNSIGNED); nfsm_srvpostop_attr(getret, &at); return (0); } error = VOP_PATHCONF(vp, _PC_LINK_MAX, &linkmax); if (!error) error = VOP_PATHCONF(vp, _PC_NAME_MAX, &namemax); if (!error) error = VOP_PATHCONF(vp, _PC_CHOWN_RESTRICTED, &chownres); if (!error) error = VOP_PATHCONF(vp, _PC_NO_TRUNC, ¬runc); getret = VOP_GETATTR(vp, &at, cred, procp); vput(vp); nfsm_reply(NFSX_V3POSTOPATTR + NFSX_V3PATHCONF); nfsm_srvpostop_attr(getret, &at); if (error) return (0); nfsm_build(pc, struct nfsv3_pathconf *, NFSX_V3PATHCONF); pc->pc_linkmax = txdr_unsigned(linkmax); pc->pc_namemax = txdr_unsigned(namemax); pc->pc_notrunc = txdr_unsigned(notrunc); pc->pc_chownrestricted = txdr_unsigned(chownres); /* * These should probably be supported by VOP_PATHCONF(), but * until msdosfs is exportable (why would you want to?), the * Unix defaults should be ok. */ pc->pc_caseinsensitive = nfs_false; pc->pc_casepreserving = nfs_true; d1822 6 a1827 6 int nfsrv_null(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; a1828 4 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; d1830 1 a1830 1 int error = NFSERR_RETVOID, cache; a1833 3 #ifndef nolint cache = 0; #endif d1835 1 a1835 1 return (0); d1842 6 a1847 6 int nfsrv_noop(nfsd, slp, procp, mrq) struct nfsrv_descript *nfsd; struct nfssvc_sock *slp; struct proc *procp; struct mbuf **mrq; a1848 4 struct mbuf *mrep = nfsd->nd_mrep, *md = nfsd->nd_md; struct mbuf *nam = nfsd->nd_nam; caddr_t dpos = nfsd->nd_dpos; struct ucred *cred = &nfsd->nd_cr; a1853 3 #ifndef nolint cache = 0; #endif d1859 1 a1859 1 return (0); a1871 1 int @ 1.1.1.4 log @Import some files that were changed after Lite2 @ text @d36 1 a36 1 * @@(#)nfs_serv.c 8.8 (Berkeley) 7/31/95 d2009 1 a2009 1 error = VOP_LINK(nd.ni_dvp, vp, &nd.ni_cnd); @