pseudofs_vnops.c (b40ce4165d5eb3a5de1515245055350ae3dbab8e) pseudofs_vnops.c (8712e867e154486e517cb997744118439d8d3d1a)
1/*-
2 * Copyright (c) 2001 Dag-Erling Co�dan Sm�rgrav
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 202 unchanged lines hidden (view full) ---

211 struct proc *proc = NULL;
212 struct sbuf *sb = NULL;
213 char *ps;
214 int error, xlen;
215
216 if (vn->v_type != VREG)
217 return (EINVAL);
218
1/*-
2 * Copyright (c) 2001 Dag-Erling Co�dan Sm�rgrav
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 202 unchanged lines hidden (view full) ---

211 struct proc *proc = NULL;
212 struct sbuf *sb = NULL;
213 char *ps;
214 int error, xlen;
215
216 if (vn->v_type != VREG)
217 return (EINVAL);
218
219 if (pn->pn_flags & PFS_WRONLY)
220 return (EBADF);
221
219 if (pvd->pvd_pid != NO_PID) {
220 if ((proc = pfind(pvd->pvd_pid)) == NULL)
221 return (EIO);
222 _PHOLD(proc);
223 PROC_UNLOCK(proc);
224 }
222 if (pvd->pvd_pid != NO_PID) {
223 if ((proc = pfind(pvd->pvd_pid)) == NULL)
224 return (EIO);
225 _PHOLD(proc);
226 PROC_UNLOCK(proc);
227 }
228
229 if (pn->pn_flags & PFS_RAWRD) {
230 error = (pn->pn_func)(curproc, proc, pn, NULL, uio);
231 if (proc != NULL)
232 PRELE(proc);
233 return (error);
234 }
225
226 sb = sbuf_new(sb, NULL, uio->uio_offset + uio->uio_resid, 0);
227 if (sb == NULL) {
228 if (proc != NULL)
229 PRELE(proc);
230 return (EIO);
231 }
232
235
236 sb = sbuf_new(sb, NULL, uio->uio_offset + uio->uio_resid, 0);
237 if (sb == NULL) {
238 if (proc != NULL)
239 PRELE(proc);
240 return (EIO);
241 }
242
233 error = (pn->pn_func)(curthread, proc, pn, sb);
243 error = (pn->pn_func)(curthread, proc, pn, sb, uio);
234
235 if (proc != NULL)
236 PRELE(proc);
237
238 if (error) {
239 sbuf_delete(sb);
240 return (error);
241 }

--- 145 unchanged lines hidden (view full) ---

387 return (EIO);
388 _PHOLD(proc);
389 PROC_UNLOCK(proc);
390 }
391
392 /* sbuf_new() can't fail with a static buffer */
393 sbuf_new(&sb, buf, sizeof buf, 0);
394
244
245 if (proc != NULL)
246 PRELE(proc);
247
248 if (error) {
249 sbuf_delete(sb);
250 return (error);
251 }

--- 145 unchanged lines hidden (view full) ---

397 return (EIO);
398 _PHOLD(proc);
399 PROC_UNLOCK(proc);
400 }
401
402 /* sbuf_new() can't fail with a static buffer */
403 sbuf_new(&sb, buf, sizeof buf, 0);
404
395 error = (pn->pn_func)(curthread, proc, pn, &sb);
405 error = (pn->pn_func)(curthread, proc, pn, &sb, NULL);
396
397 if (proc != NULL)
398 PRELE(proc);
399
400 if (error) {
401 sbuf_delete(&sb);
402 return (error);
403 }

--- 25 unchanged lines hidden (view full) ---

429{
430 if (va->a_vap->va_flags != (u_long)VNOVAL)
431 return (EOPNOTSUPP);
432 /* XXX it's a bit more complex than that, really... */
433 return (0);
434}
435
436/*
406
407 if (proc != NULL)
408 PRELE(proc);
409
410 if (error) {
411 sbuf_delete(&sb);
412 return (error);
413 }

--- 25 unchanged lines hidden (view full) ---

439{
440 if (va->a_vap->va_flags != (u_long)VNOVAL)
441 return (EOPNOTSUPP);
442 /* XXX it's a bit more complex than that, really... */
443 return (0);
444}
445
446/*
437 * Dummy operations
447 * Read from a file
438 */
448 */
449static int
450pfs_write(struct vop_read_args *va)
451{
452 struct vnode *vn = va->a_vp;
453 struct pfs_vdata *pvd = (struct pfs_vdata *)vn->v_data;
454 struct pfs_node *pn = pvd->pvd_pn;
455 struct uio *uio = va->a_uio;
456 struct proc *proc = NULL;
457 int error;
458
459 if (vn->v_type != VREG)
460 return (EINVAL);
461
462 if (pn->pn_flags & PFS_RDONLY)
463 return (EBADF);
464
465 if (pvd->pvd_pid != NO_PID) {
466 if ((proc = pfind(pvd->pvd_pid)) == NULL)
467 return (EIO);
468 _PHOLD(proc);
469 PROC_UNLOCK(proc);
470 }
471
472 if (pn->pn_flags & PFS_RAWWR) {
473 error = (pn->pn_func)(curproc, proc, pn, NULL, uio);
474 if (proc != NULL)
475 PRELE(proc);
476 return (error);
477 }
478
479 /*
480 * We currently don't support non-raw writers. It's not very
481 * hard to do, but it probably requires further changes to the
482 * sbuf API.
483 */
484 return (EIO);
485}
486
487/*
488 * Dummy operations */
439static int pfs_erofs(void *va) { return (EROFS); }
440#if 0
441static int pfs_null(void *va) { return (0); }
442#endif
443
444/*
445 * Vnode operations
446 */

--- 12 unchanged lines hidden (view full) ---

459 { &vop_readdir_desc, (vop_t *)pfs_readdir },
460 { &vop_readlink_desc, (vop_t *)pfs_readlink },
461 { &vop_reclaim_desc, (vop_t *)pfs_reclaim },
462 { &vop_remove_desc, (vop_t *)pfs_erofs },
463 { &vop_rename_desc, (vop_t *)pfs_erofs },
464 { &vop_rmdir_desc, (vop_t *)pfs_erofs },
465 { &vop_setattr_desc, (vop_t *)pfs_setattr },
466 { &vop_symlink_desc, (vop_t *)pfs_erofs },
489static int pfs_erofs(void *va) { return (EROFS); }
490#if 0
491static int pfs_null(void *va) { return (0); }
492#endif
493
494/*
495 * Vnode operations
496 */

--- 12 unchanged lines hidden (view full) ---

509 { &vop_readdir_desc, (vop_t *)pfs_readdir },
510 { &vop_readlink_desc, (vop_t *)pfs_readlink },
511 { &vop_reclaim_desc, (vop_t *)pfs_reclaim },
512 { &vop_remove_desc, (vop_t *)pfs_erofs },
513 { &vop_rename_desc, (vop_t *)pfs_erofs },
514 { &vop_rmdir_desc, (vop_t *)pfs_erofs },
515 { &vop_setattr_desc, (vop_t *)pfs_setattr },
516 { &vop_symlink_desc, (vop_t *)pfs_erofs },
467 { &vop_write_desc, (vop_t *)pfs_erofs },
517 { &vop_write_desc, (vop_t *)pfs_write },
468 /* XXX I've probably forgotten a few that need pfs_erofs */
469 { NULL, (vop_t *)NULL }
470};
471
472static struct vnodeopv_desc pfs_vnodeop_opv_desc =
473 { &pfs_vnodeop_p, pfs_vnodeop_entries };
474
475VNODEOP_SET(pfs_vnodeop_opv_desc);
476
518 /* XXX I've probably forgotten a few that need pfs_erofs */
519 { NULL, (vop_t *)NULL }
520};
521
522static struct vnodeopv_desc pfs_vnodeop_opv_desc =
523 { &pfs_vnodeop_p, pfs_vnodeop_entries };
524
525VNODEOP_SET(pfs_vnodeop_opv_desc);
526