file system redirection:

o vi now works with freerdp and rdesktop
ulab-next
Laxmikant Rashinkar 12 years ago
parent 0f15c482e1
commit 652bacf07f

@ -321,6 +321,9 @@ static void xfuse_cb_create(fuse_req_t req, fuse_ino_t parent,
const char *name, mode_t mode, const char *name, mode_t mode,
struct fuse_file_info *fi); struct fuse_file_info *fi);
static void xfuse_cb_fsync(fuse_req_t req, fuse_ino_t ino, int datasync,
struct fuse_file_info *fi);
/* clipboard calls */ /* clipboard calls */
int clipboard_request_file_data(int stream_id, int lindex, int offset, int clipboard_request_file_data(int stream_id, int lindex, int offset,
int request_bytes); int request_bytes);
@ -389,6 +392,7 @@ int xfuse_init()
g_xfuse_ops.read = xfuse_cb_read; g_xfuse_ops.read = xfuse_cb_read;
g_xfuse_ops.write = xfuse_cb_write; g_xfuse_ops.write = xfuse_cb_write;
g_xfuse_ops.create = xfuse_cb_create; g_xfuse_ops.create = xfuse_cb_create;
//g_xfuse_ops.fsync = xfuse_cb_fsync; /* LK_TODO delete this */
g_xfuse_ops.getattr = xfuse_cb_getattr; g_xfuse_ops.getattr = xfuse_cb_getattr;
g_xfuse_ops.setattr = xfuse_cb_setattr; g_xfuse_ops.setattr = xfuse_cb_setattr;
@ -1824,8 +1828,11 @@ void xfuse_devredir_cb_read_file(void *vp, char *buf, size_t length)
XFUSE_INFO *fip; XFUSE_INFO *fip;
fip = (XFUSE_INFO *) vp; fip = (XFUSE_INFO *) vp;
if (fip == NULL) if ((fip == NULL) || (fip->req == NULL))
{
log_error("fip for fip->req is NULL");
return; return;
}
fuse_reply_buf(fip->req, buf, length); fuse_reply_buf(fip->req, buf, length);
free(fip); free(fip);
@ -1837,8 +1844,11 @@ void xfuse_devredir_cb_write_file(void *vp, char *buf, size_t length)
XFUSE_INFO *fip; XFUSE_INFO *fip;
fip = (XFUSE_INFO *) vp; fip = (XFUSE_INFO *) vp;
if (fip == NULL) if ((fip == NULL) || (fip->req == NULL) || (fip->fi == NULL))
{
log_error("fip, fip->req or fip->fi is NULL");
return; return;
}
log_debug("+++ XFUSE_INFO=%p, XFUSE_INFO->fi=%p XFUSE_INFO->fi->fh=%p", log_debug("+++ XFUSE_INFO=%p, XFUSE_INFO->fi=%p XFUSE_INFO->fi->fh=%p",
fip, fip->fi, fip->fi->fh); fip, fip->fi, fip->fi->fh);
@ -1955,13 +1965,23 @@ void xfuse_devredir_cb_file_close(void *vp)
fip = (XFUSE_INFO *) vp; fip = (XFUSE_INFO *) vp;
if (fip == NULL) if (fip == NULL)
{
log_error("fip is NULL");
return;
}
if (fip->fi == NULL)
{
log_error("fip->fi is NULL");
return; return;
}
log_debug("+++ XFUSE_INFO=%p XFUSE_INFO->fi=%p XFUSE_INFO->fi->fh=%p", log_debug("+++ XFUSE_INFO=%p XFUSE_INFO->fi=%p XFUSE_INFO->fi->fh=%p",
fip, fip->fi, fip->fi->fh); fip, fip->fi, fip->fi->fh);
if ((xinode = g_xrdp_fs.inode_table[fip->inode]) == NULL) if ((xinode = g_xrdp_fs.inode_table[fip->inode]) == NULL)
{ {
log_debug("inode_table[%d] is NULL", fip->inode);
fuse_reply_err(fip->req, EBADF); fuse_reply_err(fip->req, EBADF);
return; return;
} }
@ -2665,6 +2685,7 @@ static void xfuse_cb_open(fuse_req_t req, fuse_ino_t ino,
} }
/* specified file resides on redirected share */ /* specified file resides on redirected share */
if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL) if ((fip = calloc(1, sizeof(XFUSE_INFO))) == NULL)
{ {
log_error("system out of memory"); log_error("system out of memory");
@ -2847,6 +2868,9 @@ static void xfuse_cb_read(fuse_req_t req, fuse_ino_t ino, size_t size,
dev_redir_file_read(fusep, fh->DeviceId, fh->FileId, size, off); dev_redir_file_read(fusep, fh->DeviceId, fh->FileId, size, off);
} }
/**
*****************************************************************************/
static void xfuse_cb_write(fuse_req_t req, fuse_ino_t ino, const char *buf, static void xfuse_cb_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
size_t size, off_t off, struct fuse_file_info *fi) size_t size, off_t off, struct fuse_file_info *fi)
{ {
@ -2854,10 +2878,12 @@ static void xfuse_cb_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
XFUSE_INFO *fusep; XFUSE_INFO *fusep;
long handle; long handle;
log_debug("write %d bytes at off %d", size, off); log_debug("write %d bytes at off %d to inode=%d",
(int) size, (int) off, (int) ino);
if (fi->fh == 0) if (fi->fh == 0)
{ {
log_error("file handle fi->fh is NULL");
fuse_reply_err(req, EINVAL); fuse_reply_err(req, EINVAL);
return; return;
} }
@ -2868,7 +2894,7 @@ static void xfuse_cb_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
if (fh->is_loc_resource) if (fh->is_loc_resource)
{ {
/* target file is in .clipboard dir */ /* target file is in .clipboard dir */
log_debug(">>>>>>>>>>>>>>>>> THIS IS STILL A TODO!"); log_debug("THIS IS STILL A TODO!");
return; return;
} }
@ -2894,6 +2920,9 @@ static void xfuse_cb_write(fuse_req_t req, fuse_ino_t ino, const char *buf,
log_debug("exiting"); log_debug("exiting");
} }
/**
*****************************************************************************/
static void xfuse_cb_create(fuse_req_t req, fuse_ino_t parent, static void xfuse_cb_create(fuse_req_t req, fuse_ino_t parent,
const char *name, mode_t mode, const char *name, mode_t mode,
struct fuse_file_info *fi) struct fuse_file_info *fi)
@ -2904,6 +2933,20 @@ static void xfuse_cb_create(fuse_req_t req, fuse_ino_t parent,
xfuse_create_dir_or_file(req, parent, name, mode, fi, S_IFREG); xfuse_create_dir_or_file(req, parent, name, mode, fi, S_IFREG);
} }
/**
*****************************************************************************/
static void xfuse_cb_fsync(fuse_req_t req, fuse_ino_t ino, int datasync,
struct fuse_file_info *fi)
{
log_debug("#################### entered: ino=%d datasync=%d", (int) ino, datasync);
log_debug("function not required");
fuse_reply_err(req, EINVAL);
}
/**
*****************************************************************************/
static void xfuse_cb_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr, static void xfuse_cb_setattr(fuse_req_t req, fuse_ino_t ino, struct stat *attr,
int to_set, struct fuse_file_info *fi) int to_set, struct fuse_file_info *fi)
{ {

@ -775,6 +775,8 @@ void dev_redir_proc_device_iocompletion(struct stream *s)
log_debug("got CID_READ"); log_debug("got CID_READ");
xstream_rd_u32_le(s, Length); xstream_rd_u32_le(s, Length);
fuse_data = devredir_fuse_data_dequeue(irp); fuse_data = devredir_fuse_data_dequeue(irp);
if (fuse_data == NULL)
log_error("fuse_data is NULL");
xfuse_devredir_cb_read_file(fuse_data->data_ptr, s->p, Length); xfuse_devredir_cb_read_file(fuse_data->data_ptr, s->p, Length);
break; break;
@ -1066,16 +1068,20 @@ int dev_redir_file_open(void *fusep, tui32 device_id, char *path,
//CreateDisposition = CD_FILE_CREATE; //CreateDisposition = CD_FILE_CREATE;
CreateDisposition = 0x02; /* got this value from windows */ CreateDisposition = 0x02; /* got this value from windows */
} }
else //if (mode & O_RDWR) else
{ {
log_debug("open file in O_RDWR"); log_debug("open file in O_RDWR");
#if 1 #if 1
DesiredAccess = DA_FILE_READ_DATA | DA_FILE_WRITE_DATA | DA_SYNCHRONIZE; /* without the 0x00000010 rdesktop opens files in */
/* O_RDONLY instead of O_RDWR mode */
DesiredAccess = DA_FILE_READ_DATA | DA_FILE_WRITE_DATA | DA_SYNCHRONIZE | 0x00000010;
CreateOptions = CO_FILE_SYNCHRONOUS_IO_NONALERT; CreateOptions = CO_FILE_SYNCHRONOUS_IO_NONALERT;
CreateDisposition = CD_FILE_OPEN; // WAS 1 CreateDisposition = CD_FILE_OPEN; // WAS 1
#else #else
/* got this value from windows */ /* got this value from windows; the 0x00000010 was added by LK; */
DesiredAccess = 0x00120089; /* without this rdesktop opens files in O_RDONLY instead of */
/* O_RDWR mode */
DesiredAccess = 0x00120089 | 0x00000010;
CreateOptions = 0x20060; CreateOptions = 0x20060;
CreateDisposition = 0x01; CreateDisposition = 0x01;
#endif #endif

Loading…
Cancel
Save