Fixed build for R5 and dano targets. Bug fixes for fs_rename and fs_walk functions. Added simple identify functions for haiku.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20303 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Gerasim Troeglazov 2007-03-02 07:57:56 +00:00
parent 7106362e9c
commit 07a20b8072
3 changed files with 676 additions and 0 deletions

View File

@ -0,0 +1,123 @@
/*
* Copyright (c) 2000-2004 Anton Altaparmakov
* Copyright (c) 2002-2006 Szabolcs Szakacsits
*
* Copyright (c) 2006 Troeglazov Gerasim (3dEyes**)
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program/include file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program (in the main directory of the Linux-NTFS distribution in the
* file COPYING); if not, write to the Free Software Foundation,Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _fs_FUNC_H_
#define _fs_FUNC_H_
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <dirent.h>
#include <sys/stat.h>
#include <KernelExport.h>
#include <time.h>
#include <malloc.h>
#include "ntfs.h"
#include "attributes.h"
#include "lock.h"
#include "volume_util.h"
#ifdef __HAIKU__
float fs_identify_partition(int fd, partition_data *partition, void **_cookie);
status_t fs_scan_partition(int fd, partition_data *partition, void *_cookie);
void fs_free_identify_partition_cookie(partition_data *partition, void *_cookie);
status_t fs_mount( mount_id nsid, const char *device, ulong flags, const char *args, void **data, vnode_id *vnid );
status_t fs_create_symlink(void *_ns, void *_dir, const char *name, const char *target, int mode);
status_t fs_create(void *_ns, void *_dir, const char *name, int omode, int perms, void **_cookie, vnode_id *_vnid);
status_t fs_walk(void *_ns, void *_base, const char *file, vnode_id *vnid,int *_type);
status_t fs_get_vnode_name(void *_ns, void *_node, char *buffer, size_t bufferSize);
status_t fs_unmount(void *_ns);
status_t fs_rfsstat(void *_ns, struct fs_info *);
status_t fs_wfsstat(void *_vol, const struct fs_info *fss, uint32 mask);
status_t fs_sync(void *_ns);
status_t fs_read_vnode(void *_ns, vnode_id vnid, void **_node, bool reenter);
status_t fs_write_vnode(void *_ns, void *_node, bool reenter);
status_t fs_remove_vnode( void *_ns, void *_node, bool reenter );
status_t fs_access( void *ns, void *node, int mode );
status_t fs_rstat(void *_ns, void *_node, struct stat *st);
status_t fs_wstat(void *_vol, void *_node, const struct stat *st, uint32 mask);
status_t fs_open(void *_ns, void *_node, int omode, void **cookie);
status_t fs_close(void *ns, void *node, void *cookie);
status_t fs_free_cookie(void *ns, void *node, void *cookie);
status_t fs_read(void *_ns, void *_node, void *cookie, off_t pos, void *buf, size_t *len);
status_t fs_write(void *ns, void *node, void *cookie, off_t pos, const void *buf, size_t *len);
status_t fs_mkdir(void *_ns, void *_node, const char *name, int perms, vnode_id *_vnid);
status_t fs_rmdir(void *_ns, void *dir, const char *name);
status_t fs_opendir(void* _ns, void* _node, void** cookie);
status_t fs_readdir( void *_ns, void *_node, void *_cookie, struct dirent *buf, size_t bufsize, uint32 *num );
status_t fs_rewinddir(void *_ns, void *_node, void *cookie);
status_t fs_closedir(void *_ns, void *_node, void *cookie);
status_t fs_free_dircookie(void *_ns, void *_node, void *cookie);
status_t fs_readlink(void *_ns, void *_node, char *buf, size_t *bufsize);
status_t fs_fsync(void *_ns, void *_node);
status_t fs_rename(void *_ns, void *_odir, const char *oldname, void *_ndir, const char *newname);
status_t fs_unlink(void *_ns, void *_node, const char *name);
#else
int fs_mount(nspace_id nsid, const char *device, ulong flags, void *parms, size_t len, void **data, vnode_id *vnid);
int fs_unmount(void *_ns);
int fs_walk(void *_ns, void *_base, const char *file, char **newpath, vnode_id *vnid);
int fs_read_vnode(void *_ns, vnode_id vnid, char r, void **node);
int fs_write_vnode(void *_ns, void *_node, char r);
int fs_rstat(void *_ns, void *_node, struct stat *st);
int fs_wstat(void *_vol, void *_node, struct stat *st, long mask);
int fs_open(void *_ns, void *_node, int omode, void **cookie);
int fs_read(void *_ns, void *_node, void *cookie, off_t pos, void *buf, size_t *len);
int fs_write(void *ns, void *node, void *cookie, off_t pos, const void *buf, size_t *len);
int fs_free_cookie(void *ns, void *node, void *cookie);
int fs_close(void *ns, void *node, void *cookie);
int fs_access(void *_ns, void *_node, int mode);
int fs_opendir(void* _ns, void* _node, void** cookie);
int fs_readdir(void *_ns, void *_node, void *cookie, long *num, struct dirent *buf, size_t bufsize);
int fs_rewinddir(void *_ns, void *_node, void *cookie);
int fs_closedir(void *_ns, void *_node, void *cookie);
int fs_free_dircookie(void *_ns, void *_node, void *cookie);
int fs_rfsstat(void *_ns, struct fs_info *);
int fs_wfsstat(void *_vol, struct fs_info *fss, long mask);
int fs_readlink(void *_ns, void *_node, char *buf, size_t *bufsize);
int fs_mkdir(void *_ns, void *_node, const char *name, int perms);
int fs_rmdir(void *_ns, void *dir, const char *name);
int fs_remove_vnode( void *_ns, void *_node, char reenter );
int fs_rename(void *_ns, void *_odir, const char *oldname, void *_ndir, const char *newname);
int fs_create(void *_ns, void *_dir, const char *name, int omode, int perms, vnode_id *_vnid, void **_cookie);
int fs_unlink(void *_ns, void *_node, const char *name);
int fs_fsync(void *_ns, void *_node);
int fs_sync(void *_ns);
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);
#endif
#endif

View File

@ -0,0 +1,247 @@
#ifndef _FSPROTO_H
#define _FSPROTO_H
//#include <sys/dirent.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
#include <iovec.h>
#include <OS.h>
#include <fs_attr.h>
#include <fs_info.h>
#include <BeBuild.h>
typedef dev_t nspace_id;
typedef ino_t vnode_id;
/* UGLY UGLY UGLY */
#ifndef _DRIVERS_H
struct selectsync;
typedef struct selectsync selectsync;
#endif
/*
* PUBLIC PART OF THE FILE SYSTEM PROTOCOL
*/
#define WSTAT_MODE 0x0001
#define WSTAT_UID 0x0002
#define WSTAT_GID 0x0004
#define WSTAT_SIZE 0x0008
#define WSTAT_ATIME 0x0010
#define WSTAT_MTIME 0x0020
#define WSTAT_CRTIME 0x0040
#define WFSSTAT_NAME 0x0001
#define B_ENTRY_CREATED 1
#define B_ENTRY_REMOVED 2
#define B_ENTRY_MOVED 3
#define B_STAT_CHANGED 4
#define B_ATTR_CHANGED 5
#define B_DEVICE_MOUNTED 6
#define B_DEVICE_UNMOUNTED 7
#define B_STOP_WATCHING 0x0000
#define B_WATCH_NAME 0x0001
#define B_WATCH_STAT 0x0002
#define B_WATCH_ATTR 0x0004
#define B_WATCH_DIRECTORY 0x0008
#define SELECT_READ 1
#define SELECT_WRITE 2
#define SELECT_EXCEPTION 3
#define B_CUR_FS_API_VERSION 2
struct attr_info;
struct index_info;
typedef int op_read_vnode(void *ns, vnode_id vnid, char r, void **node);
typedef int op_write_vnode(void *ns, void *node, char r);
typedef int op_remove_vnode(void *ns, void *node, char r);
typedef int op_secure_vnode(void *ns, void *node);
typedef int op_walk(void *ns, void *base, const char *file, char **newpath,
vnode_id *vnid);
typedef int op_access(void *ns, void *node, int mode);
typedef int op_create(void *ns, void *dir, const char *name,
int omode, int perms, vnode_id *vnid, void **cookie);
typedef int op_mkdir(void *ns, void *dir, const char *name, int perms);
typedef int op_symlink(void *ns, void *dir, const char *name,
const char *path);
typedef int op_link(void *ns, void *dir, const char *name, void *node);
typedef int op_rename(void *ns, void *olddir, const char *oldname,
void *newdir, const char *newname);
typedef int op_unlink(void *ns, void *dir, const char *name);
typedef int op_rmdir(void *ns, void *dir, const char *name);
typedef int op_readlink(void *ns, void *node, char *buf, size_t *bufsize);
typedef int op_opendir(void *ns, void *node, void **cookie);
typedef int op_closedir(void *ns, void *node, void *cookie);
typedef int op_rewinddir(void *ns, void *node, void *cookie);
typedef int op_readdir(void *ns, void *node, void *cookie, long *num,
struct dirent *buf, size_t bufsize);
typedef int op_open(void *ns, void *node, int omode, void **cookie);
typedef int op_close(void *ns, void *node, void *cookie);
typedef int op_free_cookie(void *ns, void *node, void *cookie);
typedef int op_read(void *ns, void *node, void *cookie, off_t pos, void *buf,
size_t *len);
typedef int op_write(void *ns, void *node, void *cookie, off_t pos,
const void *buf, size_t *len);
typedef int op_readv(void *ns, void *node, void *cookie, off_t pos, const iovec *vec,
size_t count, size_t *len);
typedef int op_writev(void *ns, void *node, void *cookie, off_t pos, const iovec *vec,
size_t count, size_t *len);
typedef int op_ioctl(void *ns, void *node, void *cookie, int cmd, void *buf,
size_t len);
typedef int op_setflags(void *ns, void *node, void *cookie, int flags);
typedef int op_rstat(void *ns, void *node, struct stat *);
typedef int op_wstat(void *ns, void *node, struct stat *, long mask);
typedef int op_fsync(void *ns, void *node);
typedef int op_select(void *ns, void *node, void *cookie, uint8 event,
uint32 ref, selectsync *sync);
typedef int op_deselect(void *ns, void *node, void *cookie, uint8 event,
selectsync *sync);
typedef int op_initialize(const char *devname, void *parms, size_t len);
typedef int op_mount(nspace_id nsid, const char *devname, ulong flags,
void *parms, size_t len, void **data, vnode_id *vnid);
typedef int op_unmount(void *ns);
typedef int op_sync(void *ns);
typedef int op_rfsstat(void *ns, struct fs_info *);
typedef int op_wfsstat(void *ns, struct fs_info *, long mask);
typedef int op_open_attrdir(void *ns, void *node, void **cookie);
typedef int op_close_attrdir(void *ns, void *node, void *cookie);
typedef int op_rewind_attrdir(void *ns, void *node, void *cookie);
typedef int op_read_attrdir(void *ns, void *node, void *cookie, long *num,
struct dirent *buf, size_t bufsize);
typedef int op_remove_attr(void *ns, void *node, const char *name);
typedef int op_rename_attr(void *ns, void *node, const char *oldname,
const char *newname);
typedef int op_stat_attr(void *ns, void *node, const char *name,
struct attr_info *buf);
typedef int op_write_attr(void *ns, void *node, const char *name, int type,
const void *buf, size_t *len, off_t pos);
typedef int op_read_attr(void *ns, void *node, const char *name, int type,
void *buf, size_t *len, off_t pos);
typedef int op_open_indexdir(void *ns, void **cookie);
typedef int op_close_indexdir(void *ns, void *cookie);
typedef int op_rewind_indexdir(void *ns, void *cookie);
typedef int op_read_indexdir(void *ns, void *cookie, long *num,
struct dirent *buf, size_t bufsize);
typedef int op_create_index(void *ns, const char *name, int type, int flags);
typedef int op_remove_index(void *ns, const char *name);
typedef int op_rename_index(void *ns, const char *oldname,
const char *newname);
typedef int op_stat_index(void *ns, const char *name, struct index_info *buf);
typedef int op_open_query(void *ns, const char *query, ulong flags,
port_id port, long token, void **cookie);
typedef int op_close_query(void *ns, void *cookie);
typedef int op_read_query(void *ns, void *cookie, long *num,
struct dirent *buf, size_t bufsize);
typedef struct vnode_ops {
op_read_vnode (*read_vnode);
op_write_vnode (*write_vnode);
op_remove_vnode (*remove_vnode);
op_secure_vnode (*secure_vnode);
op_walk (*walk);
op_access (*access);
op_create (*create);
op_mkdir (*mkdir);
op_symlink (*symlink);
op_link (*link);
op_rename (*rename);
op_unlink (*unlink);
op_rmdir (*rmdir);
op_readlink (*readlink);
op_opendir (*opendir);
op_closedir (*closedir);
op_free_cookie (*free_dircookie);
op_rewinddir (*rewinddir);
op_readdir (*readdir);
op_open (*open);
op_close (*close);
op_free_cookie (*free_cookie);
op_read (*read);
op_write (*write);
op_readv (*readv);
op_writev (*writev);
op_ioctl (*ioctl);
op_setflags (*setflags);
op_rstat (*rstat);
op_wstat (*wstat);
op_fsync (*fsync);
op_initialize (*initialize);
op_mount (*mount);
op_unmount (*unmount);
op_sync (*sync);
op_rfsstat (*rfsstat);
op_wfsstat (*wfsstat);
op_select (*select);
op_deselect (*deselect);
op_open_indexdir (*open_indexdir);
op_close_indexdir (*close_indexdir);
op_free_cookie (*free_indexdircookie);
op_rewind_indexdir (*rewind_indexdir);
op_read_indexdir (*read_indexdir);
op_create_index (*create_index);
op_remove_index (*remove_index);
op_rename_index (*rename_index);
op_stat_index (*stat_index);
op_open_attrdir (*open_attrdir);
op_close_attrdir (*close_attrdir);
op_free_cookie (*free_attrdircookie);
op_rewind_attrdir (*rewind_attrdir);
op_read_attrdir (*read_attrdir);
op_write_attr (*write_attr);
op_read_attr (*read_attr);
op_remove_attr (*remove_attr);
op_rename_attr (*rename_attr);
op_stat_attr (*stat_attr);
op_open_query (*open_query);
op_close_query (*close_query);
op_free_cookie (*free_querycookie);
op_read_query (*read_query);
} vnode_ops;
extern int new_path(const char *path, char **copy);
extern void free_path(char *p);
extern int notify_listener(int op, nspace_id nsid,
vnode_id vnida, vnode_id vnidb,
vnode_id vnidc, const char *name);
extern void notify_select_event(selectsync *sync, uint32 ref);
extern int send_notification(port_id port, long token,
ulong what, long op, nspace_id nsida,
nspace_id nsidb, vnode_id vnida,
vnode_id vnidb, vnode_id vnidc,
const char *name);
extern int get_vnode(nspace_id nsid, vnode_id vnid, void **data);
extern int put_vnode(nspace_id nsid, vnode_id vnid);
extern int new_vnode(nspace_id nsid, vnode_id vnid, void *data);
extern int remove_vnode(nspace_id nsid, vnode_id vnid);
extern int unremove_vnode(nspace_id nsid, vnode_id vnid);
extern int is_vnode_removed(nspace_id nsid, vnode_id vnid);
extern _EXPORT vnode_ops fs_entry;
extern _EXPORT int32 api_version;
#endif

View File

@ -0,0 +1,306 @@
/* kernel_interface - file system interface to Haiku's vnode layer
*
* Copyright (c) 2006-2007 Troeglazov Gerasim (3dEyes**)
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program/include file is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (in the main directory of the Linux-NTFS
* 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>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <dirent.h>
#include <sys/stat.h>
#include <time.h>
#include <lock.h>
#include <malloc.h>
#include <stdio.h>
#ifdef __HAIKU__
#include <fs_interface.h>
#include <kernel/lock.h>
#include <fs_info.h>
#include <fs_cache.h>
#include <fs_attr.h>
#include <fs_info.h>
#include <fs_index.h>
#include <fs_query.h>
#include <fs_volume.h>
#include <NodeMonitor.h>
#include <util/kernel_cpp.h>
#else
#include "fsproto.h"
#include "lock.h"
#define publish_vnode new_vnode
#endif
#include "fs_func.h"
#include "ntfsdir.h"
#include "attributes.h"
#ifdef __HAIKU__
static status_t
ntfs_std_ops(int32 op, ...)
{
switch (op) {
case B_MODULE_INIT:
return B_OK;
case B_MODULE_UNINIT:
return B_OK;
default:
return B_ERROR;
}
}
static file_system_module_info sNTFSFileSystem = {
{
"file_systems/ntfs" B_CURRENT_FS_API_VERSION,
0,
ntfs_std_ops,
},
"ntfs File System",
// scanning
fs_identify_partition,
fs_scan_partition,
fs_free_identify_partition_cookie,
NULL, // free_partition_content_cookie()
&fs_mount,
&fs_unmount,
&fs_rfsstat,
#ifdef _READ_ONLY_
NULL,
#else
&fs_wfsstat,
#endif
NULL,
/* vnode operations */
&fs_walk,
&fs_get_vnode_name,
&fs_read_vnode,
&fs_write_vnode,
#ifdef _READ_ONLY_
NULL,
#else
&fs_remove_vnode,
#endif
/* VM file access */
NULL, // &fs_can_page
NULL, // &fs_read_pages
NULL, // &fs_write_pages
NULL, // &fs_get_file_map
NULL, // &fs_ioctl
NULL, // &fs_set_flags
NULL, // &fs_select
NULL, // &fs_deselect
#ifdef _READ_ONLY_
NULL,
#else
&fs_fsync,
#endif
&fs_readlink,
#ifdef _READ_ONLY_
NULL,
NULL,
NULL,
NULL,
NULL,
#else
NULL, // write link
&fs_create_symlink,
NULL, // &fs_link,
&fs_unlink,
&fs_rename,
#endif
&fs_access,
&fs_rstat,
#ifdef _READ_ONLY_
NULL,
#else
&fs_wstat,
#endif
/* file operations */
#ifdef _READ_ONLY_
NULL,
#else
&fs_create,
#endif
&fs_open,
&fs_close,
&fs_free_cookie,
&fs_read,
#ifdef _READ_ONLY_
NULL,
#else
&fs_write,
#endif
/* directory operations */
#ifdef _READ_ONLY_
NULL,
NULL,
#else
&fs_mkdir,
&fs_rmdir,
#endif
&fs_opendir,
&fs_closedir,
&fs_free_dircookie,
&fs_readdir,
&fs_rewinddir,
/* attribute directory operations */
&fs_open_attrib_dir,
&fs_close_attrib_dir,
&fs_free_attrib_dir_cookie,
&fs_read_attrib_dir,
&fs_rewind_attrib_dir,
/* attribute operations */
NULL, //&fs_create_attr,
&fs_open_attrib,
&fs_close_attrib,
&fs_free_attrib_cookie,
&fs_read_attrib,
&fs_write_attrib,
&fs_read_attrib_stat,
NULL, //&fs_write_attr_stat,
NULL, //&fs_rename_attr,
NULL, //&fs_remove_attr,
/* index directory & index operations */
NULL, // &fs_open_index_dir
NULL, // &fs_close_index_dir
NULL, // &fs_free_index_dir_cookie
NULL, // &fs_read_index_dir
NULL, // &fs_rewind_index_dir
NULL, // &fs_create_index
NULL, // &fs_remove_index
NULL, // &fs_stat_index
/* query operations */
NULL, // &fs_open_query
NULL, // &fs_close_query
NULL, // &fs_free_query_cookie
NULL, // &fs_read_query
NULL, // &fs_rewind_query
};
module_info *modules[] = {
(module_info *)&sNTFSFileSystem,
NULL,
};
#else
int32 api_version = B_CUR_FS_API_VERSION;
vnode_ops fs_entry = {
&fs_read_vnode, /* read_vnode func ptr */
&fs_write_vnode, /* write_vnode func ptr */
&fs_remove_vnode, /* remove_vnode func ptr */
NULL, /* secure_vnode func ptr */
&fs_walk, /* walk func ptr */
&fs_access, /* access func ptr */
&fs_create, /* create func ptr */
&fs_mkdir, /* mkdir func ptr */
&fs_create_symlink,
NULL,
&fs_rename,
&fs_unlink, /* unlink func ptr */
&fs_rmdir, /* rmdir func ptr */
&fs_readlink, /* readlink func ptr */
&fs_opendir, /* opendir func ptr */
&fs_closedir, /* closedir func ptr */
&fs_free_dircookie, /* free_dircookie func ptr */
&fs_rewinddir, /* rewinddir func ptr */
&fs_readdir, /* readdir func ptr */
&fs_open, /* open file func ptr */
&fs_close, /* close file func ptr */
&fs_free_cookie, /* free cookie func ptr */
&fs_read, /* read file func ptr */
&fs_write, /* write file func ptr */
NULL, /* readv */
NULL, /* writev */
NULL, /* ioctl func ptr */
NULL, /* setflags file func ptr */
&fs_rstat, /* rstat func ptr */
&fs_wstat, /* wstat func ptr */
&fs_fsync,
NULL, /* initialize func ptr */
&fs_mount, /* mount func ptr */
&fs_unmount, /* unmount func ptr */
&fs_sync, /* sync func ptr */
&fs_rfsstat, /* rfsstat func ptr */
&fs_wfsstat, /* wfsstat func ptr */
NULL, // select
NULL, // deselect
NULL, // open_indexdir
NULL, // close_indexdir
NULL, // free_indexdircookie
NULL, // rewind_indexdir
NULL, // read_indexdir
NULL, // create_index
NULL, // remove_index
NULL, // rename_index
NULL, // stat_index
&fs_open_attrib_dir, // open_attrdir
&fs_close_attrib_dir, // close_attrdir
&fs_free_attrib_dir_cookie, // free_attrdircookie
&fs_rewind_attrib_dir, // rewind_attrdir
&fs_read_attrib_dir, // read_attrdir
&fs_write_attrib, // write_attr
&fs_read_attrib, // read_attr
NULL, // remove_attr
NULL, // rename_attr
&fs_read_attrib_stat, // stat_attr
NULL, // open_query
NULL, // close_query
NULL, // free_querycookie
NULL // read_query
};
#endif