104 |
|
|
105 |
#if (defined(SOLARIS) || defined (__hpux) || defined(__BEOS__)) |
#if (defined(SOLARIS) || defined (__hpux) || defined(__BEOS__)) |
106 |
#include <sys/statvfs.h> /* solaris statvfs */ |
#include <sys/statvfs.h> /* solaris statvfs */ |
107 |
|
#include <sys/mntent.h> |
108 |
|
#define HAVE_MNTENT_H |
109 |
|
#define MNTENT_PATH "/etc/mnttab" |
110 |
#define STATFS_FN(path, buf) (statvfs(path,buf)) |
#define STATFS_FN(path, buf) (statvfs(path,buf)) |
111 |
#define STATFS_T statvfs |
#define STATFS_T statvfs |
112 |
#define F_NAMELEN(buf) ((buf).f_namemax) |
#define F_NAMELEN(buf) ((buf).f_namemax) |
120 |
|
|
121 |
#else |
#else |
122 |
#include <sys/vfs.h> /* linux statfs */ |
#include <sys/vfs.h> /* linux statfs */ |
123 |
|
#include <mntent.h> |
124 |
|
#define HAVE_MNTENT_H |
125 |
|
#define MNTENT_PATH "/etc/mtab" |
126 |
#define STATFS_FN(path, buf) (statfs(path,buf)) |
#define STATFS_FN(path, buf) (statfs(path,buf)) |
127 |
#define STATFS_T statfs |
#define STATFS_T statfs |
128 |
#define F_NAMELEN(buf) ((buf).f_namelen) |
#define F_NAMELEN(buf) ((buf).f_namelen) |
143 |
} |
} |
144 |
g_fileinfo[MAX_OPEN_FILES]; |
g_fileinfo[MAX_OPEN_FILES]; |
145 |
|
|
146 |
|
typedef struct |
147 |
|
{ |
148 |
|
char name[256]; |
149 |
|
char label[256]; |
150 |
|
unsigned long serial; |
151 |
|
char type[256]; |
152 |
|
} FsInfoType; |
153 |
|
|
154 |
|
|
155 |
time_t |
time_t |
156 |
get_create_time(struct stat *st) |
get_create_time(struct stat *st) |
157 |
{ |
{ |
718 |
return STATUS_SUCCESS; |
return STATUS_SUCCESS; |
719 |
} |
} |
720 |
|
|
721 |
|
FsInfoType * |
722 |
|
FsVolumeInfo(char *fpath) |
723 |
|
{ |
724 |
|
|
725 |
|
#ifdef HAVE_MNTENT_H |
726 |
|
FILE *fdfs; |
727 |
|
struct mntent *e; |
728 |
|
static FsInfoType info; |
729 |
|
|
730 |
|
/* initialize */ |
731 |
|
memset(&info, 0, sizeof(info)); |
732 |
|
strcpy(info.label, "RDESKTOP"); |
733 |
|
strcpy(info.type, "RDPFS"); |
734 |
|
|
735 |
|
fdfs = setmntent(MNTENT_PATH, "r"); |
736 |
|
if (!fdfs) |
737 |
|
return &info; |
738 |
|
|
739 |
|
while ((e = getmntent(fdfs))) |
740 |
|
{ |
741 |
|
if (strncmp(fpath, e->mnt_dir, strlen(fpath)) == 0) |
742 |
|
{ |
743 |
|
strcpy(info.type, e->mnt_type); |
744 |
|
strcpy(info.name, e->mnt_fsname); |
745 |
|
if (strstr(e->mnt_opts, "vfat") || strstr(e->mnt_opts, "iso9660")) |
746 |
|
{ |
747 |
|
int fd = open(e->mnt_fsname, O_RDONLY); |
748 |
|
if (fd >= 0) |
749 |
|
{ |
750 |
|
unsigned char buf[512]; |
751 |
|
memset(buf, 0, sizeof(buf)); |
752 |
|
if (strstr(e->mnt_opts, "vfat")) |
753 |
|
/*FAT*/ |
754 |
|
{ |
755 |
|
strcpy(info.type, "vfat"); |
756 |
|
read(fd, buf, sizeof(buf)); |
757 |
|
info.serial = |
758 |
|
(buf[42] << 24) + (buf[41] << 16) + |
759 |
|
(buf[40] << 8) + buf[39]; |
760 |
|
strncpy(info.label, buf + 43, 10); |
761 |
|
info.label[10] = '\0'; |
762 |
|
} |
763 |
|
else if (lseek(fd, 32767, SEEK_SET) >= 0) /* ISO9660 */ |
764 |
|
{ |
765 |
|
read(fd, buf, sizeof(buf)); |
766 |
|
strncpy(info.label, buf + 41, 32); |
767 |
|
info.label[32] = '\0'; |
768 |
|
//info.Serial = (buf[128]<<24)+(buf[127]<<16)+(buf[126]<<8)+buf[125]; |
769 |
|
} |
770 |
|
close(fd); |
771 |
|
} |
772 |
|
} |
773 |
|
} |
774 |
|
} |
775 |
|
endmntent(fdfs); |
776 |
|
#else |
777 |
|
static FsInfoType info; |
778 |
|
|
779 |
|
/* initialize */ |
780 |
|
memset(&info, 0, sizeof(info)); |
781 |
|
strcpy(info.label, "RDESKTOP"); |
782 |
|
strcpy(info.type, "RDPFS"); |
783 |
|
|
784 |
|
#endif |
785 |
|
return &info; |
786 |
|
} |
787 |
|
|
788 |
|
|
789 |
NTSTATUS |
NTSTATUS |
790 |
disk_query_volume_information(HANDLE handle, uint32 info_class, STREAM out) |
disk_query_volume_information(HANDLE handle, uint32 info_class, STREAM out) |
791 |
{ |
{ |
|
char *volume, *fs_type; |
|
792 |
struct STATFS_T stat_fs; |
struct STATFS_T stat_fs; |
793 |
struct fileinfo *pfinfo; |
struct fileinfo *pfinfo; |
794 |
|
FsInfoType *fsinfo; |
795 |
|
|
796 |
pfinfo = &(g_fileinfo[handle]); |
pfinfo = &(g_fileinfo[handle]); |
|
volume = "RDESKTOP"; |
|
|
fs_type = "RDPFS"; |
|
797 |
|
|
798 |
if (STATFS_FN(pfinfo->path, &stat_fs) != 0) |
if (STATFS_FN(pfinfo->path, &stat_fs) != 0) |
799 |
{ |
{ |
801 |
return STATUS_ACCESS_DENIED; |
return STATUS_ACCESS_DENIED; |
802 |
} |
} |
803 |
|
|
804 |
|
fsinfo = FsVolumeInfo(pfinfo->path); |
805 |
|
|
806 |
switch (info_class) |
switch (info_class) |
807 |
{ |
{ |
808 |
case 1: /* FileFsVolumeInformation */ |
case 1: /* FileFsVolumeInformation */ |
809 |
|
|
810 |
out_uint32_le(out, 0); /* volume creation time low */ |
out_uint32_le(out, 0); /* volume creation time low */ |
811 |
out_uint32_le(out, 0); /* volume creation time high */ |
out_uint32_le(out, 0); /* volume creation time high */ |
812 |
out_uint32_le(out, 0); /* serial */ |
out_uint32_le(out, fsinfo->serial); /* serial */ |
813 |
out_uint32_le(out, 2 * strlen(volume)); /* length of string */ |
|
814 |
|
out_uint32_le(out, 2 * strlen(fsinfo->label)); /* length of string */ |
815 |
|
|
816 |
out_uint8(out, 0); /* support objects? */ |
out_uint8(out, 0); /* support objects? */ |
817 |
rdp_out_unistr(out, volume, 2 * strlen(volume) - 2); |
rdp_out_unistr(out, fsinfo->label, 2 * strlen(fsinfo->label) - 2); |
818 |
break; |
break; |
819 |
|
|
820 |
case 3: /* FileFsSizeInformation */ |
case 3: /* FileFsSizeInformation */ |
831 |
|
|
832 |
out_uint32_le(out, FS_CASE_SENSITIVE | FS_CASE_IS_PRESERVED); /* fs attributes */ |
out_uint32_le(out, FS_CASE_SENSITIVE | FS_CASE_IS_PRESERVED); /* fs attributes */ |
833 |
out_uint32_le(out, F_NAMELEN(stat_fs)); /* max length of filename */ |
out_uint32_le(out, F_NAMELEN(stat_fs)); /* max length of filename */ |
834 |
out_uint32_le(out, 2 * strlen(fs_type)); /* length of fs_type */ |
|
835 |
rdp_out_unistr(out, fs_type, 2 * strlen(fs_type) - 2); |
out_uint32_le(out, 2 * strlen(fsinfo->type)); /* length of fs_type */ |
836 |
|
rdp_out_unistr(out, fsinfo->type, 2 * strlen(fsinfo->type) - 2); |
837 |
break; |
break; |
838 |
|
|
839 |
case 2: /* FileFsLabelInformation */ |
case 2: /* FileFsLabelInformation */ |