Added implementation of the functions in fs_index.h.
Commented system_time() in time.c - it's already implemented in atomic.S (not that it would belong there). Fixed linking of rewind.c Added syscalls for the index functions. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1565 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4,6 +4,7 @@ KernelObjects
|
||||
<$(SOURCE_GRIST)>area.c
|
||||
<$(SOURCE_GRIST)>debug.c
|
||||
<$(SOURCE_GRIST)>fs_attr.c
|
||||
<$(SOURCE_GRIST)>fs_index.c
|
||||
<$(SOURCE_GRIST)>port.c
|
||||
<$(SOURCE_GRIST)>sem.c
|
||||
<$(SOURCE_GRIST)>systeminfo.c
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
** Copyright 2002, Axel Dörfler, [email protected]. All rights reserved.
|
||||
** Distributed under the terms of the OpenBeOS License.
|
||||
*/
|
||||
|
||||
|
||||
#include <fs_index.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "syscalls.h"
|
||||
|
||||
|
||||
#define RETURN_AND_SET_ERRNO(status) \
|
||||
{ \
|
||||
if (status < 0) { \
|
||||
errno = status; \
|
||||
return -1; \
|
||||
} \
|
||||
return status; \
|
||||
}
|
||||
|
||||
// for the DIR structure
|
||||
#define BUFFER_SIZE 2048
|
||||
|
||||
|
||||
int
|
||||
fs_create_index(dev_t device, const char *name, uint32 type, uint32 flags)
|
||||
{
|
||||
status_t status = sys_create_index(device, name, type, flags);
|
||||
|
||||
RETURN_AND_SET_ERRNO(status);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
fs_remove_index(dev_t device, const char *name)
|
||||
{
|
||||
status_t status = sys_remove_index(device, name);
|
||||
|
||||
RETURN_AND_SET_ERRNO(status);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
fs_stat_index(dev_t device, const char *name, struct index_info *indexInfo)
|
||||
{
|
||||
struct stat stat;
|
||||
|
||||
status_t status = sys_read_index_stat(device, name, &stat);
|
||||
if (status == B_OK) {
|
||||
indexInfo->type = stat.st_type;
|
||||
indexInfo->size = stat.st_size;
|
||||
indexInfo->modification_time = stat.st_mtime;
|
||||
indexInfo->creation_time = stat.st_crtime;
|
||||
indexInfo->uid = stat.st_uid;
|
||||
indexInfo->gid = stat.st_gid;
|
||||
}
|
||||
|
||||
RETURN_AND_SET_ERRNO(status);
|
||||
}
|
||||
|
||||
|
||||
DIR *
|
||||
fs_open_index_dir(dev_t device)
|
||||
{
|
||||
DIR *dir;
|
||||
|
||||
int fd = sys_open_index_dir(device);
|
||||
if (fd < 0) {
|
||||
errno = fd;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* allocate the memory for the DIR structure */
|
||||
if ((dir = (DIR *)malloc(sizeof(DIR) + BUFFER_SIZE)) == NULL) {
|
||||
errno = B_NO_MEMORY;
|
||||
sys_close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dir->fd = fd;
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
fs_close_index_dir(DIR *dir)
|
||||
{
|
||||
int status = sys_close(dir->fd);
|
||||
|
||||
free(dir);
|
||||
|
||||
RETURN_AND_SET_ERRNO(status);
|
||||
}
|
||||
|
||||
|
||||
struct dirent *
|
||||
fs_read_index_dir(DIR *dir)
|
||||
{
|
||||
ssize_t count = sys_read_dir(dir->fd, &dir->ent, BUFFER_SIZE, 1);
|
||||
if (count <= 0) {
|
||||
if (count < 0)
|
||||
errno = count;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &dir->ent;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
fs_rewind_index_dir(DIR *dir)
|
||||
{
|
||||
int status = sys_rewind_dir(dir->fd);
|
||||
if (status < 0)
|
||||
errno = status;
|
||||
}
|
||||
|
||||
@@ -72,6 +72,12 @@ SYSCALL3(sys_open_attr, 99)
|
||||
SYSCALL2(sys_remove_attr, 101)
|
||||
SYSCALL4(sys_rename_attr, 102)
|
||||
|
||||
/* VFS index calls */
|
||||
SYSCALL1(sys_open_index_dir, 106)
|
||||
SYSCALL4(sys_create_index, 107)
|
||||
SYSCALL3(sys_read_index_stat, 108)
|
||||
SYSCALL2(sys_remove_index, 109)
|
||||
|
||||
/* semaphore calls */
|
||||
SYSCALL2(sys_create_sem, 18)
|
||||
SYSCALL1(sys_delete_sem, 19)
|
||||
|
||||
@@ -39,12 +39,15 @@ set_timezone(char *timezone)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// ToDo: currently defined in atomic.S - but should be in its own file time.S
|
||||
bigtime_t
|
||||
system_time(void)
|
||||
{
|
||||
/* time since booting in microseconds */
|
||||
// time since booting in microseconds
|
||||
return sys_system_time();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
bigtime_t
|
||||
|
||||
@@ -34,18 +34,15 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char rcsid[] = "$OpenBSD: rewind.c,v 1.2 1996/08/19 08:33:02 tholo Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void
|
||||
rewind(fp)
|
||||
register FILE *fp;
|
||||
{
|
||||
(void) fseek(fp, 0L, SEEK_SET);
|
||||
clearerr(fp);
|
||||
//clearerr(fp);
|
||||
errno = 0; /* not required, but seems reasonable */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user