smbnetfs  0.6.3
About: SMBNetFS is a Linux/FreeBSD filesystem that allow you to use samba/microsoft network in the same manner as the network neighborhood in Microsoft Windows.
  Fossies Dox: smbnetfs-0.6.3.tar.bz2  ("unofficial" and yet experimental doxygen-generated source code documentation)  

samba.c File Reference
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "list.h"
#include "smb_conn.h"
#include "samba.h"
#include "common.h"
Include dependency graph for samba.c:

Go to the source code of this file.

Data Structures

struct  samba_ctx
 

Macros

#define smb_conn_ctx_to_samba_ctx(ptr)    (struct samba_ctx *)((char*)(ptr) - offsetof(struct samba_ctx, smb_ctx))
 

Functions

int samba_init (size_t max_rw_block_size)
 
static void samba_set_context_name (struct samba_ctx *ctx, const char *name, size_t len)
 
static struct samba_ctxsamba_add_new_context (const char *name, size_t len)
 
static int samba_try_to_remove_context (struct samba_ctx *ctx)
 
static struct samba_ctxsamba_find_by_name (const char *name, size_t len)
 
static struct samba_ctxsamba_find_oldest (void)
 
static const char * samba_get_context_status_string (void)
 
static void samba_touch_ctx_without_lock (struct samba_ctx *ctx)
 
static void samba_touch_ctx (struct samba_ctx *ctx)
 
int samba_set_max_ctx_count (int count)
 
void samba_allocate_ctxs (void)
 
void samba_destroy_unused_ctxs (void)
 
static struct samba_ctxsamba_get_ctx (const char *url)
 
static void samba_release_ctx (struct samba_ctx *ctx)
 
samba_fd samba_open (const char *url, int flags, mode_t mode)
 
samba_fd samba_creat (const char *url, mode_t mode)
 
ssize_t samba_read (samba_fd fd, off_t offset, char *buf, size_t bufsize)
 
ssize_t samba_write (samba_fd fd, off_t offset, const char *buf, size_t bufsize)
 
int samba_close (samba_fd fd)
 
int samba_unlink (const char *url)
 
int samba_rename (const char *old_url, const char *new_url)
 
samba_fd samba_opendir (const char *url)
 
int samba_closedir (samba_fd fd)
 
ssize_t samba_readdir (samba_fd fd, void *buf, size_t bufsize)
 
int samba_mkdir (const char *url, mode_t mode)
 
int samba_rmdir (const char *url)
 
int samba_stat (const char *url, struct stat *st)
 
int samba_fstat (samba_fd fd, struct stat *st)
 
int samba_ftruncate (samba_fd fd, off_t size)
 
int samba_chmod (const char *url, mode_t mode)
 
int samba_utimes (const char *url, struct timeval *tbuf)
 
int samba_setxattr (const char *url, const char *name, const void *value, size_t size, int flags)
 
int samba_getxattr (const char *url, const char *name, void *value, size_t size)
 
int samba_listxattr (const char *url, char *list, size_t size)
 
int samba_removexattr (const char *url, const char *name)
 

Variables

static size_t samba_max_rw_block_size = (128 * 1024)
 
static int samba_ctx_count = 0
 
static int samba_ctx_max_count = 15
 
static LIST samba_ctx_list = { &( samba_ctx_list ), &( samba_ctx_list ) }
 
static pthread_mutex_t m_samba = PTHREAD_MUTEX_INITIALIZER
 

Macro Definition Documentation

◆ smb_conn_ctx_to_samba_ctx

#define smb_conn_ctx_to_samba_ctx (   ptr)     (struct samba_ctx *)((char*)(ptr) - offsetof(struct samba_ctx, smb_ctx))

Definition at line 20 of file samba.c.

Function Documentation

◆ samba_add_new_context()

static struct samba_ctx* samba_add_new_context ( const char *  name,
size_t  len 
)
static

◆ samba_allocate_ctxs()

void samba_allocate_ctxs ( void  )

Definition at line 154 of file samba.c.

References m_samba, samba_add_new_context(), samba_ctx_count, and samba_ctx_max_count.

Referenced by main().

◆ samba_chmod()

int samba_chmod ( const char *  url,
mode_t  mode 
)

Definition at line 453 of file samba.c.

References samba_get_ctx(), samba_release_ctx(), smb_conn_chmod(), and samba_ctx::smb_ctx.

Referenced by function_chmod().

◆ samba_close()

int samba_close ( samba_fd  fd)

◆ samba_closedir()

◆ samba_creat()

samba_fd samba_creat ( const char *  url,
mode_t  mode 
)

Definition at line 241 of file samba.c.

References samba_get_ctx(), samba_release_ctx(), smb_conn_creat(), and samba_ctx::smb_ctx.

Referenced by function_mknod().

◆ samba_destroy_unused_ctxs()

◆ samba_find_by_name()

static struct samba_ctx* samba_find_by_name ( const char *  name,
size_t  len 
)
static

◆ samba_find_oldest()

static struct samba_ctx* samba_find_oldest ( void  )
static

Definition at line 87 of file samba.c.

References samba_ctx::entries, is_valid_list_elem(), last_list_elem(), list_entry, and samba_ctx_list.

Referenced by samba_get_ctx().

◆ samba_fstat()

int samba_fstat ( samba_fd  fd,
struct stat *  st 
)

Definition at line 435 of file samba.c.

References smb_conn_file::ctx, samba_touch_ctx(), smb_conn_ctx_to_samba_ctx, and smb_conn_fstat().

Referenced by function_fstat().

◆ samba_ftruncate()

int samba_ftruncate ( samba_fd  fd,
off_t  size 
)

◆ samba_get_context_status_string()

static const char* samba_get_context_status_string ( void  )
static

◆ samba_get_ctx()

◆ samba_getxattr()

int samba_getxattr ( const char *  url,
const char *  name,
void *  value,
size_t  size 
)

◆ samba_init()

int samba_init ( size_t  max_rw_block_size)

Definition at line 30 of file samba.c.

References DPRINTF, and samba_max_rw_block_size.

Referenced by main(), and reconfigure_analyse_simple_option().

◆ samba_listxattr()

int samba_listxattr ( const char *  url,
char *  list,
size_t  size 
)

Definition at line 517 of file samba.c.

References samba_get_ctx(), samba_release_ctx(), smb_conn_listxattr(), and samba_ctx::smb_ctx.

Referenced by function_listxattr().

◆ samba_mkdir()

int samba_mkdir ( const char *  url,
mode_t  mode 
)

Definition at line 390 of file samba.c.

References samba_get_ctx(), samba_release_ctx(), smb_conn_mkdir(), and samba_ctx::smb_ctx.

Referenced by function_mkdir().

◆ samba_open()

samba_fd samba_open ( const char *  url,
int  flags,
mode_t  mode 
)

Definition at line 225 of file samba.c.

References samba_get_ctx(), samba_release_ctx(), smb_conn_open(), and samba_ctx::smb_ctx.

Referenced by function_open(), and function_truncate().

◆ samba_opendir()

samba_fd samba_opendir ( const char *  url)

◆ samba_read()

ssize_t samba_read ( samba_fd  fd,
off_t  offset,
char *  buf,
size_t  bufsize 
)

◆ samba_readdir()

ssize_t samba_readdir ( samba_fd  fd,
void *  buf,
size_t  bufsize 
)

◆ samba_release_ctx()

◆ samba_removexattr()

int samba_removexattr ( const char *  url,
const char *  name 
)

◆ samba_rename()

int samba_rename ( const char *  old_url,
const char *  new_url 
)

Definition at line 334 of file samba.c.

References samba_get_ctx(), samba_release_ctx(), smb_conn_rename(), and samba_ctx::smb_ctx.

Referenced by function_rename().

◆ samba_rmdir()

int samba_rmdir ( const char *  url)

Definition at line 405 of file samba.c.

References samba_get_ctx(), samba_release_ctx(), smb_conn_rmdir(), and samba_ctx::smb_ctx.

Referenced by function_rmdir().

◆ samba_set_context_name()

static void samba_set_context_name ( struct samba_ctx ctx,
const char *  name,
size_t  len 
)
static

Definition at line 42 of file samba.c.

References samba_ctx::name.

Referenced by samba_add_new_context(), and samba_get_ctx().

◆ samba_set_max_ctx_count()

int samba_set_max_ctx_count ( int  count)

Definition at line 145 of file samba.c.

References DPRINTF, m_samba, and samba_ctx_max_count.

Referenced by reconfigure_analyse_simple_option().

◆ samba_setxattr()

int samba_setxattr ( const char *  url,
const char *  name,
const void *  value,
size_t  size,
int  flags 
)

◆ samba_stat()

int samba_stat ( const char *  url,
struct stat *  st 
)

Definition at line 420 of file samba.c.

References samba_get_ctx(), samba_release_ctx(), smb_conn_stat(), and samba_ctx::smb_ctx.

Referenced by function_stat().

◆ samba_touch_ctx()

static void samba_touch_ctx ( struct samba_ctx ctx)
static

Definition at line 139 of file samba.c.

References m_samba, and samba_touch_ctx_without_lock().

Referenced by samba_fstat(), samba_ftruncate(), samba_read(), samba_readdir(), and samba_write().

◆ samba_touch_ctx_without_lock()

static void samba_touch_ctx_without_lock ( struct samba_ctx ctx)
inlinestatic

Definition at line 133 of file samba.c.

References add_to_list(), samba_ctx::entries, remove_from_list(), and samba_ctx_list.

Referenced by samba_get_ctx(), and samba_touch_ctx().

◆ samba_try_to_remove_context()

static int samba_try_to_remove_context ( struct samba_ctx ctx)
static

◆ samba_unlink()

int samba_unlink ( const char *  url)

Definition at line 319 of file samba.c.

References samba_get_ctx(), samba_release_ctx(), smb_conn_unlink(), and samba_ctx::smb_ctx.

Referenced by function_unlink().

◆ samba_utimes()

int samba_utimes ( const char *  url,
struct timeval *  tbuf 
)

Definition at line 468 of file samba.c.

References samba_get_ctx(), samba_release_ctx(), smb_conn_utimes(), and samba_ctx::smb_ctx.

Referenced by function_utimes().

◆ samba_write()

ssize_t samba_write ( samba_fd  fd,
off_t  offset,
const char *  buf,
size_t  bufsize 
)

Variable Documentation

◆ m_samba

pthread_mutex_t m_samba = PTHREAD_MUTEX_INITIALIZER
static

◆ samba_ctx_count

◆ samba_ctx_list

LIST samba_ctx_list = { &( samba_ctx_list ), &( samba_ctx_list ) }
static

◆ samba_ctx_max_count

int samba_ctx_max_count = 15
static

◆ samba_max_rw_block_size

size_t samba_max_rw_block_size = (128 * 1024)
static

Definition at line 23 of file samba.c.

Referenced by samba_add_new_context(), samba_init(), samba_read(), and samba_write().