-# Makefile for libpuffs
+# $NetBSD: Makefile,v 1.24 2010/12/06 14:50:34 pooka Exp $
+#
-LIB= puffs
-CC= clang
-SRCS= callcontext.c creds.c null.c pnode.c puffs.c subr.c\
- table.c link.c misc.c open.c path.c path_puffs.c protect.c\
- read.c stadir.c time.c utility.c mount.c inode.c
-INCS= puffs.h puffs_msgif.h
-INCSDIR= /usr/include
-MAN= puffs.3 puffs_cc.3 puffs_cred.3 puffs_node.3 \
- puffs_ops.3 puffs_path.3
+.include <bsd.own.mk>
-DEFAULT_NR_BUFS= 1024
+USE_FORT?= no # data-driven bugs?
-CPPFLAGS+= -D_MINIX -D_POSIX_SOURCE -D_POSIX_C_SOURCE -D_NETBSD_SOURCE -DDEFAULT_NR_BUFS=${DEFAULT_NR_BUFS}
+WARNS= 4
+
+LIB= puffs
+
+SRCS= puffs.c callcontext.c creds.c \
+ null.c pnode.c \
+ subr.c \
+ inode.c link.c misc.c mount.c open.c path.c path_puffs.c \
+ protect.c read.c stadir.c time.c utility.c table.c
+MAN= puffs.3 puffs_cc.3 puffs_cred.3 \
+ puffs_node.3 puffs_ops.3 puffs_path.3
+INCS= puffs.h puffs_msgif.h
+INCSDIR= /usr/include
+LINTFLAGS+=-S -w
.include <bsd.lib.mk>
/* The following are so basic, all the *.c files get them automatically. */
#include <minix/config.h> /* MUST be first */
#include <minix/ansi.h> /* MUST be second */
+#include <sys/cdefs.h>
#include <sys/types.h>
#include <minix/const.h>
#include <minix/type.h>
time_t cur_time;
struct puffs_kcn pkcnp;
PUFFS_MAKECRED(pcr, &global_kcred);
- struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *)pcr, {0}};
+ struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) __UNCONST(pcr), {0,0,0}};
if (global_pu->pu_ops.puffs_node_link == NULL)
return(OK);
register int r; /* return value */
size_t copylen;
struct puffs_node *pn;
- char user_path[PATH_MAX];
+ char path[PATH_MAX];
PUFFS_MAKECRED(pcr, &global_kcred);
copylen = fs_m_in.REQ_MEM_SIZE < UMAX_FILE_POS ?
if (global_pu->pu_ops.puffs_node_readlink == NULL)
return(EINVAL);
- r = global_pu->pu_ops.puffs_node_readlink(global_pu, pn, pcr, user_path,
+ r = global_pu->pu_ops.puffs_node_readlink(global_pu, pn, pcr, path,
©len);
if (r != OK) {
if (r > 0) r = -r;
}
r = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_GRANT,
- (vir_bytes) 0, (vir_bytes) user_path, (size_t) copylen, D);
+ (vir_bytes) 0, (vir_bytes) path, (size_t) copylen, D);
if (r == OK)
fs_m_out.RES_NBYTES = copylen;
}
-FORWARD _PROTOTYPE( void release_node, (struct puffs_usermount *pu,
- struct puffs_node *pn ));
-
/*===========================================================================*
* fs_rename *
*===========================================================================*/
struct puffs_node *new_dirp, *new_ip; /* ptrs to new dir, file pnodes */
struct puffs_kcn pkcnp_src;
PUFFS_MAKECRED(pcr_src, &global_kcred);
- struct puffs_cn pcn_src = {&pkcnp_src, (struct puffs_cred *) pcr_src, {0}};
+ struct puffs_cn pcn_src = {&pkcnp_src, (struct puffs_cred *) __UNCONST(pcr_src), {0,0,0}};
struct puffs_kcn pkcnp_dest;
PUFFS_MAKECRED(pcr_dest, &global_kcred);
- struct puffs_cn pcn_targ = {&pkcnp_dest, (struct puffs_cred *) pcr_dest, {0}};
+ struct puffs_cn pcn_targ = {&pkcnp_dest, (struct puffs_cred *) __UNCONST(pcr_dest), {0,0,0}};
int r = OK; /* error flag; initially no error */
int odir, ndir; /* TRUE iff {old|new} file is dir */
int same_pdir; /* TRUE iff parent dirs are the same */
struct puffs_node *pn, *pn_dir;
time_t cur_time;
struct puffs_kcn pkcnp;
- struct puffs_cn pcn = {&pkcnp, 0, {0}};
+ struct puffs_cn pcn = {&pkcnp, 0, {0,0,0}};
PUFFS_KCREDTOCRED(pcn.pcn_cred, &global_kcred);
int len;
if (chown(path, va->va_uid, va->va_gid) == -1)
return errno;
+#ifndef __minix
if (va->va_mode != (unsigned)PUFFS_VNOVAL)
+#endif
/* FIXME: lchmod */
if (chmod(path, va->va_mode) == -1)
return errno;
struct puffs_newinfo pni;
struct puffs_kcn pkcnp;
PUFFS_MAKECRED(pcr, &global_kcred);
- struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) pcr, {0}};
+ struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) __UNCONST(pcr), {0,0,0}};
struct vattr va;
time_t cur_time;
int len;
struct puffs_newinfo pni;
struct puffs_kcn pkcnp;
PUFFS_MAKECRED(pcr, &global_kcred);
- struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) pcr, {0}};
+ struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) __UNCONST(pcr), {0,0,0}};
struct vattr va;
time_t cur_time;
int len;
struct puffs_newinfo pni;
struct puffs_kcn pkcnp;
PUFFS_MAKECRED(pcr, &global_kcred);
- struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) pcr, {0}};
+ struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) __UNCONST(pcr), {0,0,0}};
struct vattr va;
time_t cur_time;
int len;
struct puffs_newinfo pni;
struct puffs_kcn pkcnp;
PUFFS_MAKECRED(pcr, &global_kcred);
- struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) pcr, {0}};
+ struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) __UNCONST(pcr), {0,0,0}};
struct vattr va;
int len;
struct puffs_kcn pkcnp;
PUFFS_MAKECRED(pcr, &global_kcred);
- struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) pcr, {0}};
+ struct puffs_cn pcn = {&pkcnp, (struct puffs_cred *) __UNCONST(pcr), {0,0,0}};
enum vtype node_vtype;
voff_t size;
assert(pn_parent->pn_po.po_path != NULL);
assert(pu->pu_flags & PUFFS_FLAG_BUILDPATH);
+ pcn_orig = *pcn;
if (pu->pu_pathtransform) {
rv = pu->pu_pathtransform(pu, &pn_parent->pn_po, pcn, &po);
}
if (pu->pu_namemod) {
- /* XXX: gcc complains if I do assignment */
- memcpy(&pcn_orig, pcn, sizeof(pcn_orig));
rv = pu->pu_namemod(pu, &pn_parent->pn_po, pcn);
if (rv)
return rv;
#ifndef PUFFS_PROTO_H
#define PUFFS_PROTO_H
+struct puffs_usermount;
+struct puffs_node;
+
/* Function prototypes. */
_PROTOTYPE( int fs_new_driver, (void) );
/* inode.c */
_PROTOTYPE( int fs_putnode, (void) );
+_PROTOTYPE( void release_node, (struct puffs_usermount *pu,
+ struct puffs_node *pn ) );
/* device.c */
_PROTOTYPE( int dev_open, (endpoint_t driver_e, dev_t dev,
/* utility.c */
_PROTOTYPE( int no_sys, (void) );
-_PROTOTYPE( void mfs_nul_f, (char *file, int line, char *str,
+_PROTOTYPE( void mfs_nul_f, (const char *file, int line, char *str,
unsigned int len, unsigned int maxlen) );
_PROTOTYPE( time_t clock_time, (void) );
_PROTOTYPE( int update_times, (struct puffs_node *pn, int fl, time_t t) );
-_PROTOTYPE( void lpuffs_debug, (char *format, ...) );
+_PROTOTYPE( void lpuffs_debug, (const char *format, ...) );
#endif /* PUFFS_PROTO_H */
int r = OK, rw_flag;
cp_grant_id_t gid;
off_t pos;
- size_t nrbytes, bytes_left, bytes_done;
+ size_t nrbytes, bytes_left, bytes_done = 0;
struct puffs_node *pn;
struct vattr va;
PUFFS_MAKECRED(pcr, &global_kcred);
if (nrbytes > RW_BUFSIZ)
nrbytes = bytes_left = RW_BUFSIZ;
- memset(getdents_buf, '\0', RW_BUFSIZ); /* Avoid leaking any data */
+ memset(getdents_buf, '\0', GETDENTS_BUFSIZ); /* Avoid leaking any data */
if (rw_flag == READING) {
if (global_pu->pu_ops.puffs_node_read == NULL)
/*===========================================================================*
* mfs_nul *
*===========================================================================*/
-PUBLIC void mfs_nul_f(char *file, int line, char *str, unsigned int len,
+PUBLIC void mfs_nul_f(const char *file, int line, char *str, unsigned int len,
unsigned int maxlen)
{
if (len < maxlen && str[len-1] != '\0') {
/*===========================================================================*
* lpuffs_debug *
*===========================================================================*/
-PUBLIC void lpuffs_debug(char *format, ...)
+PUBLIC void lpuffs_debug(const char *format, ...)
{
char buffer[256];
va_list args;