From 6a15f740b9fd6994316ee8c5c18600857acfbd79 Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3deyes@gmail.com> Date: Sat, 3 Mar 2007 06:59:35 +0000 Subject: [PATCH] Some code and style cleanup git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20309 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/file_systems/ntfs/fs_func.c | 19 +--- .../kernel/file_systems/ntfs/fs_func.h | 2 +- src/add-ons/kernel/file_systems/ntfs/ntfs.h | 4 - .../kernel/file_systems/ntfs/ntfsdir.c | 95 ++++++++----------- 4 files changed, 47 insertions(+), 73 deletions(-) diff --git a/src/add-ons/kernel/file_systems/ntfs/fs_func.c b/src/add-ons/kernel/file_systems/ntfs/fs_func.c index 5fc1567ec2..5405fad56d 100644 --- a/src/add-ons/kernel/file_systems/ntfs/fs_func.c +++ b/src/add-ons/kernel/file_systems/ntfs/fs_func.c @@ -40,10 +40,6 @@ #include "volume_util.h" #include "fs_func.h" -#ifndef _READ_ONLY_ -static status_t do_unlink(nspace *vol, vnode *dir, const char *name, bool isdir); -#endif - #ifdef __HAIKU__ typedef struct identify_cookie { @@ -129,10 +125,6 @@ fs_mount(nspace_id nsid, const char *device, ulong flags, void *parms, size_t le *ns = (nspace) { .state = NF_FreeClustersOutdate | NF_FreeMFTOutdate, - .uid = 0, - .gid = 0, - .fmask = 0177, - .dmask = 0777, .show_sys_files = false, }; @@ -558,7 +550,7 @@ fs_rstat( void *_ns, void *_node, struct stat *stbuf ) stbuf->st_ino = MREF(ni->mft_no); if ( ni->mrec->flags & MFT_RECORD_IS_DIRECTORY ) { - stbuf->st_mode = S_IFDIR | (0777 & ~ns->dmask); + stbuf->st_mode = S_IFDIR | 0777; na = ntfs_attr_open(ni, AT_INDEX_ALLOCATION, NTFS_INDEX_I30, 4); if (na) { stbuf->st_size = na->data_size; @@ -606,10 +598,10 @@ fs_rstat( void *_ns, void *_node, struct stat *stbuf ) free(intx_file); } ntfs_attr_close(na); - stbuf->st_mode |= (0777 & ~ns->fmask); + stbuf->st_mode |= 0666; } - stbuf->st_uid = ns->uid; - stbuf->st_gid = ns->gid; + stbuf->st_uid = 0; + stbuf->st_gid = 0; stbuf->st_atime = ni->last_access_time; stbuf->st_ctime = ni->last_mft_change_time; stbuf->st_mtime = ni->last_data_change_time; @@ -704,7 +696,7 @@ exit: if(ni) ntfs_inode_close(ni); - ERRPRINT("dosfs_wstat: EXIT with (%s)\n", strerror(result)); + ERRPRINT("fs_wstat: EXIT with (%s)\n", strerror(result)); UNLOCK_VOL(ns); @@ -1694,7 +1686,6 @@ exit: #endif #ifndef _READ_ONLY_ -static status_t do_unlink(nspace *vol, vnode *dir, const char *name, bool isdir) { diff --git a/src/add-ons/kernel/file_systems/ntfs/fs_func.h b/src/add-ons/kernel/file_systems/ntfs/fs_func.h index e375304387..78e3d25d67 100644 --- a/src/add-ons/kernel/file_systems/ntfs/fs_func.h +++ b/src/add-ons/kernel/file_systems/ntfs/fs_func.h @@ -117,7 +117,7 @@ int fs_create_symlink(void *ns, void *_dir, const char *name, const char *path #endif //__HAIKU__ #ifndef _READ_ONLY_ -static status_t do_unlink(nspace *vol, vnode *dir, const char *name, bool isdir); +status_t do_unlink(nspace *vol, vnode *dir, const char *name, bool isdir); #endif #endif diff --git a/src/add-ons/kernel/file_systems/ntfs/ntfs.h b/src/add-ons/kernel/file_systems/ntfs/ntfs.h index 324429ea23..020fd04fbb 100644 --- a/src/add-ons/kernel/file_systems/ntfs/ntfs.h +++ b/src/add-ons/kernel/file_systems/ntfs/ntfs.h @@ -122,10 +122,6 @@ typedef struct nspace int state; s64 free_clusters; long free_mft; - unsigned int uid; - unsigned int gid; - unsigned int fmask; - unsigned int dmask; BOOL ro; BOOL show_sys_files; BOOL silent; diff --git a/src/add-ons/kernel/file_systems/ntfs/ntfsdir.c b/src/add-ons/kernel/file_systems/ntfs/ntfsdir.c index c101e59490..425125111b 100644 --- a/src/add-ons/kernel/file_systems/ntfs/ntfsdir.c +++ b/src/add-ons/kernel/file_systems/ntfs/ntfsdir.c @@ -46,17 +46,16 @@ int _ntfs_dirent_dot_filler(void *_dirent, const ntfschar *name, char *filename = NULL; dircookie *cookie = (dircookie*)_dirent; - if (name_type == FILE_NAME_DOS)return 0; + if (name_type == FILE_NAME_DOS) + return 0; - if (ntfs_ucstombs(name, name_len, &filename, 0) < 0) - { + if (ntfs_ucstombs(name, name_len, &filename, 0) < 0) { ERRPRINT("Skipping unrepresentable filename\n"); return 0; } - if(strcmp(filename,".")==0 || strcmp(filename,"..")==0) - if (MREF(mref) == FILE_root || MREF(mref) >= FILE_first_user || false) - { + if(strcmp(filename,".")==0 || strcmp(filename,"..")==0) { + if (MREF(mref) == FILE_root || MREF(mref) >= FILE_first_user || false) { struct direntry *ent = (direntry*)ntfs_calloc(sizeof(direntry)); ent->name = (char*)ntfs_calloc(strlen(filename)+1); strcpy(ent->name,filename); @@ -64,8 +63,7 @@ int _ntfs_dirent_dot_filler(void *_dirent, const ntfschar *name, ent->ino=MREF(mref); ent->next = NULL; - if(cookie->root==NULL) - { + if(cookie->root==NULL) { cookie->root = ent; cookie->walk = ent; } @@ -74,12 +72,11 @@ int _ntfs_dirent_dot_filler(void *_dirent, const ntfschar *name, cookie->last->next = ent; cookie->last = ent; - } else { - - free(filename); - return -1; - } - + } else { + free(filename); + return -1; + } + } free(filename); return 0; } @@ -92,19 +89,18 @@ int _ntfs_dirent_filler(void *_dirent, const ntfschar *name, char *filename = NULL; dircookie *cookie = (dircookie*)_dirent; - if (name_type == FILE_NAME_DOS)return 0; + if (name_type == FILE_NAME_DOS) + return 0; - if (ntfs_ucstombs(name, name_len, &filename, 0) < 0) - { + if (ntfs_ucstombs(name, name_len, &filename, 0) < 0) { ERRPRINT("Skipping unrepresentable filename\n"); return 0; } if(strcmp(filename,".")==0 || strcmp(filename,"..")==0) - return 0; + return 0; - if (MREF(mref) == FILE_root || MREF(mref) >= FILE_first_user || false) - { + if (MREF(mref) == FILE_root || MREF(mref) >= FILE_first_user || false) { struct direntry *ent = (direntry*)ntfs_calloc(sizeof(direntry)); ent->name = (char*)ntfs_calloc(strlen(filename)+1); strcpy(ent->name,filename); @@ -112,8 +108,7 @@ int _ntfs_dirent_filler(void *_dirent, const ntfschar *name, ent->ino=MREF(mref); ent->next = NULL; - if(cookie->root==NULL) - { + if(cookie->root==NULL) { cookie->root = ent; cookie->walk = ent; } @@ -163,7 +158,6 @@ fs_opendir( void *_ns, void *_node, void **_cookie ) int result = B_NO_ERROR; ntfs_inode *ni=NULL; dircookie *cookie = (dircookie*)ntfs_calloc( sizeof(dircookie) ); - u64 pos=0; LOCK_VOL(ns); @@ -180,8 +174,7 @@ fs_opendir( void *_ns, void *_node, void **_cookie ) goto exit; } - if ( cookie != NULL ) - { + if ( cookie != NULL ) { cookie->dev = ns->id; cookie->pos = 0; //cookie->walk_dir = ni; @@ -190,9 +183,9 @@ fs_opendir( void *_ns, void *_node, void **_cookie ) cookie->last = NULL; cookie->walk = NULL; *_cookie = (void*)cookie; - } - else + } else { result = ENOMEM; + } exit: if(ni) @@ -222,22 +215,22 @@ fs_closedir( void *_ns, void *node, void *_cookie ) ERRPRINT("fs_closedir - ENTER\n"); entry=cookie->root; - if(entry) - for(;;) - { - entrynext = entry->next; + if(entry) { + for(;;) { + entrynext = entry->next; - if(entry->name) - free(entry->name); + if(entry->name) + free(entry->name); - if(entry) - free(entry); + if(entry) + free(entry); - entry = entrynext; + entry = entrynext; - if(!entry) - break; + if(!entry) + break; } + } ERRPRINT("fs_closedir - EXIT\n"); @@ -266,14 +259,12 @@ fs_readdir(void *_ns, void *_node, void *_cookie, long *num, struct dirent *buf, ERRPRINT("fs_readdir - ENTER:\n"); - if (!ns || !node || !cookie || !num || bufsize < sizeof(buf)) - { + if (!ns || !node || !cookie || !num || bufsize < sizeof(buf)) { result = -1; goto quit; } - if(cookie->pos==0) - { + if(cookie->pos==0) { ni = ntfs_inode_open(ns->ntvol, node->vnid); if(ni==NULL) { result = ENOENT; @@ -281,28 +272,25 @@ fs_readdir(void *_ns, void *_node, void *_cookie, long *num, struct dirent *buf, } ntfs_readdir(ni, &pos, cookie, (ntfs_filldir_t)_ntfs_dirent_dot_filler); cookie->pos+=2; - } - else - if(cookie->pos==2) - { - ni = ntfs_inode_open(ns->ntvol, node->vnid); + } else { + if(cookie->pos==2) { + ni = ntfs_inode_open(ns->ntvol, node->vnid); if(ni==NULL) { result = ENOENT; goto quit; } ntfs_readdir(ni, &pos, cookie, (ntfs_filldir_t)_ntfs_dirent_filler); cookie->pos++; + } } - if(cookie->root==NULL || cookie->last==NULL) - { + if(cookie->root==NULL || cookie->last==NULL) { result = -1; goto quit; } - if(cookie->walk==NULL) - { + if(cookie->walk==NULL) { result = ENOENT; goto quit; } @@ -354,9 +342,8 @@ fs_rewinddir( void *_ns, void *_node, void *_cookie ) LOCK_VOL(ns); ERRPRINT("fs_rewinddir - ENTER\n"); - if ( cookie != NULL ) - { - //cookie->pos = 0; + if ( cookie != NULL ) { + cookie->pos = 0; cookie->walk = cookie->root; result = B_NO_ERROR; }