gnome-vfs-method.c revision 7e7bd3dccbfe8f79e25e5c1554b5bc3a9aaca321
/*
* gnome-vfs-method.c - Gnome-VFS init/shutdown implementation of interface to
* libntfs. Part of the Linux-NTFS project.
*
* Copyright (c) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
* Copyright (c) 2003-2006 Anton Altaparmakov
*
* 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.
*
* 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 "config.h"
#include "types.h" /* for 'FALSE'/'TRUE' libntfs definition */
#include "gnome-vfs-method.h" /* self */
#include <libgnomevfs/gnome-vfs-method.h>
#include <glib/gmessages.h>
#include "gnome-vfs-module.h"
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <libgnomevfs/gnome-vfs-utils.h>
#include "volume.h"
#include "dir.h"
static GnomeVFSMethod GnomeVFSMethod_static;
/* map: (gchar *)method_name -> (struct method_name_info *) */
static GHashTable *method_name_hash;
#ifdef __sun
#endif
struct method_name_info {
};
{
}
{
}
static void method_name_hash_init(void)
{
if (!method_name_hash) {
g_str_hash, /* hash_func */
g_str_equal, /* key_equal_func */
}
}
/*
* map: (gchar *)uri_parent_string "method_name:uri_parent" -> (ntfs_volume *)
*/
static GHashTable *uri_parent_string_hash;
{
}
{
ntfs_umount( /* errors ignored */
value, /* vol */
TRUE); /* force; possibly loose modifications */
}
static void uri_parent_string_hash_init(void)
{
if (!uri_parent_string_hash) {
g_str_hash, /* hash_func */
g_str_equal, /* key_equal_func */
}
}
{
return GNOME_VFS_ERROR_INVALID_URI;
return GNOME_VFS_ERROR_INVALID_URI;
if (!volume) {
struct method_name_info *method_name_info;
uri->method_string);
if (!method_name_info) {
/* should not happend */
}
/* TODO: Generic GnomeVFS filter. */
return GNOME_VFS_ERROR_INVALID_URI;
}
NTFS_MNT_RDONLY))) {
return GNOME_VFS_ERROR_WRONG_FORMAT;
}
}
*volume_return = volume;
return GNOME_VFS_OK;
}
{
int errint;
for (;;) {
int i;
if (!inode)
return GNOME_VFS_ERROR_NOT_FOUND;
if (!*pathname_parse) {
*inode_return = inode;
return GNOME_VFS_OK;
}
if (*pathname_next) {
/* terminate current path element */
*pathname_next++ = 0;
}
while (*pathname_next == G_DIR_SEPARATOR)
/* FIXME: Is 'pathname' utf8? */
#ifdef __sun
#else /* !__sun */
#endif /* __sun */
for (i = 0; pathname_parse_unescaped[i]; i++)
pathname_parse_ucs2[i] = 0;
return GNOME_VFS_ERROR_NOT_FOUND;
if (errint)
}
/* NOTREACHED */
}
struct libntfs_directory {
};
{
struct libntfs_directory *libntfs_directory;
if (GNOME_VFS_OK != (errvfsresult =
return errvfsresult;
return errvfsresult;
#ifdef __sun
#else /* !__sun */
#endif /* __sun */
return errvfsresult;
}
{
struct libntfs_directory *libntfs_directory;
int errint;
if (errint)
if (libntfs_directory->file_info_list) {
/*
* Prevent gnome_vfs_file_info_list_free() and its
* gnome_vfs_file_info_unref() on the last 'file_info_list'
* items as it is EOF with NULL '->data'.
*/
}
return GNOME_VFS_OK;
}
{
int i;
for (i = 0; i < name_len; i++)
le16_to_cpu(name[i]));
FALSE); /* free_segment */
}
/*
* Do not lock 'libntfs' here as we are already locked inside ntfs_readdir().
*/
static int libntfs_gnomevfs_read_directory_filldir(
{
/* system directory */
return 0; /* continue traversal */
file_info->valid_fields = 0;
switch (dt_type) {
case NTFS_DT_FIFO:
break;
case NTFS_DT_CHR:
break;
case NTFS_DT_DIR:
break;
case NTFS_DT_BLK:
break;
case NTFS_DT_REG:
break;
case NTFS_DT_LNK:
break;
case NTFS_DT_SOCK:
break;
/* FIXME: What is 'NTFS_DT_WHT'? */
default:
}
/* Detect 'file_info->size': */
/* FIXME: Check failed 'inode' open. */
if (inode) {
int errint;
AT_DATA, /* type */
AT_UNNAMED, /* name */
0); /* name_len */
/* FIXME: Check failed 'attr' open. */
if (attr) {
/* FIXME: Is 'data_size' the right field? */
}
/* FIXME: Check 'errint'. */
}
}
return 0; /* continue traversal */
}
{
struct libntfs_directory *libntfs_directory;
if (!libntfs_directory->file_info_list) {
int errint;
pos = 0; /* read from the start; incl. "." and ".." entries */
&pos, /* pos */
libntfs_directory, /* dirent */
if (errint)
return GNOME_VFS_ERROR_INTERNAL;
}
/*
* Do not clear the list to leave us stuck at EOF - GnomeVFS
* behaves that way.
*/
} else {
/* Cut first list item. */
}
return errvfsresult;
}
struct libntfs_file {
};
{
if (!libntfs_file->attr) {
AT_DATA, /* type */
AT_UNNAMED, /* name */
0); /* name_len */
if (!libntfs_file->attr)
return GNOME_VFS_ERROR_BAD_FILE;
libntfs_file->pos = 0;
}
return GNOME_VFS_OK;
}
{
struct libntfs_file *libntfs_file;
if (GNOME_VFS_OK != (errvfsresult =
return errvfsresult;
if (mode & GNOME_VFS_OPEN_WRITE)
if (GNOME_VFS_OK != (errvfsresult =
return errvfsresult;
#ifdef __sun
#else /* !__sun */
#endif /* __sun */
return errvfsresult;
}
{
if (GNOME_VFS_OK != (errvfsresult =
return errvfsresult;
}
{
struct libntfs_file *libntfs_file;
int errint;
if (libntfs_file->attr) {
}
if (errint)
return GNOME_VFS_OK;
}
{
struct libntfs_file *libntfs_file;
return errvfsresult;
buffer);
if (got == -1)
return GNOME_VFS_ERROR_IO;
*bytes_read_return = got;
return GNOME_VFS_OK;
}
{
struct libntfs_file *libntfs_file;
return errvfsresult;
switch (whence) {
case GNOME_VFS_SEEK_START:
break;
case GNOME_VFS_SEEK_CURRENT:
break;
case GNOME_VFS_SEEK_END:
/* FIXME: NOT IMPLEMENTED YET */
default:
}
return GNOME_VFS_OK;
}
{
struct libntfs_file *libntfs_file;
return errvfsresult;
return errvfsresult;
}
const GnomeVFSURI *uri)
{
}
{
struct libntfs_file *libntfs_file;
/* handle 'options & GNOME_VFS_FILE_INFO_GET_MIME_TYPE'? */
file_info->valid_fields = 0;
/* FIXME: It is complicated to read filename of open 'ntfs_inode'. */
/* Assume we are directory: */
/*
* Do not: file_info->valid_fields |=
* GNOME_VFS_FILE_INFO_FIELDS_TYPE;
* as gnome-vfs-xfer.c/copy_items() does not check
* 'GNOME_VFS_FILE_INFO_FIELDS_TYPE' and we are just bluffing
* we know it.
*/
return GNOME_VFS_OK;
}
/* FIXME: Is 'data_size' the right field? */
/*
* FIXME: We do not really know the type of 'libntfs_file' but
* gnome-vfs-xfer.c/copy_items() requires 'GNOME_VFS_FILE_TYPE_REGULAR'
* to copy it.
*/
/*
* Do not: file_info->valid_fields|=GNOME_VFS_FILE_INFO_FIELDS_TYPE;
* as gnome-vfs-xfer.c/copy_items() does not check
* 'GNOME_VFS_FILE_INFO_FIELDS_TYPE' and we are just bluffing we know
* it.
*/
return errvfsresult;
}
{
/* handle 'options & GNOME_VFS_FILE_INFO_GET_MIME_TYPE'? */
if (GNOME_VFS_OK != (errvfsresult =
return errvfsresult;
if (GNOME_VFS_OK != (errvfsresult =
return errvfsresult;
if (GNOME_VFS_OK != (errvfsresult =
return errvfsresult;
return GNOME_VFS_OK;
}
{
return GNOME_VFS_OK;
}
/**
* libntfs_gnomevfs_init:
*
* Returns: Initialized structure of #GnomeVFSMethod with static methods of
* libntfs-gnomevfs.
*/
{
struct method_name_info *method_name_info;
/* 'args' may be NULL if not supplied. */
if (!method_name_info) {
#ifdef __sun
#else /* !__sun */
#endif /* __sun */
}
libntfs_gnomevfs_get_file_info; /* mandatory */
libntfs_gnomevfs_is_local; /* mandatory */
/* TODO: GnomeVFSMethodFindDirectoryFunc find_directory; */
/* TODO: GnomeVFSMethodFileControlFunc file_control; */
/* R/W: GnomeVFSMethodCreateSymbolicLinkFunc create_symbolic_link; */
/* R/W: GnomeVFSMethodMonitorAddFunc monitor_add; */
/* R/W: GnomeVFSMethodMonitorCancelFunc monitor_cancel; */
/* R/W: GnomeVFSMethod_static.write; */
/* R/W: GnomeVFSMethod_static.truncate_handle; */
/* R/W: GnomeVFSMethod_static.make_directory; */
/* R/W: GnomeVFSMethod_static.remove_directory; */
/* R/W: GnomeVFSMethod_static.move; */
/* R/W: GnomeVFSMethod_static.unlink; */
/* R/W: GnomeVFSMethod_static.set_file_info; */
/* R/W: GnomeVFSMethod_static.truncate; */
return &GnomeVFSMethod_static;
}
/**
* libntfs_gnomevfs_method_shutdown:
*
* Shutdowns libntfs-gnomevfs successfuly flushing all caches.
*
* Sad note about gnome-vfs-2.1.5 is that it never calls this function. :-)
*/
void libntfs_gnomevfs_method_shutdown(void)
{
}