|
|
|
@ -87,9 +87,8 @@ void xfuse_devredir_cb_file_close(void *vp) {}
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define FUSE_USE_VERSION 26
|
|
|
|
|
#define _FILE_OFFSET_BITS 64
|
|
|
|
|
|
|
|
|
|
#include <fuse/fuse_lowlevel.h>
|
|
|
|
|
#include <fuse_lowlevel.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
@ -101,9 +100,12 @@ void xfuse_devredir_cb_file_close(void *vp) {}
|
|
|
|
|
|
|
|
|
|
#include "arch.h"
|
|
|
|
|
#include "os_calls.h"
|
|
|
|
|
#include "clipboard_file.h"
|
|
|
|
|
#include "chansrv_fuse.h"
|
|
|
|
|
#include "devredir.h"
|
|
|
|
|
#include "list.h"
|
|
|
|
|
#include "fifo.h"
|
|
|
|
|
#include "file.h"
|
|
|
|
|
|
|
|
|
|
#ifndef EREMOTEIO
|
|
|
|
|
#define EREMOTEIO EIO
|
|
|
|
@ -256,7 +258,7 @@ static tintptr g_bufsize = 0;
|
|
|
|
|
static int xfuse_init_xrdp_fs(void);
|
|
|
|
|
static int xfuse_deinit_xrdp_fs(void);
|
|
|
|
|
static int xfuse_init_lib(struct fuse_args *args);
|
|
|
|
|
static int xfuse_is_inode_valid(int ino);
|
|
|
|
|
static int xfuse_is_inode_valid(fuse_ino_t ino);
|
|
|
|
|
|
|
|
|
|
// LK_TODO
|
|
|
|
|
#if 0
|
|
|
|
@ -265,39 +267,26 @@ static void xfuse_create_file(fuse_req_t req, fuse_ino_t parent,
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static void xfuse_dump_fs(void);
|
|
|
|
|
static void xfuse_dump_xrdp_inode(struct xrdp_inode *xino);
|
|
|
|
|
static tui32 xfuse_get_device_id_for_inode(tui32 ino, char *full_path);
|
|
|
|
|
static tui32 xfuse_get_device_id_for_inode(fuse_ino_t ino, char *full_path);
|
|
|
|
|
static void fuse_reverse_pathname(char *full_path, char *reverse_path);
|
|
|
|
|
|
|
|
|
|
static struct xrdp_inode * xfuse_get_inode_from_pinode_name(tui32 pinode,
|
|
|
|
|
static struct xrdp_inode * xfuse_get_inode_from_pinode_name(fuse_ino_t pinode,
|
|
|
|
|
const char *name);
|
|
|
|
|
|
|
|
|
|
static struct xrdp_inode * xfuse_create_file_in_xrdp_fs(tui32 device_id,
|
|
|
|
|
int pinode, char *name,
|
|
|
|
|
int type);
|
|
|
|
|
|
|
|
|
|
static int xfuse_does_file_exist(int parent, char *name);
|
|
|
|
|
static int xfuse_delete_file(int parent, char *name);
|
|
|
|
|
static int xfuse_does_file_exist(fuse_ino_t parent, char *name);
|
|
|
|
|
static int xfuse_delete_file_with_xinode(XRDP_INODE *xinode);
|
|
|
|
|
static int xfuse_delete_dir_with_xinode(XRDP_INODE *xinode);
|
|
|
|
|
static int xfuse_recursive_delete_dir_with_xinode(XRDP_INODE *xinode);
|
|
|
|
|
static void xfuse_update_xrdpfs_size(void);
|
|
|
|
|
|
|
|
|
|
#ifdef USE_SYNC_FLAG
|
|
|
|
|
static void xfuse_enum_dir(fuse_req_t req, fuse_ino_t ino, size_t size,
|
|
|
|
|
off_t off, struct fuse_file_info *fi);
|
|
|
|
|
|
|
|
|
|
/* forward declarations for calls we make into devredir */
|
|
|
|
|
int dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path);
|
|
|
|
|
|
|
|
|
|
int dev_redir_file_open(void *fusep, tui32 device_id, char *path,
|
|
|
|
|
int mode, int type, char *gen_buf);
|
|
|
|
|
|
|
|
|
|
int devredir_file_read(void *fusep, tui32 device_id, tui32 FileId,
|
|
|
|
|
tui32 Length, tui64 Offset);
|
|
|
|
|
|
|
|
|
|
int dev_redir_file_write(void *fusep, tui32 device_id, tui32 FileId,
|
|
|
|
|
const char *buf, int Length, tui64 Offset);
|
|
|
|
|
|
|
|
|
|
int devredir_file_close(void *fusep, tui32 device_id, tui32 FileId);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* forward declarations for FUSE callbacks */
|
|
|
|
|
static void xfuse_cb_lookup(fuse_req_t req, fuse_ino_t parent,
|
|
|
|
@ -307,9 +296,6 @@ static void xfuse_cb_getattr(fuse_req_t req, fuse_ino_t ino,
|
|
|
|
|
struct fuse_file_info *fi);
|
|
|
|
|
|
|
|
|
|
/* this is not a callback, but it's used by xfuse_cb_readdir() */
|
|
|
|
|
static void xfuse_dirbuf_add(fuse_req_t req, struct dirbuf *b,
|
|
|
|
|
const char *name, fuse_ino_t ino);
|
|
|
|
|
|
|
|
|
|
static int xfuse_dirbuf_add1(fuse_req_t req, struct dirbuf1 *b,
|
|
|
|
|
const char *name, fuse_ino_t ino);
|
|
|
|
|
|
|
|
|
@ -353,8 +339,10 @@ static void xfuse_cb_create(fuse_req_t req, fuse_ino_t parent,
|
|
|
|
|
const char *name, mode_t mode,
|
|
|
|
|
struct fuse_file_info *fi);
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
static void xfuse_cb_fsync(fuse_req_t req, fuse_ino_t ino, int datasync,
|
|
|
|
|
struct fuse_file_info *fi);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static void xfuse_cb_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,
|
|
|
|
|
int to_set, struct fuse_file_info *fi);
|
|
|
|
@ -368,13 +356,9 @@ static int xfuse_proc_opendir_req(fuse_req_t req, fuse_ino_t ino,
|
|
|
|
|
static void xfuse_cb_releasedir(fuse_req_t req, fuse_ino_t ino,
|
|
|
|
|
struct fuse_file_info *fi);
|
|
|
|
|
|
|
|
|
|
/* clipboard calls */
|
|
|
|
|
int clipboard_request_file_data(int stream_id, int lindex, int offset,
|
|
|
|
|
int request_bytes);
|
|
|
|
|
|
|
|
|
|
/* misc calls */
|
|
|
|
|
static void xfuse_mark_as_stale(int pinode);
|
|
|
|
|
static void xfuse_delete_stale_entries(int pinode);
|
|
|
|
|
static void xfuse_mark_as_stale(fuse_ino_t pinode);
|
|
|
|
|
static void xfuse_delete_stale_entries(fuse_ino_t pinode);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
int APP_CC
|
|
|
|
@ -623,9 +607,10 @@ int xfuse_create_share(tui32 device_id, char *dirname)
|
|
|
|
|
if (dirname == NULL || strlen(dirname) == 0)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if ((xinode = calloc(1, sizeof(struct xrdp_inode))) == NULL)
|
|
|
|
|
xinode = g_new0(struct xrdp_inode, 1);
|
|
|
|
|
if (xinode == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_debug("calloc() failed");
|
|
|
|
|
log_debug("g_new0() failed");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -658,7 +643,8 @@ int xfuse_create_share(tui32 device_id, char *dirname)
|
|
|
|
|
xinode->nentries++;
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL)
|
|
|
|
|
fip = g_new0(XFUSE_INFO, 1);
|
|
|
|
|
if (fip == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
return -1;
|
|
|
|
@ -687,7 +673,7 @@ int xfuse_create_share(tui32 device_id, char *dirname)
|
|
|
|
|
|
|
|
|
|
int xfuse_clear_clip_dir(void)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
fuse_ino_t i;
|
|
|
|
|
XRDP_INODE *xinode;
|
|
|
|
|
XRDP_INODE *xip;
|
|
|
|
|
|
|
|
|
@ -846,7 +832,7 @@ static int xfuse_init_lib(struct fuse_args *args)
|
|
|
|
|
fuse_session_add_chan(g_se, g_ch);
|
|
|
|
|
g_bufsize = fuse_chan_bufsize(g_ch);
|
|
|
|
|
|
|
|
|
|
g_buffer = calloc(g_bufsize, 1);
|
|
|
|
|
g_buffer = g_new0(char, g_bufsize);
|
|
|
|
|
g_fd = fuse_chan_fd(g_ch);
|
|
|
|
|
|
|
|
|
|
g_req_list = list_create();
|
|
|
|
@ -866,7 +852,7 @@ static int xfuse_init_xrdp_fs()
|
|
|
|
|
{
|
|
|
|
|
struct xrdp_inode *xino;
|
|
|
|
|
|
|
|
|
|
g_xrdp_fs.inode_table = calloc(4096, sizeof(struct xrdp_inode *));
|
|
|
|
|
g_xrdp_fs.inode_table = g_new0(struct xrdp_inode *, 4096);
|
|
|
|
|
if (g_xrdp_fs.inode_table == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
@ -877,7 +863,8 @@ static int xfuse_init_xrdp_fs()
|
|
|
|
|
* index 0 is our .. dir
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if ((xino = calloc(1, sizeof(struct xrdp_inode))) == NULL)
|
|
|
|
|
xino = g_new0(struct xrdp_inode, 1);
|
|
|
|
|
if (xino == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
free(g_xrdp_fs.inode_table);
|
|
|
|
@ -900,7 +887,8 @@ static int xfuse_init_xrdp_fs()
|
|
|
|
|
* index 1 is our . dir
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if ((xino = calloc(1, sizeof(struct xrdp_inode))) == NULL)
|
|
|
|
|
xino = g_new0(struct xrdp_inode, 1);
|
|
|
|
|
if (xino == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
free(g_xrdp_fs.inode_table[0]);
|
|
|
|
@ -924,7 +912,8 @@ static int xfuse_init_xrdp_fs()
|
|
|
|
|
* index 2 is for clipboard use
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if ((xino = calloc(1, sizeof(struct xrdp_inode))) == NULL)
|
|
|
|
|
xino = g_new0(struct xrdp_inode, 1);
|
|
|
|
|
if (xino == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
free(g_xrdp_fs.inode_table[0]);
|
|
|
|
@ -971,7 +960,7 @@ static int xfuse_deinit_xrdp_fs()
|
|
|
|
|
* @return 1 if it does, 0 otherwise
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static int xfuse_is_inode_valid(int ino)
|
|
|
|
|
static int xfuse_is_inode_valid(fuse_ino_t ino)
|
|
|
|
|
{
|
|
|
|
|
/* is ino present in our table? */
|
|
|
|
|
if ((ino < FIRST_INODE) || (ino >= g_xrdp_fs.next_node))
|
|
|
|
@ -1004,9 +993,10 @@ static void xfuse_create_file(fuse_req_t req, fuse_ino_t parent,
|
|
|
|
|
fuse_reply_err(req, EBADF);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((xinode = calloc(1, sizeof(struct xrdp_inode))) == NULL)
|
|
|
|
|
xinode = g_new0(struct xrdp_inode, 1);
|
|
|
|
|
if (xinode == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("calloc() failed");
|
|
|
|
|
log_error("g_new0() failed");
|
|
|
|
|
fuse_reply_err(req, ENOMEM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1055,7 +1045,7 @@ static void xfuse_create_file(fuse_req_t req, fuse_ino_t parent,
|
|
|
|
|
|
|
|
|
|
static void xfuse_dump_fs()
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
fuse_ino_t i;
|
|
|
|
|
struct xrdp_inode *xinode;
|
|
|
|
|
|
|
|
|
|
log_debug("found %d entries", g_xrdp_fs.num_entries - FIRST_INODE);
|
|
|
|
@ -1084,6 +1074,7 @@ static void xfuse_dump_fs()
|
|
|
|
|
* @param xino xinode structure to dump
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
static void xfuse_dump_xrdp_inode(struct xrdp_inode *xino)
|
|
|
|
|
{
|
|
|
|
|
log_debug("--- dumping struct xinode ---");
|
|
|
|
@ -1098,6 +1089,7 @@ static void xfuse_dump_xrdp_inode(struct xrdp_inode *xino)
|
|
|
|
|
log_debug("device_id: %d", xino->device_id);
|
|
|
|
|
log_debug("%s", "");
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Return the device_id associated with specified inode and copy the
|
|
|
|
@ -1109,10 +1101,10 @@ static void xfuse_dump_xrdp_inode(struct xrdp_inode *xino)
|
|
|
|
|
* @return the device_id of specified inode
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static tui32 xfuse_get_device_id_for_inode(tui32 ino, char *full_path)
|
|
|
|
|
static tui32 xfuse_get_device_id_for_inode(fuse_ino_t ino, char *full_path)
|
|
|
|
|
{
|
|
|
|
|
tui32 parent_inode = 0;
|
|
|
|
|
tui32 child_inode = ino;
|
|
|
|
|
fuse_ino_t parent_inode = 0;
|
|
|
|
|
fuse_ino_t child_inode = ino;
|
|
|
|
|
char reverse_path[4096];
|
|
|
|
|
|
|
|
|
|
/* ino == 1 is a special case; we already know that it is not */
|
|
|
|
@ -1120,7 +1112,7 @@ static tui32 xfuse_get_device_id_for_inode(tui32 ino, char *full_path)
|
|
|
|
|
if (ino == 1)
|
|
|
|
|
{
|
|
|
|
|
/* just return the device_id for the file in full_path */
|
|
|
|
|
log_debug("looking for file with pinode=%d name=%s", ino, full_path);
|
|
|
|
|
log_debug("looking for file with pinode=%ld name=%s", ino, full_path);
|
|
|
|
|
xfuse_dump_fs();
|
|
|
|
|
|
|
|
|
|
XRDP_INODE *xinode = xfuse_get_inode_from_pinode_name(ino, full_path);
|
|
|
|
@ -1179,10 +1171,10 @@ static void fuse_reverse_pathname(char *full_path, char *reverse_path)
|
|
|
|
|
* Return the inode that matches the name and parent inode
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static struct xrdp_inode * xfuse_get_inode_from_pinode_name(tui32 pinode,
|
|
|
|
|
static struct xrdp_inode * xfuse_get_inode_from_pinode_name(fuse_ino_t pinode,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
fuse_ino_t i;
|
|
|
|
|
struct xrdp_inode * xinode;
|
|
|
|
|
|
|
|
|
|
for (i = FIRST_INODE; i < g_xrdp_fs.num_entries; i++)
|
|
|
|
@ -1222,7 +1214,8 @@ static struct xrdp_inode * xfuse_create_file_in_xrdp_fs(tui32 device_id,
|
|
|
|
|
if ((name == NULL) || (strlen(name) == 0))
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
if ((xinode = calloc(1, sizeof(XRDP_INODE))) == NULL)
|
|
|
|
|
xinode = g_new0(XRDP_INODE, 1);
|
|
|
|
|
if (xinode == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
return NULL;
|
|
|
|
@ -1274,9 +1267,9 @@ static struct xrdp_inode * xfuse_create_file_in_xrdp_fs(tui32 device_id,
|
|
|
|
|
* @return 1 if specified file exists, 0 otherwise
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static int xfuse_does_file_exist(int parent, char *name)
|
|
|
|
|
static int xfuse_does_file_exist(fuse_ino_t parent, char *name)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
fuse_ino_t i;
|
|
|
|
|
XRDP_INODE *xinode;
|
|
|
|
|
|
|
|
|
|
for (i = FIRST_INODE; i < g_xrdp_fs.num_entries; i++)
|
|
|
|
@ -1294,11 +1287,6 @@ static int xfuse_does_file_exist(int parent, char *name)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int xfuse_delete_file(int parent, char *name)
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int xfuse_delete_file_with_xinode(XRDP_INODE *xinode)
|
|
|
|
|
{
|
|
|
|
|
/* make sure it is not a dir */
|
|
|
|
@ -1318,7 +1306,7 @@ static int xfuse_delete_file_with_xinode(XRDP_INODE *xinode)
|
|
|
|
|
static int xfuse_delete_dir_with_xinode(XRDP_INODE *xinode)
|
|
|
|
|
{
|
|
|
|
|
XRDP_INODE *xip;
|
|
|
|
|
int i;
|
|
|
|
|
fuse_ino_t i;
|
|
|
|
|
|
|
|
|
|
/* make sure it is not a file */
|
|
|
|
|
if ((xinode == NULL) || (xinode->mode & S_IFREG))
|
|
|
|
@ -1354,7 +1342,7 @@ static int xfuse_delete_dir_with_xinode(XRDP_INODE *xinode)
|
|
|
|
|
static int xfuse_recursive_delete_dir_with_xinode(XRDP_INODE *xinode)
|
|
|
|
|
{
|
|
|
|
|
XRDP_INODE *xip;
|
|
|
|
|
int i;
|
|
|
|
|
fuse_ino_t i;
|
|
|
|
|
|
|
|
|
|
/* make sure it is not a file */
|
|
|
|
|
if ((xinode == NULL) || (xinode->mode & S_IFREG))
|
|
|
|
@ -1419,12 +1407,12 @@ static void xfuse_update_xrdpfs_size()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* zero newly added memory */
|
|
|
|
|
memset(vp + g_xrdp_fs.max_entries * sizeof(struct xrdp_inode *),
|
|
|
|
|
memset((char *) vp + g_xrdp_fs.max_entries * sizeof(struct xrdp_inode *),
|
|
|
|
|
0,
|
|
|
|
|
100 * sizeof(struct xrdp_inode *));
|
|
|
|
|
|
|
|
|
|
g_xrdp_fs.max_entries += 100;
|
|
|
|
|
g_xrdp_fs.inode_table = vp;
|
|
|
|
|
g_xrdp_fs.inode_table = (struct xrdp_inode **) vp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
@ -1530,9 +1518,9 @@ void xfuse_devredir_cb_enum_dir_done(void *vp, tui32 IoStatus)
|
|
|
|
|
xfuse_delete_stale_entries(fip->inode);
|
|
|
|
|
|
|
|
|
|
/* this will be used by xfuse_cb_readdir() */
|
|
|
|
|
di = calloc(1, sizeof(struct dir_info));
|
|
|
|
|
di = g_new0(struct dir_info, 1);
|
|
|
|
|
di->index = FIRST_INODE;
|
|
|
|
|
fip->fi->fh = (long) di;
|
|
|
|
|
fip->fi->fh = (tintptr) di;
|
|
|
|
|
|
|
|
|
|
fuse_reply_open(fip->req, fip->fi);
|
|
|
|
|
|
|
|
|
@ -1547,7 +1535,7 @@ done:
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
/* process next request */
|
|
|
|
|
odreq = fifo_peek(&g_fifo_opendir);
|
|
|
|
|
odreq = (struct opendir_req *) fifo_peek(&g_fifo_opendir);
|
|
|
|
|
if (!odreq)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
@ -1600,7 +1588,8 @@ void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId,
|
|
|
|
|
|
|
|
|
|
if (fip->fi != NULL)
|
|
|
|
|
{
|
|
|
|
|
if ((fh = calloc(1, sizeof(XFUSE_HANDLE))) == NULL)
|
|
|
|
|
fh = g_new0(XFUSE_HANDLE, 1);
|
|
|
|
|
if (fh == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
if (fip->invoke_fuse)
|
|
|
|
@ -1614,7 +1603,7 @@ void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId,
|
|
|
|
|
fh->DeviceId = DeviceId;
|
|
|
|
|
fh->FileId = FileId;
|
|
|
|
|
|
|
|
|
|
fip->fi->fh = (uint64_t) ((long) fh);
|
|
|
|
|
fip->fi->fh = (tintptr) fh;
|
|
|
|
|
log_debug("+++ XFUSE_INFO=%p XFUSE_INFO->fi=%p XFUSE_INFO->fi->fh=0x%llx",
|
|
|
|
|
fip, fip->fi, (long long) fip->fi->fh);
|
|
|
|
|
}
|
|
|
|
@ -1872,7 +1861,7 @@ void xfuse_devredir_cb_file_close(void *vp)
|
|
|
|
|
fip->fi, (long long) fip->fi->fh);
|
|
|
|
|
|
|
|
|
|
free((char *) (tintptr) (fip->fi->fh));
|
|
|
|
|
fip->fi->fh = NULL;
|
|
|
|
|
fip->fi->fh = 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
@ -1976,6 +1965,7 @@ static void xfuse_cb_getattr(fuse_req_t req, fuse_ino_t ino,
|
|
|
|
|
*
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
static void xfuse_dirbuf_add(fuse_req_t req, struct dirbuf *b,
|
|
|
|
|
const char *name, fuse_ino_t ino)
|
|
|
|
|
{
|
|
|
|
@ -1992,6 +1982,7 @@ static void xfuse_dirbuf_add(fuse_req_t req, struct dirbuf *b,
|
|
|
|
|
fuse_add_direntry(req, b->p + oldsize, b->size - oldsize, name, &stbuf,
|
|
|
|
|
b->size);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
static int xfuse_dirbuf_add1(fuse_req_t req, struct dirbuf1 *b,
|
|
|
|
|
const char *name, fuse_ino_t ino)
|
|
|
|
@ -2032,7 +2023,7 @@ static void xfuse_cb_readdir(fuse_req_t req, fuse_ino_t ino, size_t size,
|
|
|
|
|
XRDP_INODE *ti;
|
|
|
|
|
struct dir_info *di;
|
|
|
|
|
struct dirbuf1 b;
|
|
|
|
|
int i;
|
|
|
|
|
fuse_ino_t i;
|
|
|
|
|
int first_time;
|
|
|
|
|
|
|
|
|
|
log_debug("req=%p inode=%ld size=%zd offset=%lld", req, ino, size, (long long) off);
|
|
|
|
@ -2214,7 +2205,8 @@ static void xfuse_remove_dir_or_file(fuse_req_t req, fuse_ino_t parent,
|
|
|
|
|
|
|
|
|
|
/* specified file resides on redirected share */
|
|
|
|
|
|
|
|
|
|
if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL)
|
|
|
|
|
fip = g_new0(XFUSE_INFO, 1);
|
|
|
|
|
if (fip == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
fuse_reply_err(req, ENOMEM);
|
|
|
|
@ -2263,7 +2255,7 @@ static void xfuse_cb_rename(fuse_req_t req,
|
|
|
|
|
char *cptr;
|
|
|
|
|
char old_full_path[1024];
|
|
|
|
|
char new_full_path[1024];
|
|
|
|
|
char *cp;
|
|
|
|
|
const char *cp;
|
|
|
|
|
|
|
|
|
|
tui32 device_id;
|
|
|
|
|
|
|
|
|
@ -2343,7 +2335,8 @@ static void xfuse_cb_rename(fuse_req_t req,
|
|
|
|
|
strcat(old_full_path, "/");
|
|
|
|
|
strcat(old_full_path, old_name);
|
|
|
|
|
|
|
|
|
|
if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL)
|
|
|
|
|
fip = g_new0(XFUSE_INFO, 1);
|
|
|
|
|
if (fip == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
fuse_reply_err(req, ENOMEM);
|
|
|
|
@ -2447,7 +2440,8 @@ static void xfuse_create_dir_or_file(fuse_req_t req, fuse_ino_t parent,
|
|
|
|
|
|
|
|
|
|
/* specified file resides on redirected share */
|
|
|
|
|
|
|
|
|
|
if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL)
|
|
|
|
|
fip = g_new0(XFUSE_INFO, 1);
|
|
|
|
|
if (fip == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
fuse_reply_err(req, ENOMEM);
|
|
|
|
@ -2527,21 +2521,22 @@ static void xfuse_cb_open(fuse_req_t req, fuse_ino_t ino,
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
device_id = xfuse_get_device_id_for_inode((tui32) ino, full_path);
|
|
|
|
|
device_id = xfuse_get_device_id_for_inode(ino, full_path);
|
|
|
|
|
|
|
|
|
|
if (xinode->is_loc_resource)
|
|
|
|
|
{
|
|
|
|
|
/* specified file is a local resource */
|
|
|
|
|
XFUSE_HANDLE *fh = calloc(1, sizeof(XFUSE_HANDLE));
|
|
|
|
|
XFUSE_HANDLE *fh = g_new0(XFUSE_HANDLE, 1);
|
|
|
|
|
fh->is_loc_resource = 1;
|
|
|
|
|
fi->fh = (uint64_t) ((long) fh);
|
|
|
|
|
fi->fh = (tintptr) fh;
|
|
|
|
|
fuse_reply_open(req, fi);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* specified file resides on redirected share */
|
|
|
|
|
|
|
|
|
|
if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL)
|
|
|
|
|
fip = g_new0(XFUSE_INFO, 1);
|
|
|
|
|
if (fip == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
fuse_reply_err(req, ENOMEM);
|
|
|
|
@ -2587,7 +2582,6 @@ static void xfuse_cb_release(fuse_req_t req, fuse_ino_t ino, struct
|
|
|
|
|
{
|
|
|
|
|
XFUSE_INFO *fip = NULL;
|
|
|
|
|
XFUSE_HANDLE *handle = (XFUSE_HANDLE *) (tintptr) (fi->fh);
|
|
|
|
|
tui32 FileId;
|
|
|
|
|
|
|
|
|
|
log_debug("entered: ino=%ld fi=%p fi->fh=0x%llx", ino, fi,
|
|
|
|
|
(long long) fi->fh);
|
|
|
|
@ -2625,7 +2619,8 @@ static void xfuse_cb_release(fuse_req_t req, fuse_ino_t ino, struct
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL)
|
|
|
|
|
fip = g_new0(XFUSE_INFO, 1);
|
|
|
|
|
if (fip == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
fuse_reply_err(req, ENOMEM);
|
|
|
|
@ -2641,7 +2636,6 @@ static void xfuse_cb_release(fuse_req_t req, fuse_ino_t ino, struct
|
|
|
|
|
log_debug(" +++ created XFUSE_INFO=%p XFUSE_INFO->fi=%p XFUSE_INFO->fi->fh=0x%llx",
|
|
|
|
|
fip, fip->fi, (long long) fip->fi->fh);
|
|
|
|
|
|
|
|
|
|
FileId = handle->FileId;
|
|
|
|
|
fip->fi->fh = 0;
|
|
|
|
|
xinode->close_in_progress = 1;
|
|
|
|
|
|
|
|
|
@ -2690,8 +2684,7 @@ static void xfuse_cb_read(fuse_req_t req, fuse_ino_t ino, size_t size,
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rli = (struct req_list_item *)
|
|
|
|
|
g_malloc(sizeof(struct req_list_item), 1);
|
|
|
|
|
rli = g_new0(struct req_list_item, 1);
|
|
|
|
|
|
|
|
|
|
rli->stream_id = 0;
|
|
|
|
|
rli->req = req;
|
|
|
|
@ -2714,7 +2707,8 @@ static void xfuse_cb_read(fuse_req_t req, fuse_ino_t ino, size_t size,
|
|
|
|
|
|
|
|
|
|
/* target file is on a remote device */
|
|
|
|
|
|
|
|
|
|
if ((fusep = calloc(1, sizeof(XFUSE_INFO))) == NULL)
|
|
|
|
|
fusep = g_new0(XFUSE_INFO, 1);
|
|
|
|
|
if (fusep == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
fuse_reply_err(req, ENOMEM);
|
|
|
|
@ -2761,7 +2755,8 @@ static void xfuse_cb_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
|
|
|
|
|
|
|
|
|
|
/* target file is on a remote device */
|
|
|
|
|
|
|
|
|
|
if ((fusep = calloc(1, sizeof(XFUSE_INFO))) == NULL)
|
|
|
|
|
fusep = g_new0(XFUSE_INFO, 1);
|
|
|
|
|
if (fusep == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
fuse_reply_err(req, ENOMEM);
|
|
|
|
@ -2797,6 +2792,7 @@ static void xfuse_cb_create(fuse_req_t req, fuse_ino_t parent,
|
|
|
|
|
/**
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
static void xfuse_cb_fsync(fuse_req_t req, fuse_ino_t ino, int datasync,
|
|
|
|
|
struct fuse_file_info *fi)
|
|
|
|
|
{
|
|
|
|
@ -2804,6 +2800,7 @@ static void xfuse_cb_fsync(fuse_req_t req, fuse_ino_t ino, int datasync,
|
|
|
|
|
log_debug("function not required");
|
|
|
|
|
fuse_reply_err(req, EINVAL);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*****************************************************************************/
|
|
|
|
@ -2902,7 +2899,7 @@ static void xfuse_cb_opendir(fuse_req_t req, fuse_ino_t ino,
|
|
|
|
|
struct opendir_req *odreq;
|
|
|
|
|
|
|
|
|
|
/* save request */
|
|
|
|
|
odreq = malloc(sizeof(struct opendir_req));
|
|
|
|
|
odreq = g_new(struct opendir_req, 1);
|
|
|
|
|
odreq->req = req;
|
|
|
|
|
odreq->ino = ino;
|
|
|
|
|
odreq->fi = fi;
|
|
|
|
@ -2971,18 +2968,19 @@ static int xfuse_proc_opendir_req(fuse_req_t req, fuse_ino_t ino,
|
|
|
|
|
{
|
|
|
|
|
goto do_remote_lookup;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
do_remote_lookup:
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
xfuse_mark_as_stale((int) ino);
|
|
|
|
|
xfuse_mark_as_stale(ino);
|
|
|
|
|
|
|
|
|
|
log_debug("did not find entry; redirecting call to dev_redir");
|
|
|
|
|
device_id = xfuse_get_device_id_for_inode((tui32) ino, full_path);
|
|
|
|
|
device_id = xfuse_get_device_id_for_inode(ino, full_path);
|
|
|
|
|
|
|
|
|
|
log_debug("dev_id=%d ino=%ld full_path=%s", device_id, ino, full_path);
|
|
|
|
|
|
|
|
|
|
if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL)
|
|
|
|
|
fip = g_new0(XFUSE_INFO, 1);
|
|
|
|
|
if (fip == NULL)
|
|
|
|
|
{
|
|
|
|
|
log_error("system out of memory");
|
|
|
|
|
fuse_reply_err(req, ENOMEM);
|
|
|
|
@ -3024,9 +3022,9 @@ do_remote_lookup:
|
|
|
|
|
|
|
|
|
|
done:
|
|
|
|
|
|
|
|
|
|
di = calloc(1, sizeof(struct dir_info));
|
|
|
|
|
di = g_new0(struct dir_info, 1);
|
|
|
|
|
di->index = FIRST_INODE;
|
|
|
|
|
fi->fh = (long) di;
|
|
|
|
|
fi->fh = (tintptr) di;
|
|
|
|
|
fuse_reply_open(req, fi);
|
|
|
|
|
g_free(fifo_remove(&g_fifo_opendir));
|
|
|
|
|
return -1;
|
|
|
|
@ -3058,9 +3056,9 @@ static void xfuse_cb_releasedir(fuse_req_t req, fuse_ino_t ino,
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xfuse_mark_as_stale(int pinode)
|
|
|
|
|
xfuse_mark_as_stale(fuse_ino_t pinode)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
fuse_ino_t i;
|
|
|
|
|
XRDP_INODE *xinode;
|
|
|
|
|
|
|
|
|
|
if ((pinode < FIRST_INODE) || (pinode >= g_xrdp_fs.num_entries))
|
|
|
|
@ -3087,9 +3085,9 @@ xfuse_mark_as_stale(int pinode)
|
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
xfuse_delete_stale_entries(int pinode)
|
|
|
|
|
xfuse_delete_stale_entries(fuse_ino_t pinode)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
fuse_ino_t i;
|
|
|
|
|
XRDP_INODE *xinode;
|
|
|
|
|
|
|
|
|
|
if ((pinode < FIRST_INODE) || (pinode >= g_xrdp_fs.num_entries))
|
|
|
|
|