New syscalls vfsavailmounts() and vfsmountstat() to get info about current VFS mountpoints
This commit is contained in:
@ -32,6 +32,8 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = {
|
|||||||
|
|
||||||
[SYS_VFSMOUNT] = &sys_vfsmount,
|
[SYS_VFSMOUNT] = &sys_vfsmount,
|
||||||
[SYS_VFSUNMOUNT] = &sys_vfsunmount,
|
[SYS_VFSUNMOUNT] = &sys_vfsunmount,
|
||||||
|
[SYS_VFSAVAILMOUNTS] = &sys_vfsavailmounts,
|
||||||
|
[SYS_VFSMOUNTSTAT] = &sys_vfsmountstat,
|
||||||
|
|
||||||
[SYS_IPC_PIPEREAD] = &sys_ipc_piperead,
|
[SYS_IPC_PIPEREAD] = &sys_ipc_piperead,
|
||||||
[SYS_IPC_PIPEWRITE] = &sys_ipc_pipewrite,
|
[SYS_IPC_PIPEWRITE] = &sys_ipc_pipewrite,
|
||||||
|
|||||||
@ -6,12 +6,14 @@
|
|||||||
#include "vfs.h"
|
#include "vfs.h"
|
||||||
#include "errors.h"
|
#include "errors.h"
|
||||||
#include "sysdefs/dev.h"
|
#include "sysdefs/dev.h"
|
||||||
|
#include "sysdefs/vfs.h"
|
||||||
#include "vfs/vfs.h"
|
#include "vfs/vfs.h"
|
||||||
#include "spinlock/spinlock.h"
|
#include "spinlock/spinlock.h"
|
||||||
#include "dev/dev.h"
|
#include "dev/dev.h"
|
||||||
#include "proc/proc.h"
|
#include "proc/proc.h"
|
||||||
#include "storedev/storedev.h"
|
#include "storedev/storedev.h"
|
||||||
#include "util/util.h"
|
#include "util/util.h"
|
||||||
|
#include "hshtb.h"
|
||||||
|
|
||||||
int32_t SYSCALL4(sys_vfsmount, mountpoint1, fstypestr1, devid1, format1) {
|
int32_t SYSCALL4(sys_vfsmount, mountpoint1, fstypestr1, devid1, format1) {
|
||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
@ -63,3 +65,59 @@ int32_t SYSCALL1(sys_vfsunmount, mountpoint1) {
|
|||||||
done:
|
done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t SYSCALL1(sys_vfsavailmounts, availmounts1) {
|
||||||
|
VfsAvailMounts *availmounts = (VfsAvailMounts *)availmounts1;
|
||||||
|
if (availmounts == NULL) {
|
||||||
|
return E_INVALIDARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
spinlock_acquire(&VFS_TABLE.spinlock);
|
||||||
|
for (size_t i = 0; i < VFS_MOUNTPOINTS_MAX; i++) {
|
||||||
|
VfsMountPoint *vmp = &VFS_TABLE.mountpoints[i];
|
||||||
|
if (vmp->_hshtbstate == HSHTB_TAKEN) {
|
||||||
|
hal_memcpy(availmounts->labels[i], vmp->label, VFS_MOUNTPOINT_LABEL_MAX);
|
||||||
|
availmounts->fieldavail[i] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spinlock_release(&VFS_TABLE.spinlock);
|
||||||
|
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t SYSCALL2(sys_vfsmountstat, statbuf1, label1) {
|
||||||
|
VfsMountStat *statbuf = (VfsMountStat *)statbuf1;
|
||||||
|
if (statbuf == NULL) {
|
||||||
|
return E_INVALIDARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *label = (char *)label1;
|
||||||
|
if (label == NULL) {
|
||||||
|
return E_INVALIDARGUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
VfsMountPoint *vmp = NULL;
|
||||||
|
spinlock_acquire(&VFS_TABLE.spinlock);
|
||||||
|
HSHTB_GET(VFS_TABLE.mountpoints, label, label, vmp);
|
||||||
|
spinlock_release(&VFS_TABLE.spinlock);
|
||||||
|
|
||||||
|
if (vmp == NULL) {
|
||||||
|
return E_NOENTRY;
|
||||||
|
}
|
||||||
|
|
||||||
|
hal_memcpy(statbuf->label, vmp->label, sizeof(statbuf->label));
|
||||||
|
statbuf->fstype = vmp->fstype;
|
||||||
|
|
||||||
|
StoreDev *vmpsd = vmp->backingsd;
|
||||||
|
spinlock_acquire(&DEVTABLE.spinlock);
|
||||||
|
for (size_t i = 0; i < LEN(DEVTABLE.devs); i++) {
|
||||||
|
Dev *dev = &DEVTABLE.devs[i];
|
||||||
|
if (dev->extra != NULL && ((StoreDev *)dev->extra)->_magic == STOREDEV_MAGIC && vmpsd == dev->extra) {
|
||||||
|
hal_memcpy(statbuf->devname, dev->ident, sizeof(statbuf->devname));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spinlock_release(&DEVTABLE.spinlock);
|
||||||
|
|
||||||
|
return E_OK;
|
||||||
|
}
|
||||||
|
|||||||
@ -7,5 +7,7 @@
|
|||||||
|
|
||||||
int32_t SYSCALL4(sys_vfsmount, mountpoint1, fstypestr1, devid1, format1);
|
int32_t SYSCALL4(sys_vfsmount, mountpoint1, fstypestr1, devid1, format1);
|
||||||
int32_t SYSCALL1(sys_vfsunmount, mountpoint1);
|
int32_t SYSCALL1(sys_vfsunmount, mountpoint1);
|
||||||
|
int32_t SYSCALL1(sys_vfsavailmounts, availmounts1);
|
||||||
|
int32_t SYSCALL2(sys_vfsmountstat, statbuf1, label1);
|
||||||
|
|
||||||
#endif // SYSCALL_VFS_H_
|
#endif // SYSCALL_VFS_H_
|
||||||
|
|||||||
@ -9,6 +9,8 @@
|
|||||||
#define SYS_RAND 9
|
#define SYS_RAND 9
|
||||||
#define SYS_VFSMOUNT 10
|
#define SYS_VFSMOUNT 10
|
||||||
#define SYS_VFSUNMOUNT 11
|
#define SYS_VFSUNMOUNT 11
|
||||||
|
#define SYS_VFSAVAILMOUNTS 2
|
||||||
|
#define SYS_VFSMOUNTSTAT 3
|
||||||
#define SYS_IPC_PIPEREAD 12
|
#define SYS_IPC_PIPEREAD 12
|
||||||
#define SYS_IPC_PIPEWRITE 13
|
#define SYS_IPC_PIPEWRITE 13
|
||||||
#define SYS_IPC_PIPEMAKE 14
|
#define SYS_IPC_PIPEMAKE 14
|
||||||
|
|||||||
15
share/sysdefs/vfs.h
Normal file
15
share/sysdefs/vfs.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef SHARE_SYSDEFS_VFS_H_
|
||||||
|
#define SHARE_SYSDEFS_VFS_H_
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char label[128];
|
||||||
|
int32_t fstype;
|
||||||
|
char devname[0x100];
|
||||||
|
} VfsMountStat;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char labels[30][128];
|
||||||
|
uint8_t fieldavail[30];
|
||||||
|
} VfsAvailMounts;
|
||||||
|
|
||||||
|
#endif // SHARE_SYSDEFS_VFS_H_
|
||||||
Reference in New Issue
Block a user