channels/drive: renamed to drive from disk for consistency with mstsc and accuracy (drive is more of a generic term, while disk does not apply to all)

This commit is contained in:
Marc-André Moreau 2012-11-02 19:59:07 -04:00
parent eb718a1b79
commit 3dad679330
10 changed files with 126 additions and 124 deletions

View File

@ -15,8 +15,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
define_channel("disk")
define_channel("drive")
if(WITH_CLIENT_CHANNELS)
add_channel_client(${MODULE_PREFIX} ${CHANNEL_NAME})
endif()

View File

@ -12,8 +12,8 @@ if(${OPTION_CLIENT_DEFAULT} OR ${OPTION_SERVER_DEFAULT})
set(OPTION_DEFAULT ON)
endif()
define_channel_options(NAME "disk" TYPE "device"
DESCRIPTION "Disk Redirection Virtual Channel Extension"
define_channel_options(NAME "drive" TYPE "device"
DESCRIPTION "Drive Redirection Virtual Channel Extension"
SPECIFICATIONS "[MS-RDPEFS]"
DEFAULT ${OPTION_DEFAULT})

View File

@ -15,13 +15,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
define_channel_client("disk")
define_channel_client("drive")
set(${MODULE_PREFIX}_SRCS
disk_file.c
disk_file.h
disk_main.c)
drive_file.c
drive_file.h
drive_main.c)
if(WIN32)
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS}
statvfs.c

View File

@ -53,14 +53,14 @@
#include <fcntl.h>
#endif
#include "disk_file.h"
#include "drive_file.h"
#ifdef _WIN32
#pragma warning(push)
#pragma warning(disable: 4244)
#endif
static BOOL disk_file_wildcard_match(const char* pattern, const char* filename)
static BOOL drive_file_wildcard_match(const char* pattern, const char* filename)
{
const char *p = pattern, *f = filename;
char c;
@ -89,7 +89,7 @@ static BOOL disk_file_wildcard_match(const char* pattern, const char* filename)
return FALSE;
}
static void disk_file_fix_path(char* path)
static void drive_file_fix_path(char* path)
{
int i;
int length;
@ -114,19 +114,19 @@ static void disk_file_fix_path(char* path)
path[length - 1] = '\0';
}
static char* disk_file_combine_fullpath(const char* base_path, const char* path)
static char* drive_file_combine_fullpath(const char* base_path, const char* path)
{
char* fullpath;
fullpath = (char*) malloc(strlen(base_path) + strlen(path) + 1);
strcpy(fullpath, base_path);
strcat(fullpath, path);
disk_file_fix_path(fullpath);
drive_file_fix_path(fullpath);
return fullpath;
}
static BOOL disk_file_remove_dir(const char* path)
static BOOL drive_file_remove_dir(const char* path)
{
DIR* dir;
char* p;
@ -159,7 +159,7 @@ static BOOL disk_file_remove_dir(const char* path)
}
else if (S_ISDIR(st.st_mode))
{
ret = disk_file_remove_dir(p);
ret = drive_file_remove_dir(p);
}
else if (unlink(p) < 0)
{
@ -193,7 +193,7 @@ static BOOL disk_file_remove_dir(const char* path)
return ret;
}
static void disk_file_set_fullpath(DISK_FILE* file, char* fullpath)
static void drive_file_set_fullpath(DRIVE_FILE* file, char* fullpath)
{
free(file->fullpath);
file->fullpath = fullpath;
@ -205,7 +205,7 @@ static void disk_file_set_fullpath(DISK_FILE* file, char* fullpath)
file->filename += 1;
}
static BOOL disk_file_init(DISK_FILE* file, UINT32 DesiredAccess, UINT32 CreateDisposition, UINT32 CreateOptions)
static BOOL drive_file_init(DRIVE_FILE* file, UINT32 DesiredAccess, UINT32 CreateDisposition, UINT32 CreateOptions)
{
struct STAT st;
BOOL exists;
@ -311,27 +311,27 @@ static BOOL disk_file_init(DISK_FILE* file, UINT32 DesiredAccess, UINT32 CreateD
return TRUE;
}
DISK_FILE* disk_file_new(const char* base_path, const char* path, UINT32 id,
DRIVE_FILE* drive_file_new(const char* base_path, const char* path, UINT32 id,
UINT32 DesiredAccess, UINT32 CreateDisposition, UINT32 CreateOptions)
{
DISK_FILE* file;
DRIVE_FILE* file;
file = xnew(DISK_FILE);
file = xnew(DRIVE_FILE);
file->id = id;
file->basepath = (char*) base_path;
disk_file_set_fullpath(file, disk_file_combine_fullpath(base_path, path));
drive_file_set_fullpath(file, drive_file_combine_fullpath(base_path, path));
file->fd = -1;
if (!disk_file_init(file, DesiredAccess, CreateDisposition, CreateOptions))
if (!drive_file_init(file, DesiredAccess, CreateDisposition, CreateOptions))
{
disk_file_free(file);
drive_file_free(file);
return NULL;
}
return file;
}
void disk_file_free(DISK_FILE* file)
void drive_file_free(DRIVE_FILE* file)
{
if (file->fd != -1)
close(file->fd);
@ -341,7 +341,7 @@ void disk_file_free(DISK_FILE* file)
if (file->delete_pending)
{
if (file->is_dir)
disk_file_remove_dir(file->fullpath);
drive_file_remove_dir(file->fullpath);
else
unlink(file->fullpath);
}
@ -351,7 +351,7 @@ void disk_file_free(DISK_FILE* file)
free(file);
}
BOOL disk_file_seek(DISK_FILE* file, UINT64 Offset)
BOOL drive_file_seek(DRIVE_FILE* file, UINT64 Offset)
{
if (file->is_dir || file->fd == -1)
return FALSE;
@ -362,7 +362,7 @@ BOOL disk_file_seek(DISK_FILE* file, UINT64 Offset)
return TRUE;
}
BOOL disk_file_read(DISK_FILE* file, BYTE* buffer, UINT32* Length)
BOOL drive_file_read(DRIVE_FILE* file, BYTE* buffer, UINT32* Length)
{
ssize_t r;
@ -377,7 +377,7 @@ BOOL disk_file_read(DISK_FILE* file, BYTE* buffer, UINT32* Length)
return TRUE;
}
BOOL disk_file_write(DISK_FILE* file, BYTE* buffer, UINT32 Length)
BOOL drive_file_write(DRIVE_FILE* file, BYTE* buffer, UINT32 Length)
{
ssize_t r;
@ -396,7 +396,7 @@ BOOL disk_file_write(DISK_FILE* file, BYTE* buffer, UINT32 Length)
return TRUE;
}
BOOL disk_file_query_information(DISK_FILE* file, UINT32 FsInformationClass, STREAM* output)
BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, STREAM* output)
{
struct STAT st;
@ -447,7 +447,7 @@ BOOL disk_file_query_information(DISK_FILE* file, UINT32 FsInformationClass, STR
return TRUE;
}
BOOL disk_file_set_information(DISK_FILE* file, UINT32 FsInformationClass, UINT32 Length, STREAM* input)
BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UINT32 Length, STREAM* input)
{
char* s;
@ -522,14 +522,14 @@ BOOL disk_file_set_information(DISK_FILE* file, UINT32 FsInformationClass, UINT3
freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(input), &s, FileNameLength / 2);
fullpath = disk_file_combine_fullpath(file->basepath, s);
fullpath = drive_file_combine_fullpath(file->basepath, s);
free(s);
/* TODO rename does not work on win32 */
if (rename(file->fullpath, fullpath) == 0)
{
DEBUG_SVC("renamed %s to %s", file->fullpath, fullpath);
disk_file_set_fullpath(file, fullpath);
drive_file_set_fullpath(file, fullpath);
}
else
{
@ -548,7 +548,7 @@ BOOL disk_file_set_information(DISK_FILE* file, UINT32 FsInformationClass, UINT3
return TRUE;
}
BOOL disk_file_query_directory(DISK_FILE* file, UINT32 FsInformationClass, BYTE InitialQuery,
BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYTE InitialQuery,
const char* path, STREAM* output)
{
int length;
@ -586,7 +586,7 @@ BOOL disk_file_query_directory(DISK_FILE* file, UINT32 FsInformationClass, BYTE
if (ent == NULL)
continue;
if (disk_file_wildcard_match(file->pattern, ent->d_name))
if (drive_file_wildcard_match(file->pattern, ent->d_name))
break;
} while (ent);
}

View File

@ -19,8 +19,8 @@
* limitations under the License.
*/
#ifndef __DISK_FILE_H
#define __DISK_FILE_H
#ifndef FREERDP_CHANNEL_DRIVE_FILE_H
#define FREERDP_CHANNEL_DRIVE_FILE_H
#include <sys/types.h>
#include <sys/stat.h>
@ -84,8 +84,9 @@ typedef UINT32 mode_t;
(_f->delete_pending ? FILE_ATTRIBUTE_TEMPORARY : 0) | \
(st.st_mode & S_IWUSR ? 0 : FILE_ATTRIBUTE_READONLY))
typedef struct _DISK_FILE DISK_FILE;
struct _DISK_FILE
typedef struct _DRIVE_FILE DRIVE_FILE;
struct _DRIVE_FILE
{
UINT32 id;
BOOL is_dir;
@ -99,16 +100,16 @@ struct _DISK_FILE
BOOL delete_pending;
};
DISK_FILE* disk_file_new(const char* base_path, const char* path, UINT32 id,
DRIVE_FILE* drive_file_new(const char* base_path, const char* path, UINT32 id,
UINT32 DesiredAccess, UINT32 CreateDisposition, UINT32 CreateOptions);
void disk_file_free(DISK_FILE* file);
void drive_file_free(DRIVE_FILE* file);
BOOL disk_file_seek(DISK_FILE* file, UINT64 Offset);
BOOL disk_file_read(DISK_FILE* file, BYTE* buffer, UINT32* Length);
BOOL disk_file_write(DISK_FILE* file, BYTE* buffer, UINT32 Length);
BOOL disk_file_query_information(DISK_FILE* file, UINT32 FsInformationClass, STREAM* output);
BOOL disk_file_set_information(DISK_FILE* file, UINT32 FsInformationClass, UINT32 Length, STREAM* input);
BOOL disk_file_query_directory(DISK_FILE* file, UINT32 FsInformationClass, BYTE InitialQuery,
BOOL drive_file_seek(DRIVE_FILE* file, UINT64 Offset);
BOOL drive_file_read(DRIVE_FILE* file, BYTE* buffer, UINT32* Length);
BOOL drive_file_write(DRIVE_FILE* file, BYTE* buffer, UINT32 Length);
BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, STREAM* output);
BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UINT32 Length, STREAM* input);
BOOL drive_file_query_directory(DRIVE_FILE* file, UINT32 FsInformationClass, BYTE InitialQuery,
const char* path, STREAM* output);
#endif /* __DISK_FILE_H */
#endif /* FREERDP_CHANNEL_DRIVE_FILE_H */

View File

@ -47,11 +47,11 @@
#include <winpr/thread.h>
#include <winpr/interlocked.h>
#include "disk_file.h"
#include "drive_file.h"
typedef struct _DISK_DEVICE DISK_DEVICE;
typedef struct _DRIVE_DEVICE DRIVE_DEVICE;
struct _DISK_DEVICE
struct _DRIVE_DEVICE
{
DEVICE device;
@ -66,7 +66,7 @@ struct _DISK_DEVICE
DEVMAN* devman;
};
static UINT32 disk_map_posix_err(int fs_errno)
static UINT32 drive_map_posix_err(int fs_errno)
{
UINT32 rc;
@ -101,14 +101,14 @@ static UINT32 disk_map_posix_err(int fs_errno)
return rc;
}
static DISK_FILE* disk_get_file_by_id(DISK_DEVICE* disk, UINT32 id)
static DRIVE_FILE* drive_get_file_by_id(DRIVE_DEVICE* disk, UINT32 id)
{
LIST_ITEM* item;
DISK_FILE* file;
DRIVE_FILE* file;
for (item = disk->files->head; item; item = item->next)
{
file = (DISK_FILE*) item->data;
file = (DRIVE_FILE*) item->data;
if (file->id == id)
return file;
@ -117,11 +117,11 @@ static DISK_FILE* disk_get_file_by_id(DISK_DEVICE* disk, UINT32 id)
return NULL;
}
static void disk_process_irp_create(DISK_DEVICE* disk, IRP* irp)
static void drive_process_irp_create(DRIVE_DEVICE* disk, IRP* irp)
{
char* path;
UINT32 FileId;
DISK_FILE* file;
DRIVE_FILE* file;
BYTE Information;
UINT32 DesiredAccess;
UINT32 CreateDisposition;
@ -138,7 +138,7 @@ static void disk_process_irp_create(DISK_DEVICE* disk, IRP* irp)
FileId = irp->devman->id_sequence++;
file = disk_file_new(disk->path, path, FileId,
file = drive_file_new(disk->path, path, FileId,
DesiredAccess, CreateDisposition, CreateOptions);
if (file == NULL)
@ -155,8 +155,8 @@ static void disk_process_irp_create(DISK_DEVICE* disk, IRP* irp)
Information = 0;
/* map errno to windows result */
irp->IoStatus = disk_map_posix_err(file->err);
disk_file_free(file);
irp->IoStatus = drive_map_posix_err(file->err);
drive_file_free(file);
}
else
{
@ -191,11 +191,11 @@ static void disk_process_irp_create(DISK_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void disk_process_irp_close(DISK_DEVICE* disk, IRP* irp)
static void drive_process_irp_close(DRIVE_DEVICE* disk, IRP* irp)
{
DISK_FILE* file;
DRIVE_FILE* file;
file = disk_get_file_by_id(disk, irp->FileId);
file = drive_get_file_by_id(disk, irp->FileId);
if (file == NULL)
{
@ -208,7 +208,7 @@ static void disk_process_irp_close(DISK_DEVICE* disk, IRP* irp)
DEBUG_SVC("%s(%d) closed.", file->fullpath, file->id);
list_remove(disk->files, file);
disk_file_free(file);
drive_file_free(file);
}
stream_write_zero(irp->output, 5); /* Padding(5) */
@ -216,9 +216,9 @@ static void disk_process_irp_close(DISK_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void disk_process_irp_read(DISK_DEVICE* disk, IRP* irp)
static void drive_process_irp_read(DRIVE_DEVICE* disk, IRP* irp)
{
DISK_FILE* file;
DRIVE_FILE* file;
UINT32 Length;
UINT64 Offset;
BYTE* buffer = NULL;
@ -226,7 +226,7 @@ static void disk_process_irp_read(DISK_DEVICE* disk, IRP* irp)
stream_read_UINT32(irp->input, Length);
stream_read_UINT64(irp->input, Offset);
file = disk_get_file_by_id(disk, irp->FileId);
file = drive_get_file_by_id(disk, irp->FileId);
if (file == NULL)
{
@ -235,7 +235,7 @@ static void disk_process_irp_read(DISK_DEVICE* disk, IRP* irp)
DEBUG_WARN("FileId %d not valid.", irp->FileId);
}
else if (!disk_file_seek(file, Offset))
else if (!drive_file_seek(file, Offset))
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
Length = 0;
@ -245,7 +245,7 @@ static void disk_process_irp_read(DISK_DEVICE* disk, IRP* irp)
else
{
buffer = (BYTE*) malloc(Length);
if (!disk_file_read(file, buffer, &Length))
if (!drive_file_read(file, buffer, &Length))
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
free(buffer);
@ -273,9 +273,9 @@ static void disk_process_irp_read(DISK_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void disk_process_irp_write(DISK_DEVICE* disk, IRP* irp)
static void drive_process_irp_write(DRIVE_DEVICE* disk, IRP* irp)
{
DISK_FILE* file;
DRIVE_FILE* file;
UINT32 Length;
UINT64 Offset;
@ -283,7 +283,7 @@ static void disk_process_irp_write(DISK_DEVICE* disk, IRP* irp)
stream_read_UINT64(irp->input, Offset);
stream_seek(irp->input, 20); /* Padding */
file = disk_get_file_by_id(disk, irp->FileId);
file = drive_get_file_by_id(disk, irp->FileId);
if (file == NULL)
{
@ -292,14 +292,14 @@ static void disk_process_irp_write(DISK_DEVICE* disk, IRP* irp)
DEBUG_WARN("FileId %d not valid.", irp->FileId);
}
else if (!disk_file_seek(file, Offset))
else if (!drive_file_seek(file, Offset))
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
Length = 0;
DEBUG_WARN("seek %s(%d) failed.", file->fullpath, file->id);
}
else if (!disk_file_write(file, stream_get_tail(irp->input), Length))
else if (!drive_file_write(file, stream_get_tail(irp->input), Length))
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
Length = 0;
@ -317,14 +317,14 @@ static void disk_process_irp_write(DISK_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void disk_process_irp_query_information(DISK_DEVICE* disk, IRP* irp)
static void drive_process_irp_query_information(DRIVE_DEVICE* disk, IRP* irp)
{
DISK_FILE* file;
DRIVE_FILE* file;
UINT32 FsInformationClass;
stream_read_UINT32(irp->input, FsInformationClass);
file = disk_get_file_by_id(disk, irp->FileId);
file = drive_get_file_by_id(disk, irp->FileId);
if (file == NULL)
{
@ -332,7 +332,7 @@ static void disk_process_irp_query_information(DISK_DEVICE* disk, IRP* irp)
DEBUG_WARN("FileId %d not valid.", irp->FileId);
}
else if (!disk_file_query_information(file, FsInformationClass, irp->output))
else if (!drive_file_query_information(file, FsInformationClass, irp->output))
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
@ -346,9 +346,9 @@ static void disk_process_irp_query_information(DISK_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void disk_process_irp_set_information(DISK_DEVICE* disk, IRP* irp)
static void drive_process_irp_set_information(DRIVE_DEVICE* disk, IRP* irp)
{
DISK_FILE* file;
DRIVE_FILE* file;
UINT32 FsInformationClass;
UINT32 Length;
@ -356,7 +356,7 @@ static void disk_process_irp_set_information(DISK_DEVICE* disk, IRP* irp)
stream_read_UINT32(irp->input, Length);
stream_seek(irp->input, 24); /* Padding */
file = disk_get_file_by_id(disk, irp->FileId);
file = drive_get_file_by_id(disk, irp->FileId);
if (file == NULL)
{
@ -364,7 +364,7 @@ static void disk_process_irp_set_information(DISK_DEVICE* disk, IRP* irp)
DEBUG_WARN("FileId %d not valid.", irp->FileId);
}
else if (!disk_file_set_information(file, FsInformationClass, Length, irp->input))
else if (!drive_file_set_information(file, FsInformationClass, Length, irp->input))
{
irp->IoStatus = STATUS_UNSUCCESSFUL;
@ -380,7 +380,7 @@ static void disk_process_irp_set_information(DISK_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* irp)
static void drive_process_irp_query_volume_information(DRIVE_DEVICE* disk, IRP* irp)
{
UINT32 FsInformationClass;
STREAM* output = irp->output;
@ -466,10 +466,10 @@ static void disk_process_irp_query_volume_information(DISK_DEVICE* disk, IRP* ir
irp->Complete(irp);
}
static void disk_process_irp_query_directory(DISK_DEVICE* disk, IRP* irp)
static void drive_process_irp_query_directory(DRIVE_DEVICE* disk, IRP* irp)
{
char* path;
DISK_FILE* file;
DRIVE_FILE* file;
BYTE InitialQuery;
UINT32 PathLength;
UINT32 FsInformationClass;
@ -481,7 +481,7 @@ static void disk_process_irp_query_directory(DISK_DEVICE* disk, IRP* irp)
freerdp_UnicodeToAsciiAlloc((WCHAR*) stream_get_tail(irp->input), &path, PathLength / 2);
file = disk_get_file_by_id(disk, irp->FileId);
file = drive_get_file_by_id(disk, irp->FileId);
if (file == NULL)
{
@ -489,7 +489,7 @@ static void disk_process_irp_query_directory(DISK_DEVICE* disk, IRP* irp)
stream_write_UINT32(irp->output, 0); /* Length */
DEBUG_WARN("FileId %d not valid.", irp->FileId);
}
else if (!disk_file_query_directory(file, FsInformationClass, InitialQuery, path, irp->output))
else if (!drive_file_query_directory(file, FsInformationClass, InitialQuery, path, irp->output))
{
irp->IoStatus = STATUS_NO_MORE_FILES;
}
@ -499,12 +499,12 @@ static void disk_process_irp_query_directory(DISK_DEVICE* disk, IRP* irp)
irp->Complete(irp);
}
static void disk_process_irp_directory_control(DISK_DEVICE* disk, IRP* irp)
static void drive_process_irp_directory_control(DRIVE_DEVICE* disk, IRP* irp)
{
switch (irp->MinorFunction)
{
case IRP_MN_QUERY_DIRECTORY:
disk_process_irp_query_directory(disk, irp);
drive_process_irp_query_directory(disk, irp);
break;
case IRP_MN_NOTIFY_CHANGE_DIRECTORY: /* TODO */
@ -520,52 +520,52 @@ static void disk_process_irp_directory_control(DISK_DEVICE* disk, IRP* irp)
}
}
static void disk_process_irp_device_control(DISK_DEVICE* disk, IRP* irp)
static void drive_process_irp_device_control(DRIVE_DEVICE* disk, IRP* irp)
{
stream_write_UINT32(irp->output, 0); /* OutputBufferLength */
irp->Complete(irp);
}
static void disk_process_irp(DISK_DEVICE* disk, IRP* irp)
static void drive_process_irp(DRIVE_DEVICE* disk, IRP* irp)
{
irp->IoStatus = STATUS_SUCCESS;
switch (irp->MajorFunction)
{
case IRP_MJ_CREATE:
disk_process_irp_create(disk, irp);
drive_process_irp_create(disk, irp);
break;
case IRP_MJ_CLOSE:
disk_process_irp_close(disk, irp);
drive_process_irp_close(disk, irp);
break;
case IRP_MJ_READ:
disk_process_irp_read(disk, irp);
drive_process_irp_read(disk, irp);
break;
case IRP_MJ_WRITE:
disk_process_irp_write(disk, irp);
drive_process_irp_write(disk, irp);
break;
case IRP_MJ_QUERY_INFORMATION:
disk_process_irp_query_information(disk, irp);
drive_process_irp_query_information(disk, irp);
break;
case IRP_MJ_SET_INFORMATION:
disk_process_irp_set_information(disk, irp);
drive_process_irp_set_information(disk, irp);
break;
case IRP_MJ_QUERY_VOLUME_INFORMATION:
disk_process_irp_query_volume_information(disk, irp);
drive_process_irp_query_volume_information(disk, irp);
break;
case IRP_MJ_DIRECTORY_CONTROL:
disk_process_irp_directory_control(disk, irp);
drive_process_irp_directory_control(disk, irp);
break;
case IRP_MJ_DEVICE_CONTROL:
disk_process_irp_device_control(disk, irp);
drive_process_irp_device_control(disk, irp);
break;
default:
@ -576,7 +576,7 @@ static void disk_process_irp(DISK_DEVICE* disk, IRP* irp)
}
}
static void disk_process_irp_list(DISK_DEVICE* disk)
static void drive_process_irp_list(DRIVE_DEVICE* disk)
{
IRP* irp;
@ -590,13 +590,13 @@ static void disk_process_irp_list(DISK_DEVICE* disk)
if (irp == NULL)
break;
disk_process_irp(disk, irp);
drive_process_irp(disk, irp);
}
}
static void* disk_thread_func(void* arg)
static void* drive_thread_func(void* arg)
{
DISK_DEVICE* disk = (DISK_DEVICE*) arg;
DRIVE_DEVICE* disk = (DRIVE_DEVICE*) arg;
while (1)
{
@ -606,26 +606,26 @@ static void* disk_thread_func(void* arg)
break;
ResetEvent(disk->irpEvent);
disk_process_irp_list(disk);
drive_process_irp_list(disk);
}
return NULL;
}
static void disk_irp_request(DEVICE* device, IRP* irp)
static void drive_irp_request(DEVICE* device, IRP* irp)
{
DISK_DEVICE* disk = (DISK_DEVICE*) device;
DRIVE_DEVICE* disk = (DRIVE_DEVICE*) device;
InterlockedPushEntrySList(disk->pIrpList, &(irp->ItemEntry));
SetEvent(disk->irpEvent);
}
static void disk_free(DEVICE* device)
static void drive_free(DEVICE* device)
{
IRP* irp;
DISK_FILE* file;
DISK_DEVICE* disk = (DISK_DEVICE*) device;
DRIVE_FILE* file;
DRIVE_DEVICE* disk = (DRIVE_DEVICE*) device;
SetEvent(disk->stopEvent);
CloseHandle(disk->thread);
@ -636,17 +636,17 @@ static void disk_free(DEVICE* device)
_aligned_free(disk->pIrpList);
while ((file = (DISK_FILE*) list_dequeue(disk->files)) != NULL)
disk_file_free(file);
while ((file = (DRIVE_FILE*) list_dequeue(disk->files)) != NULL)
drive_file_free(file);
list_free(disk->files);
free(disk);
}
void disk_register_disk_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char* name, char* path)
void drive_register_drive_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char* name, char* path)
{
int i, length;
DISK_DEVICE* disk;
DRIVE_DEVICE* disk;
#ifdef WIN32
/*
@ -664,12 +664,12 @@ void disk_register_disk_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char* na
if (name[0] && path[0])
{
disk = xnew(DISK_DEVICE);
disk = xnew(DRIVE_DEVICE);
disk->device.type = RDPDR_DTYP_FILESYSTEM;
disk->device.name = name;
disk->device.IRPRequest = disk_irp_request;
disk->device.Free = disk_free;
disk->device.IRPRequest = drive_irp_request;
disk->device.Free = drive_free;
length = strlen(name);
disk->device.data = stream_new(length + 1);
@ -685,7 +685,7 @@ void disk_register_disk_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char* na
disk->irpEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
disk->stopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
disk->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) disk_thread_func, disk, CREATE_SUSPENDED, NULL);
disk->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) drive_thread_func, disk, CREATE_SUSPENDED, NULL);
pEntryPoints->RegisterDevice(pEntryPoints->devman, (DEVICE*) disk);
@ -694,7 +694,7 @@ void disk_register_disk_path(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints, char* na
}
#ifdef STATIC_CHANNELS
#define DeviceServiceEntry disk_DeviceServiceEntry
#define DeviceServiceEntry drive_DeviceServiceEntry
#endif
int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
@ -711,14 +711,14 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
path = (char*) pEntryPoints->plugin_data->data[2];
#ifndef WIN32
disk_register_disk_path(pEntryPoints, name, path);
drive_register_drive_path(pEntryPoints, name, path);
#else
/* Special case: path[0] == '*' -> export all drives */
/* Special case: path[0] == '%' -> user home dir */
if( path[0] == '%' )
{
_snprintf(buf, sizeof(buf), "%s\\", getenv("USERPROFILE"));
disk_register_disk_path(pEntryPoints, name, _strdup(buf));
drive_register_drive_path(pEntryPoints, name, _strdup(buf));
}
else if( path[0] == '*' )
{
@ -738,13 +738,13 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
buf[len + 1] = dev[0];
buf[len + 2] = 0;
buf[len + 3] = 0;
disk_register_disk_path(pEntryPoints, _strdup(buf), _strdup(dev));
drive_register_drive_path(pEntryPoints, _strdup(buf), _strdup(dev));
}
}
}
else
{
disk_register_disk_path(pEntryPoints, name, path);
drive_register_drive_path(pEntryPoints, name, path);
}
#endif

View File

@ -1,3 +1,3 @@
LIBRARY "disk"
LIBRARY "drive"
EXPORTS
DeviceServiceEntry @1

View File

@ -1,6 +1,6 @@
/**
* FreeRDP: A Remote Desktop Protocol Implementation
* statvfs emulation für windows
* statvfs emulation for Windows
*
* Copyright 2012 Gerald Richter
*