Style cleanup.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39955 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2010-12-26 23:16:04 +00:00
parent 6b81e70656
commit 79dd7e57fa
+46 -37
View File
@@ -37,25 +37,27 @@
#include "lock.h"
#include "ntfsdir.h"
//callback function for readdir()
static int _ntfs_dirent_filler(void *_dirent, const ntfschar *name,
const int name_len, const int name_type, const s64 pos,
const MFT_REF mref, const unsigned dt_type)
const int name_len, const int name_type, const s64 pos, const MFT_REF mref,
const unsigned dt_type)
{
char *filename = NULL;
dircookie *cookie = (dircookie*)_dirent;
dircookie *cookie = (dircookie*)_dirent;
if (name_type == FILE_NAME_DOS)
return 0;
if (MREF(mref) == FILE_root || MREF(mref) >= FILE_first_user || cookie->show_sys_files) {
if(cookie->readed==1) {
if (MREF(mref) == FILE_root || MREF(mref) >= FILE_first_user
|| cookie->show_sys_files) {
if (cookie->readed == 1) {
cookie->pos=pos;
cookie->readed = 0;
return -1;
} else {
if (ntfs_ucstombs(name, name_len, &filename, 0) >= 0) {
if(filename) {
if (filename) {
strcpy(cookie->name,filename);
cookie->ino=MREF(mref);
cookie->readed = 1;
@@ -63,21 +65,24 @@ static int _ntfs_dirent_filler(void *_dirent, const ntfschar *name,
return 0;
}
}
return -1;
}
}
}
}
return 0;
}
status_t
fs_free_dircookie( fs_volume *_vol, fs_vnode *vnode, void *cookie )
fs_free_dircookie(fs_volume *_vol, fs_vnode *vnode, void *cookie)
{
nspace *ns = (nspace*)_vol->private_volume;
LOCK_VOL(ns);
ERRPRINT("fs_free_dircookie - ENTER\n");
if ( cookie != NULL )
free( cookie );
if (cookie != NULL)
free(cookie);
ERRPRINT("fs_free_dircookie - EXIT\n");
@@ -86,23 +91,24 @@ fs_free_dircookie( fs_volume *_vol, fs_vnode *vnode, void *cookie )
return B_NO_ERROR;
}
status_t
fs_opendir( fs_volume *_vol, fs_vnode *_node, void** _cookie )
fs_opendir(fs_volume *_vol, fs_vnode *_node, void** _cookie)
{
nspace *ns = (nspace*)_vol->private_volume;
vnode *node = (vnode*)_node->private_node;
dircookie *cookie = (dircookie*)ntfs_calloc( sizeof(dircookie) );
dircookie *cookie = (dircookie*)ntfs_calloc(sizeof(dircookie));
int result = B_NO_ERROR;
ntfs_inode *ni=NULL;
ntfs_inode *ni = NULL;
LOCK_VOL(ns);
ERRPRINT("fs_opendir - ENTER\n");
ni = ntfs_inode_open(ns->ntvol, node->vnid);
if(ni==NULL) {
result = ENOENT;
goto exit;
if (ni == NULL) {
result = ENOENT;
goto exit;
}
if (!(ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)) {
@@ -110,7 +116,7 @@ fs_opendir( fs_volume *_vol, fs_vnode *_node, void** _cookie )
goto exit;
}
if ( cookie != NULL ) {
if (cookie != NULL) {
cookie->pos = 0;
cookie->ino = 0;
cookie->readed = 0;
@@ -118,11 +124,11 @@ fs_opendir( fs_volume *_vol, fs_vnode *_node, void** _cookie )
cookie->name[0] = 0;
cookie->show_sys_files = ns->show_sys_files;
*_cookie = (void*)cookie;
}
else
} else
result = ENOMEM;
exit:
if(ni)
if (ni)
ntfs_inode_close(ni);
ERRPRINT("fs_opendir - EXIT\n");
@@ -132,20 +138,21 @@ exit:
return result;
}
status_t
fs_closedir( fs_volume *_vol, fs_vnode *_node, void *cookie )
fs_closedir(fs_volume *_vol, fs_vnode *_node, void *cookie)
{
nspace *ns = (nspace*)_vol->private_volume;
vnode *node = (vnode*)_node->private_node;
int result = B_NO_ERROR;
ntfs_inode *ni=NULL;
ntfs_inode *ni = NULL;
LOCK_VOL(ns);
ERRPRINT("fs_closedir - ENTER\n");
ni = ntfs_inode_open(ns->ntvol, node->vnid);
if(ni==NULL) {
if (ni == NULL) {
result = ENOENT;
goto exit;
}
@@ -153,7 +160,7 @@ fs_closedir( fs_volume *_vol, fs_vnode *_node, void *cookie )
fs_ntfs_update_times(_vol, ni, NTFS_UPDATE_ATIME);
exit:
if(ni)
if (ni)
ntfs_inode_close(ni);
ERRPRINT("fs_closedir - EXIT\n");
@@ -163,6 +170,7 @@ exit:
return result;
}
status_t
fs_readdir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf,
size_t bufsize, uint32 *num)
@@ -172,7 +180,7 @@ fs_readdir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf,
dircookie *cookie = (dircookie*)_cookie;
uint32 nameLength = bufsize - sizeof(struct dirent), realLen;
int result = B_NO_ERROR;
ntfs_inode *ni=NULL;
ntfs_inode *ni = NULL;
LOCK_VOL(ns);
@@ -181,15 +189,15 @@ fs_readdir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf,
if (!ns || !node || !cookie || !num || bufsize < sizeof(buf)) {
result = EINVAL;
goto exit;
}
}
if(cookie->readed == 1 || cookie->last == 1) {
if (cookie->readed == 1 || cookie->last == 1) {
result = ENOENT;
goto exit;
}
}
ni = ntfs_inode_open(ns->ntvol, node->vnid);
if(ni==NULL) {
if (ni == NULL) {
ERRPRINT("fs_readdir - dir not opened\n");
result = ENOENT;
goto exit;
@@ -203,7 +211,7 @@ fs_readdir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf,
strlcpy(buf->d_name, cookie->name, realLen + 1);
buf->d_reclen = sizeof(struct dirent) + realLen;
if(result==0)
if (result == 0)
cookie->last = 1;
result = B_NO_ERROR;
@@ -211,15 +219,15 @@ fs_readdir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf,
ERRPRINT("fs_readdir - FILE: [%s]\n",buf->d_name);
exit:
if(ni)
if (ni)
ntfs_inode_close(ni);
if ( result == B_NO_ERROR )
if (result == B_NO_ERROR)
*num = 1;
else
*num = 0;
if ( result == ENOENT )
if (result == ENOENT)
result = B_NO_ERROR;
ERRPRINT("fs_readdir - EXIT result (%s)\n", strerror(result));
@@ -229,8 +237,9 @@ exit:
return result;
}
status_t
fs_rewinddir( fs_volume *_vol, fs_vnode *vnode, void *_cookie )
fs_rewinddir(fs_volume *_vol, fs_vnode *vnode, void *_cookie)
{
nspace *ns = (nspace*)_vol->private_volume;
dircookie *cookie = (dircookie*)_cookie;
@@ -239,7 +248,7 @@ fs_rewinddir( fs_volume *_vol, fs_vnode *vnode, void *_cookie )
LOCK_VOL(ns);
ERRPRINT("fs_rewinddir - ENTER\n");
if ( cookie != NULL ) {
if (cookie != NULL) {
cookie->pos = 0;
cookie->ino = 0;
cookie->readed = 0;
@@ -247,10 +256,10 @@ fs_rewinddir( fs_volume *_vol, fs_vnode *vnode, void *_cookie )
cookie->name[0] = 0;
result = B_NO_ERROR;
}
ERRPRINT("fs_rewinddir - EXIT, result is %s\n", strerror(result));
UNLOCK_VOL(ns);
return result;
}