Move to attributes rather than type.

This commit is contained in:
Michael Jumper 2013-08-02 17:23:09 -07:00
parent 32fdcdc660
commit 439cd7c903
5 changed files with 48 additions and 52 deletions

View File

@ -115,6 +115,7 @@ int guac_rdpdr_fs_open(guac_rdpdr_device* device, const char* path,
guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data; guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data;
char real_path[GUAC_RDPDR_FS_MAX_PATH]; char real_path[GUAC_RDPDR_FS_MAX_PATH];
char normalized_path[GUAC_RDPDR_FS_MAX_PATH]; char normalized_path[GUAC_RDPDR_FS_MAX_PATH];
char* filename;
struct stat file_stat; struct stat file_stat;
int fd; int fd;
@ -193,14 +194,17 @@ int guac_rdpdr_fs_open(guac_rdpdr_device* device, const char* path,
/* Translate normalized path to real path */ /* Translate normalized path to real path */
__guac_rdpdr_fs_translate_path(device, normalized_path, real_path); __guac_rdpdr_fs_translate_path(device, normalized_path, real_path);
guac_client_log_info(device->rdpdr->client,
"Path virtual=\"%s\" -> normalized=\"%s\", real=\"%s\"",
path, normalized_path, real_path);
/* Open file */ /* Open file */
fd = open(real_path, flags, mode); fd = open(real_path, flags, mode);
if (fd == -1) if (fd == -1) {
guac_client_log_error(device->rdpdr->client,
"Open of real file failed: \"%s\"", real_path);
return GUAC_RDPDR_FS_ENOENT; return GUAC_RDPDR_FS_ENOENT;
}
else
guac_client_log_info(device->rdpdr->client,
"Opened real file: \"%s\"", real_path);
/* Get file ID, init file */ /* Get file ID, init file */
file_id = guac_pool_next_int(data->file_id_pool); file_id = guac_pool_next_int(data->file_id_pool);
@ -209,20 +213,27 @@ int guac_rdpdr_fs_open(guac_rdpdr_device* device, const char* path,
file->dir = NULL; file->dir = NULL;
file->absolute_path = strdup(normalized_path); file->absolute_path = strdup(normalized_path);
/* Parse out filename */
filename = file->absolute_path;
while (*filename != '\\' && *filename != '/' && *filename != 0)
filename++;
file->name = filename;
/* Attempt to pull file information */ /* Attempt to pull file information */
if (fstat(fd, &file_stat) == 0) { if (fstat(fd, &file_stat) == 0) {
/* Load size and times */ /* Load size and times */
file->size = file_stat.st_size; file->size = file_stat.st_size;
file->ctime = file_stat.st_ctime; file->ctime = WINDOWS_TIME(file_stat.st_ctime);
file->mtime = file_stat.st_mtime; file->mtime = WINDOWS_TIME(file_stat.st_mtime);
file->atime = file_stat.st_atime; file->atime = WINDOWS_TIME(file_stat.st_atime);
/* Set type */ /* Set type */
if (S_ISDIR(file_stat.st_mode)) if (S_ISDIR(file_stat.st_mode))
file->type = GUAC_RDPDR_FS_DIRECTORY; file->attributes = FILE_ATTRIBUTE_DIRECTORY;
else else
file->type = GUAC_RDPDR_FS_FILE; file->attributes = FILE_ATTRIBUTE_NORMAL;
} }
@ -237,7 +248,7 @@ int guac_rdpdr_fs_open(guac_rdpdr_device* device, const char* path,
file->ctime = 0; file->ctime = 0;
file->mtime = 0; file->mtime = 0;
file->atime = 0; file->atime = 0;
file->type = GUAC_RDPDR_FS_FILE; file->attributes = FILE_ATTRIBUTE_NORMAL;
} }

View File

@ -138,38 +138,22 @@
*/ */
#define WINDOWS_TIME(t) ((t - ((uint64_t) 11644473600)) * 10000000) #define WINDOWS_TIME(t) ((t - ((uint64_t) 11644473600)) * 10000000)
/**
* Enumeration of all supported file types.
*/
typedef enum guac_rdpdr_fs_file_type {
/**
* A regular file.
*/
GUAC_RDPDR_FS_FILE,
/**
* A directory.
*/
GUAC_RDPDR_FS_DIRECTORY
} guac_rdpdr_fs_file_type;
/** /**
* An arbitrary file on the virtual filesystem of the Guacamole drive. * An arbitrary file on the virtual filesystem of the Guacamole drive.
*/ */
typedef struct guac_rdpdr_fs_file { typedef struct guac_rdpdr_fs_file {
/**
* The filename of this file. The data of this name is actually stored
* within the absolute_path.
*/
char* name;
/** /**
* The absolute path, including filename, of this file. * The absolute path, including filename, of this file.
*/ */
char* absolute_path; char* absolute_path;
/**
* The type of this file.
*/
guac_rdpdr_fs_file_type type;
/** /**
* Associated local file descriptor. * Associated local file descriptor.
*/ */
@ -187,25 +171,30 @@ typedef struct guac_rdpdr_fs_file {
*/ */
struct dirent __dirent; struct dirent __dirent;
/**
* Bitwise OR of all associated Windows file attributes.
*/
int attributes;
/** /**
* The size of this file, in bytes. * The size of this file, in bytes.
*/ */
off_t size; int size;
/** /**
* The time this file was created, as a UNIX timestamp. * The time this file was created, as a Windows timestamp.
*/ */
time_t ctime; uint64_t ctime;
/** /**
* The time this file was last modified, as a UNIX timestamp. * The time this file was last modified, as a Windows timestamp.
*/ */
time_t mtime; uint64_t mtime;
/** /**
* The time this file was last accessed, as a UNIX timestamp. * The time this file was last accessed, as a Windows timestamp.
*/ */
time_t atime; uint64_t atime;
} guac_rdpdr_fs_file; } guac_rdpdr_fs_file;

View File

@ -69,16 +69,11 @@ void guac_rdpdr_fs_process_query_basic_info(guac_rdpdr_device* device, wStream*
Stream_Write_UINT32(output_stream, STATUS_SUCCESS); Stream_Write_UINT32(output_stream, STATUS_SUCCESS);
Stream_Write_UINT32(output_stream, 18 + GUAC_FILESYSTEM_NAME_LENGTH); Stream_Write_UINT32(output_stream, 18 + GUAC_FILESYSTEM_NAME_LENGTH);
Stream_Write_UINT64(output_stream, WINDOWS_TIME(file->ctime)); /* CreationTime */ Stream_Write_UINT64(output_stream, file->ctime); /* CreationTime */
Stream_Write_UINT64(output_stream, WINDOWS_TIME(file->atime)); /* LastAccessTime */ Stream_Write_UINT64(output_stream, file->atime); /* LastAccessTime */
Stream_Write_UINT64(output_stream, WINDOWS_TIME(file->mtime)); /* LastWriteTime */ Stream_Write_UINT64(output_stream, file->mtime); /* LastWriteTime */
Stream_Write_UINT64(output_stream, WINDOWS_TIME(file->mtime)); /* ChangeTime */ Stream_Write_UINT64(output_stream, file->mtime); /* ChangeTime */
Stream_Write_UINT32(output_stream, file->attributes); /* FileAttributes */
/* FileAttributes */
if (file->type == GUAC_RDPDR_FS_DIRECTORY)
Stream_Write_UINT32(output_stream, FILE_ATTRIBUTE_DIRECTORY);
else
Stream_Write_UINT32(output_stream, FILE_ATTRIBUTE_NORMAL); /* FileAttributes */
/* Reserved */ /* Reserved */
Stream_Write_UINT32(output_stream, 0); Stream_Write_UINT32(output_stream, 0);

View File

@ -68,7 +68,7 @@ void guac_rdpdr_fs_process_query_volume_info(guac_rdpdr_device* device, wStream*
Stream_Write_UINT32(output_stream, STATUS_SUCCESS); Stream_Write_UINT32(output_stream, STATUS_SUCCESS);
Stream_Write_UINT32(output_stream, 18 + GUAC_FILESYSTEM_NAME_LENGTH); Stream_Write_UINT32(output_stream, 18 + GUAC_FILESYSTEM_NAME_LENGTH);
Stream_Write_UINT64(output_stream, WINDOWS_TIME(file->ctime)); /* VolumeCreationTime */ Stream_Write_UINT64(output_stream, file->ctime); /* VolumeCreationTime */
Stream_Write(output_stream, "GUAC", 4); /* VolumeSerialNumber */ Stream_Write(output_stream, "GUAC", 4); /* VolumeSerialNumber */
Stream_Write_UINT32(output_stream, GUAC_FILESYSTEM_NAME_LENGTH); Stream_Write_UINT32(output_stream, GUAC_FILESYSTEM_NAME_LENGTH);
Stream_Write_UINT8(output_stream, FALSE); /* SupportsObjects */ Stream_Write_UINT8(output_stream, FALSE); /* SupportsObjects */

View File

@ -196,6 +196,7 @@
* Status constants. * Status constants.
*/ */
#define STATUS_SUCCESS 0x00000000 #define STATUS_SUCCESS 0x00000000
#define STATUS_NO_MORE_FILES 0x80000006
#define STATUS_DEVICE_OFF_LINE 0x80000010 #define STATUS_DEVICE_OFF_LINE 0x80000010
#define STATUS_NO_SUCH_FILE 0xC000000F #define STATUS_NO_SUCH_FILE 0xC000000F
#define STATUS_END_OF_FILE 0xC0000011 #define STATUS_END_OF_FILE 0xC0000011