diff --git a/include/minix/callnr.h b/include/minix/callnr.h index 0a492a4ac..3b52911ad 100644 --- a/include/minix/callnr.h +++ b/include/minix/callnr.h @@ -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 */ diff --git a/include/minix/com.h b/include/minix/com.h index 9a2c2d4fc..bb7820b9c 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -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 * *===========================================================================*/ diff --git a/include/minix/vfsif.h b/include/minix/vfsif.h index a46e7c2e6..32149ec27 100644 --- a/include/minix/vfsif.h +++ b/include/minix/vfsif.h @@ -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 diff --git a/servers/vfs/proto.h b/servers/vfs/proto.h index 8fad59a95..2d799972d 100644 --- a/servers/vfs/proto.h +++ b/servers/vfs/proto.h @@ -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) ); diff --git a/servers/vfs/request.c b/servers/vfs/request.c index 329c7cef4..cdd208da4 100644 --- a/servers/vfs/request.c +++ b/servers/vfs/request.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -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 * *===========================================================================*/ diff --git a/servers/vfs/stadir.c b/servers/vfs/stadir.c index 142784f25..3805f63db 100644 --- a/servers/vfs/stadir.c +++ b/servers/vfs/stadir.c @@ -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 * diff --git a/servers/vfs/table.c b/servers/vfs/table.c index 064990f8b..6d7f4f28a 100644 --- a/servers/vfs/table.c +++ b/servers/vfs/table.c @@ -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 */