1/* 2 * Copyright 2005-2008, Axel D��rfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6//! This file includes some known R5 syscalls 7 8#include <errno.h> 9#include <sys/resource.h> 10#include <sys/stat.h> 11 12#include <SupportDefs.h> 13#include <errno_private.h> 14#include <fs_info.h> 15#include <fs_volume.h> 16#include <PCI.h> 17 18#include <syscalls.h> 19 20 21int _kset_mon_limit_(int num); 22int _kset_fd_limit_(int num); 23int _klock_node_(int fd); 24int _kunlock_node_(int fd); 25int _kget_cpu_state_(int cpuNum); 26int _kset_cpu_state_(int cpuNum, int state); 27int _kstatfs_(dev_t device, void *whatever, int fd, const char *path, fs_info *info); 28int mount(const char *filesystem, const char *where, const char *device, ulong flags, 29 void *parms, int len); 30int unmount(const char *path); 31long get_nth_pci_info(long index, pci_info *info); 32 33 34int 35_kset_mon_limit_(int num) 36{ 37 struct rlimit rl; 38 if (num < 1) 39 return EINVAL; 40 rl.rlim_cur = num; 41 rl.rlim_max = RLIM_SAVED_MAX; 42 if (setrlimit(RLIMIT_NOVMON, &rl) < 0) 43 return errno; 44 return B_OK; 45} 46 47 48int 49_kset_fd_limit_(int num) 50{ 51 struct rlimit rl; 52 if (num < 1) 53 return EINVAL; 54 rl.rlim_cur = num; 55 rl.rlim_max = RLIM_SAVED_MAX; 56 if (setrlimit(RLIMIT_NOFILE, &rl) < 0) 57 return errno; 58 return B_OK; 59} 60 61 62int 63_klock_node_(int fd) 64{ 65 return _kern_lock_node(fd); 66} 67 68 69int 70_kunlock_node_(int fd) 71{ 72 return _kern_unlock_node(fd); 73} 74 75 76int 77_kget_cpu_state_(int cpuNum) 78{ 79 return _kern_cpu_enabled(cpuNum); 80} 81 82 83int 84_kset_cpu_state_(int cpuNum, int state) 85{ 86 return _kern_set_cpu_enabled(cpuNum, state != 0); 87} 88 89 90int 91_kstatfs_(dev_t device, void *whatever, int fd, const char *path, fs_info *info) 92{ 93 if (device < 0) { 94 if (fd >= 0) { 95 struct stat stat; 96 if (fstat(fd, &stat) < 0) 97 return -1; 98 99 device = stat.st_dev; 100 } else if (path != NULL) 101 device = dev_for_path(path); 102 } 103 if (device < 0) 104 return B_ERROR; 105 106 return fs_stat_dev(device, info); 107} 108 109 110int 111mount(const char *filesystem, const char *where, const char *device, ulong flags, 112 void *parms, int len) 113{ 114 status_t err; 115 uint32 mountFlags = 0; 116 117 if (flags & 1) 118 mountFlags |= B_MOUNT_READ_ONLY; 119 120 // we don't support passing (binary) parameters 121 if (parms != NULL || len != 0 || flags & ~1) { 122 __set_errno(B_BAD_VALUE); 123 return -1; 124 } 125 126 err = fs_mount_volume(where, device, filesystem, mountFlags, NULL); 127 if (err < B_OK) { 128 __set_errno(err); 129 return -1; 130 } 131 return 0; 132} 133 134 135int 136unmount(const char *path) 137{ 138 status_t err; 139 140 err = fs_unmount_volume(path, 0); 141 if (err < B_OK) { 142 __set_errno(err); 143 return -1; 144 } 145 return 0; 146} 147 148 149long get_nth_pci_info(long index,pci_info *info) 150{ 151 return B_ERROR; 152} 153