include, vfs: statvfs, fstatvfs calls, contributed by Buccapatnam Tirumala, Gautam.

This commit is contained in:
Ben Gras 2010-06-23 23:53:50 +00:00
parent 45e4cce8c2
commit fc01683584
7 changed files with 78 additions and 3 deletions

View file

@ -73,6 +73,8 @@
#define GETDENTS 80 /* to FS */
#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 */
#define FCHDIR 86 /* to VFS */
#define FSYNC 87 /* to VFS */

View file

@ -245,6 +245,14 @@
#define TAPE_STAT0 m2_l1
#define TAPE_STAT1 m2_l2
/* Field names for the fstatvfs call */
#define FSTATVFS_FD m1_i1
#define FSTATVFS_BUF m1_p1
/* Field names for the statvfs call */
#define STATVFS_LEN m1_i1
#define STATVFS_NAME m1_p1
#define STATVFS_BUF m1_p2
/*===========================================================================*
* Messages for networking layer *
*===========================================================================*/

View file

@ -113,8 +113,9 @@ typedef struct {
#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 NREQS 32
#define NREQS 33
#endif

View file

@ -165,6 +165,7 @@ _PROTOTYPE( int req_create, (int fs_e, ino_t inode_nr, int omode,
uid_t uid, gid_t gid, char *path, node_details_t *res) );
_PROTOTYPE( int req_flush, (endpoint_t fs_e, dev_t dev) );
_PROTOTYPE( int req_fstatfs, (int fs_e, int who_e, char *buf) );
_PROTOTYPE( int req_statvfs, (int fs_e, int who_e, char *buf) );
_PROTOTYPE( int req_ftrunc, (endpoint_t fs_e, ino_t inode_nr,
off_t start, off_t end) );
_PROTOTYPE( int req_getdents, (endpoint_t fs_e, ino_t inode_nr, u64_t pos,
@ -220,6 +221,8 @@ _PROTOTYPE( int do_chroot, (void) );
_PROTOTYPE( int do_fstat, (void) );
_PROTOTYPE( int do_stat, (void) );
_PROTOTYPE( int do_fstatfs, (void) );
_PROTOTYPE( int do_statvfs, (void) );
_PROTOTYPE( int do_fstatvfs, (void) );
_PROTOTYPE( int do_rdlink, (void) );
_PROTOTYPE( int do_lstat, (void) );

View file

@ -11,6 +11,7 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/statvfs.h>
#include <minix/vfsif.h>
#include <minix/com.h>
#include <minix/const.h>
@ -227,6 +228,32 @@ PUBLIC int req_fstatfs(int fs_e, int who_e, char *buf)
}
/*===========================================================================*
* req_statvfs *
*===========================================================================*/
PUBLIC int req_statvfs(int fs_e, int who_e, char *buf)
{
int r;
cp_grant_id_t grant_id;
message m;
grant_id = cpf_grant_magic(fs_e, who_e, (vir_bytes) buf, sizeof(struct statvfs),
CPF_WRITE);
if(grant_id == -1)
panic("req_statvfs: cpf_grant_magic failed");
/* Fill in request message */
m.m_type = REQ_STATVFS;
m.REQ_GRANT = grant_id;
/* Send/rec request */
r = fs_sendrec(fs_e, &m);
cpf_revoke(grant_id);
return(r);
}
/*===========================================================================*
* req_ftrunc *
*===========================================================================*/

View file

@ -8,6 +8,8 @@
* 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"
@ -169,6 +171,38 @@ PUBLIC int do_fstatfs()
return req_fstatfs(rfilp->filp_vno->v_fs_e, who_e, m_in.buffer);
}
/*===========================================================================*
* do_statvfs *
*===========================================================================*/
PUBLIC int do_statvfs()
{
/* Perform the stat(name, buf) system call. */
int r;
struct vnode *vp;
if (fetch_name(m_in.STATVFS_NAME, m_in.STATVFS_LEN, M1) != OK) return(err_code);
if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code);
r = req_statvfs(vp->v_fs_e, who_e, m_in.STATVFS_BUF);
put_vnode(vp);
return r;
}
/*===========================================================================*
* do_fstatvfs *
*===========================================================================*/
PUBLIC int do_fstatvfs()
{
/* Perform the fstat(fd, buf) system call. */
register struct filp *rfilp;
/* Is the file descriptor valid? */
if ((rfilp = get_filp(m_in.FSTATVFS_FD)) == NULL) return(err_code);
return req_statvfs(rfilp->filp_vno->v_fs_e, who_e, m_in.FSTATVFS_BUF);
}
/*===========================================================================*
* do_lstat *

View file

@ -98,8 +98,8 @@ PUBLIC _PROTOTYPE (int (*call_vec[]), (void) ) = {
do_getdents, /* 80 = getdents */
do_llseek, /* 81 = llseek */
do_fstatfs, /* 82 = fstatfs */
no_sys, /* 83 = unused */
no_sys, /* 84 = unused */
do_statvfs, /* 83 = fstatvfs */
do_fstatvfs, /* 84 = statvfs */
do_select, /* 85 = select */
do_fchdir, /* 86 = fchdir */
do_fsync, /* 87 = fsync */