int devredir_rmdir_or_file(void *fusep, tui32 device_id, char *path, int mode) { tui32 DesiredAccess; tui32 CreateOptions; tui32 CreateDisposition; int rval; IRP *irp; if ((irp = devredir_irp_new()) == NULL) return -1; irp->CompletionId = g_completion_id++; irp->completion_type = CID_RMDIR_OR_FILE; irp->DeviceId = device_id; strcpy(irp->pathname, path); dev_redir_fuse_data_enqueue(irp, fusep); //DesiredAccess = DA_DELETE | DA_FILE_READ_ATTRIBUTES | DA_SYNCHRONIZE; DesiredAccess = 0x00100080; /* got this value from windows */ //CreateOptions = CO_FILE_DELETE_ON_CLOSE | CO_FILE_DIRECTORY_FILE | // CO_FILE_SYNCHRONOUS_IO_NONALERT; CreateOptions = 0x020; /* got this value from windows */ //CreateDisposition = CD_FILE_OPEN; // WAS 1 CreateDisposition = 0x01; /* got this value from windows */ rval = dev_redir_send_drive_create_request(device_id, path, DesiredAccess, CreateOptions, CreateDisposition, irp->CompletionId); return rval; }
int APP_CC dev_redir_get_dir_listing(void *fusep, tui32 device_id, const char *path) { tui32 DesiredAccess; tui32 CreateOptions; tui32 CreateDisposition; int rval; IRP *irp; log_debug("fusep=%p", fusep); if ((irp = devredir_irp_new()) == NULL) return -1; 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; 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, irp->pathname, DesiredAccess, CreateOptions, CreateDisposition, irp->CompletionId); 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 */ /* at the end of the path argument */ if (dev_redir_string_ends_with(irp->pathname, '\\')) strcat(irp->pathname, "*"); else strcat(irp->pathname, "\\*"); return rval; }
int dev_redir_file_open(void *fusep, tui32 device_id, char *path, int mode, int type, char *gen_buf) { tui32 DesiredAccess; tui32 CreateOptions; tui32 CreateDisposition; int rval; IRP *irp; log_debug("device_id=%d path=%s mode=0x%x", device_id, path, mode); if ((irp = devredir_irp_new()) == NULL) return -1; if (type & OP_RENAME_FILE) { irp->completion_type = CID_RENAME_FILE; strcpy(irp->gen_buf, gen_buf); } else { irp->completion_type = CID_CREATE_OPEN_REQ; } irp->CompletionId = g_completion_id++; irp->DeviceId = device_id; strcpy(irp->pathname, path); dev_redir_fuse_data_enqueue(irp, fusep); if (mode & O_CREAT) { log_debug("open file in O_CREAT"); DesiredAccess = 0x0016019f; /* got this value from windows */ if (type & S_IFDIR) { log_debug("creating dir"); CreateOptions = CO_FILE_DIRECTORY_FILE | CO_FILE_SYNCHRONOUS_IO_NONALERT; irp->type = S_IFDIR; } else { log_debug("creating file"); CreateOptions = 0x44; /* got this value from windows */ } //CreateDisposition = CD_FILE_CREATE; CreateDisposition = 0x02; /* got this value from windows */ } else //if (mode & O_RDWR) { log_debug("open file in O_RDWR"); #if 1 DesiredAccess = DA_FILE_READ_DATA | DA_FILE_WRITE_DATA | DA_SYNCHRONIZE; CreateOptions = CO_FILE_SYNCHRONOUS_IO_NONALERT; CreateDisposition = CD_FILE_OPEN; // WAS 1 #else /* got this value from windows */ DesiredAccess = 0x00120089; CreateOptions = 0x20060; CreateDisposition = 0x01; #endif } rval = dev_redir_send_drive_create_request(device_id, path, DesiredAccess, CreateOptions, CreateDisposition, irp->CompletionId); return rval; }