Implemented some more calls in unistd.h.
Replaced the unused syscall for getdtablesize() with one for access(). Implemented sys_access() and added it to the file system interface. Removed the fs function interface from vfs.h. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@738 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -348,6 +348,8 @@ KernelStaticLibraryObjects libc.a :
|
||||
<$(SOURCE_GRIST)!libc!system>wrappers.o
|
||||
<$(SOURCE_GRIST)!libc!system!arch!$(OBOS_ARCH)>atomic.o
|
||||
|
||||
<$(SOURCE_GRIST)!libc!unistd>access.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>chown.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>close.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>dup.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>dup2.o
|
||||
@@ -360,6 +362,7 @@ KernelStaticLibraryObjects libc.a :
|
||||
<$(SOURCE_GRIST)!libc!unistd>write.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>sleep.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>usleep.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>truncate.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>ioctl.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>mount.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>conf.o
|
||||
@@ -466,6 +469,8 @@ KernelLd libc.so :
|
||||
<$(SOURCE_GRIST)!libc!system>wrappers.o
|
||||
<$(SOURCE_GRIST)!libc!system!arch!$(OBOS_ARCH)>atomic.o
|
||||
|
||||
<$(SOURCE_GRIST)!libc!unistd>access.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>chown.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>close.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>dup.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>dup2.o
|
||||
@@ -478,6 +483,7 @@ KernelLd libc.so :
|
||||
<$(SOURCE_GRIST)!libc!unistd>write.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>sleep.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>usleep.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>truncate.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>ioctl.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>mount.o
|
||||
<$(SOURCE_GRIST)!libc!unistd>conf.o
|
||||
|
||||
@@ -1034,6 +1034,7 @@ static struct fs_calls bootfs_calls = {
|
||||
&bootfs_unlink,
|
||||
&bootfs_rename,
|
||||
|
||||
NULL, // access
|
||||
&bootfs_read_stat,
|
||||
&bootfs_write_stat,
|
||||
|
||||
|
||||
@@ -1072,6 +1072,7 @@ static struct fs_calls devfs_calls = {
|
||||
&devfs_unlink,
|
||||
&devfs_rename,
|
||||
|
||||
NULL, // access
|
||||
&devfs_read_stat,
|
||||
&devfs_write_stat,
|
||||
|
||||
|
||||
@@ -925,6 +925,7 @@ static struct fs_calls rootfs_calls = {
|
||||
&rootfs_unlink,
|
||||
&rootfs_rename,
|
||||
|
||||
NULL, // fs_access()
|
||||
&rootfs_read_stat,
|
||||
&rootfs_write_stat,
|
||||
|
||||
|
||||
@@ -2111,6 +2111,27 @@ common_unlink(char *path, bool kernel)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
common_access(char *path, int mode, bool kernel)
|
||||
{
|
||||
struct vnode *vnode;
|
||||
int status;
|
||||
|
||||
status = path_to_vnode(path, true, &vnode, kernel);
|
||||
if (status < B_OK)
|
||||
return status;
|
||||
|
||||
if (FS_CALL(vnode,fs_access) != NULL)
|
||||
status = FS_CALL(vnode,fs_access)(vnode->mount->cookie, vnode->private_node, mode);
|
||||
else
|
||||
status = EOPNOTSUPP;
|
||||
|
||||
put_vnode(vnode);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
common_rename(char *path, char *newPath, bool kernel)
|
||||
{
|
||||
@@ -2749,6 +2770,18 @@ sys_rename(const char *oldpath, const char *newpath)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
sys_access(const char *path, int mode)
|
||||
{
|
||||
char pathCopy[SYS_MAX_PATH_LEN + 1];
|
||||
int status;
|
||||
|
||||
strlcpy(pathCopy, path, SYS_MAX_PATH_LEN - 1);
|
||||
|
||||
return common_access(pathCopy, mode, true);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
sys_read_stat(const char *path, bool traverseLeafLink, struct stat *stat)
|
||||
{
|
||||
@@ -3127,18 +3160,18 @@ user_create_symlink(const char *userPath, const char *userToPath, int mode)
|
||||
|
||||
|
||||
int
|
||||
user_unlink(const char *upath)
|
||||
user_unlink(const char *userPath)
|
||||
{
|
||||
char path[SYS_MAX_PATH_LEN + 1];
|
||||
int rc;
|
||||
int status;
|
||||
|
||||
if ((addr)upath >= KERNEL_BASE && (addr)upath <= KERNEL_TOP)
|
||||
return ERR_VM_BAD_USER_MEMORY;
|
||||
if (!CHECK_USER_ADDRESS(userPath))
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
rc = user_strncpy(path, upath, SYS_MAX_PATH_LEN);
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
path[SYS_MAX_PATH_LEN] = 0;
|
||||
status = user_strncpy(path, userPath, SYS_MAX_PATH_LEN - 1);
|
||||
if (status < 0)
|
||||
return status;
|
||||
path[SYS_MAX_PATH_LEN - 1] = '\0';
|
||||
|
||||
return common_unlink(path, false);
|
||||
}
|
||||
@@ -3171,6 +3204,24 @@ user_rename(const char *uoldpath, const char *unewpath)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
user_access(const char *userPath, int mode)
|
||||
{
|
||||
char path[SYS_MAX_PATH_LEN + 1];
|
||||
int status;
|
||||
|
||||
if (!CHECK_USER_ADDRESS(userPath))
|
||||
return B_BAD_ADDRESS;
|
||||
|
||||
status = user_strncpy(path, userPath, SYS_MAX_PATH_LEN - 1);
|
||||
if (status < 0)
|
||||
return status;
|
||||
path[SYS_MAX_PATH_LEN - 1] = '\0';
|
||||
|
||||
return common_access(path, mode, false);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
user_read_stat(const char *userPath, bool traverseLink, struct stat *userStat)
|
||||
{
|
||||
|
||||
@@ -126,12 +126,15 @@ int syscall_dispatcher(unsigned long call_num, void *arg_buffer, uint64 *call_re
|
||||
case SYSCALL_READ_STAT:
|
||||
*call_ret = user_read_stat((const char *)arg0, (bool)arg1, (struct stat *)arg2);
|
||||
break;
|
||||
case SYSCALL_FD_STAT:
|
||||
case SYSCALL_READ_STAT_FD:
|
||||
*call_ret = user_fstat((int)arg0, (struct stat*)arg1);
|
||||
break;
|
||||
case SYSCALL_WRITE_STAT:
|
||||
*call_ret = user_write_stat((int)arg0, (const char *)arg1, (bool)arg2, (struct stat *)arg3, (int)arg4);
|
||||
break;
|
||||
case SYSCALL_ACCESS:
|
||||
*call_ret = user_access((const char *)arg0, (int)arg1);
|
||||
break;
|
||||
case SYSCALL_SYSTEM_TIME:
|
||||
*call_ret = system_time();
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user