smbfs: implmentation of file-related functions. Code refactoring

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
Slava Zanko 2013-06-01 01:19:38 +03:00
parent d7f3a8ab9f
commit 8b3ea959f0
11 changed files with 703 additions and 57 deletions

View File

@ -3,8 +3,10 @@ AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir)
noinst_LTLIBRARIES = libvfs-smbfs.la
libvfs_smbfs_la_SOURCES = \
attr.c \
auth_dialog.c \
dir.c \
file.c \
init.c init.h \
internal.c internal.h \
stat.c \

76
src/vfs/smbfs/attr.c Normal file
View File

@ -0,0 +1,76 @@
/* Virtual File System: SFTP file system.
The internal functions: attributes
Copyright (C) 2011
The Free Software Foundation, Inc.
Written by:
Ilia Maslakov <il.smind@gmail.com>, 2011
Slava Zanko <slavazanko@gmail.com>, 2011, 2012
This file is part of the Midnight Commander.
The Midnight Commander 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 3 of the License,
or (at your option) any later version.
The Midnight Commander 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. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <errno.h>
#include "lib/global.h"
#include "internal.h"
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
/**
* Changes the permissions of the file.
*
* @param vpath path to file or directory
* @param mode mode (see man 2 open)
* @param error pointer to error object
* @return 0 if sucess, negative value otherwise
*/
int
smbfs_attr_chmod (const vfs_path_t * vpath, mode_t mode, GError ** error)
{
int rc;
char *smb_url;
const vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, -1);
smb_url = smbfs_make_url (path_element, TRUE);
errno = 0;
rc = smbc_chmod (smb_url, mode);
g_free (smb_url);
if (rc < 0)
g_set_error (error, MC_ERROR, errno, "%s", smbfs_strerror (errno));
return rc;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -60,7 +60,7 @@ typedef struct
*/
void *
smbfs_opendir (const vfs_path_t * vpath, GError ** error)
smbfs_dir_open (const vfs_path_t * vpath, GError ** error)
{
smbfs_dir_data_t *smbfs_dir = NULL;
struct vfs_s_super *super;
@ -104,7 +104,7 @@ smbfs_opendir (const vfs_path_t * vpath, GError ** error)
*/
void *
smbfs_readdir (void *data, GError ** error)
smbfs_dir_read (void *data, GError ** error)
{
struct smbc_dirent *smb_direntry;
smbfs_dir_data_t *smbfs_dir = (smbfs_dir_data_t *) data;
@ -135,7 +135,7 @@ smbfs_readdir (void *data, GError ** error)
*/
int
smbfs_closedir (void *data, GError ** error)
smbfs_dir_close (void *data, GError ** error)
{
int return_code;
smbfs_dir_data_t *smbfs_dir = (smbfs_dir_data_t *) data;
@ -161,7 +161,7 @@ smbfs_closedir (void *data, GError ** error)
*/
int
smbfs_mkdir (const vfs_path_t * vpath, mode_t mode, GError ** error)
smbfs_dir_make (const vfs_path_t * vpath, mode_t mode, GError ** error)
{
int return_code;
char *smb_url;
@ -189,7 +189,7 @@ smbfs_mkdir (const vfs_path_t * vpath, mode_t mode, GError ** error)
*/
int
smbfs_rmdir (const vfs_path_t * vpath, GError ** error)
smbfs_dir_remove (const vfs_path_t * vpath, GError ** error)
{
int return_code;
char *smb_url;

238
src/vfs/smbfs/file.c Normal file
View File

@ -0,0 +1,238 @@
/* Virtual File System: SFTP file system.
The internal functions: files
Copyright (C) 2011
The Free Software Foundation, Inc.
Written by:
Ilia Maslakov <il.smind@gmail.com>, 2011
Slava Zanko <slavazanko@gmail.com>, 2011, 2012
This file is part of the Midnight Commander.
The Midnight Commander 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 3 of the License,
or (at your option) any later version.
The Midnight Commander 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. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <errno.h>
#include "lib/global.h"
#include "internal.h"
/*** global variables ****************************************************************************/
/*** file scope macro definitions ****************************************************************/
/*** file scope type declarations ****************************************************************/
/*** file scope variables ************************************************************************/
/*** file scope functions ************************************************************************/
/* --------------------------------------------------------------------------------------------- */
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
/**
* Open file.
*
* @param file_handler the file handler data
* @param flags flags (see man 2 open)
* @param mode mode (see man 2 open)
* @param error pointer to the error handler
* @return TRUE if connection was created successfully, FALSE otherwise
*/
gboolean
smbfs_file_open (vfs_file_handler_t * file_handler, const vfs_path_t * vpath, int flags,
mode_t mode, GError ** error)
{
const vfs_path_element_t *path_element;
char *smb_url;
path_element = vfs_path_get_by_index (vpath, -1);
smb_url = smbfs_make_url (path_element, TRUE);
errno = 0;
file_handler->handle = smbc_open (smb_url, flags, mode);
g_free (smb_url);
if (file_handler->handle < 0)
g_set_error (error, MC_ERROR, errno, "%s", smbfs_strerror (errno));
return (file_handler->handle >= 0);
}
/* --------------------------------------------------------------------------------------------- */
/**
* Read up to 'count' bytes from the file descriptor 'file_handler' to the buffer starting at 'buffer'.
*
* @param file_handler file data handler
* @param buffer buffer for data
* @param count data size
* @param error pointer to the error handler
*
* @return 0 on sucess, negative value otherwise
*/
ssize_t
smbfs_file_read (vfs_file_handler_t * file_handler, char *buffer, size_t count, GError ** error)
{
ssize_t rc;
if (file_handler == NULL)
{
g_set_error (error, MC_ERROR, -1,
_("smbfs: No file handler data present for reading file"));
return -1;
}
errno = 0;
smbfs_file_lseek (file_handler, file_handler->pos, SEEK_SET, NULL);
rc = smbc_read (file_handler->handle, buffer, count);
if (rc < 0)
g_set_error (error, MC_ERROR, errno, "%s", smbfs_strerror (errno));
else
file_handler->pos += rc;
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Close a file descriptor.
*
* @param file_handler file data handler
* @param error pointer to the error handler
*
* @return 0 on sucess, negative value otherwise
*/
int
smbfs_file_close (vfs_file_handler_t * file_handler, GError ** error)
{
int rc;
if (file_handler == NULL)
{
g_set_error (error, MC_ERROR, -1,
_("smbfs: No file handler data present for closing file"));
return -1;
}
errno = 0;
rc = smbc_close (file_handler->handle);
if (rc < 0)
g_set_error (error, MC_ERROR, errno, "%s", smbfs_strerror (errno));
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Stats the file specified by the file descriptor.
*
* @param data file data handler
* @param buf buffer for store stat-info
* @param error pointer to the error handler
* @return 0 if sucess, negative value otherwise
*/
int
smbfs_file_stat (vfs_file_handler_t * file_handler, struct stat *buf, GError ** error)
{
int rc;
if (file_handler == NULL)
{
g_set_error (error, MC_ERROR, -1, _("smbfs: No file handler data present for fstat file"));
return -1;
}
errno = 0;
rc = smbc_fstat (file_handler->handle, buf);
if (rc < 0)
g_set_error (error, MC_ERROR, errno, "%s", smbfs_strerror (errno));
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Write up to 'count' bytes from the buffer starting at 'buffer' to the descriptor 'file_handler'.
*
* @param file_handler file data handler
* @param buffer buffer for data
* @param count data size
* @param error pointer to the error handler
*
* @return 0 on sucess, negative value otherwise
*/
ssize_t
smbfs_file_write (vfs_file_handler_t * file_handler, const char *buffer, size_t count,
GError ** error)
{
ssize_t rc;
if (file_handler == NULL)
{
g_set_error (error, MC_ERROR, -1, _("smbfs: No file handler data present for fstat file"));
return -1;
}
errno = 0;
rc = smbc_write (file_handler->handle, buffer, count);
if (rc < 0)
g_set_error (error, MC_ERROR, errno, "%s", smbfs_strerror (errno));
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Reposition the offset of the open file associated with the file descriptor.
*
* @param file_handler file data handler
* @param offset file offset
* @param whence method of seek (at begin, at current, at end)
* @param error pointer to the error handler
*
* @return 0 on sucess, negative value otherwise
*/
off_t
smbfs_file_lseek (vfs_file_handler_t * file_handler, off_t offset, int whence, GError ** error)
{
off_t rc;
if (file_handler == NULL)
{
g_set_error (error, MC_ERROR, -1, _("smbfs: No file handler data present for fstat file"));
return -1;
}
errno = 0;
rc = smbc_lseek (file_handler->handle, offset, whence);
if (rc == -1)
g_set_error (error, MC_ERROR, errno, "%s", smbfs_strerror (errno));
else
file_handler->pos = rc;
return rc;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -215,3 +215,83 @@ smbfs_assign_value_if_not_null (char *value, char **assignee)
}
/* --------------------------------------------------------------------------------------------- */
/**
* Delete a name from the file system.
*
* @param vpath path to file or directory
* @param error pointer to error object
* @return 0 if sucess, negative value otherwise
*/
int
smbfs_unlink (const vfs_path_t * vpath, GError ** error)
{
int rc;
char *smb_url;
const vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, -1);
smb_url = smbfs_make_url (path_element, TRUE);
errno = 0;
rc = smbc_unlink (smb_url);
g_free (smb_url);
if (rc < 0)
g_set_error (error, MC_ERROR, errno, "%s", smbfs_strerror (errno));
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Rename a file, moving it between directories if required.
*
* @param vpath1 path to source file or directory
* @param vpath2 path to destination file or directory
* @param error pointer to error object
* @return 0 if sucess, negative value otherwise
*/
int
smbfs_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2, GError ** error)
{
int rc;
char *smb_url1, *smb_url2;
const vfs_path_element_t *path_element1, *path_element2;
path_element1 = vfs_path_get_by_index (vpath1, -1);
path_element2 = vfs_path_get_by_index (vpath2, -1);
smb_url1 = smbfs_make_url (path_element1, TRUE);
smb_url2 = smbfs_make_url (path_element2, TRUE);
errno = 0;
rc = smbc_rename (smb_url1, smb_url2);
g_free (smb_url1);
g_free (smb_url2);
if (rc < 0)
g_set_error (error, MC_ERROR, errno, "%s", smbfs_strerror (errno));
return rc;
}
/* --------------------------------------------------------------------------------------------- */
int
smbfs_file_change_modification_time (const vfs_path_t * vpath, struct utimbuf *tbuf,
GError ** error)
{
int rc;
char *smb_url;
const vfs_path_element_t *path_element;
path_element = vfs_path_get_by_index (vpath, -1);
smb_url = smbfs_make_url (path_element, TRUE);
errno = 0;
rc = smbc_utime (smb_url, tbuf);
g_free (smb_url);
if (rc < 0)
g_set_error (error, MC_ERROR, errno, "%s", smbfs_strerror (errno));
return rc;
}

View File

@ -48,16 +48,35 @@ const char *smbfs_strerror (int err_no);
char *smbfs_make_url (const vfs_path_element_t * element, gboolean with_path);
void *smbfs_opendir (const vfs_path_t * vpath, GError ** error);
void *smbfs_readdir (void *data, GError ** error);
int smbfs_closedir (void *data, GError ** error);
int smbfs_mkdir (const vfs_path_t * vpath, mode_t mode, GError ** error);
int smbfs_rmdir (const vfs_path_t * vpath, GError ** error);
void *smbfs_dir_open (const vfs_path_t * vpath, GError ** error);
void *smbfs_dir_read (void *data, GError ** error);
int smbfs_dir_close (void *data, GError ** error);
int smbfs_dir_make (const vfs_path_t * vpath, mode_t mode, GError ** error);
int smbfs_dir_remove (const vfs_path_t * vpath, GError ** error);
int smbfs_lstat (const vfs_path_t * vpath, struct stat *buf, GError ** error);
int smbfs_stat (const vfs_path_t * vpath, struct stat *buf, GError ** error);
void smbfs_assign_value_if_not_null (char *value, char **assignee);
gboolean smbfs_file_open (vfs_file_handler_t * file_handler, const vfs_path_t * vpath, int flags,
mode_t mode, GError ** error);
int smbfs_file_stat (vfs_file_handler_t * data, struct stat *buf, GError ** error);
off_t smbfs_file_lseek (vfs_file_handler_t * file_handler, off_t offset, int whence,
GError ** error);
ssize_t smbfs_file_read (vfs_file_handler_t * file_handler, char *buffer, size_t count,
GError ** error);
ssize_t smbfs_file_write (vfs_file_handler_t * file_handler, const char *buffer, size_t count,
GError ** error);
int smbfs_file_close (vfs_file_handler_t * file_handler, GError ** error);
int smbfs_attr_chmod (const vfs_path_t * vpath, mode_t mode, GError ** error);
int smbfs_unlink (const vfs_path_t * vpath, GError ** error);
int smbfs_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2, GError ** error);
int smbfs_file_change_modification_time (const vfs_path_t * vpath, struct utimbuf *tbuf,
GError ** error);
/*** inline functions ****************************************************************************/

View File

@ -27,6 +27,7 @@
#include <errno.h>
#include "lib/global.h"
#include "lib/vfs/gc.h"
#include "lib/vfs/utilvfs.h"
#include "lib/tty/tty.h" /* tty_enable_interrupt_key () */
@ -99,7 +100,7 @@ smbfs_cb_opendir (const vfs_path_t * vpath)
/* reset interrupt flag */
tty_got_interrupt ();
ret_value = smbfs_opendir (vpath, &error);
ret_value = smbfs_dir_open (vpath, &error);
vfs_show_gerror (&error);
return ret_value;
}
@ -124,7 +125,7 @@ smbfs_cb_readdir (void *data)
return NULL;
}
smbfs_dirent = smbfs_readdir (data, &error);
smbfs_dirent = smbfs_dir_read (data, &error);
if (!vfs_show_gerror (&error))
{
if (smbfs_dirent != NULL)
@ -150,7 +151,7 @@ smbfs_cb_closedir (void *data)
int rc;
GError *error = NULL;
rc = smbfs_closedir (data, &error);
rc = smbfs_dir_close (data, &error);
vfs_show_gerror (&error);
return rc;
}
@ -199,7 +200,7 @@ smbfs_cb_mkdir (const vfs_path_t * vpath, mode_t mode)
int rc;
GError *error = NULL;
rc = smbfs_mkdir (vpath, mode, &error);
rc = smbfs_dir_make (vpath, mode, &error);
vfs_show_gerror (&error);
return rc;
}
@ -219,7 +220,7 @@ smbfs_cb_rmdir (const vfs_path_t * vpath)
int rc;
GError *error = NULL;
rc = smbfs_rmdir (vpath, &error);
rc = smbfs_dir_remove (vpath, &error);
vfs_show_gerror (&error);
return rc;
}
@ -264,6 +265,247 @@ smbfs_cb_stat (const vfs_path_t * vpath, struct stat *buf)
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Callback for fstat VFS-function.
*
* @param data file data handler
* @param buf buffer for store stat-info
* @return 0 if sucess, negative value otherwise
*/
static int
smbfs_cb_fstat (void *data, struct stat *buf)
{
int rc;
GError *error = NULL;
vfs_file_handler_t *file_handler = (vfs_file_handler_t *) data;
rc = smbfs_file_stat (file_handler, buf, &error);
if (rc < 0)
vfs_show_gerror (&error);
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Callback for opening file.
*
* @param vpath path to file
* @param flags flags (see man 2 open)
* @param mode mode (see man 2 open)
* @return file data handler if success, NULL otherwise
*/
static void *
smbfs_cb_open (const vfs_path_t * vpath, int flags, mode_t mode)
{
vfs_file_handler_t *file_handler;
struct vfs_s_super *super;
GError *error = NULL;
super = vfs_get_super_by_vpath (vpath, TRUE);
if (super == NULL)
return NULL;
file_handler = vfs_s_create_file_handler (super, vpath, flags);
if (file_handler == NULL)
return NULL;
if (!smbfs_file_open (file_handler, vpath, flags, mode, &error))
{
vfs_show_gerror (&error);
g_free (file_handler);
return NULL;
}
vfs_s_open_file_post_action (vpath, super, file_handler);
return file_handler;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Callback for reading file content.
*
* @param data file data handler
* @param buffer buffer for data
* @param count data size
* @return 0 if sucess, negative value otherwise
*/
static ssize_t
smbfs_cb_read (void *data, char *buffer, size_t count)
{
int rc;
GError *error = NULL;
vfs_file_handler_t *fh = (vfs_file_handler_t *) data;
if (tty_got_interrupt ())
{
tty_disable_interrupt_key ();
return 0;
}
rc = smbfs_file_read (fh, buffer, count, &error);
vfs_show_gerror (&error);
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Callback for writing file content.
*
* @param data file data handler
* @param buf buffer for data
* @param count data size
* @return 0 if sucess, negative value otherwise
*/
static ssize_t
smbfs_cb_write (void *data, const char *buf, size_t nbyte)
{
int rc;
GError *error = NULL;
vfs_file_handler_t *fh = (vfs_file_handler_t *) data;
rc = smbfs_file_write (fh, buf, nbyte, &error);
vfs_show_gerror (&error);
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Callback for close file.
*
* @param data file data handler
* @return 0 if sucess, negative value otherwise
*/
static int
smbfs_cb_close (void *data)
{
int rc;
GError *error = NULL;
struct vfs_s_super *super;
vfs_file_handler_t *file_handler = (vfs_file_handler_t *) data;
super = file_handler->ino->super;
super->fd_usage--;
if (super->fd_usage == 0)
vfs_stamp_create (&smbfs_class, super);
rc = smbfs_file_close (file_handler, &error);
vfs_show_gerror (&error);
vfs_s_free_inode (&smbfs_class, file_handler->ino);
g_free (file_handler);
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Callback for lseek VFS-function.
*
* @param data file data handler
* @param offset file offset
* @param whence method of seek (at begin, at current, at end)
* @return 0 if sucess, negative value otherwise
*/
static off_t
smbfs_cb_lseek (void *data, off_t offset, int whence)
{
off_t ret_offset;
vfs_file_handler_t *file_handler = (vfs_file_handler_t *) data;
GError *error = NULL;
ret_offset = smbfs_file_lseek (file_handler, offset, whence, &error);
vfs_show_gerror (&error);
return ret_offset;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Callback for chmod VFS-function.
*
* @param vpath path to file or directory
* @param mode mode (see man 2 open)
* @return 0 if sucess, negative value otherwise
*/
static int
smbfs_cb_chmod (const vfs_path_t * vpath, mode_t mode)
{
int rc;
GError *error = NULL;
rc = smbfs_attr_chmod (vpath, mode, &error);
vfs_show_gerror (&error);
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Callback for unlink VFS-function.
*
* @param vpath path to file or directory
* @return 0 if sucess, negative value otherwise
*/
static int
smbfs_cb_unlink (const vfs_path_t * vpath)
{
int rc;
GError *error = NULL;
rc = smbfs_unlink (vpath, &error);
vfs_show_gerror (&error);
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Callback for rename VFS-function.
*
* @param vpath1 path to source file or directory
* @param vpath2 path to destination file or directory
* @return 0 if sucess, negative value otherwise
*/
static int
smbfs_cb_rename (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
{
int rc;
GError *error = NULL;
rc = smbfs_rename (vpath1, vpath2, &error);
vfs_show_gerror (&error);
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/**
* Callback for utime VFS-function.
*
* @param vpath unused
* @param times unused
* @return always 0
*/
static int
smbfs_cb_utime (const vfs_path_t * vpath, struct utimbuf *times)
{
int rc;
GError *error = NULL;
rc = smbfs_file_change_modification_time (vpath, times, &error);
vfs_show_gerror (&error);
return rc;
}
/* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */
@ -294,33 +536,23 @@ smbfs_init_class_callbacks (void)
smbfs_class.done = smbfs_cb_done;
smbfs_class.fill_names = smbfs_cb_fill_names;
smbfs_class.opendir = smbfs_cb_opendir;
smbfs_class.readdir = smbfs_cb_readdir;
smbfs_class.closedir = smbfs_cb_closedir;
smbfs_class.mkdir = smbfs_cb_mkdir;
smbfs_class.rmdir = smbfs_cb_rmdir;
smbfs_class.stat = smbfs_cb_stat;
smbfs_class.lstat = smbfs_cb_lstat;
/*
smbfs_class.fstat = smbfs_cb_fstat;
smbfs_class.symlink = smbfs_cb_symlink;
smbfs_class.link = smbfs_cb_link;
smbfs_class.utime = smbfs_cb_utime;
smbfs_class.mknod = smbfs_cb_mknod;
smbfs_class.chown = smbfs_cb_chown;
smbfs_class.chmod = smbfs_cb_chmod;
smbfs_class.open = smbfs_cb_open;
smbfs_class.read = smbfs_cb_read;
smbfs_class.write = smbfs_cb_write;
smbfs_class.close = smbfs_cb_close;
smbfs_class.lseek = smbfs_cb_lseek;
smbfs_class.unlink = smbfs_cb_unlink;
smbfs_class.rename = smbfs_cb_rename;
smbfs_class.ferrno = smbfs_cb_errno;
*/
smbfs_class.fstat = smbfs_cb_fstat;
smbfs_class.utime = smbfs_cb_utime;
smbfs_class.chmod = smbfs_cb_chmod;
smbfs_class.open = smbfs_cb_open;
smbfs_class.read = smbfs_cb_read;
smbfs_class.write = smbfs_cb_write;
smbfs_class.close = smbfs_cb_close;
smbfs_class.lseek = smbfs_cb_lseek;
smbfs_class.unlink = smbfs_cb_unlink;
smbfs_class.rename = smbfs_cb_rename;
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -15,26 +15,25 @@ LIBS=@CHECK_LIBS@ \
$(top_builddir)/lib/libmc.la
TESTS = \
dir__smbfs_opendir \
dir__smbfs_readdir \
smbfs_dir_open \
smbfs_dir_read \
internal__smbfs_make_url \
internal__smbfs_strerror \
stat__smbfs_lstat
smbfs_lstat
check_PROGRAMS = $(TESTS)
dir__smbfs_opendir_SOURCES = \
dir__smbfs_opendir.c
smbfs_dir_open_SOURCES = \
smbfs_dir_open.c
dir__smbfs_readdir_SOURCES = \
dir__smbfs_readdir.c
smbfs_dir_read_SOURCES = \
smbfs_dir_read.c
dir__smbfs_strerror_SOURCES = \
internal__smbfs_strerror_SOURCES = \
internal__smbfs_strerror.c
internal__smbfs_make_url_SOURCES = \
internal__smbfs_make_url.c
stat__smbfs_lstat_SOURCES = \
stat__smbfs_lstat.c
smbfs_lstat_SOURCES = \
smbfs_lstat.c

View File

@ -150,7 +150,7 @@ START_TEST (test_smbfs_open_dir_fail)
/* when */
actual_result = smbfs_opendir (input_vpath, &error);
actual_result = smbfs_dir_open (input_vpath, &error);
/* then */
@ -196,7 +196,7 @@ START_TEST (test_smbfs_open_dir_success)
/* when */
actual_result = smbfs_opendir (input_vpath, &error);
actual_result = smbfs_dir_open (input_vpath, &error);
/* then */
@ -241,7 +241,7 @@ main (void)
suite_add_tcase (s, tc_core);
sr = srunner_create (s);
srunner_set_log (sr, "smbfs_opendir.log");
srunner_set_log (sr, "smbfs_dir_open.log");
srunner_run_all (sr, CK_NORMAL);
number_failed = srunner_ntests_failed (sr);
srunner_free (sr);

View File

@ -43,7 +43,7 @@ typedef struct
/* --------------------------------------------------------------------------------------------- */
static int smbfs_readdir__errno;
static int smbfs_dir_read__errno;
/* @CapturedValue */
static int smbc_readdir__handle__captured;
@ -55,7 +55,7 @@ struct smbc_dirent *
smbc_readdir (unsigned int handle)
{
smbc_readdir__handle__captured = handle;
errno = smbfs_readdir__errno;
errno = smbfs_dir_read__errno;
return smbc_readdir__return_value;
}
@ -103,8 +103,8 @@ START_TEST (test_smbfs_read_dir_fail)
smbc_readdir__return_value = NULL;
/* when */
smbfs_readdir__errno = ENODEV;
actual_result = smbfs_readdir (&input_smbfs_dir_data, &error);
smbfs_dir_read__errno = ENODEV;
actual_result = smbfs_dir_read (&input_smbfs_dir_data, &error);
/* then */
@ -144,8 +144,8 @@ START_TEST (test_smbfs_read_dir_success)
/* when */
smbfs_readdir__errno = 0;
actual_result = smbfs_readdir (&input_smbfs_dir_data, &error);
smbfs_dir_read__errno = 0;
actual_result = smbfs_dir_read (&input_smbfs_dir_data, &error);
/* then */
@ -183,7 +183,7 @@ main (void)
suite_add_tcase (s, tc_core);
sr = srunner_create (s);
srunner_set_log (sr, "smbfs_readdir.log");
srunner_set_log (sr, "smbfs_dir_read.log");
srunner_run_all (sr, CK_NORMAL);
number_failed = srunner_ntests_failed (sr);
srunner_free (sr);

View File

@ -196,7 +196,7 @@ main (void)
suite_add_tcase (s, tc_core);
sr = srunner_create (s);
srunner_set_log (sr, "smbfs_opendir.log");
srunner_set_log (sr, "smbfs_lstat.log");
srunner_run_all (sr, CK_NORMAL);
number_failed = srunner_ntests_failed (sr);
srunner_free (sr);