summon daemon(3) in mainloop unless the nodaemon flag is given

This commit is contained in:
pooka 2006-11-30 05:37:48 +00:00
parent fd011e452f
commit c145fb5a17
2 changed files with 19 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs.c,v 1.8 2006/11/18 12:40:35 pooka Exp $ */
/* $NetBSD: puffs.c,v 1.9 2006/11/30 05:37:48 pooka Exp $ */
/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
@ -34,12 +34,13 @@
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: puffs.c,v 1.8 2006/11/18 12:40:35 pooka Exp $");
__RCSID("$NetBSD: puffs.c,v 1.9 2006/11/30 05:37:48 pooka Exp $");
#endif /* !lint */
#include <sys/param.h>
#include <sys/mount.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <puffs.h>
@ -70,6 +71,7 @@ puffs_mount(struct puffs_vfsops *pvfs, struct puffs_vnops *pvn,
fd = open("/dev/puffs", O_RDONLY);
if (fd == -1)
return NULL;
assert(fd > 2);
pargs.pa_vers = 0; /* XXX: for now */
pargs.pa_flags = PUFFSFLAG_KERN(pflags);
@ -118,7 +120,7 @@ puffs_mount(struct puffs_vfsops *pvfs, struct puffs_vnops *pvn,
}
int
puffs_mainloop(struct puffs_usermount *pu)
puffs_mainloop(struct puffs_usermount *pu, int flags)
{
uint8_t *buf;
int rv;
@ -127,6 +129,10 @@ puffs_mainloop(struct puffs_usermount *pu)
if (!buf)
return -1;
if ((flags & PUFFSLOOP_NODAEMON) == 0)
if (daemon(0, 0) == -1)
return -1;
for (;;)
if ((rv = puffs_oneop(pu, buf, pu->pu_maxreqlen)) != 0)
return rv;

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs.h,v 1.11 2006/11/23 16:44:28 pooka Exp $ */
/* $NetBSD: puffs.h,v 1.12 2006/11/30 05:37:48 pooka Exp $ */
/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
@ -175,21 +175,27 @@ struct puffs_usermount {
void *pu_privdata;
};
#define PUFFSFLAG_KERN(a) ((a) & 0xffff)
#define PUFFSFLAG_OPDUMP 0x10000 /* dump all operations */
#define PUFFSFLAG_KERN(a) ((a) & 0x0000ffff)
#define PUFFSFLAG_LIB(a) ((a) & 0xffff0000)
#define PUFFSFLAG_OPDUMP 0x80000000 /* dump all operations */
struct puffs_usermount *puffs_mount(struct puffs_vfsops *, struct puffs_vnops *,
const char *, int, const char *,
uint32_t, size_t);
int puffs_mainloop(struct puffs_usermount *);
int puffs_mainloop(struct puffs_usermount *, int);
int puffs_oneop(struct puffs_usermount *, uint8_t *, size_t);
int puffs_getselectable(struct puffs_usermount *);
int puffs_setblockingmode(struct puffs_usermount *, int);
void puffs_dummyops(struct puffs_vnops *);
/* blocking mode argument */
#define PUFFSDEV_BLOCK 0
#define PUFFSDEV_NONBLOCK 1
/* mainloop flags */
#define PUFFSLOOP_NODAEMON 0x01
struct puffs_node * puffs_newpnode(struct puffs_usermount *, void *,
enum vtype);
void puffs_putpnode(struct puffs_node *);