diff options
author | metalefty <meta@vmeta.jp> | 2016-11-28 10:14:09 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-28 10:14:09 +0900 |
commit | 679c4b35583da8080b32ece6d45ff800f6e623ac (patch) | |
tree | 6aabd79626c5b8c29bc88a20dd37e838fa5b75ec | |
parent | 589b29f92f7aabc3ff2212cd5be93bb6bce6b811 (diff) | |
parent | e46d15ca84e3adcd47560e1f3efe2fdd9df85850 (diff) | |
download | xrdp-proprietary-679c4b35583da8080b32ece6d45ff800f6e623ac.tar.gz xrdp-proprietary-679c4b35583da8080b32ece6d45ff800f6e623ac.zip |
Merge pull request #502 from proski/fuse1
Fix all FUSE warnings and C++ compatibility, add Mac compilation support
-rw-r--r-- | sesman/chansrv/Makefile.am | 4 | ||||
-rw-r--r-- | sesman/chansrv/chansrv_fuse.c | 188 | ||||
-rw-r--r-- | sesman/chansrv/devredir.c | 24 | ||||
-rw-r--r-- | sesman/chansrv/devredir.h | 18 |
4 files changed, 121 insertions, 113 deletions
diff --git a/sesman/chansrv/Makefile.am b/sesman/chansrv/Makefile.am index 2ecd67b4..221437e9 100644 --- a/sesman/chansrv/Makefile.am +++ b/sesman/chansrv/Makefile.am @@ -8,8 +8,8 @@ AM_CPPFLAGS = \ CHANSRV_EXTRA_LIBS = if XRDP_FUSE -AM_CPPFLAGS += -DXRDP_FUSE -CHANSRV_EXTRA_LIBS += -lfuse +AM_CPPFLAGS += -DXRDP_FUSE $(FUSE_CFLAGS) +CHANSRV_EXTRA_LIBS += $(FUSE_LIBS) endif if XRDP_OPUS diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c index 04209fd9..16fda322 100644 --- a/sesman/chansrv/chansrv_fuse.c +++ b/sesman/chansrv/chansrv_fuse.c @@ -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)) diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c index 2ce30286..111ac465 100644 --- a/sesman/chansrv/devredir.c +++ b/sesman/chansrv/devredir.c @@ -430,7 +430,8 @@ void devredir_send_server_device_announce_resp(tui32 device_id) * @return 0 on success, -1 on failure *****************************************************************************/ -int dev_redir_send_drive_create_request(tui32 device_id, char *path, +int dev_redir_send_drive_create_request(tui32 device_id, + const char *path, tui32 DesiredAccess, tui32 CreateOptions, tui32 CreateDisposition, @@ -997,7 +998,7 @@ dev_redir_proc_query_dir_response(IRP *irp, *****************************************************************************/ int APP_CC -dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path) +dev_redir_get_dir_listing(void *fusep, tui32 device_id, const char *path) { tui32 DesiredAccess; tui32 CreateOptions; @@ -1010,26 +1011,27 @@ dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path) if ((irp = devredir_irp_new()) == NULL) return -1; - /* cvt / to windows compatible \ */ - devredir_cvt_slash(path); + strncpy(irp->pathname, path, 255); + + /* convert / to windows compatible \ */ + devredir_cvt_slash(irp->pathname); irp->CompletionId = g_completion_id++; irp->completion_type = CID_CREATE_DIR_REQ; irp->DeviceId = device_id; - strncpy(irp->pathname, path, 255); devredir_fuse_data_enqueue(irp, fusep); DesiredAccess = DA_FILE_READ_DATA | DA_SYNCHRONIZE; CreateOptions = CO_FILE_DIRECTORY_FILE | CO_FILE_SYNCHRONOUS_IO_NONALERT; CreateDisposition = CD_FILE_OPEN; - rval = dev_redir_send_drive_create_request(device_id, path, + rval = dev_redir_send_drive_create_request(device_id, irp->pathname, DesiredAccess, CreateOptions, CreateDisposition, irp->CompletionId); - log_debug("looking for device_id=%d path=%s", device_id, path); + log_debug("looking for device_id=%d path=%s", device_id, irp->pathname); /* when we get a response to dev_redir_send_drive_create_request(), we */ /* call dev_redir_send_drive_dir_request(), which needs the following */ @@ -1043,8 +1045,8 @@ dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path) } int APP_CC -dev_redir_file_open(void *fusep, tui32 device_id, char *path, - int mode, int type, char *gen_buf) +dev_redir_file_open(void *fusep, tui32 device_id, const char *path, + int mode, int type, const char *gen_buf) { tui32 DesiredAccess; tui32 CreateOptions; @@ -1161,7 +1163,7 @@ int devredir_file_close(void *fusep, tui32 device_id, tui32 FileId) *****************************************************************************/ int APP_CC -devredir_rmdir_or_file(void *fusep, tui32 device_id, char *path, int mode) +devredir_rmdir_or_file(void *fusep, tui32 device_id, const char *path, int mode) { tui32 DesiredAccess; tui32 CreateOptions; @@ -1445,7 +1447,7 @@ devredir_cvt_slash(char *path) } void APP_CC -devredir_cvt_to_unicode(char *unicode, char *path) +devredir_cvt_to_unicode(char *unicode, const char *path) { char *dest; char *src; diff --git a/sesman/chansrv/devredir.h b/sesman/chansrv/devredir.h index b49eb1dd..6479c6f6 100644 --- a/sesman/chansrv/devredir.h +++ b/sesman/chansrv/devredir.h @@ -48,7 +48,8 @@ void devredir_send_server_device_announce_resp(tui32 device_id); void dev_redir_send_drive_dir_request(IRP *irp, tui32 device_id, tui32 InitialQuery, char *Path); -int dev_redir_send_drive_create_request(tui32 device_id, char *path, +int dev_redir_send_drive_create_request(tui32 device_id, + const char *path, tui32 DesiredAccess, tui32 CreateOptions, tui32 CreateDisposition, @@ -81,7 +82,7 @@ void devredir_insert_DeviceIoRequest(struct stream *s, tui32 MinorFunction); void devredir_cvt_slash(char *path); -void devredir_cvt_to_unicode(char *unicode, char *path); +void devredir_cvt_to_unicode(char *unicode, const char *path); void devredir_cvt_from_unicode_len(char *path, char *unicode, int len); int dev_redir_string_ends_with(char *string, char c); @@ -94,16 +95,23 @@ void devredir_proc_cid_rename_file(IRP *irp, tui32 IoStatus); void devredir_proc_cid_rename_file_resp(IRP *irp, tui32 IoStatus); /* called from FUSE module */ -int dev_redir_get_dir_listing(void *fusep, tui32 device_id, char *path); +int dev_redir_get_dir_listing(void *fusep, tui32 device_id, const char *path); -int dev_redir_file_open(void *fusep, tui32 device_id, char *path, - int mode, int type, char *gen_buf); +int dev_redir_file_open(void *fusep, tui32 device_id, const char *path, + int mode, int type, const char *gen_buf); int devredir_file_close(void *fusep, tui32 device_id, tui32 file_id); int devredir_file_read(void *fusep, tui32 device_id, tui32 FileId, tui32 Length, tui64 Offset); +int APP_CC +dev_redir_file_write(void *fusep, tui32 DeviceId, tui32 FileId, + const char *buf, int Length, tui64 Offset); + +int APP_CC +devredir_rmdir_or_file(void *fusep, tui32 device_id, const char *path, int mode); + int send_channel_data(int chan_id, char *data, int size); /* |