* Consolidated '*' style.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29341 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2009-02-27 23:09:39 +00:00
parent 595d8a3b9c
commit 2e47b62e2c

View File

@ -1,6 +1,6 @@
/*
* Copyright 2005-2008, Ingo Weinhold, ingo_weinhold@gmx.de.
* Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2002-2009, Axel Dörfler, axeld@pinc-software.de.
* Distributed under the terms of the MIT License.
*
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@ -443,49 +443,63 @@ mode_t __gUmask = 022;
/* function declarations */
// file descriptor operation prototypes
static status_t file_read(struct file_descriptor *, off_t pos, void *buffer, size_t *);
static status_t file_write(struct file_descriptor *, off_t pos, const void *buffer, size_t *);
static off_t file_seek(struct file_descriptor *, off_t pos, int seek_type);
static void file_free_fd(struct file_descriptor *);
static status_t file_close(struct file_descriptor *);
static status_t file_select(struct file_descriptor *, uint8 event,
static status_t file_read(struct file_descriptor* descriptor, off_t pos,
void* buffer, size_t* _bytes);
static status_t file_write(struct file_descriptor* descriptor, off_t pos,
const void* buffer, size_t* _bytes);
static off_t file_seek(struct file_descriptor* descriptor, off_t pos,
int seekType);
static void file_free_fd(struct file_descriptor* descriptor);
static status_t file_close(struct file_descriptor* descriptor);
static status_t file_select(struct file_descriptor* descriptor, uint8 event,
struct selectsync* sync);
static status_t file_deselect(struct file_descriptor *, uint8 event,
static status_t file_deselect(struct file_descriptor* descriptor, uint8 event,
struct selectsync* sync);
static status_t dir_read(struct io_context *, struct file_descriptor *,
struct dirent *buffer, size_t bufferSize, uint32 *_count);
static status_t dir_read(struct io_context* context,
struct file_descriptor* descriptor, struct dirent* buffer, size_t bufferSize,
uint32* _count);
static status_t dir_read(struct io_context* ioContext, struct vnode* vnode,
void* cookie, struct dirent* buffer, size_t bufferSize, uint32* _count);
static status_t dir_rewind(struct file_descriptor *);
static void dir_free_fd(struct file_descriptor *);
static status_t dir_close(struct file_descriptor *);
static status_t attr_dir_read(struct io_context *, struct file_descriptor *,
struct dirent *buffer, size_t bufferSize, uint32 *_count);
static status_t attr_dir_rewind(struct file_descriptor *);
static void attr_dir_free_fd(struct file_descriptor *);
static status_t attr_dir_close(struct file_descriptor *);
static status_t attr_read(struct file_descriptor *, off_t pos, void *buffer, size_t *);
static status_t attr_write(struct file_descriptor *, off_t pos, const void *buffer, size_t *);
static off_t attr_seek(struct file_descriptor *, off_t pos, int seek_type);
static void attr_free_fd(struct file_descriptor *);
static status_t attr_close(struct file_descriptor *);
static status_t attr_read_stat(struct file_descriptor *, struct stat *);
static status_t attr_write_stat(struct file_descriptor *, const struct stat *, int statMask);
static status_t index_dir_read(struct io_context *, struct file_descriptor *,
struct dirent *buffer, size_t bufferSize, uint32 *_count);
static status_t index_dir_rewind(struct file_descriptor *);
static void index_dir_free_fd(struct file_descriptor *);
static status_t index_dir_close(struct file_descriptor *);
static status_t query_read(struct io_context *, struct file_descriptor *,
struct dirent *buffer, size_t bufferSize, uint32 *_count);
static status_t query_rewind(struct file_descriptor *);
static void query_free_fd(struct file_descriptor *);
static status_t query_close(struct file_descriptor *);
static status_t common_ioctl(struct file_descriptor *, ulong, void *buf, size_t len);
static status_t common_read_stat(struct file_descriptor *, struct stat *);
static status_t common_write_stat(struct file_descriptor *, const struct stat *, int statMask);
static status_t dir_rewind(struct file_descriptor* descriptor);
static void dir_free_fd(struct file_descriptor* descriptor);
static status_t dir_close(struct file_descriptor* descriptor);
static status_t attr_dir_read(struct io_context* context,
struct file_descriptor* descriptor, struct dirent* buffer, size_t bufferSize,
uint32* _count);
static status_t attr_dir_rewind(struct file_descriptor* descriptor);
static void attr_dir_free_fd(struct file_descriptor* descriptor);
static status_t attr_dir_close(struct file_descriptor* descriptor);
static status_t attr_read(struct file_descriptor* descriptor, off_t pos,
void* buffer, size_t* _bytes);
static status_t attr_write(struct file_descriptor* descriptor, off_t pos,
const void* buffer, size_t* _bytes);
static off_t attr_seek(struct file_descriptor* descriptor, off_t pos,
int seekType);
static void attr_free_fd(struct file_descriptor* descriptor);
static status_t attr_close(struct file_descriptor* descriptor);
static status_t attr_read_stat(struct file_descriptor* descriptor,
struct stat* statData);
static status_t attr_write_stat(struct file_descriptor* descriptor,
const struct stat* descriptor, int statMask);
static status_t index_dir_read(struct io_context* context,
struct file_descriptor* descriptor, struct dirent* buffer, size_t bufferSize,
uint32* _count);
static status_t index_dir_rewind(struct file_descriptor* descriptor);
static void index_dir_free_fd(struct file_descriptor* descriptor);
static status_t index_dir_close(struct file_descriptor* descriptor);
static status_t query_read(struct io_context* context,
struct file_descriptor* descriptor, struct dirent* buffer, size_t bufferSize,
uint32* _count);
static status_t query_rewind(struct file_descriptor* descriptor);
static void query_free_fd(struct file_descriptor* descriptor);
static status_t query_close(struct file_descriptor* descriptor);
static status_t common_ioctl(struct file_descriptor* descriptor, ulong op,
void* buffer, size_t length);
static status_t common_read_stat(struct file_descriptor* descriptor,
struct stat* statData);
static status_t common_write_stat(struct file_descriptor* descriptor,
const struct stat* statData, int statMask);
static status_t common_path_read_stat(int fd, char* path, bool traverseLeafLink,
struct stat* stat, bool kernel);
@ -4101,7 +4115,8 @@ status_t
vfs_get_module_path(const char* basePath, const char* moduleName,
char* pathBuffer, size_t bufferSize)
{
struct vnode *dir, *file;
struct vnode* dir;
struct vnode* file;
status_t status;
size_t length;
char* path;
@ -4824,34 +4839,26 @@ vfs_getrlimit(int resource, struct rlimit * rlp)
switch (resource) {
case RLIMIT_NOFILE:
{
struct io_context *ioctx = get_current_io_context(false);
struct io_context* context = get_current_io_context(false);
MutexLocker _(context->io_mutex);
mutex_lock(&ioctx->io_mutex);
rlp->rlim_cur = ioctx->table_size;
rlp->rlim_cur = context->table_size;
rlp->rlim_max = MAX_FD_TABLE_SIZE;
mutex_unlock(&ioctx->io_mutex);
return 0;
}
case RLIMIT_NOVMON:
{
struct io_context *ioctx = get_current_io_context(false);
struct io_context* context = get_current_io_context(false);
MutexLocker _(context->io_mutex);
mutex_lock(&ioctx->io_mutex);
rlp->rlim_cur = ioctx->max_monitors;
rlp->rlim_cur = context->max_monitors;
rlp->rlim_max = MAX_NODE_MONITORS;
mutex_unlock(&ioctx->io_mutex);
return 0;
}
default:
return EINVAL;
return B_BAD_VALUE;
}
}
@ -4867,18 +4874,22 @@ vfs_setrlimit(int resource, const struct rlimit * rlp)
/* TODO: check getuid() */
if (rlp->rlim_max != RLIM_SAVED_MAX
&& rlp->rlim_max != MAX_FD_TABLE_SIZE)
return EPERM;
return vfs_resize_fd_table(get_current_io_context(false), rlp->rlim_cur);
return B_NOT_ALLOWED;
return vfs_resize_fd_table(get_current_io_context(false),
rlp->rlim_cur);
case RLIMIT_NOVMON:
/* TODO: check getuid() */
if (rlp->rlim_max != RLIM_SAVED_MAX
&& rlp->rlim_max != MAX_NODE_MONITORS)
return EPERM;
return vfs_resize_monitor_table(get_current_io_context(false), rlp->rlim_cur);
return B_NOT_ALLOWED;
return vfs_resize_monitor_table(get_current_io_context(false),
rlp->rlim_cur);
default:
return EINVAL;
return B_BAD_VALUE;
}
}
@ -5365,7 +5376,8 @@ file_deselect(struct file_descriptor *descriptor, uint8 event,
static status_t
dir_create_entry_ref(dev_t mountID, ino_t parentID, const char *name, int perms, bool kernel)
dir_create_entry_ref(dev_t mountID, ino_t parentID, const char* name, int perms,
bool kernel)
{
struct vnode* vnode;
ino_t newID;
@ -5374,7 +5386,8 @@ dir_create_entry_ref(dev_t mountID, ino_t parentID, const char *name, int perms,
if (name == NULL || *name == '\0')
return B_BAD_VALUE;
FUNCTION(("dir_create_entry_ref(dev = %ld, ino = %Ld, name = '%s', perms = %d)\n", mountID, parentID, name, perms));
FUNCTION(("dir_create_entry_ref(dev = %ld, ino = %Ld, name = '%s', "
"perms = %d)\n", mountID, parentID, name, perms));
status = get_vnode(mountID, parentID, &vnode, true, false);
if (status < B_OK)
@ -5944,10 +5957,12 @@ common_create_link(char *path, char *toPath, bool kernel)
{
// path validity checks have to be in the calling function!
char name[B_FILE_NAME_LENGTH];
struct vnode *directory, *vnode;
struct vnode* directory;
struct vnode* vnode;
status_t status;
FUNCTION(("common_create_link(path = %s, toPath = %s, kernel = %d)\n", path, toPath, kernel));
FUNCTION(("common_create_link(path = %s, toPath = %s, kernel = %d)\n", path,
toPath, kernel));
status = path_to_dir_vnode(path, &directory, name, kernel);
if (status < B_OK)
@ -6024,12 +6039,14 @@ common_access(char *path, int mode, bool kernel)
static status_t
common_rename(int fd, char* path, int newFD, char* newPath, bool kernel)
{
struct vnode *fromVnode, *toVnode;
struct vnode* fromVnode;
struct vnode* toVnode;
char fromName[B_FILE_NAME_LENGTH];
char toName[B_FILE_NAME_LENGTH];
status_t status;
FUNCTION(("common_rename(fd = %d, path = %s, newFD = %d, newPath = %s, kernel = %d)\n", fd, path, newFD, newPath, kernel));
FUNCTION(("common_rename(fd = %d, path = %s, newFD = %d, newPath = %s, "
"kernel = %d)\n", fd, path, newFD, newPath, kernel));
status = fd_and_path_to_dir_vnode(fd, path, &fromVnode, fromName, kernel);
if (status < B_OK)
@ -6079,11 +6096,14 @@ common_read_stat(struct file_descriptor *descriptor, struct stat *stat)
static status_t
common_write_stat(struct file_descriptor *descriptor, const struct stat *stat, int statMask)
common_write_stat(struct file_descriptor* descriptor, const struct stat* stat,
int statMask)
{
struct vnode* vnode = descriptor->u.vnode;
FUNCTION(("common_write_stat(vnode = %p, stat = %p, statMask = %d)\n", vnode, stat, statMask));
FUNCTION(("common_write_stat(vnode = %p, stat = %p, statMask = %d)\n", vnode,
stat, statMask));
if (!HAS_FS_CALL(vnode, write_stat))
return EROFS;
@ -6098,9 +6118,11 @@ common_path_read_stat(int fd, char *path, bool traverseLeafLink,
struct vnode* vnode;
status_t status;
FUNCTION(("common_path_read_stat: fd: %d, path '%s', stat %p,\n", fd, path, stat));
FUNCTION(("common_path_read_stat: fd: %d, path '%s', stat %p,\n", fd, path,
stat));
status = fd_and_path_to_vnode(fd, path, traverseLeafLink, &vnode, NULL, kernel);
status = fd_and_path_to_vnode(fd, path, traverseLeafLink, &vnode, NULL,
kernel);
if (status < 0)
return status;
@ -6320,11 +6342,14 @@ attr_free_fd(struct file_descriptor *descriptor)
static status_t
attr_read(struct file_descriptor *descriptor, off_t pos, void *buffer, size_t *length)
attr_read(struct file_descriptor* descriptor, off_t pos, void* buffer,
size_t* length)
{
struct vnode* vnode = descriptor->u.vnode;
FUNCTION(("attr_read: buf %p, pos %Ld, len %p = %ld\n", buffer, pos, length, *length));
FUNCTION(("attr_read: buf %p, pos %Ld, len %p = %ld\n", buffer, pos, length,
*length));
if (!HAS_FS_CALL(vnode, read_attr))
return EOPNOTSUPP;
@ -6333,7 +6358,8 @@ attr_read(struct file_descriptor *descriptor, off_t pos, void *buffer, size_t *l
static status_t
attr_write(struct file_descriptor *descriptor, off_t pos, const void *buffer, size_t *length)
attr_write(struct file_descriptor* descriptor, off_t pos, const void* buffer,
size_t* length)
{
struct vnode* vnode = descriptor->u.vnode;
@ -6403,7 +6429,8 @@ attr_read_stat(struct file_descriptor *descriptor, struct stat *stat)
static status_t
attr_write_stat(struct file_descriptor *descriptor, const struct stat *stat, int statMask)
attr_write_stat(struct file_descriptor* descriptor, const struct stat* stat,
int statMask)
{
struct vnode* vnode = descriptor->u.vnode;
@ -6426,7 +6453,8 @@ attr_remove(int fd, const char *name, bool kernel)
if (name == NULL || *name == '\0')
return B_BAD_VALUE;
FUNCTION(("attr_remove: fd = %d, name = \"%s\", kernel %d\n", fd, name, kernel));
FUNCTION(("attr_remove: fd = %d, name = \"%s\", kernel %d\n", fd, name,
kernel));
descriptor = get_fd_and_vnode(fd, &vnode, kernel);
if (descriptor == NULL)
@ -6444,22 +6472,27 @@ attr_remove(int fd, const char *name, bool kernel)
static status_t
attr_rename(int fromfd, const char *fromName, int tofd, const char *toName, bool kernel)
attr_rename(int fromFD, const char* fromName, int toFD, const char* toName,
bool kernel)
{
struct file_descriptor *fromDescriptor, *toDescriptor;
struct vnode *fromVnode, *toVnode;
struct file_descriptor* fromDescriptor;
struct file_descriptor* toDescriptor;
struct vnode* fromVnode;
struct vnode* toVnode;
status_t status;
if (fromName == NULL || *fromName == '\0' || toName == NULL || *toName == '\0')
if (fromName == NULL || *fromName == '\0' || toName == NULL
|| *toName == '\0')
return B_BAD_VALUE;
FUNCTION(("attr_rename: from fd = %d, from name = \"%s\", to fd = %d, to name = \"%s\", kernel %d\n", fromfd, fromName, tofd, toName, kernel));
FUNCTION(("attr_rename: from fd = %d, from name = \"%s\", to fd = %d, to "
"name = \"%s\", kernel %d\n", fromFD, fromName, toFD, toName, kernel));
fromDescriptor = get_fd_and_vnode(fromfd, &fromVnode, kernel);
fromDescriptor = get_fd_and_vnode(fromFD, &fromVnode, kernel);
if (fromDescriptor == NULL)
return B_FILE_ERROR;
toDescriptor = get_fd_and_vnode(tofd, &toVnode, kernel);
toDescriptor = get_fd_and_vnode(toFD, &toVnode, kernel);
if (toDescriptor == NULL) {
status = B_FILE_ERROR;
goto err;
@ -6574,9 +6607,11 @@ index_dir_rewind(struct file_descriptor *descriptor)
static status_t
index_create(dev_t mountID, const char *name, uint32 type, uint32 flags, bool kernel)
index_create(dev_t mountID, const char* name, uint32 type, uint32 flags,
bool kernel)
{
FUNCTION(("index_create(mountID = %ld, name = %s, kernel = %d)\n", mountID, name, kernel));
FUNCTION(("index_create(mountID = %ld, name = %s, kernel = %d)\n", mountID,
name, kernel));
struct fs_mount* mount;
status_t status = get_mount(mountID, &mount);
@ -6626,9 +6661,11 @@ index_free_fd(struct file_descriptor *descriptor)
static status_t
index_name_read_stat(dev_t mountID, const char *name, struct stat *stat, bool kernel)
index_name_read_stat(dev_t mountID, const char* name, struct stat* stat,
bool kernel)
{
FUNCTION(("index_remove(mountID = %ld, name = %s, kernel = %d)\n", mountID, name, kernel));
FUNCTION(("index_remove(mountID = %ld, name = %s, kernel = %d)\n", mountID,
name, kernel));
struct fs_mount* mount;
status_t status = get_mount(mountID, &mount);
@ -6651,7 +6688,8 @@ out:
static status_t
index_remove(dev_t mountID, const char* name, bool kernel)
{
FUNCTION(("index_remove(mountID = %ld, name = %s, kernel = %d)\n", mountID, name, kernel));
FUNCTION(("index_remove(mountID = %ld, name = %s, kernel = %d)\n", mountID,
name, kernel));
struct fs_mount* mount;
status_t status = get_mount(mountID, &mount);
@ -6671,19 +6709,20 @@ out:
}
/*! ToDo: the query FS API is still the pretty much the same as in R5.
/*! TODO: the query FS API is still the pretty much the same as in R5.
It would be nice if the FS would find some more kernel support
for them.
For example, query parsing should be moved into the kernel.
*/
static int
query_open(dev_t device, const char *query, uint32 flags,
port_id port, int32 token, bool kernel)
query_open(dev_t device, const char* query, uint32 flags, port_id port,
int32 token, bool kernel)
{
struct fs_mount* mount;
void* cookie;
FUNCTION(("query_open(device = %ld, query = \"%s\", kernel = %d)\n", device, query, kernel));
FUNCTION(("query_open(device = %ld, query = \"%s\", kernel = %d)\n", device,
query, kernel));
status_t status = get_mount(device, &mount);
if (status < B_OK)
@ -7638,7 +7677,8 @@ _kern_get_next_fd_info(team_id teamID, uint32 *_cookie, fd_info *info,
int
_kern_open_entry_ref(dev_t device, ino_t inode, const char *name, int openMode, int perms)
_kern_open_entry_ref(dev_t device, ino_t inode, const char* name, int openMode,
int perms)
{
if (openMode & O_CREAT)
return file_create_entry_ref(device, inode, name, openMode, perms, true);
@ -7753,7 +7793,8 @@ _kern_unlock_node(int fd)
status_t
_kern_create_dir_entry_ref(dev_t device, ino_t inode, const char *name, int perms)
_kern_create_dir_entry_ref(dev_t device, ino_t inode, const char* name,
int perms)
{
return dir_create_entry_ref(device, inode, name, perms, true);
}
@ -8085,7 +8126,8 @@ _kern_remove_attr(int fd, const char *name)
status_t
_kern_rename_attr(int fromFile, const char *fromName, int toFile, const char *toName)
_kern_rename_attr(int fromFile, const char* fromName, int toFile,
const char* toName)
{
return attr_rename(fromFile, fromName, toFile, toName, true);
}
@ -8147,8 +8189,9 @@ _kern_setcwd(int fd, const char *path)
dev_t
_user_mount(const char *userPath, const char *userDevice, const char *userFileSystem,
uint32 flags, const char *userArgs, size_t argsLength)
_user_mount(const char* userPath, const char* userDevice,
const char* userFileSystem, uint32 flags, const char* userArgs,
size_t argsLength)
{
char fileSystem[B_FILE_NAME_LENGTH];
KPath path, device;
@ -8603,7 +8646,8 @@ _user_unlock_node(int fd)
status_t
_user_create_dir_entry_ref(dev_t device, ino_t inode, const char *userName, int perms)
_user_create_dir_entry_ref(dev_t device, ino_t inode, const char* userName,
int perms)
{
char name[B_FILE_NAME_LENGTH];
status_t status;
@ -8656,7 +8700,8 @@ _user_remove_dir(int fd, const char *userPath)
status_t
_user_read_link(int fd, const char *userPath, char *userBuffer, size_t *userBufferSize)
_user_read_link(int fd, const char* userPath, char* userBuffer,
size_t* userBufferSize)
{
KPath pathBuffer(B_PATH_NAME_LENGTH + 1), linkBuffer;
if (pathBuffer.InitCheck() != B_OK || linkBuffer.InitCheck() != B_OK)
@ -9064,7 +9109,8 @@ _user_remove_attr(int fd, const char *userName)
status_t
_user_rename_attr(int fromFile, const char *userFromName, int toFile, const char *userToName)
_user_rename_attr(int fromFile, const char* userFromName, int toFile,
const char* userToName)
{
if (!IS_USER_ADDRESS(userFromName)
|| !IS_USER_ADDRESS(userToName))