Style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39955 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -37,10 +37,11 @@
|
|||||||
#include "lock.h"
|
#include "lock.h"
|
||||||
#include "ntfsdir.h"
|
#include "ntfsdir.h"
|
||||||
|
|
||||||
|
|
||||||
//callback function for readdir()
|
//callback function for readdir()
|
||||||
static int _ntfs_dirent_filler(void *_dirent, const ntfschar *name,
|
static int _ntfs_dirent_filler(void *_dirent, const ntfschar *name,
|
||||||
const int name_len, const int name_type, const s64 pos,
|
const int name_len, const int name_type, const s64 pos, const MFT_REF mref,
|
||||||
const MFT_REF mref, const unsigned dt_type)
|
const unsigned dt_type)
|
||||||
{
|
{
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
dircookie *cookie = (dircookie*)_dirent;
|
dircookie *cookie = (dircookie*)_dirent;
|
||||||
@@ -48,14 +49,15 @@ static int _ntfs_dirent_filler(void *_dirent, const ntfschar *name,
|
|||||||
if (name_type == FILE_NAME_DOS)
|
if (name_type == FILE_NAME_DOS)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (MREF(mref) == FILE_root || MREF(mref) >= FILE_first_user || cookie->show_sys_files) {
|
if (MREF(mref) == FILE_root || MREF(mref) >= FILE_first_user
|
||||||
if(cookie->readed==1) {
|
|| cookie->show_sys_files) {
|
||||||
|
if (cookie->readed == 1) {
|
||||||
cookie->pos=pos;
|
cookie->pos=pos;
|
||||||
cookie->readed = 0;
|
cookie->readed = 0;
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
if (ntfs_ucstombs(name, name_len, &filename, 0) >= 0) {
|
if (ntfs_ucstombs(name, name_len, &filename, 0) >= 0) {
|
||||||
if(filename) {
|
if (filename) {
|
||||||
strcpy(cookie->name,filename);
|
strcpy(cookie->name,filename);
|
||||||
cookie->ino=MREF(mref);
|
cookie->ino=MREF(mref);
|
||||||
cookie->readed = 1;
|
cookie->readed = 1;
|
||||||
@@ -63,21 +65,24 @@ static int _ntfs_dirent_filler(void *_dirent, const ntfschar *name,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
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;
|
nspace *ns = (nspace*)_vol->private_volume;
|
||||||
|
|
||||||
LOCK_VOL(ns);
|
LOCK_VOL(ns);
|
||||||
ERRPRINT("fs_free_dircookie - ENTER\n");
|
ERRPRINT("fs_free_dircookie - ENTER\n");
|
||||||
if ( cookie != NULL )
|
if (cookie != NULL)
|
||||||
free( cookie );
|
free(cookie);
|
||||||
|
|
||||||
ERRPRINT("fs_free_dircookie - EXIT\n");
|
ERRPRINT("fs_free_dircookie - EXIT\n");
|
||||||
|
|
||||||
@@ -86,21 +91,22 @@ fs_free_dircookie( fs_volume *_vol, fs_vnode *vnode, void *cookie )
|
|||||||
return B_NO_ERROR;
|
return B_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
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;
|
nspace *ns = (nspace*)_vol->private_volume;
|
||||||
vnode *node = (vnode*)_node->private_node;
|
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;
|
int result = B_NO_ERROR;
|
||||||
ntfs_inode *ni=NULL;
|
ntfs_inode *ni = NULL;
|
||||||
|
|
||||||
LOCK_VOL(ns);
|
LOCK_VOL(ns);
|
||||||
|
|
||||||
ERRPRINT("fs_opendir - ENTER\n");
|
ERRPRINT("fs_opendir - ENTER\n");
|
||||||
|
|
||||||
ni = ntfs_inode_open(ns->ntvol, node->vnid);
|
ni = ntfs_inode_open(ns->ntvol, node->vnid);
|
||||||
if(ni==NULL) {
|
if (ni == NULL) {
|
||||||
result = ENOENT;
|
result = ENOENT;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
@@ -110,7 +116,7 @@ fs_opendir( fs_volume *_vol, fs_vnode *_node, void** _cookie )
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( cookie != NULL ) {
|
if (cookie != NULL) {
|
||||||
cookie->pos = 0;
|
cookie->pos = 0;
|
||||||
cookie->ino = 0;
|
cookie->ino = 0;
|
||||||
cookie->readed = 0;
|
cookie->readed = 0;
|
||||||
@@ -118,11 +124,11 @@ fs_opendir( fs_volume *_vol, fs_vnode *_node, void** _cookie )
|
|||||||
cookie->name[0] = 0;
|
cookie->name[0] = 0;
|
||||||
cookie->show_sys_files = ns->show_sys_files;
|
cookie->show_sys_files = ns->show_sys_files;
|
||||||
*_cookie = (void*)cookie;
|
*_cookie = (void*)cookie;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
result = ENOMEM;
|
result = ENOMEM;
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
if(ni)
|
if (ni)
|
||||||
ntfs_inode_close(ni);
|
ntfs_inode_close(ni);
|
||||||
|
|
||||||
ERRPRINT("fs_opendir - EXIT\n");
|
ERRPRINT("fs_opendir - EXIT\n");
|
||||||
@@ -132,20 +138,21 @@ exit:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
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;
|
nspace *ns = (nspace*)_vol->private_volume;
|
||||||
vnode *node = (vnode*)_node->private_node;
|
vnode *node = (vnode*)_node->private_node;
|
||||||
int result = B_NO_ERROR;
|
int result = B_NO_ERROR;
|
||||||
ntfs_inode *ni=NULL;
|
ntfs_inode *ni = NULL;
|
||||||
|
|
||||||
LOCK_VOL(ns);
|
LOCK_VOL(ns);
|
||||||
|
|
||||||
ERRPRINT("fs_closedir - ENTER\n");
|
ERRPRINT("fs_closedir - ENTER\n");
|
||||||
|
|
||||||
ni = ntfs_inode_open(ns->ntvol, node->vnid);
|
ni = ntfs_inode_open(ns->ntvol, node->vnid);
|
||||||
if(ni==NULL) {
|
if (ni == NULL) {
|
||||||
result = ENOENT;
|
result = ENOENT;
|
||||||
goto exit;
|
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);
|
fs_ntfs_update_times(_vol, ni, NTFS_UPDATE_ATIME);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
if(ni)
|
if (ni)
|
||||||
ntfs_inode_close(ni);
|
ntfs_inode_close(ni);
|
||||||
|
|
||||||
ERRPRINT("fs_closedir - EXIT\n");
|
ERRPRINT("fs_closedir - EXIT\n");
|
||||||
@@ -163,6 +170,7 @@ exit:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
fs_readdir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf,
|
fs_readdir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf,
|
||||||
size_t bufsize, uint32 *num)
|
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;
|
dircookie *cookie = (dircookie*)_cookie;
|
||||||
uint32 nameLength = bufsize - sizeof(struct dirent), realLen;
|
uint32 nameLength = bufsize - sizeof(struct dirent), realLen;
|
||||||
int result = B_NO_ERROR;
|
int result = B_NO_ERROR;
|
||||||
ntfs_inode *ni=NULL;
|
ntfs_inode *ni = NULL;
|
||||||
|
|
||||||
LOCK_VOL(ns);
|
LOCK_VOL(ns);
|
||||||
|
|
||||||
@@ -183,13 +191,13 @@ fs_readdir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf,
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(cookie->readed == 1 || cookie->last == 1) {
|
if (cookie->readed == 1 || cookie->last == 1) {
|
||||||
result = ENOENT;
|
result = ENOENT;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
ni = ntfs_inode_open(ns->ntvol, node->vnid);
|
ni = ntfs_inode_open(ns->ntvol, node->vnid);
|
||||||
if(ni==NULL) {
|
if (ni == NULL) {
|
||||||
ERRPRINT("fs_readdir - dir not opened\n");
|
ERRPRINT("fs_readdir - dir not opened\n");
|
||||||
result = ENOENT;
|
result = ENOENT;
|
||||||
goto exit;
|
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);
|
strlcpy(buf->d_name, cookie->name, realLen + 1);
|
||||||
buf->d_reclen = sizeof(struct dirent) + realLen;
|
buf->d_reclen = sizeof(struct dirent) + realLen;
|
||||||
|
|
||||||
if(result==0)
|
if (result == 0)
|
||||||
cookie->last = 1;
|
cookie->last = 1;
|
||||||
|
|
||||||
result = B_NO_ERROR;
|
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);
|
ERRPRINT("fs_readdir - FILE: [%s]\n",buf->d_name);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
if(ni)
|
if (ni)
|
||||||
ntfs_inode_close(ni);
|
ntfs_inode_close(ni);
|
||||||
|
|
||||||
if ( result == B_NO_ERROR )
|
if (result == B_NO_ERROR)
|
||||||
*num = 1;
|
*num = 1;
|
||||||
else
|
else
|
||||||
*num = 0;
|
*num = 0;
|
||||||
|
|
||||||
if ( result == ENOENT )
|
if (result == ENOENT)
|
||||||
result = B_NO_ERROR;
|
result = B_NO_ERROR;
|
||||||
|
|
||||||
ERRPRINT("fs_readdir - EXIT result (%s)\n", strerror(result));
|
ERRPRINT("fs_readdir - EXIT result (%s)\n", strerror(result));
|
||||||
@@ -229,8 +237,9 @@ exit:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
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;
|
nspace *ns = (nspace*)_vol->private_volume;
|
||||||
dircookie *cookie = (dircookie*)_cookie;
|
dircookie *cookie = (dircookie*)_cookie;
|
||||||
@@ -239,7 +248,7 @@ fs_rewinddir( fs_volume *_vol, fs_vnode *vnode, void *_cookie )
|
|||||||
LOCK_VOL(ns);
|
LOCK_VOL(ns);
|
||||||
|
|
||||||
ERRPRINT("fs_rewinddir - ENTER\n");
|
ERRPRINT("fs_rewinddir - ENTER\n");
|
||||||
if ( cookie != NULL ) {
|
if (cookie != NULL) {
|
||||||
cookie->pos = 0;
|
cookie->pos = 0;
|
||||||
cookie->ino = 0;
|
cookie->ino = 0;
|
||||||
cookie->readed = 0;
|
cookie->readed = 0;
|
||||||
@@ -247,10 +256,10 @@ fs_rewinddir( fs_volume *_vol, fs_vnode *vnode, void *_cookie )
|
|||||||
cookie->name[0] = 0;
|
cookie->name[0] = 0;
|
||||||
result = B_NO_ERROR;
|
result = B_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
ERRPRINT("fs_rewinddir - EXIT, result is %s\n", strerror(result));
|
ERRPRINT("fs_rewinddir - EXIT, result is %s\n", strerror(result));
|
||||||
|
|
||||||
UNLOCK_VOL(ns);
|
UNLOCK_VOL(ns);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user