Introduce PUFFS_STACKSIZE_MIN to avoid overloading 0 and getting

a warning from the library when really wanting to say "just the
minimum, please".
This commit is contained in:
pooka 2008-01-14 13:57:26 +00:00
parent bfc70617c5
commit d7412d56b1
4 changed files with 26 additions and 17 deletions

View File

@ -1,6 +1,6 @@
.\" $NetBSD: puffs.3,v 1.37 2007/12/15 20:11:38 pooka Exp $
.\" $NetBSD: puffs.3,v 1.38 2008/01/14 13:57:26 pooka Exp $
.\"
.\" Copyright (c) 2006, 2007 Antti Kantee. All rights reserved.
.\" Copyright (c) 2006, 2007, 2008 Antti Kantee. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@ -23,7 +23,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd December 15, 2007
.Dd January 14, 2008
.Dt PUFFS 3
.Os
.Sh NAME
@ -272,11 +272,14 @@ Possible values are
.Dv PUFFS_STATE_UNMOUNTING
and
.Dv PUFFS_STATE_UNMOUNTED .
.It Fn puffs_setstacksize "stacksize"
.It Fn puffs_setstacksize "pu" "stacksize"
Sets the stack size used when running callbacks.
The default is one megabyte of stack space per request.
See
.Xr puffs_cc 3 .
The default is
.Dv PUFFS_STACKSIZE_DEFAULT
bytes of stack space per request.
The minimum stacksize is architecture-dependent and can be specified
by using the opaque constant
.Dv PUFFS_STACKSIZE_MIN .
.It Fn puffs_setroot "pu" "node"
Sets the root node of mount
.Fa pu

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs.c,v 1.85 2008/01/08 00:22:31 pooka Exp $ */
/* $NetBSD: puffs.c,v 1.86 2008/01/14 13:57:26 pooka Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
__RCSID("$NetBSD: puffs.c,v 1.85 2008/01/08 00:22:31 pooka Exp $");
__RCSID("$NetBSD: puffs.c,v 1.86 2008/01/14 13:57:26 pooka Exp $");
#endif /* !lint */
#include <sys/param.h>
@ -184,17 +184,20 @@ puffs_getstate(struct puffs_usermount *pu)
void
puffs_setstacksize(struct puffs_usermount *pu, size_t ss)
{
long psize;
long psize, minsize;
int stackshift;
assert(puffs_getstate(pu) == PUFFS_STATE_BEFOREMOUNT);
psize = sysconf(_SC_PAGESIZE);
if (ss < 2*psize) {
minsize = 2*psize;
if (ss < minsize || ss == PUFFS_STACKSIZE_MIN) {
if (ss != PUFFS_STACKSIZE_MIN)
fprintf(stderr, "puffs_setstacksize: adjusting "
"stacksize to minimum %ld\n", minsize);
ss = 2*psize;
fprintf(stderr, "puffs_setstacksize: adjusting stacksize "
"to minimum %zu\n", ss);
}
assert(puffs_getstate(pu) == PUFFS_STATE_BEFOREMOUNT);
stackshift = -1;
while (ss) {
ss >>= 1;

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs.h,v 1.103 2007/12/25 20:38:01 pooka Exp $ */
/* $NetBSD: puffs.h,v 1.104 2008/01/14 13:57:27 pooka Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@ -263,6 +263,9 @@ enum {
#define PUFFSDEV_BLOCK 0
#define PUFFSDEV_NONBLOCK 1
#define PUFFS_STACKSIZE_DEFAULT (1<<PUFFS_CC_STACKSHIFT_DEFAULT)
#define PUFFS_STACKSIZE_MIN ((size_t)-1)
#define DENT_DOT 0
#define DENT_DOTDOT 1
#define DENT_ADJ(a) ((a)-2) /* nth request means dir's n-2th */

View File

@ -1,4 +1,4 @@
/* $NetBSD: p2k.c,v 1.36 2008/01/08 00:23:15 pooka Exp $ */
/* $NetBSD: p2k.c,v 1.37 2008/01/14 13:57:27 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -174,7 +174,7 @@ p2k_run_fs(const char *vfsname, const char *devpath, const char *mountpath,
pn_root = puffs_pn_new(pu, ukfs_getrvp(ukfs));
puffs_setroot(pu, pn_root);
puffs_setfhsize(pu, 0, PUFFS_FHFLAG_PASSTHROUGH);
puffs_setstacksize(pu, 0);
puffs_setstacksize(pu, PUFFS_STACKSIZE_MIN);
puffs_usethreads = 1;
puffs_set_prepost(pu, makelwp, clearlwp);