VFS/FS: remove fstatfs(2) and REQ_FSTATFS

The fstatfs(3) call now uses fstatvfs(2).

Change-Id: I3fa5d31f078457b4d80418c23060bb2c148cb460
This commit is contained in:
David van Moolenbroek 2013-08-20 00:55:49 +02:00 committed by Lionel Sambuc
parent 474b24f91c
commit f10229eafb
28 changed files with 38 additions and 227 deletions

View file

@ -74,7 +74,6 @@
#define SYSUNAME 78
#define GETDENTS_321 80 /* to VFS */
#define LLSEEK 81 /* to VFS */
#define FSTATFS 82 /* to VFS */
#define STATVFS 83 /* to VFS */
#define FSTATVFS 84 /* to VFS */
#define SELECT 85 /* to VFS */

View file

@ -124,7 +124,7 @@ typedef u32_t pino_t; /* Protocol version of ino_t */
#define REQ_INHIBREAD (VFS_BASE + 7)
#define REQ_STAT (VFS_BASE + 8)
#define REQ_UTIME (VFS_BASE + 9)
#define REQ_FSTATFS (VFS_BASE + 10)
#define REQ_STATVFS (VFS_BASE + 10)
#define REQ_BREAD (VFS_BASE + 11)
#define REQ_BWRITE (VFS_BASE + 12)
#define REQ_UNLINK (VFS_BASE + 13)
@ -146,11 +146,10 @@ typedef u32_t pino_t; /* Protocol version of ino_t */
#define REQ_NEWNODE (VFS_BASE + 29)
#define REQ_RDLINK (VFS_BASE + 30)
#define REQ_GETDENTS (VFS_BASE + 31)
#define REQ_STATVFS (VFS_BASE + 32)
#define REQ_PEEK (VFS_BASE + 33)
#define REQ_BPEEK (VFS_BASE + 34)
#define REQ_PEEK (VFS_BASE + 32)
#define REQ_BPEEK (VFS_BASE + 33)
#define NREQS 35
#define NREQS 34
#define IS_VFS_RQ(type) (((type) & ~0xff) == VFS_BASE)

View file

@ -4,6 +4,7 @@
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
#ifdef __weak_alias
__weak_alias(fstatfs, _fstatfs)
@ -11,9 +12,13 @@ __weak_alias(fstatfs, _fstatfs)
int fstatfs(int fd, struct statfs *buffer)
{
message m;
struct statvfs svbuffer;
int r;
m.m1_i1 = fd;
m.m1_p1 = (char *) buffer;
return(_syscall(VFS_PROC_NR, FSTATFS, &m));
if ((r = fstatvfs(fd, &svbuffer)) != 0)
return r;
buffer->f_bsize = svbuffer.f_bsize;
return 0;
}

View file

@ -57,7 +57,6 @@ int fs_breadwrite(void);
int fs_readwrite(void);
/* stadir.c */
int fs_fstatfs(void);
int fs_stat(void);
int fs_statvfs(void);

View file

@ -4,7 +4,6 @@
#include "fs.h"
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
#include <minix/vfsif.h>
@ -12,30 +11,6 @@
#include "puffs_priv.h"
/*===========================================================================*
* fs_fstatfs *
*===========================================================================*/
int fs_fstatfs()
{
int r;
struct statvfs st_vfs;
struct statfs st;
if (global_pu->pu_ops.puffs_fs_statvfs(global_pu, &st_vfs) != 0) {
lpuffs_debug("statfs failed\n");
return(EINVAL);
}
st.f_bsize = st_vfs.f_bsize;
/* Copy the struct to user space. */
r = sys_safecopyto(fs_m_in.m_source, (cp_grant_id_t) fs_m_in.REQ_GRANT,
(vir_bytes) 0, (vir_bytes) &st, (size_t) sizeof(st));
return(r);
}
/*===========================================================================*
* fs_stat *
*===========================================================================*/

View file

@ -20,7 +20,7 @@ int (*fs_call_vec[])(void) = {
fs_inhibread, /* 7 */
fs_stat, /* 8 */
fs_utime, /* 9 */
fs_fstatfs, /* 10 */
fs_statvfs, /* 10 */
fs_breadwrite, /* 11 */
fs_breadwrite, /* 12 */
fs_unlink, /* 13 */
@ -42,7 +42,6 @@ int (*fs_call_vec[])(void) = {
no_sys, /* 29 */ /* Was: fs_newnode */
fs_rdlink, /* 30 */
fs_getdents, /* 31 */
fs_statvfs, /* 32 */
no_sys, /* 33 peek */
no_sys, /* 34 bpeek */
no_sys, /* 32 peek */
no_sys, /* 33 bpeek */
};

View file

@ -8,8 +8,8 @@
/* Number of entries in the name hashtable. */
#define NUM_HASH_SLOTS 1023
/* Arbitrary block size constant returned by fstatfs and statvfs.
* Also used by getdents. This is not the underlying data transfer unit size.
/* Arbitrary block size constant returned by statvfs. Also used by getdents.
* This is not the underlying data transfer unit size.
*/
#define BLOCK_SIZE 4096

View file

@ -1,7 +1,6 @@
/* This file contains miscellaneous file system call handlers.
*
* The entry points into this file are:
* do_fstatfs perform the FSTATFS file system call
* do_statvfs perform the STATVFS file system call
*
* Created:
@ -10,24 +9,8 @@
#include "inc.h"
#include <sys/statfs.h>
#include <sys/statvfs.h>
/*===========================================================================*
* do_fstatfs *
*===========================================================================*/
int do_fstatfs()
{
/* Retrieve file system statistics.
*/
struct statfs statfs;
statfs.f_bsize = BLOCK_SIZE; /* arbitrary block size constant */
return sys_safecopyto(m_in.m_source, m_in.REQ_GRANT, 0,
(vir_bytes) &statfs, sizeof(statfs));
}
/*===========================================================================*
* do_statvfs *
*===========================================================================*/

View file

@ -37,7 +37,6 @@ int do_lookup(void);
int main(int argc, char *argv[]);
/* misc.c */
int do_fstatfs(void);
int do_statvfs(void);
/* mount.c */

View file

@ -18,7 +18,7 @@ int (*call_vec[])(void) = {
do_noop, /* 7 inhibread */
do_stat, /* 8 stat */
do_utime, /* 9 utime */
do_fstatfs, /* 10 fstatfs */
do_statvfs, /* 10 statvfs */
no_sys, /* 11 bread */
no_sys, /* 12 bwrite */
do_unlink, /* 13 unlink */
@ -40,8 +40,7 @@ int (*call_vec[])(void) = {
no_sys, /* 29 newnode */
no_sys, /* 30 rdlink */
do_getdents, /* 31 getdents */
do_statvfs, /* 32 statvfs */
no_sys, /* 33 peek */
no_sys, /* 32 peek */
no_sys, /* 33 bpeek */
};

View file

@ -32,7 +32,6 @@ long sdbm_hash(char *str, int len);
/* stadir.c */
int fs_stat(void);
int fs_fstatfs(void);
int fs_statvfs(void);
/* utility.c */

View file

@ -3,7 +3,6 @@
#include "inc.h"
#include <time.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
#include <string.h>
@ -56,23 +55,7 @@ int fs_stat(void)
}
/*===========================================================================*
* fs_fstatfs *
*===========================================================================*/
int fs_fstatfs(void)
{
/* Retrieve file system statistics.
*/
struct statfs statfs;
memset(&statfs, 0, sizeof(statfs));
/* Copy the struct to user space. */
return sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT, 0,
(vir_bytes) &statfs, (phys_bytes) sizeof(statfs));
}
/*===========================================================================*
* fs_fstatfs *
* fs_statvfs *
*===========================================================================*/
int fs_statvfs(void)
{

View file

@ -14,7 +14,7 @@ int (*fs_call_vec[])(void) = {
do_noop, /* 7 inhibread */
fs_stat, /* 8 stat */
no_sys, /* 9 utime */
fs_fstatfs, /* 10 fstatfs */
fs_statvfs, /* 10 statvfs */
no_sys, /* 11 bread */
no_sys, /* 12 bwrite */
no_sys, /* 13 unlink */
@ -36,9 +36,8 @@ int (*fs_call_vec[])(void) = {
no_sys, /* 29 newnode */
fs_rdlink, /* 30 rdlink */
fs_getdents, /* 31 getdents */
fs_statvfs, /* 32 statvfs */
no_sys, /* 33 peek */
no_sys, /* 34 bpeek */
no_sys, /* 32 peek */
no_sys, /* 33 bpeek */
};
/* This should not fail with "array size is negative": */

View file

@ -81,7 +81,6 @@ block_t read_map(struct inode *rip, off_t pos, int opportunistic);
struct buf *get_block_map(register struct inode *rip, u64_t position);
/* stadir.c */
int fs_fstatfs(void);
int fs_stat(void);
int fs_statvfs(void);

View file

@ -5,7 +5,6 @@
#include "fs.h"
#include <string.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
#include "inode.h"
#include "super.h"
@ -60,28 +59,6 @@ static int stat_inode(
}
/*===========================================================================*
* fs_fstatfs *
*===========================================================================*/
int fs_fstatfs()
{
struct statfs st;
struct inode *rip;
int r;
if((rip = find_inode(fs_dev, ROOT_INODE)) == NULL)
return(EINVAL);
st.f_bsize = rip->i_sp->s_block_size;
/* Copy the struct to user space. */
r = sys_safecopyto(fs_m_in.m_source, (cp_grant_id_t) fs_m_in.REQ_GRANT,
(vir_bytes) 0, (vir_bytes) &st, (size_t) sizeof(st));
return(r);
}
/*===========================================================================*
* fs_stat *
*===========================================================================*/

View file

@ -23,7 +23,7 @@ int (*fs_call_vec[])(void) = {
fs_inhibread, /* 7 */
fs_stat, /* 8 */
fs_utime, /* 9 */
fs_fstatfs, /* 10 */
fs_statvfs, /* 10 */
fs_breadwrite, /* 11 */
fs_breadwrite, /* 12 */
fs_unlink, /* 13 */
@ -45,7 +45,6 @@ int (*fs_call_vec[])(void) = {
no_sys, /* 29 */ /* Was: fs_newnode */
fs_rdlink, /* 30 */
fs_getdents, /* 31 */
fs_statvfs, /* 32 */
fs_readwrite, /* 33 */
fs_bpeek, /* 34 */
fs_readwrite, /* 32 */
fs_bpeek, /* 33 */
};

View file

@ -53,7 +53,6 @@ int read_chunk(struct dir_record *rip, u64_t position, unsigned off, int
/* stadir.c */
int fs_stat(void);
int fs_fstatfs(void);
int fs_statvfs(void);
/* super.c */

View file

@ -1,7 +1,6 @@
#include "inc.h"
#include <assert.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
#include <minix/com.h>
#include <string.h>
@ -93,24 +92,6 @@ int fs_stat()
}
/*===========================================================================*
* fs_fstatfs *
*===========================================================================*/
int fs_fstatfs()
{
struct statfs st;
int r;
st.f_bsize = v_pri.logical_block_size_l;
/* Copy the struct to user space. */
r = sys_safecopyto(fs_m_in.m_source, fs_m_in.REQ_GRANT, 0,
(vir_bytes) &st, (phys_bytes) sizeof(st));
return(r);
}
/*===========================================================================*
* fs_statvfs *
*===========================================================================*/

View file

@ -18,7 +18,7 @@ int (*fs_call_vec[])(void) = {
do_noop, /* 7 */
fs_stat, /* 8 */
no_sys, /* 9: not used */
fs_fstatfs, /* 10 */
fs_statvfs, /* 10 */
fs_bread, /* 11 */
no_sys, /* 12: not used */
no_sys, /* 13: not used */
@ -40,12 +40,11 @@ int (*fs_call_vec[])(void) = {
no_sys, /* 29: not used */
no_sys, /* 30: not used */
fs_getdents, /* 31 */
fs_statvfs, /* 32 */
#if 0
fs_read, /* 33 */
no_sys,
fs_read, /* 32 */
no_sys, /* 33 */
#else
no_sys,
no_sys,
no_sys, /* 32 */
no_sys, /* 33 */
#endif
};

View file

@ -80,7 +80,6 @@ struct buf *get_block_map(register struct inode *rip, u64_t position);
zone_t rd_indir(struct buf *bp, int index);
/* stadir.c */
int fs_fstatfs(void);
int fs_stat(void);
int fs_statvfs(void);

View file

@ -2,7 +2,6 @@
#include <string.h>
#include <assert.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
#include "inode.h"
#include "super.h"
@ -86,28 +85,6 @@ static int stat_inode(
return(r);
}
/*===========================================================================*
* fs_fstatfs *
*===========================================================================*/
int fs_fstatfs()
{
struct statfs st;
struct inode *rip;
int r;
if((rip = find_inode(fs_dev, ROOT_INODE)) == NULL)
return(EINVAL);
st.f_bsize = rip->i_sp->s_block_size;
/* Copy the struct to user space. */
r = sys_safecopyto(fs_m_in.m_source, (cp_grant_id_t) fs_m_in.REQ_GRANT,
(vir_bytes) 0, (vir_bytes) &st, (size_t) sizeof(st));
return(r);
}
/*===========================================================================*
* fs_statvfs *
*===========================================================================*/

View file

@ -23,7 +23,7 @@ int (*fs_call_vec[])(void) = {
fs_inhibread, /* 7 */
fs_stat, /* 8 */
fs_utime, /* 9 */
fs_fstatfs, /* 10 */
fs_statvfs, /* 10 */
fs_breadwrite, /* 11 */
fs_breadwrite, /* 12 */
fs_unlink, /* 13 */
@ -45,8 +45,7 @@ int (*fs_call_vec[])(void) = {
no_sys, /* 29 */ /* Was: fs_newnode */
fs_rdlink, /* 30 */
fs_getdents, /* 31 */
fs_statvfs, /* 32 */
fs_readwrite, /* 33 */
fs_bpeek, /* 34 */
fs_readwrite, /* 32 */
fs_bpeek, /* 33 */
};

View file

@ -93,7 +93,7 @@ int (*call_vec[])(void) = {
no_sys, /* 79 = unused */
no_sys, /* 80 = (getdents) */
no_sys, /* 81 = unused */
no_sys, /* 82 = (fstatfs) */
no_sys, /* 82 = unused */
no_sys, /* 83 = unused */
no_sys, /* 84 = unused */
no_sys, /* 85 = (select) */

View file

@ -38,7 +38,7 @@ it supports a few calls necessary for libc. The following system calls are
handled by VFS:
access, chdir, chmod, chown, chroot, close, creat, fchdir, fcntl, fstat,
fstatfs, fstatvfs, fsync, ftruncate getdents, ioctl, link, llseek, lseek,
fstatvfs, fsync, ftruncate getdents, ioctl, link, llseek, lseek,
lstat, mkdir, mknod, mount, open, pipe, read, readlink, rename, rmdir, select,
stat, statvfs, symlink, sync, truncate, umask, umount, unlink, utime, write.
@ -572,8 +572,6 @@ REQ_INODE_NR field in requests, unless the notes say otherwise.
| REQ_FLUSH | | | Mutually exclusive to REQ_BREAD and |
| | | | REQ_BWRITE |
+--------------+---------+---------+-----------------------------------------+
| REQ_FSTATFS | | | |
+--------------+---------+---------+-----------------------------------------+
| REQ_FTRUNC | READ | WRITE | vmnt is only locked if file is not |
| | | | already opened |
+--------------+---------+---------+-----------------------------------------+

View file

@ -238,7 +238,6 @@ int req_chown(endpoint_t fs_e, ino_t inode_nr, uid_t newuid, gid_t newgid,
int req_create(endpoint_t fs_e, ino_t inode_nr, int omode, uid_t uid,
gid_t gid, char *path, node_details_t *res);
int req_flush(endpoint_t fs_e, dev_t dev);
int req_fstatfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf);
int req_statvfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf);
int req_ftrunc(endpoint_t fs_e, ino_t inode_nr, off_t start, off_t end);
int req_getdents(endpoint_t fs_e, ino_t inode_nr, off_t pos, char *buf,
@ -285,7 +284,6 @@ int do_fchdir(message *m_out);
int do_chroot(message *m_out);
int do_fstat(message *m_out);
int do_stat(message *m_out);
int do_fstatfs(message *m_out);
int do_statvfs(message *m_out);
int do_fstatvfs(message *m_out);
int do_rdlink(message *m_out);

View file

@ -13,7 +13,6 @@
#include <minix/vfsif.h>
#include <sys/dirent.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
#include <assert.h>
#include <stddef.h>
@ -224,32 +223,6 @@ int req_flush(endpoint_t fs_e, dev_t dev)
}
/*===========================================================================*
* req_fstatfs *
*===========================================================================*/
int req_fstatfs(endpoint_t fs_e, endpoint_t proc_e, vir_bytes buf)
{
int r;
cp_grant_id_t grant_id;
message m;
grant_id = cpf_grant_magic(fs_e, proc_e, buf, sizeof(struct statfs),
CPF_WRITE);
if (grant_id == GRANT_INVALID)
panic("req_fstatfs: cpf_grant_magic failed");
/* Fill in request message */
m.m_type = REQ_FSTATFS;
m.REQ_GRANT = grant_id;
/* Send/rec request */
r = fs_sendrec(fs_e, &m);
cpf_revoke(grant_id);
return(r);
}
/*===========================================================================*
* req_statvfs *
*===========================================================================*/

View file

@ -7,14 +7,12 @@
* do_lstat: perform the LSTAT system call
* do_stat: perform the STAT system call
* do_fstat: perform the FSTAT system call
* do_fstatfs: perform the FSTATFS system call
* do_statvfs: perform the STATVFS system call
* do_fstatvfs: perform the FSTATVFS system call
*/
#include "fs.h"
#include <sys/stat.h>
#include <sys/statfs.h>
#include <minix/com.h>
#include <minix/u64.h>
#include <string.h>
@ -210,29 +208,6 @@ int do_fstat(message *UNUSED(m_out))
return(r);
}
/*===========================================================================*
* do_fstatfs *
*===========================================================================*/
int do_fstatfs(message *UNUSED(m_out))
{
/* Perform the fstatfs(fd, buf) system call. */
struct filp *rfilp;
int r, rfd;
vir_bytes statbuf;
rfd = job_m_in.fd;
statbuf = (vir_bytes) job_m_in.buffer;
/* Is the file descriptor valid? */
if( (rfilp = get_filp(rfd, VNODE_READ)) == NULL) return(err_code);
r = req_fstatfs(rfilp->filp_vno->v_fs_e, who_e, statbuf);
unlock_filp(rfilp);
return(r);
}
/*===========================================================================*
* do_statvfs *
*===========================================================================*/

View file

@ -97,7 +97,7 @@ int (*call_vec[])(message *m_out) = {
no_sys, /* 79 = unused */
do_getdents, /* 80 = getdents_321 (to be phased out) */
do_lseek, /* 81 = llseek */
do_fstatfs, /* 82 = fstatfs */
no_sys, /* 82 = unused */
do_statvfs, /* 83 = fstatvfs */
do_fstatvfs, /* 84 = statvfs */
do_select, /* 85 = select */