Style cleanup.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39955 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
* distribution in the file COPYING); if not, write to the Free Software
|
||||
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
@@ -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;
|
||||
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,45 +91,46 @@ 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;
|
||||
}
|
||||
ERRPRINT("fs_opendir - ENTER\n");
|
||||
|
||||
ni = ntfs_inode_open(ns->ntvol, node->vnid);
|
||||
if (ni == NULL) {
|
||||
result = ENOENT;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!(ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)) {
|
||||
result = EMFILE;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if ( cookie != NULL ) {
|
||||
cookie->pos = 0;
|
||||
cookie->ino = 0;
|
||||
cookie->readed = 0;
|
||||
cookie->last = 0;
|
||||
if (cookie != NULL) {
|
||||
cookie->pos = 0;
|
||||
cookie->ino = 0;
|
||||
cookie->readed = 0;
|
||||
cookie->last = 0;
|
||||
cookie->name[0] = 0;
|
||||
cookie->show_sys_files = ns->show_sys_files;
|
||||
*_cookie = (void*)cookie;
|
||||
}
|
||||
else
|
||||
} else
|
||||
result = ENOMEM;
|
||||
exit:
|
||||
if(ni)
|
||||
ntfs_inode_close(ni);
|
||||
|
||||
|
||||
exit:
|
||||
if (ni)
|
||||
ntfs_inode_close(ni);
|
||||
|
||||
ERRPRINT("fs_opendir - EXIT\n");
|
||||
|
||||
UNLOCK_VOL(ns);
|
||||
@@ -132,37 +138,39 @@ 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;
|
||||
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) {
|
||||
ni = ntfs_inode_open(ns->ntvol, node->vnid);
|
||||
if (ni == NULL) {
|
||||
result = ENOENT;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
||||
fs_ntfs_update_times(_vol, ni, NTFS_UPDATE_ATIME);
|
||||
|
||||
exit:
|
||||
if(ni)
|
||||
exit:
|
||||
if (ni)
|
||||
ntfs_inode_close(ni);
|
||||
|
||||
|
||||
ERRPRINT("fs_closedir - EXIT\n");
|
||||
|
||||
|
||||
UNLOCK_VOL(ns);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
fs_readdir(fs_volume *_vol, fs_vnode *_node, void *_cookie, struct dirent *buf,
|
||||
size_t bufsize, uint32 *num)
|
||||
@@ -172,65 +180,66 @@ 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);
|
||||
|
||||
|
||||
ERRPRINT("fs_readdir - ENTER (sizeof(buf)=%d, bufsize=%d, num=%d\n",sizeof(buf),bufsize,*num);
|
||||
|
||||
|
||||
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) {
|
||||
}
|
||||
|
||||
ni = ntfs_inode_open(ns->ntvol, node->vnid);
|
||||
if (ni == NULL) {
|
||||
ERRPRINT("fs_readdir - dir not opened\n");
|
||||
result = ENOENT;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
result = ntfs_readdir(ni, &cookie->pos, cookie, (ntfs_filldir_t)_ntfs_dirent_filler);
|
||||
}
|
||||
|
||||
result = ntfs_readdir(ni, &cookie->pos, cookie, (ntfs_filldir_t)_ntfs_dirent_filler);
|
||||
|
||||
realLen = nameLength > 255 ? 255 : nameLength;
|
||||
buf->d_dev = ns->id;
|
||||
buf->d_ino = cookie->ino;
|
||||
buf->d_ino = cookie->ino;
|
||||
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;
|
||||
|
||||
|
||||
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));
|
||||
|
||||
|
||||
UNLOCK_VOL(ns);
|
||||
|
||||
|
||||
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,18 +248,18 @@ fs_rewinddir( fs_volume *_vol, fs_vnode *vnode, void *_cookie )
|
||||
LOCK_VOL(ns);
|
||||
|
||||
ERRPRINT("fs_rewinddir - ENTER\n");
|
||||
if ( cookie != NULL ) {
|
||||
cookie->pos = 0;
|
||||
cookie->ino = 0;
|
||||
cookie->readed = 0;
|
||||
cookie->last = 0;
|
||||
if (cookie != NULL) {
|
||||
cookie->pos = 0;
|
||||
cookie->ino = 0;
|
||||
cookie->readed = 0;
|
||||
cookie->last = 0;
|
||||
cookie->name[0] = 0;
|
||||
result = B_NO_ERROR;
|
||||
}
|
||||
|
||||
ERRPRINT("fs_rewinddir - EXIT, result is %s\n", strerror(result));
|
||||
|
||||
|
||||
UNLOCK_VOL(ns);
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user