apply wide-angle rotollation beam to match libpuffs changes
This commit is contained in:
parent
fb7890b666
commit
6a42c9c838
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dtfs.c,v 1.11 2006/12/07 22:49:04 pooka Exp $ */
|
||||
/* $NetBSD: dtfs.c,v 1.12 2006/12/29 15:37:06 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
|
||||
|
@ -56,7 +56,7 @@ static void
|
|||
usage()
|
||||
{
|
||||
|
||||
errx(1, "usage: %s [-acds] mountpath", getprogname());
|
||||
errx(1, "usage: %s [-abcds] mountpath", getprogname());
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -64,19 +64,23 @@ main(int argc, char *argv[])
|
|||
{
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
struct dtfs_mount dtm;
|
||||
struct puffs_usermount *pu;
|
||||
struct puffs_ops pops;
|
||||
struct puffs_ops *pops;
|
||||
int pflags, lflags;
|
||||
int ch;
|
||||
|
||||
setprogname(argv[0]);
|
||||
|
||||
pflags = lflags = 0;
|
||||
while ((ch = getopt(argc, argv, "acds")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "abcds")) != -1) {
|
||||
switch (ch) {
|
||||
case 'a': /* all ops */
|
||||
pflags |= PUFFS_KFLAG_ALLOPS;
|
||||
break;
|
||||
case 'b': /* build paths */
|
||||
pflags |= PUFFS_FLAG_BUILDPATH;
|
||||
break;
|
||||
case 'c': /* no cache */
|
||||
pflags |= PUFFS_KFLAG_NOCACHE;
|
||||
break;
|
||||
|
@ -97,32 +101,33 @@ main(int argc, char *argv[])
|
|||
if (argc != 1)
|
||||
usage();
|
||||
|
||||
PUFFSOP_INIT(&pops);
|
||||
PUFFSOP_INIT(pops);
|
||||
|
||||
PUFFSOP_SET(&pops, dtfs, fs, mount);
|
||||
PUFFSOP_SET(&pops, dtfs, fs, statvfs);
|
||||
PUFFSOP_SETFSNOP(&pops, unmount);
|
||||
PUFFSOP_SETFSNOP(&pops, sync);
|
||||
PUFFSOP_SET(pops, dtfs, fs, mount);
|
||||
PUFFSOP_SET(pops, dtfs, fs, statvfs);
|
||||
PUFFSOP_SETFSNOP(pops, unmount);
|
||||
PUFFSOP_SETFSNOP(pops, sync);
|
||||
|
||||
PUFFSOP_SET(&pops, dtfs, node, lookup);
|
||||
PUFFSOP_SET(&pops, dtfs, node, getattr);
|
||||
PUFFSOP_SET(&pops, dtfs, node, setattr);
|
||||
PUFFSOP_SET(&pops, dtfs, node, create);
|
||||
PUFFSOP_SET(&pops, dtfs, node, remove);
|
||||
PUFFSOP_SET(&pops, dtfs, node, readdir);
|
||||
PUFFSOP_SET(&pops, dtfs, node, mkdir);
|
||||
PUFFSOP_SET(&pops, dtfs, node, rmdir);
|
||||
PUFFSOP_SET(&pops, dtfs, node, rename);
|
||||
PUFFSOP_SET(&pops, dtfs, node, read);
|
||||
PUFFSOP_SET(&pops, dtfs, node, write);
|
||||
PUFFSOP_SET(&pops, dtfs, node, link);
|
||||
PUFFSOP_SET(&pops, dtfs, node, symlink);
|
||||
PUFFSOP_SET(&pops, dtfs, node, readlink);
|
||||
PUFFSOP_SET(&pops, dtfs, node, mknod);
|
||||
PUFFSOP_SET(&pops, dtfs, node, inactive);
|
||||
PUFFSOP_SET(&pops, dtfs, node, reclaim);
|
||||
PUFFSOP_SET(pops, dtfs, node, lookup);
|
||||
PUFFSOP_SET(pops, dtfs, node, getattr);
|
||||
PUFFSOP_SET(pops, dtfs, node, setattr);
|
||||
PUFFSOP_SET(pops, dtfs, node, create);
|
||||
PUFFSOP_SET(pops, dtfs, node, remove);
|
||||
PUFFSOP_SET(pops, dtfs, node, readdir);
|
||||
PUFFSOP_SET(pops, dtfs, node, mkdir);
|
||||
PUFFSOP_SET(pops, dtfs, node, rmdir);
|
||||
PUFFSOP_SET(pops, dtfs, node, rename);
|
||||
PUFFSOP_SET(pops, dtfs, node, read);
|
||||
PUFFSOP_SET(pops, dtfs, node, write);
|
||||
PUFFSOP_SET(pops, dtfs, node, link);
|
||||
PUFFSOP_SET(pops, dtfs, node, symlink);
|
||||
PUFFSOP_SET(pops, dtfs, node, readlink);
|
||||
PUFFSOP_SET(pops, dtfs, node, mknod);
|
||||
PUFFSOP_SET(pops, dtfs, node, inactive);
|
||||
PUFFSOP_SET(pops, dtfs, node, reclaim);
|
||||
|
||||
if ((pu = puffs_mount(&pops, argv[0], 0, FSNAME, pflags, 0)) == NULL)
|
||||
if ((pu = puffs_mount(pops, argv[0], 0, FSNAME, &dtm, pflags, 0))
|
||||
== NULL)
|
||||
err(1, "mount");
|
||||
|
||||
if (puffs_mainloop(pu, lflags) == -1)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dtfs_subr.c,v 1.8 2006/12/05 14:32:03 pooka Exp $ */
|
||||
/* $NetBSD: dtfs_subr.c,v 1.9 2006/12/29 15:37:06 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
|
||||
|
@ -88,7 +88,7 @@ dtfs_genfile(struct puffs_node *dir, const char *name, enum vtype type)
|
|||
struct dtfs_mount *dtm;
|
||||
struct puffs_node *newpn;
|
||||
|
||||
assert(dir->pn_type == VDIR);
|
||||
assert(dir->pn_va.va_type == VDIR);
|
||||
assert(dir->pn_mnt != NULL);
|
||||
|
||||
if (type == VDIR) {
|
||||
|
@ -98,7 +98,7 @@ dtfs_genfile(struct puffs_node *dir, const char *name, enum vtype type)
|
|||
dff = dtfs_newfile();
|
||||
|
||||
dtm = dir->pn_mnt->pu_privdata;
|
||||
newpn = puffs_newpnode(dir->pn_mnt, dff, type);
|
||||
newpn = puffs_pn_new(dir->pn_mnt, dff);
|
||||
if (newpn == NULL)
|
||||
errx(1, "getnewpnode");
|
||||
dtfs_baseattrs(&newpn->pn_va, type, dtm->dtm_nextfileid++);
|
||||
|
@ -197,7 +197,7 @@ dtfs_freenode(struct puffs_node *pn)
|
|||
assert(pn->pn_va.va_nlink == 0);
|
||||
dtm = pn->pn_mnt->pu_privdata;
|
||||
|
||||
switch (pn->pn_type) {
|
||||
switch (pn->pn_va.va_type) {
|
||||
case VREG:
|
||||
assert(dtm->dtm_fsizes >= pn->pn_va.va_size);
|
||||
dtm->dtm_fsizes -= pn->pn_va.va_size;
|
||||
|
@ -218,7 +218,7 @@ dtfs_freenode(struct puffs_node *pn)
|
|||
}
|
||||
|
||||
free(df);
|
||||
puffs_putpnode(pn);
|
||||
puffs_pn_put(pn);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -259,7 +259,7 @@ dtfs_adddent(struct puffs_node *pn_dir, struct dtfs_dirent *dent)
|
|||
struct dtfs_file *file = DTFS_PTOF(pn_file);
|
||||
struct dtfs_mount *dtm;
|
||||
|
||||
assert(pn_dir->pn_type == VDIR);
|
||||
assert(pn_dir->pn_va.va_type == VDIR);
|
||||
LIST_INSERT_HEAD(&dir->df_dirents, dent, dfd_entries);
|
||||
pn_file->pn_va.va_nlink++;
|
||||
|
||||
|
@ -267,7 +267,7 @@ dtfs_adddent(struct puffs_node *pn_dir, struct dtfs_dirent *dent)
|
|||
dtm->dtm_nfiles++;
|
||||
|
||||
dent->dfd_parent = pn_dir;
|
||||
if (dent->dfd_node->pn_type == VDIR) {
|
||||
if (dent->dfd_node->pn_va.va_type == VDIR) {
|
||||
file->df_dotdot = pn_dir;
|
||||
pn_dir->pn_va.va_nlink++;
|
||||
}
|
||||
|
@ -281,9 +281,9 @@ dtfs_removedent(struct puffs_node *pn_dir, struct dtfs_dirent *dent)
|
|||
{
|
||||
struct puffs_node *pn_file = dent->dfd_node;
|
||||
|
||||
assert(pn_dir->pn_type == VDIR);
|
||||
assert(pn_dir->pn_va.va_type == VDIR);
|
||||
LIST_REMOVE(dent, dfd_entries);
|
||||
if (pn_file->pn_type == VDIR)
|
||||
if (pn_file->pn_va.va_type == VDIR)
|
||||
pn_dir->pn_va.va_nlink--;
|
||||
pn_file->pn_va.va_nlink--;
|
||||
assert(pn_dir->pn_va.va_nlink >= 2);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dtfs_vfsops.c,v 1.7 2006/12/07 10:54:29 pooka Exp $ */
|
||||
/* $NetBSD: dtfs_vfsops.c,v 1.8 2006/12/29 15:37:06 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
|
||||
|
@ -40,18 +40,19 @@
|
|||
#include "dtfs.h"
|
||||
|
||||
int
|
||||
dtfs_fs_mount(struct puffs_usermount *pu, void **rootcookie)
|
||||
dtfs_fs_mount(struct puffs_usermount *pu, void **rootcookie,
|
||||
struct statvfs *sbp)
|
||||
{
|
||||
struct dtfs_mount *dtm;
|
||||
struct dtfs_file *dff;
|
||||
struct puffs_node *pn;
|
||||
struct vattr *va;
|
||||
|
||||
/* create mount-local thingie */
|
||||
dtm = emalloc(sizeof(struct dtfs_mount));
|
||||
dtm = pu->pu_privdata;
|
||||
dtm->dtm_nextfileid = 2;
|
||||
dtm->dtm_nfiles = 1;
|
||||
dtm->dtm_fsizes = 0;
|
||||
pu->pu_privdata = dtm;
|
||||
|
||||
/*
|
||||
* create root directory, do it "by hand" to avoid special-casing
|
||||
|
@ -59,17 +60,21 @@ dtfs_fs_mount(struct puffs_usermount *pu, void **rootcookie)
|
|||
*/
|
||||
dff = dtfs_newdir();
|
||||
dff->df_dotdot = NULL;
|
||||
pn = puffs_newpnode(pu, dff, VDIR);
|
||||
pn = puffs_pn_new(pu, dff);
|
||||
if (!pn)
|
||||
errx(1, "puffs_newpnode");
|
||||
|
||||
dtfs_baseattrs(&pn->pn_va, VDIR, dtm->dtm_nextfileid++);
|
||||
va = &pn->pn_va;
|
||||
dtfs_baseattrs(va, VDIR, dtm->dtm_nextfileid++);
|
||||
/* not adddented, so compensate */
|
||||
pn->pn_va.va_nlink = 2;
|
||||
va->va_nlink = 2;
|
||||
|
||||
pu->pu_rootnode = pn;
|
||||
pu->pu_pn_root = pn;
|
||||
puffs_setrootpath(pu, ".");
|
||||
*rootcookie = pn;
|
||||
|
||||
memset(sbp, 0, sizeof(struct statvfs));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -97,13 +102,15 @@ dtfs_fs_mount(struct puffs_usermount *pu, void **rootcookie)
|
|||
#define ROUND(a,b) (((a) + ((b)-1)) & ~((b)-1))
|
||||
#define NFILES 1024*1024
|
||||
int
|
||||
dtfs_fs_statvfs(struct puffs_usermount *pu, struct statvfs *sbp, pid_t pid)
|
||||
dtfs_fs_statvfs(struct puffs_cc *pcc, struct statvfs *sbp, pid_t pid)
|
||||
{
|
||||
struct puffs_usermount *pu;
|
||||
struct rlimit rlim;
|
||||
struct dtfs_mount *dtm;
|
||||
off_t btot, bfree;
|
||||
int pgsize;
|
||||
|
||||
pu = puffs_cc_getusermount(pcc);
|
||||
dtm = pu->pu_privdata;
|
||||
pgsize = getpagesize();
|
||||
memset(sbp, 0, sizeof(struct statvfs));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: dtfs_vnops.c,v 1.9 2006/12/07 10:54:29 pooka Exp $ */
|
||||
/* $NetBSD: dtfs_vnops.c,v 1.10 2006/12/29 15:37:06 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
|
||||
|
@ -36,12 +36,13 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ucontext.h>
|
||||
#include <util.h>
|
||||
|
||||
#include "dtfs.h"
|
||||
|
||||
int
|
||||
dtfs_node_lookup(struct puffs_usermount *pu, void *opc, void **newnode,
|
||||
dtfs_node_lookup(struct puffs_cc *pcc, void *opc, void **newnode,
|
||||
enum vtype *newtype, voff_t *newsize, dev_t *newrdev,
|
||||
const struct puffs_cn *pcn)
|
||||
{
|
||||
|
@ -72,7 +73,7 @@ dtfs_node_lookup(struct puffs_usermount *pu, void *opc, void **newnode,
|
|||
|
||||
/* no credcheck */
|
||||
int
|
||||
dtfs_node_getattr(struct puffs_usermount *pu, void *opc,
|
||||
dtfs_node_getattr(struct puffs_cc *pcc, void *opc,
|
||||
struct vattr *va, const struct puffs_cred *pcr, pid_t pid)
|
||||
{
|
||||
struct dtfs_file *df = DTFS_CTOF(opc);
|
||||
|
@ -87,7 +88,7 @@ dtfs_node_getattr(struct puffs_usermount *pu, void *opc,
|
|||
|
||||
/* no credcheck */
|
||||
int
|
||||
dtfs_node_setattr(struct puffs_usermount *pu, void *opc,
|
||||
dtfs_node_setattr(struct puffs_cc *pcc, void *opc,
|
||||
const struct vattr *va, const struct puffs_cred *pcr, pid_t pid)
|
||||
{
|
||||
struct puffs_node *pn = opc;
|
||||
|
@ -96,7 +97,7 @@ dtfs_node_setattr(struct puffs_usermount *pu, void *opc,
|
|||
/* (must be called before setattr! XXX) */
|
||||
|
||||
if (va->va_size != PUFFS_VNOVAL) {
|
||||
switch (pn->pn_type) {
|
||||
switch (pn->pn_va.va_type) {
|
||||
case VREG:
|
||||
dtfs_setsize(pn, va->va_size, 0);
|
||||
pn->pn_va.va_bytes = va->va_size;
|
||||
|
@ -119,7 +120,7 @@ dtfs_node_setattr(struct puffs_usermount *pu, void *opc,
|
|||
|
||||
/* create a new node in the parent directory specified by opc */
|
||||
int
|
||||
dtfs_node_create(struct puffs_usermount *pu, void *opc, void **newnode,
|
||||
dtfs_node_create(struct puffs_cc *pcc, void *opc, void **newnode,
|
||||
const struct puffs_cn *pcn, const struct vattr *va)
|
||||
{
|
||||
struct puffs_node *pn_parent = opc;
|
||||
|
@ -137,7 +138,7 @@ dtfs_node_create(struct puffs_usermount *pu, void *opc, void **newnode,
|
|||
}
|
||||
|
||||
int
|
||||
dtfs_node_remove(struct puffs_usermount *pu, void *opc, void *targ,
|
||||
dtfs_node_remove(struct puffs_cc *pcc, void *opc, void *targ,
|
||||
const struct puffs_cn *pcn)
|
||||
{
|
||||
struct puffs_node *pn_parent = opc;
|
||||
|
@ -152,7 +153,7 @@ dtfs_node_remove(struct puffs_usermount *pu, void *opc, void *targ,
|
|||
}
|
||||
|
||||
int
|
||||
dtfs_node_mkdir(struct puffs_usermount *pu, void *opc, void **newnode,
|
||||
dtfs_node_mkdir(struct puffs_cc *pcc, void *opc, void **newnode,
|
||||
const struct puffs_cn *pcn, const struct vattr *va)
|
||||
{
|
||||
struct puffs_node *pn_parent = opc;
|
||||
|
@ -167,7 +168,7 @@ dtfs_node_mkdir(struct puffs_usermount *pu, void *opc, void **newnode,
|
|||
}
|
||||
|
||||
int
|
||||
dtfs_node_rmdir(struct puffs_usermount *pu, void *opc, void *targ,
|
||||
dtfs_node_rmdir(struct puffs_cc *pcc, void *opc, void *targ,
|
||||
const struct puffs_cn *pcn)
|
||||
{
|
||||
struct puffs_node *pn_parent = opc;
|
||||
|
@ -182,7 +183,7 @@ dtfs_node_rmdir(struct puffs_usermount *pu, void *opc, void *targ,
|
|||
}
|
||||
|
||||
int
|
||||
dtfs_node_readdir(struct puffs_usermount *pi, void *opc,
|
||||
dtfs_node_readdir(struct puffs_cc *pcc, void *opc,
|
||||
struct dirent *dent, const struct puffs_cred *pcr, off_t *readoff,
|
||||
size_t *reslen)
|
||||
{
|
||||
|
@ -190,7 +191,7 @@ dtfs_node_readdir(struct puffs_usermount *pi, void *opc,
|
|||
struct puffs_node *pn_nth;
|
||||
struct dtfs_dirent *dfd_nth;
|
||||
|
||||
if (pn->pn_type != VDIR)
|
||||
if (pn->pn_va.va_type != VDIR)
|
||||
return ENOTDIR;
|
||||
|
||||
dtfs_updatetimes(pn, 1, 0, 0);
|
||||
|
@ -210,7 +211,7 @@ dtfs_node_readdir(struct puffs_usermount *pi, void *opc,
|
|||
|
||||
if (!puffs_nextdent(&dent, dfd_nth->dfd_name,
|
||||
pn_nth->pn_va.va_fileid,
|
||||
puffs_vtype2dt(pn_nth->pn_type),
|
||||
puffs_vtype2dt(pn_nth->pn_va.va_type),
|
||||
reslen))
|
||||
return 0;
|
||||
(*readoff)++;
|
||||
|
@ -218,7 +219,7 @@ dtfs_node_readdir(struct puffs_usermount *pi, void *opc,
|
|||
}
|
||||
|
||||
int
|
||||
dtfs_node_rename(struct puffs_usermount *pu, void *opc, void *src,
|
||||
dtfs_node_rename(struct puffs_cc *pcc, void *opc, void *src,
|
||||
const struct puffs_cn *pcn_src, void *targ_dir, void *targ,
|
||||
const struct puffs_cn *pcn_targ)
|
||||
{
|
||||
|
@ -236,7 +237,7 @@ dtfs_node_rename(struct puffs_usermount *pu, void *opc, void *src,
|
|||
|
||||
/* if there's a target file, nuke it for atomic replacement */
|
||||
if (pn_tfile) {
|
||||
assert(pn_tfile->pn_type != VDIR); /* XXX? */
|
||||
assert(pn_tfile->pn_va.va_type != VDIR); /* XXX? */
|
||||
dtfs_nukenode(pn_tfile, pn_sdir, pcn_targ->pcn_name);
|
||||
}
|
||||
|
||||
|
@ -255,7 +256,7 @@ dtfs_node_rename(struct puffs_usermount *pu, void *opc, void *src,
|
|||
}
|
||||
|
||||
int
|
||||
dtfs_node_link(struct puffs_usermount *pu, void *opc, void *targ,
|
||||
dtfs_node_link(struct puffs_cc *pcc, void *opc, void *targ,
|
||||
const struct puffs_cn *pcn)
|
||||
{
|
||||
struct puffs_node *pn_dir = opc;
|
||||
|
@ -272,7 +273,7 @@ dtfs_node_link(struct puffs_usermount *pu, void *opc, void *targ,
|
|||
}
|
||||
|
||||
int
|
||||
dtfs_node_symlink(struct puffs_usermount *pu, void *opc, void **newnode,
|
||||
dtfs_node_symlink(struct puffs_cc *pcc, void *opc, void **newnode,
|
||||
const struct puffs_cn *pcn_src, const struct vattr *va,
|
||||
const char *link_target)
|
||||
{
|
||||
|
@ -295,13 +296,13 @@ dtfs_node_symlink(struct puffs_usermount *pu, void *opc, void **newnode,
|
|||
}
|
||||
|
||||
int
|
||||
dtfs_node_readlink(struct puffs_usermount *pu, void *opc,
|
||||
dtfs_node_readlink(struct puffs_cc *pcc, void *opc,
|
||||
const struct puffs_cred *cred, char *link, size_t *linklen)
|
||||
{
|
||||
struct dtfs_file *df = DTFS_CTOF(opc);
|
||||
struct puffs_node *pn = opc;
|
||||
|
||||
assert(pn->pn_type == VLNK);
|
||||
assert(pn->pn_va.va_type == VLNK);
|
||||
strlcpy(link, df->df_linktarget, *linklen);
|
||||
*linklen = strlen(link);
|
||||
|
||||
|
@ -309,7 +310,7 @@ dtfs_node_readlink(struct puffs_usermount *pu, void *opc,
|
|||
}
|
||||
|
||||
int
|
||||
dtfs_node_mknod(struct puffs_usermount *pu, void *opc, void **newnode,
|
||||
dtfs_node_mknod(struct puffs_cc *pcc, void *opc, void **newnode,
|
||||
const struct puffs_cn *pcn, const struct vattr *va)
|
||||
{
|
||||
struct puffs_node *pn_parent = opc;
|
||||
|
@ -334,7 +335,7 @@ dtfs_node_mknod(struct puffs_usermount *pu, void *opc, void **newnode,
|
|||
* Read operation, used both for VOP_READ and VOP_GETPAGES
|
||||
*/
|
||||
int
|
||||
dtfs_node_read(struct puffs_usermount *pu, void *opc, uint8_t *buf,
|
||||
dtfs_node_read(struct puffs_cc *pcc, void *opc, uint8_t *buf,
|
||||
off_t offset, size_t *resid, const struct puffs_cred *pcr, int ioflag)
|
||||
{
|
||||
struct puffs_node *pn = opc;
|
||||
|
@ -360,7 +361,7 @@ dtfs_node_read(struct puffs_usermount *pu, void *opc, uint8_t *buf,
|
|||
* write operation on the wing
|
||||
*/
|
||||
int
|
||||
dtfs_node_write(struct puffs_usermount *pu, void *opc, uint8_t *buf,
|
||||
dtfs_node_write(struct puffs_cc *pcc, void *opc, uint8_t *buf,
|
||||
off_t offset, size_t *resid, const struct puffs_cred *pcr, int ioflag)
|
||||
{
|
||||
struct puffs_node *pn = opc;
|
||||
|
@ -382,7 +383,7 @@ dtfs_node_write(struct puffs_usermount *pu, void *opc, uint8_t *buf,
|
|||
}
|
||||
|
||||
int
|
||||
dtfs_node_reclaim(struct puffs_usermount *pu, void *opc, pid_t pid)
|
||||
dtfs_node_reclaim(struct puffs_cc *pcc, void *opc, pid_t pid)
|
||||
{
|
||||
struct puffs_node *pn = opc;
|
||||
|
||||
|
@ -393,7 +394,7 @@ dtfs_node_reclaim(struct puffs_usermount *pu, void *opc, pid_t pid)
|
|||
}
|
||||
|
||||
int
|
||||
dtfs_node_inactive(struct puffs_usermount *pu, void *opc, pid_t pid,
|
||||
dtfs_node_inactive(struct puffs_cc *pcc, void *opc, pid_t pid,
|
||||
int *refcount)
|
||||
{
|
||||
struct puffs_node *pn = opc;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sysctlfs.c,v 1.9 2006/12/07 10:59:03 pooka Exp $ */
|
||||
/* $NetBSD: sysctlfs.c,v 1.10 2006/12/29 15:37:06 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
|
||||
|
@ -34,9 +34,6 @@
|
|||
* XXXX: this is a very quick hack fs. it's not even complete,
|
||||
* please don't use it as an example. actually, this code is so bad that
|
||||
* it's nearly a laugh, it's nearly a laugh, but it's really a cry
|
||||
*
|
||||
* and The Final Cut: find /sysctl doesn't traverse the directories
|
||||
* correctly, but find -H /sysctl does. *dumbfounded*.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
@ -74,32 +71,33 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
struct puffs_usermount *pu;
|
||||
struct puffs_ops pops;
|
||||
struct puffs_ops *pops;
|
||||
|
||||
setprogname(argv[0]);
|
||||
|
||||
if (argc < 2)
|
||||
errx(1, "usage: %s mountpath\n", getprogname());
|
||||
errx(1, "usage: %s mountpath", getprogname());
|
||||
|
||||
PUFFSOP_INIT(&pops);
|
||||
PUFFSOP_INIT(pops);
|
||||
|
||||
PUFFSOP_SET(&pops, sysctlfs, fs, mount);
|
||||
PUFFSOP_SETFSNOP(&pops, unmount);
|
||||
PUFFSOP_SETFSNOP(&pops, sync);
|
||||
PUFFSOP_SETFSNOP(&pops, statvfs);
|
||||
PUFFSOP_SET(pops, sysctlfs, fs, mount);
|
||||
PUFFSOP_SETFSNOP(pops, unmount);
|
||||
PUFFSOP_SETFSNOP(pops, sync);
|
||||
PUFFSOP_SETFSNOP(pops, statvfs);
|
||||
|
||||
PUFFSOP_SET(&pops, sysctlfs, node, lookup);
|
||||
PUFFSOP_SET(&pops, sysctlfs, node, getattr);
|
||||
PUFFSOP_SET(&pops, sysctlfs, node, setattr);
|
||||
PUFFSOP_SET(&pops, sysctlfs, node, readdir);
|
||||
PUFFSOP_SET(&pops, sysctlfs, node, read);
|
||||
PUFFSOP_SET(&pops, sysctlfs, node, write);
|
||||
PUFFSOP_SET(&pops, sysctlfs, node, reclaim);
|
||||
/* XXX: theoretically should support reclaim */
|
||||
PUFFSOP_SET(pops, sysctlfs, node, lookup);
|
||||
PUFFSOP_SET(pops, sysctlfs, node, getattr);
|
||||
PUFFSOP_SET(pops, sysctlfs, node, setattr);
|
||||
PUFFSOP_SET(pops, sysctlfs, node, readdir);
|
||||
PUFFSOP_SET(pops, sysctlfs, node, read);
|
||||
PUFFSOP_SET(pops, sysctlfs, node, write);
|
||||
|
||||
if ((pu = puffs_mount(&pops, argv[1], 0, "sysctlfs",
|
||||
PUFFS_KFLAG_NOCACHE, 0)) == NULL)
|
||||
if ((pu = puffs_mount(pops, argv[1], 0, "sysctlfs", NULL,
|
||||
PUFFS_FLAG_OPDUMP, 0)) == NULL)
|
||||
err(1, "mount");
|
||||
|
||||
puffs_setstacksize(pu, 1024*1024);
|
||||
if (puffs_mainloop(pu, 0) == -1)
|
||||
err(1, "mainloop");
|
||||
|
||||
|
@ -107,7 +105,8 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
int
|
||||
sysctlfs_fs_mount(struct puffs_usermount *pu, void **rootcookie)
|
||||
sysctlfs_fs_mount(struct puffs_usermount *pu, void **rootcookie,
|
||||
struct statvfs *sbp)
|
||||
{
|
||||
struct timeval tv_now;
|
||||
|
||||
|
@ -121,6 +120,8 @@ sysctlfs_fs_mount(struct puffs_usermount *pu, void **rootcookie)
|
|||
gettimeofday(&tv_now, NULL);
|
||||
TIMEVAL_TO_TIMESPEC(&tv_now, &fstime);
|
||||
|
||||
puffs_fsnop_statvfs(NULL, sbp, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -180,7 +181,7 @@ getlinks(struct sfsnode *sfs)
|
|||
return 1;
|
||||
|
||||
memset(&qnode, 0, sizeof(qnode));
|
||||
sl = 128 * sizeof(struct sysctlnode);
|
||||
sl = sizeof(sn);
|
||||
qnode.sysctl_flags = SYSCTL_VERSION;
|
||||
sfs->name[sfs->hierlen] = CTL_QUERY;
|
||||
|
||||
|
@ -205,7 +206,7 @@ getsize(struct sfsnode *sfs)
|
|||
|
||||
/* fast & loose */
|
||||
int
|
||||
sysctlfs_node_lookup(struct puffs_usermount *pu, void *opc, void **newnode,
|
||||
sysctlfs_node_lookup(struct puffs_cc *pcc, void *opc, void **newnode,
|
||||
enum vtype *newtype, voff_t *newsize, dev_t *newrdev,
|
||||
const struct puffs_cn *pcn)
|
||||
{
|
||||
|
@ -265,7 +266,7 @@ sysctlfs_node_lookup(struct puffs_usermount *pu, void *opc, void **newnode,
|
|||
}
|
||||
|
||||
int
|
||||
sysctlfs_node_getattr(struct puffs_usermount *pu, void *opc, struct vattr *va,
|
||||
sysctlfs_node_getattr(struct puffs_cc *pcc, void *opc, struct vattr *va,
|
||||
const struct puffs_cred *pcr, pid_t pid)
|
||||
{
|
||||
struct sfsnode *sfs = opc;
|
||||
|
@ -280,7 +281,6 @@ sysctlfs_node_getattr(struct puffs_usermount *pu, void *opc, struct vattr *va,
|
|||
va->va_mode = 0666;
|
||||
}
|
||||
va->va_nlink = getlinks(sfs);
|
||||
va->va_fsid = pu->pu_fsidx.__fsid_val[0];
|
||||
va->va_fileid = sfs->myid;
|
||||
va->va_size = getsize(sfs);
|
||||
va->va_gen = 1;
|
||||
|
@ -294,7 +294,7 @@ sysctlfs_node_getattr(struct puffs_usermount *pu, void *opc, struct vattr *va,
|
|||
}
|
||||
|
||||
int
|
||||
sysctlfs_node_setattr(struct puffs_usermount *pu, void *opc,
|
||||
sysctlfs_node_setattr(struct puffs_cc *pcc, void *opc,
|
||||
const struct vattr *va, const struct puffs_cred *pcr, pid_t pid)
|
||||
{
|
||||
|
||||
|
@ -303,7 +303,7 @@ sysctlfs_node_setattr(struct puffs_usermount *pu, void *opc,
|
|||
}
|
||||
|
||||
int
|
||||
sysctlfs_node_readdir(struct puffs_usermount *pu, void *opc,
|
||||
sysctlfs_node_readdir(struct puffs_cc *pcc, void *opc,
|
||||
struct dirent *dent, const struct puffs_cred *pcr,
|
||||
off_t *readoff, size_t *reslen)
|
||||
{
|
||||
|
@ -346,7 +346,7 @@ sysctlfs_node_readdir(struct puffs_usermount *pu, void *opc,
|
|||
}
|
||||
|
||||
int
|
||||
sysctlfs_node_read(struct puffs_usermount *pu, void *opc, uint8_t *buf,
|
||||
sysctlfs_node_read(struct puffs_cc *pcc, void *opc, uint8_t *buf,
|
||||
off_t offset, size_t *resid, const struct puffs_cred *pcr,
|
||||
int ioflag)
|
||||
{
|
||||
|
@ -370,7 +370,7 @@ sysctlfs_node_read(struct puffs_usermount *pu, void *opc, uint8_t *buf,
|
|||
}
|
||||
|
||||
int
|
||||
sysctlfs_node_write(struct puffs_usermount *pu, void *opc, uint8_t *buf,
|
||||
sysctlfs_node_write(struct puffs_cc *pcc, void *opc, uint8_t *buf,
|
||||
off_t offset, size_t *resid, const struct puffs_cred *cred,
|
||||
int ioflag)
|
||||
{
|
||||
|
@ -414,20 +414,3 @@ sysctlfs_node_write(struct puffs_usermount *pu, void *opc, uint8_t *buf,
|
|||
*resid = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
sysctlfs_node_reclaim(struct puffs_usermount *pu, void *opc, pid_t pid)
|
||||
{
|
||||
struct sfsnode *sfs = opc;
|
||||
|
||||
/*
|
||||
* refcount nodes so that we don't accidentally release dotdot
|
||||
* while we could still reference it in lookup
|
||||
*/
|
||||
if (--sfs->dotdot->refcount == 0)
|
||||
free(sfs->dotdot);
|
||||
if (--sfs->refcount == 0)
|
||||
free(sfs);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue