folder redirection: fixed language issues

This commit is contained in:
Laxmikant Rashinkar 2013-06-08 18:44:21 -07:00
parent 2029867510
commit 6ad1d7f78d
5 changed files with 224 additions and 410 deletions

View File

@ -27,252 +27,130 @@
#include "arch.h"
int APP_CC
g_rm_temp_dir(void);
int APP_CC
g_mk_temp_dir(const char* app_name);
void APP_CC
g_init(const char* app_name);
void APP_CC
g_deinit(void);
void* APP_CC
g_malloc(int size, int zero);
void APP_CC
g_free(void* ptr);
void DEFAULT_CC
g_printf(const char *format, ...);
void DEFAULT_CC
g_sprintf(char* dest, const char* format, ...);
void DEFAULT_CC
g_snprintf(char* dest, int len, const char* format, ...);
void DEFAULT_CC
g_writeln(const char* format, ...);
void DEFAULT_CC
g_write(const char* format, ...);
void APP_CC
g_hexdump(char* p, int len);
void APP_CC
g_memset(void* ptr, int val, int size);
void APP_CC
g_memcpy(void* d_ptr, const void* s_ptr, int size);
int APP_CC
g_getchar(void);
int APP_CC
g_tcp_set_no_delay(int sck);
int APP_CC
g_tcp_set_keepalive(int sck);
int APP_CC
g_tcp_socket(void);
int APP_CC
g_tcp_local_socket(void);
void APP_CC
g_tcp_close(int sck);
int APP_CC
g_tcp_connect(int sck, const char* address, const char* port);
int APP_CC
g_tcp_local_connect(int sck, const char* port);
int APP_CC
g_tcp_force_send(int sck, char* data, int len);
int APP_CC
g_tcp_force_recv(int sck, char* data, int len);
int APP_CC
g_tcp_set_non_blocking(int sck);
int APP_CC
g_tcp_bind(int sck, const char *port);
int APP_CC
g_tcp_local_bind(int sck, const char* port);
int APP_CC
g_tcp_bind_address(int sck, const char* port, const char* address);
int APP_CC
g_tcp_listen(int sck);
int APP_CC
g_tcp_accept(int sck);
int APP_CC
g_tcp_recv(int sck, void* ptr, int len, int flags);
int APP_CC
g_tcp_send(int sck, const void* ptr, int len, int flags);
int APP_CC
g_tcp_last_error_would_block(int sck);
int APP_CC
g_tcp_socket_ok(int sck);
int APP_CC
g_tcp_can_send(int sck, int millis);
int APP_CC
g_tcp_can_recv(int sck, int millis);
int APP_CC
g_tcp_select(int sck1, int sck2);
void APP_CC
g_write_ip_address(int rcv_sck, char* ip_address, int bytes);
void APP_CC
g_sleep(int msecs);
tbus APP_CC
g_create_wait_obj(char* name);
tbus APP_CC
g_create_wait_obj_from_socket(tbus socket, int write);
void APP_CC
g_delete_wait_obj_from_socket(tbus wait_obj);
int APP_CC
g_set_wait_obj(tbus obj);
int APP_CC
g_reset_wait_obj(tbus obj);
int APP_CC
g_is_wait_obj_set(tbus obj);
int APP_CC
g_delete_wait_obj(tbus obj);
int APP_CC
g_close_wait_obj(tbus obj);
int APP_CC
g_obj_wait(tbus* read_objs, int rcount, tbus* write_objs, int wcount,
int mstimeout);
void APP_CC
g_random(char* data, int len);
int APP_CC
g_abs(int i);
int APP_CC
g_memcmp(const void* s1, const void* s2, int len);
int APP_CC
g_file_open(const char* file_name);
int APP_CC
g_file_open_ex(const char *file_name, int aread, int awrite,
int APP_CC g_rm_temp_dir(void);
int APP_CC g_mk_temp_dir(const char* app_name);
void APP_CC g_init(const char* app_name);
void APP_CC g_deinit(void);
void* APP_CC g_malloc(int size, int zero);
void APP_CC g_free(void* ptr);
void DEFAULT_CC g_printf(const char *format, ...);
void DEFAULT_CC g_sprintf(char* dest, const char* format, ...);
void DEFAULT_CC g_snprintf(char* dest, int len, const char* format, ...);
void DEFAULT_CC g_writeln(const char* format, ...);
void DEFAULT_CC g_write(const char* format, ...);
void APP_CC g_hexdump(char* p, int len);
void APP_CC g_memset(void* ptr, int val, int size);
void APP_CC g_memcpy(void* d_ptr, const void* s_ptr, int size);
int APP_CC g_getchar(void);
int APP_CC g_tcp_set_no_delay(int sck);
int APP_CC g_tcp_set_keepalive(int sck);
int APP_CC g_tcp_socket(void);
int APP_CC g_tcp_local_socket(void);
void APP_CC g_tcp_close(int sck);
int APP_CC g_tcp_connect(int sck, const char* address, const char* port);
int APP_CC g_tcp_local_connect(int sck, const char* port);
int APP_CC g_tcp_force_send(int sck, char* data, int len);
int APP_CC g_tcp_force_recv(int sck, char* data, int len);
int APP_CC g_tcp_set_non_blocking(int sck);
int APP_CC g_tcp_bind(int sck, const char *port);
int APP_CC g_tcp_local_bind(int sck, const char* port);
int APP_CC g_tcp_bind_address(int sck, const char* port, const char* address);
int APP_CC g_tcp_listen(int sck);
int APP_CC g_tcp_accept(int sck);
int APP_CC g_tcp_recv(int sck, void* ptr, int len, int flags);
int APP_CC g_tcp_send(int sck, const void* ptr, int len, int flags);
int APP_CC g_tcp_last_error_would_block(int sck);
int APP_CC g_tcp_socket_ok(int sck);
int APP_CC g_tcp_can_send(int sck, int millis);
int APP_CC g_tcp_can_recv(int sck, int millis);
int APP_CC g_tcp_select(int sck1, int sck2);
void APP_CC g_write_ip_address(int rcv_sck, char* ip_address, int bytes);
void APP_CC g_sleep(int msecs);
tbus APP_CC g_create_wait_obj(char* name);
tbus APP_CC g_create_wait_obj_from_socket(tbus socket, int write);
void APP_CC g_delete_wait_obj_from_socket(tbus wait_obj);
int APP_CC g_set_wait_obj(tbus obj);
int APP_CC g_reset_wait_obj(tbus obj);
int APP_CC g_is_wait_obj_set(tbus obj);
int APP_CC g_delete_wait_obj(tbus obj);
int APP_CC g_close_wait_obj(tbus obj);
int APP_CC g_obj_wait(tbus* read_objs, int rcount, tbus* write_objs,
int wcount,int mstimeout);
void APP_CC g_random(char* data, int len);
int APP_CC g_abs(int i);
int APP_CC g_memcmp(const void* s1, const void* s2, int len);
int APP_CC g_file_open(const char* file_name);
int APP_CC g_file_open_ex(const char *file_name, int aread, int awrite,
int acreate, int atrunc);
int APP_CC
g_file_close(int fd);
int APP_CC
g_file_read(int fd, char* ptr, int len);
int APP_CC
g_file_write(int fd, char* ptr, int len);
int APP_CC
g_file_seek(int fd, int offset);
int APP_CC
g_file_lock(int fd, int start, int len);
int APP_CC
g_chmod_hex(const char* filename, int flags);
int APP_CC
g_chown(const char* name, int uid, int gid);
int APP_CC
g_mkdir(const char* dirname);
char* APP_CC
g_get_current_dir(char* dirname, int maxlen);
int APP_CC
g_set_current_dir(char* dirname);
int APP_CC
g_file_exist(const char* filename);
int APP_CC
g_directory_exist(const char* dirname);
int APP_CC
g_create_dir(const char* dirname);
int APP_CC
g_create_path(const char* path);
int APP_CC
g_remove_dir(const char* dirname);
int APP_CC
g_file_delete(const char* filename);
int APP_CC
g_file_get_size(const char* filename);
int APP_CC
g_strlen(const char* text);
char* APP_CC
g_strchr(const char* text, int c);
char* APP_CC
g_strcpy(char* dest, const char* src);
char* APP_CC
g_strncpy(char* dest, const char* src, int len);
char* APP_CC
g_strcat(char* dest, const char* src);
char* APP_CC
g_strdup(const char* in);
char* APP_CC
g_strndup(const char* in, const unsigned int maxlen);
int APP_CC
g_strcmp(const char* c1, const char* c2);
int APP_CC
g_strncmp(const char* c1, const char* c2, int len);
int APP_CC
g_strcasecmp(const char* c1, const char* c2);
int APP_CC
g_strncasecmp(const char* c1, const char* c2, int len);
int APP_CC
g_atoi(const char* str);
int APP_CC
g_htoi(char* str);
int APP_CC
g_pos(const char* str, const char* to_find);
int APP_CC
g_mbstowcs(twchar* dest, const char* src, int n);
int APP_CC
g_wcstombs(char* dest, const twchar* src, int n);
int APP_CC
g_strtrim(char* str, int trim_flags);
long APP_CC
g_load_library(char* in);
int APP_CC
g_free_library(long lib);
void* APP_CC
g_get_proc_address(long lib, const char* name);
int APP_CC
g_system(char* aexec);
char* APP_CC
g_get_strerror(void);
int APP_CC
g_get_errno(void);
int APP_CC
g_execvp(const char* p1, char* args[]);
int APP_CC
g_execlp3(const char* a1, const char* a2, const char* a3);
void APP_CC
g_signal_child_stop(void (*func)(int));
void APP_CC
g_signal_hang_up(void (*func)(int));
void APP_CC
g_signal_user_interrupt(void (*func)(int));
void APP_CC
g_signal_kill(void (*func)(int));
void APP_CC
g_signal_terminate(void (*func)(int));
void APP_CC
g_signal_pipe(void (*func)(int));
void APP_CC
g_signal_usr1(void (*func)(int));
int APP_CC
g_fork(void);
int APP_CC
g_setgid(int pid);
int APP_CC
g_initgroups(const char* user, int gid);
int APP_CC
g_getuid(void);
int APP_CC
g_getgid(void);
int APP_CC
g_setuid(int pid);
int APP_CC
g_waitchild(void);
int APP_CC
g_waitpid(int pid);
void APP_CC
g_clearenv(void);
int APP_CC
g_setenv(const char* name, const char* value, int rewrite);
char* APP_CC
g_getenv(const char* name);
int APP_CC
g_exit(int exit_code);
int APP_CC
g_getpid(void);
int APP_CC
g_sigterm(int pid);
int APP_CC
g_getuser_info(const char* username, int* gid, int* uid, char* shell,
int APP_CC g_file_close(int fd);
int APP_CC g_file_read(int fd, char* ptr, int len);
int APP_CC g_file_write(int fd, char* ptr, int len);
int APP_CC g_file_seek(int fd, int offset);
int APP_CC g_file_lock(int fd, int start, int len);
int APP_CC g_chmod_hex(const char* filename, int flags);
int APP_CC g_chown(const char* name, int uid, int gid);
int APP_CC g_mkdir(const char* dirname);
char* APP_CC g_get_current_dir(char* dirname, int maxlen);
int APP_CC g_set_current_dir(char* dirname);
int APP_CC g_file_exist(const char* filename);
int APP_CC g_directory_exist(const char* dirname);
int APP_CC g_create_dir(const char* dirname);
int APP_CC g_create_path(const char* path);
int APP_CC g_remove_dir(const char* dirname);
int APP_CC g_file_delete(const char* filename);
int APP_CC g_file_get_size(const char* filename);
int APP_CC g_strlen(const char* text);
char* APP_CC g_strchr(const char* text, int c);
char* APP_CC g_strcpy(char* dest, const char* src);
char* APP_CC g_strncpy(char* dest, const char* src, int len);
char* APP_CC g_strcat(char* dest, const char* src);
char* APP_CC g_strdup(const char* in);
char* APP_CC g_strndup(const char* in, const unsigned int maxlen);
int APP_CC g_strcmp(const char* c1, const char* c2);
int APP_CC g_strncmp(const char* c1, const char* c2, int len);
int APP_CC g_strcasecmp(const char* c1, const char* c2);
int APP_CC g_strncasecmp(const char* c1, const char* c2, int len);
int APP_CC g_atoi(const char* str);
int APP_CC g_htoi(char* str);
int APP_CC g_pos(const char* str, const char* to_find);
int APP_CC g_mbstowcs(twchar* dest, const char* src, int n);
int APP_CC g_wcstombs(char* dest, const twchar* src, int n);
int APP_CC g_strtrim(char* str, int trim_flags);
long APP_CC g_load_library(char* in);
int APP_CC g_free_library(long lib);
void* APP_CC g_get_proc_address(long lib, const char* name);
int APP_CC g_system(char* aexec);
char* APP_CC g_get_strerror(void);
int APP_CC g_get_errno(void);
int APP_CC g_execvp(const char* p1, char* args[]);
int APP_CC g_execlp3(const char* a1, const char* a2, const char* a3);
void APP_CC g_signal_child_stop(void (*func)(int));
void APP_CC g_signal_hang_up(void (*func)(int));
void APP_CC g_signal_user_interrupt(void (*func)(int));
void APP_CC g_signal_kill(void (*func)(int));
void APP_CC g_signal_terminate(void (*func)(int));
void APP_CC g_signal_pipe(void (*func)(int));
void APP_CC g_signal_usr1(void (*func)(int));
int APP_CC g_fork(void);
int APP_CC g_setgid(int pid);
int APP_CC g_initgroups(const char* user, int gid);
int APP_CC g_getuid(void);
int APP_CC g_getgid(void);
int APP_CC g_setuid(int pid);
int APP_CC g_waitchild(void);
int APP_CC g_waitpid(int pid);
void APP_CC g_clearenv(void);
int APP_CC g_setenv(const char* name, const char* value, int rewrite);
char* APP_CC g_getenv(const char* name);
int APP_CC g_exit(int exit_code);
int APP_CC g_getpid(void);
int APP_CC g_sigterm(int pid);
int APP_CC g_getuser_info(const char* username, int* gid, int* uid, char* shell,
char* dir, char* gecos);
int APP_CC
g_getgroup_info(const char* groupname, int* gid);
int APP_CC
g_check_user_in_group(const char* username, int gid, int* ok);
int APP_CC
g_time1(void);
int APP_CC
g_time2(void);
int APP_CC
g_time3(void);
int APP_CC g_getgroup_info(const char* groupname, int* gid);
int APP_CC g_check_user_in_group(const char* username, int gid, int* ok);
int APP_CC g_time1(void);
int APP_CC g_time2(void);
int APP_CC g_time3(void);
#endif

View File

@ -68,7 +68,7 @@ int xfuse_file_contents_range(int stream_id, char *data, int data_bytes) {}
int xfuse_file_contents_size(int stream_id, int file_size) {}
int xfuse_add_clip_dir_item(char *filename, int flags, int size, int lindex) {}
int xfuse_create_share(tui32 device_id, char *dirname) {}
void xfuse_devredir_cb_open_file(void *vp, tui32 DeviceId, tui32 FileId) {}
void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId, tui32 FileId) {}
void xfuse_devredir_cb_write_file(void *vp, char *buf, size_t length) {}
void xfuse_devredir_cb_read_file(void *vp, char *buf, size_t length) {}
void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode) {}
@ -1334,134 +1334,6 @@ static void xfuse_enum_dir(fuse_req_t req, fuse_ino_t ino, size_t size,
* Add a file or directory to xrdp file system
*****************************************************************************/
/* LK_TODO delete this after testing */
#if 0
void ___xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
{
XFUSE_INFO *fip = (XFUSE_INFO *) vp;
XRDP_INODE *xip = NULL;
log_debug("<<<<<< entered");
if ((fip == NULL) || (xinode == NULL))
{
log_error("fip or xinode are NULL");
printf("RASH_TODO: fip or xinode are NULL - leaving\n");
return;
}
log_debug("req=%p", fip->req);
/* do we have a valid inode? */
if (!xfuse_is_inode_valid(fip->inode))
{
log_error("inode %d is not valid", fip->inode);
printf("RASH_TODO: inode %d is not valid - leaving\n", (tui32) fip->inode);
return;
}
/* if filename is . or .. don't add it */
if ((strcmp(xinode->name, ".") == 0) || (strcmp(xinode->name, "..") == 0))
{
free(xinode);
printf("RASH_TODO: not adding ./.. - leaving\n");
return;
}
// LK_TODO
#if 0
/* we have a parent inode and a dir name; what we need is the xinode */
/* that matches the parent inode and the dir name */
target_inode = xfuse_get_inode_from_pinode_name(fip->inode, fip->name);
if (target_inode == 0)
{
log_debug("did not find entry with inode=%d name=%s",
fip->inode, fip->name);
return;
}
#endif
if ((xip = xfuse_get_inode_from_pinode_name(fip->inode, xinode->name)) != NULL)
{
log_debug("inode=%d name=%s already exists in xrdp_fs; not adding it",
fip->inode, xinode->name);
free(xinode);
xinode = xip;
goto update_fuse;
}
xinode->parent_inode = fip->inode;
xinode->inode = g_xrdp_fs.next_node++;
xinode->uid = getuid();
xinode->gid = getgid();
xinode->device_id = fip->device_id;
g_xrdp_fs.num_entries++;
/* insert it in xrdp fs and update lookup count */
g_xrdp_fs.inode_table[xinode->inode] = xinode;
g_xrdp_fs.inode_table[fip->inode]->nentries;
xfuse_update_xrdpfs_size();
update_fuse:
#if 1
/* let FUSE know about this entry */
if (fip->invoke_fuse)
{
struct dirbuf b;
memset(&b, 0, sizeof(struct dirbuf));
/* RASH_TODO if we are not using dirbuf, change this code */
if (fip->dirbuf == NULL)
{
fip->dirbuf = calloc(1, sizeof(struct dirbuf));
xfuse_dirbuf_add(fip->req, &b, ".", xinode->inode);
xfuse_dirbuf_add(fip->req, &b, "..", xinode->parent_inode);
}
xfuse_dirbuf_add(fip->req, &b, xinode->name, xinode->inode);
if (fip->off < b.size)
{
printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): req=%p off=%d\n",
fip->req, (tui32) fip->off);
printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): dumping req b4\n\n");
g_hexdump((char *) fip->req, 128);
printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): dumping buf b4\n\n");
g_hexdump(b.p, b.size);
printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): calling fuse\n");
fuse_reply_buf(fip->req, b.p, b.size);
printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): calling fuse...done\n");
printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): dumping req aft\n\n");
g_hexdump((char *) fip->req, 128);
printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): dumping buf aft\n\n");
g_hexdump(b.p, b.size);
}
else
{
printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): calling fuse with NULL\n");
fuse_reply_buf(fip->req, NULL, 0);
printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): calling fuse with NULL...done\n");
}
log_debug("added inode=%d name=%s to FUSE", (tui32) xinode->inode, xinode->name);
}
#endif
log_debug("leaving");
printf("RASH_TODO: xfuse_devredir_cb_enum_dir(): leaving\n");
}
#endif
void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode)
{
XFUSE_INFO *fip = (XFUSE_INFO *) vp;
@ -1715,7 +1587,8 @@ done:
free(fip);
}
void xfuse_devredir_cb_open_file(void *vp, tui32 DeviceId, tui32 FileId)
void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId,
tui32 FileId)
{
XFUSE_HANDLE *fh;
XRDP_INODE *xinode;
@ -1730,14 +1603,39 @@ void xfuse_devredir_cb_open_file(void *vp, tui32 DeviceId, tui32 FileId)
log_debug("+++ XFUSE_INFO=%p XFUSE_INFO->fi=%p DeviceId=%d FileId=%d",
fip, fip->fi, DeviceId, FileId);
if (IoStatus != 0)
{
if (!fip->invoke_fuse)
goto done;
switch (IoStatus)
{
case 0xC0000022:
fuse_reply_err(fip->req, EACCES);
break;
case 0xC0000033:
case 0xC0000034:
fuse_reply_err(fip->req, ENOENT);
break;
default:
fuse_reply_err(fip->req, EIO);
break;
}
goto done;
}
if (fip->fi != NULL)
{
if ((fh = calloc(1, sizeof(XFUSE_HANDLE))) == NULL)
{
log_error("system out of memory");
free(fip);
if (fip->invoke_fuse)
fuse_reply_err(fip->req, ENOMEM);
free(fip);
return;
}

View File

@ -58,7 +58,7 @@ int xfuse_add_clip_dir_item(char *filename, int flags, int size, int lindex);
/* functions that are invoked from devredir */
void xfuse_devredir_cb_enum_dir(void *vp, struct xrdp_inode *xinode);
void xfuse_devredir_cb_enum_dir_done(void *vp, tui32 IoStatus);
void xfuse_devredir_cb_open_file(void *vp, tui32 DeviceId, tui32 FileId);
void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId, tui32 FileId);
void xfuse_devredir_cb_read_file(void *vp, char *buf, size_t length);
void xfuse_devredir_cb_rmdir_or_file(void *vp, tui32 IoStatus);
void xfuse_devredir_cb_rename_file(void *vp, tui32 IoStatus);

View File

@ -432,8 +432,8 @@ int dev_redir_send_drive_create_request(tui32 device_id, char *path,
log_debug("DesiredAccess=0x%x CreateDisposition=0x%x CreateOptions=0x%x",
DesiredAccess, CreateDisposition, CreateOptions);
/* to store path as unicode */
len = strlen(path) * 2 + 2;
/* path in unicode needs this much space */
len = ((g_mbstowcs(NULL, path, 0) * sizeof(twchar)) / 2) + 2;
xstream_new(s, 1024 + len);
@ -517,7 +517,8 @@ void dev_redir_send_drive_dir_request(IRP *irp, tui32 device_id,
if (Path == NULL)
return;
path_len = strlen(Path) * 2 + 2;
/* Path in unicode needs this much space */
path_len = ((g_mbstowcs(NULL, Path, 0) * sizeof(twchar)) / 2) + 2;
devredir_cvt_to_unicode(upath, Path);
}
@ -717,8 +718,6 @@ void dev_redir_proc_device_iocompletion(struct stream *s)
xstream_rd_u32_le(s, CompletionId);
xstream_rd_u32_le(s, IoStatus);
/* LK_TODO need to check for IoStatus */
log_debug("entered: IoStatus=0x%x CompletionId=%d", IoStatus, CompletionId);
if ((irp = devredir_irp_find(CompletionId)) == NULL)
@ -762,12 +761,14 @@ void dev_redir_proc_device_iocompletion(struct stream *s)
case CID_CREATE_OPEN_REQ:
xstream_rd_u32_le(s, irp->FileId);
log_debug("got CID_CREATE_OPEN_REQ IoStatus=0x%x FileId=%d",
IoStatus, irp->FileId);
fuse_data = devredir_fuse_data_dequeue(irp);
xfuse_devredir_cb_open_file(fuse_data->data_ptr,
xfuse_devredir_cb_open_file(fuse_data->data_ptr, IoStatus,
DeviceId, irp->FileId);
if (irp->type == S_IFDIR)
if ((irp->type == S_IFDIR) || (IoStatus != NT_STATUS_SUCCESS))
devredir_irp_delete(irp);
break;
@ -1411,29 +1412,64 @@ void devredir_cvt_slash(char *path)
void devredir_cvt_to_unicode(char *unicode, char *path)
{
int len = strlen(path);
char *dest;
char *src;
int rv;
int i;
int j = 0;
for (i = 0; i < len; i++)
rv = g_mbstowcs((twchar *) unicode, path, strlen(path));
/* unicode is typically 4 bytes, but microsoft only uses 2 bytes */
src = unicode + sizeof(twchar); /* skip 1st unicode char */
dest = unicode + 2; /* first char already in place */
for (i = 1; i < rv; i++)
{
unicode[j++] = path[i];
unicode[j++] = 0x00;
*dest++ = *src++;
*dest++ = *src++;
src += 2;
}
unicode[j++] = 0x00;
unicode[j++] = 0x00;
*dest++ = 0;
*dest++ = 0;
}
void devredir_cvt_from_unicode_len(char *path, char *unicode, int len)
{
char *dest;
char *dest_saved;
char *src;
int rv;
int i;
int j;
int bytes_to_alloc;
int max_bytes;
for (i = 0, j = 0; i < len; i += 2)
bytes_to_alloc = (((len / 2) * sizeof(twchar)) + sizeof(twchar));
src = unicode;
dest = g_malloc(bytes_to_alloc, 1);
dest_saved = dest;
for (i = 0; i < len; i += 2)
{
path[j++] = unicode[i];
*dest++ = *src++;
*dest++ = *src++;
dest += 2;
}
path[j] = 0;
*dest++ = 0;
*dest++ = 0;
*dest++ = 0;
*dest++ = 0;
max_bytes = wcstombs(NULL, (wchar_t *) dest_saved, 0);
if (max_bytes > 0)
{
rv = wcstombs(path, (wchar_t *) dest_saved, max_bytes);
path[max_bytes] = 0;
}
g_free(dest_saved);
}
int dev_redir_string_ends_with(char *string, char c)
@ -1535,25 +1571,26 @@ void devredir_proc_cid_rename_file(IRP *irp, tui32 IoStatus)
return;
}
xstream_new(s, 1024);
/* Path in unicode needs this much space */
flen = ((g_mbstowcs(NULL, irp->gen_buf, 0) * sizeof(twchar)) / 2) + 2;
sblen = 6 + flen;
xstream_new(s, 1024 + flen);
irp->completion_type = CID_RENAME_FILE_RESP;
devredir_insert_DeviceIoRequest(s, irp->DeviceId, irp->FileId,
irp->CompletionId,
IRP_MJ_SET_INFORMATION, 0);
flen = strlen(irp->gen_buf) * 2 + 2;
sblen = 6 + flen;
xstream_wr_u32_le(s, FileRenameInformation);
xstream_wr_u32_le(s, sblen); /* Length */
xstream_wr_u32_le(s, sblen); /* number of bytes after padding */
xstream_seek(s, 24); /* padding */
xstream_wr_u8(s, 1); /* ReplaceIfExists */
xstream_wr_u8(s, 0); /* RootDirectory */
xstream_wr_u32_le(s, flen); /* FileNameLength */
/* filename in unicode */
devredir_cvt_to_unicode(s->p, irp->gen_buf);
devredir_cvt_to_unicode(s->p, irp->gen_buf); /* UNICODE_TODO */
xstream_seek(s, flen);
/* send to client */

View File

@ -104,6 +104,7 @@ env_set_user(char *username, char *passwd_file, int display)
g_set_current_dir(pw_dir);
g_sprintf(text, ":%d.0", display);
g_setenv("DISPLAY", text, 1);
g_setenv("LANG", "en_US.UTF-8", 1);
if (passwd_file != 0)
{