--- sourceforge.net/trunk/rdesktop/disk.c 2004/02/06 10:41:34 600 +++ sourceforge.net/trunk/rdesktop/disk.c 2004/02/23 10:34:18 613 @@ -84,7 +84,7 @@ #define SOLARIS #endif -#ifdef SOLARIS +#if (defined(SOLARIS) || defined(__hpux)) #define DIRFD(a) ((a)->dd_fd) #else #define DIRFD(a) (dirfd(a)) @@ -102,7 +102,7 @@ #include /* ctime */ -#if defined(SOLARIS) +#if (defined(SOLARIS) || defined (__hpux) || defined(__BEOS__)) #include /* solaris statvfs */ #define STATFS_FN(path, buf) (statvfs(path,buf)) #define STATFS_T statvfs @@ -137,7 +137,6 @@ } g_fileinfo[MAX_OPEN_FILES]; - time_t get_create_time(struct stat *st) { @@ -182,10 +181,10 @@ /* Enumeration of devices from rdesktop.c */ /* returns numer of units found and initialized. */ -/* optarg looks like ':h:=/mnt/floppy,b:=/mnt/usbdevice1' */ +/* optarg looks like ':h=/mnt/floppy,b=/mnt/usbdevice1' */ /* when it arrives to this function. */ int -disk_enum_devices(int *id, char *optarg) +disk_enum_devices(uint32 * id, char *optarg) { char *pos = optarg; char *pos2; @@ -341,6 +340,9 @@ case ENOENT: return STATUS_NO_SUCH_FILE; + case EEXIST: + + return STATUS_OBJECT_NAME_COLLISION; default: perror("open"); @@ -405,8 +407,8 @@ } #endif - if (offset) - lseek(handle, offset, SEEK_SET); + lseek(handle, offset, SEEK_SET); + n = read(handle, data, length); if (n < 0) @@ -432,8 +434,7 @@ { int n; - if (offset) - lseek(handle, offset, SEEK_SET); + lseek(handle, offset, SEEK_SET); n = write(handle, data, length); @@ -547,6 +548,7 @@ struct stat filestat; time_t write_time, change_time, access_time, mod_time; struct utimbuf tvs; + struct STATFS_T stat_fs; pfinfo = &(g_fileinfo[handle]); @@ -629,6 +631,12 @@ if (fchmod(handle, mode)) return STATUS_ACCESS_DENIED; + + /* prevents start of writing if not enough space left on device */ + if (STATFS_FN(g_rdpdr_device[pfinfo->device_id].local_path, &stat_fs) == 0) + if (stat_fs.f_bsize * stat_fs.f_bfree < length) + return STATUS_DISK_FULL; + break; case 10: /* FileRenameInformation */ @@ -660,9 +668,17 @@ case 13: /* FileDispositionInformation */ //unimpl("IRP Set File Information class: FileDispositionInformation\n"); - // in_uint32_le(in, delete_on_close); + + //in_uint32_le(in, delete_on_close); // disk_close(handle); - unlink(pfinfo->path); + if ((pfinfo->flags_and_attributes & FILE_DIRECTORY_FILE)) // remove a directory + { + if (rmdir(pfinfo->path) < 0) + return STATUS_ACCESS_DENIED; + } + else if (unlink(pfinfo->path) < 0) // unlink a file + return STATUS_ACCESS_DENIED; + break; case 19: /* FileAllocationInformation */