We need to provide a size for getattr for the cp example to work, so cheat

and use fstat() to do it instead of libpuffs.
This commit is contained in:
christos 2017-05-10 16:35:18 +00:00
parent cc50bb7aa6
commit f82096efe2
1 changed files with 43 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_portal.c,v 1.8 2017/05/09 21:17:54 christos Exp $ */
/* $NetBSD: puffs_portal.c,v 1.9 2017/05/10 16:35:18 christos Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: puffs_portal.c,v 1.8 2017/05/09 21:17:54 christos Exp $");
__RCSID("$NetBSD: puffs_portal.c,v 1.9 2017/05/10 16:35:18 christos Exp $");
#endif /* !lint */
#include <sys/types.h>
@ -550,21 +550,48 @@ portal_node_getattr(struct puffs_usermount *pu, puffs_cookie_t opc,
va->va_type = VDIR;
va->va_mode = 0777;
va->va_nlink = 2;
} else {
va->va_type = VREG;
va->va_mode = 0666;
va->va_nlink = 1;
}
va->va_uid = va->va_gid = 0;
va->va_fileid = fakeid++;
va->va_size = va->va_bytes = 0;
va->va_gen = 0;
va->va_rdev = PUFFS_VNOVAL;
va->va_blocksize = DEV_BSIZE;
va->va_uid = va->va_gid = 0;
va->va_fileid = fakeid++;
va->va_size = va->va_bytes = 0;
va->va_gen = 0;
va->va_rdev = PUFFS_VNOVAL;
va->va_blocksize = DEV_BSIZE;
gettimeofday(&tv, NULL);
TIMEVAL_TO_TIMESPEC(&tv, &ts);
va->va_atime = va->va_ctime = va->va_mtime = va->va_birthtime = ts;
gettimeofday(&tv, NULL);
TIMEVAL_TO_TIMESPEC(&tv, &ts);
va->va_atime = va->va_ctime = va->va_mtime =
va->va_birthtime = ts;
} else {
/* cheat for now */
int error;
struct stat st;
struct portal_node *portn = opc;
struct portal_cred portc;
char **v = conf_match(&q, portn->path);
if (v == NULL)
return ENOENT;
credtr(&portc, pcr, 0777);
error = provide(pu, portn, &portc, v);
if (error)
return error;
if (fstat(portn->fd, &st) == -1)
return errno;
va->va_type = S_ISDIR(st.st_mode) ? VDIR : VREG; /* XXX */
va->va_mode = st.st_mode;
va->va_nlink = st.st_nlink;
va->va_uid = st.st_uid;
va->va_gid = st.st_gid;
va->va_fileid = st.st_ino;
va->va_size = va->va_bytes = st.st_size;
va->va_gen = 0;
va->va_rdev = st.st_rdev;
va->va_blocksize = st.st_blksize;
va->va_atime = st.st_atim;
va->va_ctime = st.st_ctim;
va->va_mtime = st.st_mtim;
va->va_birthtime = st.st_birthtim;
portal_node_reclaim(pu, opc);
}
return 0;
}