| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ukfs.c,v 1.8 2008/09/29 15:59:54 pooka Exp $ */ | | 1 | /* $NetBSD: ukfs.c,v 1.9 2008/09/30 19:26:23 pooka Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2007, 2008 Antti Kantee. All Rights Reserved. | | 4 | * Copyright (c) 2007, 2008 Antti Kantee. All Rights Reserved. |
5 | * | | 5 | * |
6 | * Development of this software was supported by the | | 6 | * Development of this software was supported by the |
7 | * Finnish Cultural Foundation. | | 7 | * Finnish Cultural Foundation. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -184,28 +184,32 @@ ukfs_mount(const char *vfsname, const ch | | | @@ -184,28 +184,32 @@ ukfs_mount(const char *vfsname, const ch |
184 | errno = rv; | | 184 | errno = rv; |
185 | fs = NULL; | | 185 | fs = NULL; |
186 | } | | 186 | } |
187 | | | 187 | |
188 | return fs; | | 188 | return fs; |
189 | } | | 189 | } |
190 | | | 190 | |
191 | void | | 191 | void |
192 | ukfs_release(struct ukfs *fs, int flags) | | 192 | ukfs_release(struct ukfs *fs, int flags) |
193 | { | | 193 | { |
194 | int rv; | | 194 | int rv; |
195 | | | 195 | |
196 | if ((flags & UKFS_RELFLAG_NOUNMOUNT) == 0) { | | 196 | if ((flags & UKFS_RELFLAG_NOUNMOUNT) == 0) { |
| | | 197 | kauth_cred_t cred; |
| | | 198 | |
197 | rump_vp_rele(fs->ukfs_cdir); | | 199 | rump_vp_rele(fs->ukfs_cdir); |
198 | rv = rump_vfs_sync(fs->ukfs_mp, 1, RUMPCRED_SUSER); | | 200 | cred = rump_cred_suserget(); |
| | | 201 | rv = rump_vfs_sync(fs->ukfs_mp, 1, cred); |
| | | 202 | rump_cred_suserput(cred); |
199 | rump_vp_recycle_nokidding(ukfs_getrvp(fs)); | | 203 | rump_vp_recycle_nokidding(ukfs_getrvp(fs)); |
200 | rv |= rump_vfs_unmount(fs->ukfs_mp, 0); | | 204 | rv |= rump_vfs_unmount(fs->ukfs_mp, 0); |
201 | assert(rv == 0); | | 205 | assert(rv == 0); |
202 | } | | 206 | } |
203 | | | 207 | |
204 | rump_vfs_syncwait(fs->ukfs_mp); | | 208 | rump_vfs_syncwait(fs->ukfs_mp); |
205 | rump_mnt_destroy(fs->ukfs_mp); | | 209 | rump_mnt_destroy(fs->ukfs_mp); |
206 | | | 210 | |
207 | pthread_spin_destroy(&fs->ukfs_spin); | | 211 | pthread_spin_destroy(&fs->ukfs_spin); |
208 | free(fs); | | 212 | free(fs); |
209 | } | | 213 | } |
210 | | | 214 | |
211 | /* don't need vn_lock(), since we don't have VXLOCK */ | | 215 | /* don't need vn_lock(), since we don't have VXLOCK */ |
| @@ -223,37 +227,40 @@ ukfs_release(struct ukfs *fs, int flags) | | | @@ -223,37 +227,40 @@ ukfs_release(struct ukfs *fs, int flags) |
223 | if (rv) { \ | | 227 | if (rv) { \ |
224 | errno = rv; \ | | 228 | errno = rv; \ |
225 | return -1; \ | | 229 | return -1; \ |
226 | } \ | | 230 | } \ |
227 | return 0; | | 231 | return 0; |
228 | | | 232 | |
229 | int | | 233 | int |
230 | ukfs_getdents(struct ukfs *ukfs, const char *dirname, off_t *off, | | 234 | ukfs_getdents(struct ukfs *ukfs, const char *dirname, off_t *off, |
231 | uint8_t *buf, size_t bufsize) | | 235 | uint8_t *buf, size_t bufsize) |
232 | { | | 236 | { |
233 | struct uio *uio; | | 237 | struct uio *uio; |
234 | struct vnode *vp; | | 238 | struct vnode *vp; |
235 | size_t resid; | | 239 | size_t resid; |
| | | 240 | kauth_cred_t cred; |
236 | int rv, eofflag; | | 241 | int rv, eofflag; |
237 | | | 242 | |
238 | precall(ukfs); | | 243 | precall(ukfs); |
239 | rv = rump_namei(RUMP_NAMEI_LOOKUP, RUMP_NAMEI_LOCKLEAF, dirname, | | 244 | rv = rump_namei(RUMP_NAMEI_LOOKUP, RUMP_NAMEI_LOCKLEAF, dirname, |
240 | NULL, &vp, NULL); | | 245 | NULL, &vp, NULL); |
241 | postcall(ukfs); | | 246 | postcall(ukfs); |
242 | if (rv) | | 247 | if (rv) |
243 | goto out; | | 248 | goto out; |
244 | | | 249 | |
245 | uio = rump_uio_setup(buf, bufsize, *off, RUMPUIO_READ); | | 250 | uio = rump_uio_setup(buf, bufsize, *off, RUMPUIO_READ); |
246 | rv = RUMP_VOP_READDIR(vp, uio, RUMPCRED_SUSER, &eofflag, NULL, NULL); | | 251 | cred = rump_cred_suserget(); |
| | | 252 | rv = RUMP_VOP_READDIR(vp, uio, cred, &eofflag, NULL, NULL); |
| | | 253 | rump_cred_suserput(cred); |
247 | VUL(vp); | | 254 | VUL(vp); |
248 | *off = rump_uio_getoff(uio); | | 255 | *off = rump_uio_getoff(uio); |
249 | resid = rump_uio_free(uio); | | 256 | resid = rump_uio_free(uio); |
250 | rump_vp_rele(vp); | | 257 | rump_vp_rele(vp); |
251 | | | 258 | |
252 | out: | | 259 | out: |
253 | if (rv) { | | 260 | if (rv) { |
254 | errno = rv; | | 261 | errno = rv; |
255 | return -1; | | 262 | return -1; |
256 | } | | 263 | } |
257 | | | 264 | |
258 | /* LINTED: not totally correct return type, but follows syscall */ | | 265 | /* LINTED: not totally correct return type, but follows syscall */ |
259 | return bufsize - resid; | | 266 | return bufsize - resid; |