libpuffs: make GCC happy

This commit is contained in:
Thomas Veerman 2012-02-01 11:44:26 +00:00
parent 4d3a0887b4
commit 71634240a0
10 changed files with 45 additions and 35 deletions

View file

@ -1,17 +1,23 @@
# Makefile for libpuffs # $NetBSD: Makefile,v 1.24 2010/12/06 14:50:34 pooka Exp $
#
.include <bsd.own.mk>
USE_FORT?= no # data-driven bugs?
WARNS= 4
LIB= puffs LIB= puffs
CC= clang
SRCS= callcontext.c creds.c null.c pnode.c puffs.c subr.c\ SRCS= puffs.c callcontext.c creds.c \
table.c link.c misc.c open.c path.c path_puffs.c protect.c\ null.c pnode.c \
read.c stadir.c time.c utility.c mount.c inode.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 INCS= puffs.h puffs_msgif.h
INCSDIR= /usr/include INCSDIR= /usr/include
MAN= puffs.3 puffs_cc.3 puffs_cred.3 puffs_node.3 \ LINTFLAGS+=-S -w
puffs_ops.3 puffs_path.3
DEFAULT_NR_BUFS= 1024
CPPFLAGS+= -D_MINIX -D_POSIX_SOURCE -D_POSIX_C_SOURCE -D_NETBSD_SOURCE -DDEFAULT_NR_BUFS=${DEFAULT_NR_BUFS}
.include <bsd.lib.mk> .include <bsd.lib.mk>

View file

@ -14,6 +14,7 @@
/* The following are so basic, all the *.c files get them automatically. */ /* The following are so basic, all the *.c files get them automatically. */
#include <minix/config.h> /* MUST be first */ #include <minix/config.h> /* MUST be first */
#include <minix/ansi.h> /* MUST be second */ #include <minix/ansi.h> /* MUST be second */
#include <sys/cdefs.h>
#include <sys/types.h> #include <sys/types.h>
#include <minix/const.h> #include <minix/const.h>
#include <minix/type.h> #include <minix/type.h>

View file

@ -79,7 +79,7 @@ PUBLIC int fs_link()
time_t cur_time; time_t cur_time;
struct puffs_kcn pkcnp; struct puffs_kcn pkcnp;
PUFFS_MAKECRED(pcr, &global_kcred); 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) if (global_pu->pu_ops.puffs_node_link == NULL)
return(OK); return(OK);
@ -157,7 +157,7 @@ PUBLIC int fs_rdlink()
register int r; /* return value */ register int r; /* return value */
size_t copylen; size_t copylen;
struct puffs_node *pn; struct puffs_node *pn;
char user_path[PATH_MAX]; char path[PATH_MAX];
PUFFS_MAKECRED(pcr, &global_kcred); PUFFS_MAKECRED(pcr, &global_kcred);
copylen = fs_m_in.REQ_MEM_SIZE < UMAX_FILE_POS ? copylen = fs_m_in.REQ_MEM_SIZE < UMAX_FILE_POS ?
@ -174,7 +174,7 @@ PUBLIC int fs_rdlink()
if (global_pu->pu_ops.puffs_node_readlink == NULL) if (global_pu->pu_ops.puffs_node_readlink == NULL)
return(EINVAL); 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,
&copylen); &copylen);
if (r != OK) { if (r != OK) {
if (r > 0) r = -r; if (r > 0) r = -r;
@ -182,7 +182,7 @@ PUBLIC int fs_rdlink()
} }
r = sys_safecopyto(VFS_PROC_NR, (cp_grant_id_t) fs_m_in.REQ_GRANT, 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) if (r == OK)
fs_m_out.RES_NBYTES = copylen; fs_m_out.RES_NBYTES = copylen;
@ -190,9 +190,6 @@ PUBLIC int fs_rdlink()
} }
FORWARD _PROTOTYPE( void release_node, (struct puffs_usermount *pu,
struct puffs_node *pn ));
/*===========================================================================* /*===========================================================================*
* fs_rename * * fs_rename *
*===========================================================================*/ *===========================================================================*/
@ -203,10 +200,10 @@ PUBLIC int fs_rename()
struct puffs_node *new_dirp, *new_ip; /* ptrs to new dir, file pnodes */ struct puffs_node *new_dirp, *new_ip; /* ptrs to new dir, file pnodes */
struct puffs_kcn pkcnp_src; struct puffs_kcn pkcnp_src;
PUFFS_MAKECRED(pcr_src, &global_kcred); 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; struct puffs_kcn pkcnp_dest;
PUFFS_MAKECRED(pcr_dest, &global_kcred); 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 r = OK; /* error flag; initially no error */
int odir, ndir; /* TRUE iff {old|new} file is dir */ int odir, ndir; /* TRUE iff {old|new} file is dir */
int same_pdir; /* TRUE iff parent dirs are the same */ int same_pdir; /* TRUE iff parent dirs are the same */
@ -406,7 +403,7 @@ PUBLIC int fs_unlink()
struct puffs_node *pn, *pn_dir; struct puffs_node *pn, *pn_dir;
time_t cur_time; time_t cur_time;
struct puffs_kcn pkcnp; 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); PUFFS_KCREDTOCRED(pcn.pcn_cred, &global_kcred);
int len; int len;

View file

@ -66,7 +66,9 @@ processvattr(const char *path, const struct vattr *va, int regular)
if (chown(path, va->va_uid, va->va_gid) == -1) if (chown(path, va->va_uid, va->va_gid) == -1)
return errno; return errno;
#ifndef __minix
if (va->va_mode != (unsigned)PUFFS_VNOVAL) if (va->va_mode != (unsigned)PUFFS_VNOVAL)
#endif
/* FIXME: lchmod */ /* FIXME: lchmod */
if (chmod(path, va->va_mode) == -1) if (chmod(path, va->va_mode) == -1)
return errno; return errno;

View file

@ -25,7 +25,7 @@ PUBLIC int fs_create()
struct puffs_newinfo pni; struct puffs_newinfo pni;
struct puffs_kcn pkcnp; struct puffs_kcn pkcnp;
PUFFS_MAKECRED(pcr, &global_kcred); 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; struct vattr va;
time_t cur_time; time_t cur_time;
int len; int len;
@ -122,7 +122,7 @@ PUBLIC int fs_mknod()
struct puffs_newinfo pni; struct puffs_newinfo pni;
struct puffs_kcn pkcnp; struct puffs_kcn pkcnp;
PUFFS_MAKECRED(pcr, &global_kcred); 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; struct vattr va;
time_t cur_time; time_t cur_time;
int len; int len;
@ -205,7 +205,7 @@ PUBLIC int fs_mkdir()
struct puffs_newinfo pni; struct puffs_newinfo pni;
struct puffs_kcn pkcnp; struct puffs_kcn pkcnp;
PUFFS_MAKECRED(pcr, &global_kcred); 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; struct vattr va;
time_t cur_time; time_t cur_time;
int len; int len;
@ -289,7 +289,7 @@ PUBLIC int fs_slink()
struct puffs_newinfo pni; struct puffs_newinfo pni;
struct puffs_kcn pkcnp; struct puffs_kcn pkcnp;
PUFFS_MAKECRED(pcr, &global_kcred); 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; struct vattr va;
int len; int len;

View file

@ -372,7 +372,7 @@ int chk_perm; /* check permissions when string is looked up*/
struct puffs_kcn pkcnp; struct puffs_kcn pkcnp;
PUFFS_MAKECRED(pcr, &global_kcred); 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; enum vtype node_vtype;
voff_t size; voff_t size;

View file

@ -54,6 +54,7 @@ puffs_path_pcnbuild(struct puffs_usermount *pu, struct puffs_cn *pcn,
assert(pn_parent->pn_po.po_path != NULL); assert(pn_parent->pn_po.po_path != NULL);
assert(pu->pu_flags & PUFFS_FLAG_BUILDPATH); assert(pu->pu_flags & PUFFS_FLAG_BUILDPATH);
pcn_orig = *pcn;
if (pu->pu_pathtransform) { if (pu->pu_pathtransform) {
rv = pu->pu_pathtransform(pu, &pn_parent->pn_po, pcn, &po); rv = pu->pu_pathtransform(pu, &pn_parent->pn_po, pcn, &po);
@ -65,8 +66,6 @@ puffs_path_pcnbuild(struct puffs_usermount *pu, struct puffs_cn *pcn,
} }
if (pu->pu_namemod) { 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); rv = pu->pu_namemod(pu, &pn_parent->pn_po, pcn);
if (rv) if (rv)
return rv; return rv;

View file

@ -1,12 +1,17 @@
#ifndef PUFFS_PROTO_H #ifndef PUFFS_PROTO_H
#define PUFFS_PROTO_H #define PUFFS_PROTO_H
struct puffs_usermount;
struct puffs_node;
/* Function prototypes. */ /* Function prototypes. */
_PROTOTYPE( int fs_new_driver, (void) ); _PROTOTYPE( int fs_new_driver, (void) );
/* inode.c */ /* inode.c */
_PROTOTYPE( int fs_putnode, (void) ); _PROTOTYPE( int fs_putnode, (void) );
_PROTOTYPE( void release_node, (struct puffs_usermount *pu,
struct puffs_node *pn ) );
/* device.c */ /* device.c */
_PROTOTYPE( int dev_open, (endpoint_t driver_e, dev_t dev, _PROTOTYPE( int dev_open, (endpoint_t driver_e, dev_t dev,
@ -62,10 +67,10 @@ _PROTOTYPE( int fs_utime, (void) );
/* utility.c */ /* utility.c */
_PROTOTYPE( int no_sys, (void) ); _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) ); unsigned int len, unsigned int maxlen) );
_PROTOTYPE( time_t clock_time, (void) ); _PROTOTYPE( time_t clock_time, (void) );
_PROTOTYPE( int update_times, (struct puffs_node *pn, int fl, time_t t) ); _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 */ #endif /* PUFFS_PROTO_H */

View file

@ -32,7 +32,7 @@ PUBLIC int fs_readwrite(void)
int r = OK, rw_flag; int r = OK, rw_flag;
cp_grant_id_t gid; cp_grant_id_t gid;
off_t pos; off_t pos;
size_t nrbytes, bytes_left, bytes_done; size_t nrbytes, bytes_left, bytes_done = 0;
struct puffs_node *pn; struct puffs_node *pn;
struct vattr va; struct vattr va;
PUFFS_MAKECRED(pcr, &global_kcred); PUFFS_MAKECRED(pcr, &global_kcred);
@ -51,7 +51,7 @@ PUBLIC int fs_readwrite(void)
if (nrbytes > RW_BUFSIZ) if (nrbytes > RW_BUFSIZ)
nrbytes = bytes_left = 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 (rw_flag == READING) {
if (global_pu->pu_ops.puffs_node_read == NULL) if (global_pu->pu_ops.puffs_node_read == NULL)

View file

@ -24,7 +24,7 @@ PUBLIC int no_sys()
/*===========================================================================* /*===========================================================================*
* mfs_nul * * 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) unsigned int maxlen)
{ {
if (len < maxlen && str[len-1] != '\0') { if (len < maxlen && str[len-1] != '\0') {
@ -103,7 +103,7 @@ PUBLIC int update_times(struct puffs_node *pn, int flags, time_t t)
/*===========================================================================* /*===========================================================================*
* lpuffs_debug * * lpuffs_debug *
*===========================================================================*/ *===========================================================================*/
PUBLIC void lpuffs_debug(char *format, ...) PUBLIC void lpuffs_debug(const char *format, ...)
{ {
char buffer[256]; char buffer[256];
va_list args; va_list args;