CVS: rdesktop disk.c,1.15,1.16
Peter Bystr?m <[email protected]>
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15785
Modified Files:
disk.c
Log Message:
get volume label for vfat and iso fs, requires mntent, did some ifdefs around the code, and we need a better name for the function anyone?
Index: disk.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/disk.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** disk.c 23 Feb 2004 10:34:18 -0000 1.15
--- disk.c 23 Feb 2004 13:35:50 -0000 1.16
***************
*** 105,108 ****
--- 105,111 ----
#if (defined(SOLARIS) || defined (__hpux) || defined(__BEOS__))
#include <sys/statvfs.h> /* solaris statvfs */
+ #include <sys/mntent.h>
+ #define HAVE_MNTENT_H
+ #define MNTENT_PATH "/etc/mnttab"
#define STATFS_FN(path, buf) (statvfs(path,buf))
#define STATFS_T statvfs
***************
*** 118,121 ****
--- 121,127 ----
#else
#include <sys/vfs.h> /* linux statfs */
+ #include <mntent.h>
+ #define HAVE_MNTENT_H
+ #define MNTENT_PATH "/etc/mtab"
#define STATFS_FN(path, buf) (statfs(path,buf))
#define STATFS_T statfs
***************
*** 138,141 ****
--- 144,156 ----
g_fileinfo[MAX_OPEN_FILES];
+ typedef struct
+ {
+ char name[256];
+ char label[256];
+ unsigned long serial;
+ char type[256];
+ } FsInfoType;
+
+
time_t
get_create_time(struct stat *st)
***************
*** 704,717 ****
}
NTSTATUS
disk_query_volume_information(HANDLE handle, uint32 info_class, STREAM out)
{
- char *volume, *fs_type;
struct STATFS_T stat_fs;
struct fileinfo *pfinfo;
pfinfo = &(g_fileinfo[handle]);
- volume = "RDESKTOP";
- fs_type = "RDPFS";
if (STATFS_FN(pfinfo->path, &stat_fs) != 0)
--- 719,798 ----
}
+ FsInfoType *
+ FsVolumeInfo(char *fpath)
+ {
+
+ #ifdef HAVE_MNTENT_H
+ FILE *fdfs;
+ struct mntent *e;
+ static FsInfoType info;
+
+ /* initialize */
+ memset(&info, 0, sizeof(info));
+ strcpy(info.label, "RDESKTOP");
+ strcpy(info.type, "RDPFS");
+
+ fdfs = setmntent(MNTENT_PATH, "r");
+ if (!fdfs)
+ return &info;
+
+ while ((e = getmntent(fdfs)))
+ {
+ if (strncmp(fpath, e->mnt_dir, strlen(fpath)) == 0)
+ {
+ strcpy(info.type, e->mnt_type);
+ strcpy(info.name, e->mnt_fsname);
+ if (strstr(e->mnt_opts, "vfat") || strstr(e->mnt_opts, "iso9660"))
+ {
+ int fd = open(e->mnt_fsname, O_RDONLY);
+ if (fd >= 0)
+ {
+ unsigned char buf[512];
+ memset(buf, 0, sizeof(buf));
+ if (strstr(e->mnt_opts, "vfat"))
+ /*FAT*/
+ {
+ strcpy(info.type, "vfat");
+ read(fd, buf, sizeof(buf));
+ info.serial =
+ (buf[42] << 24) + (buf[41] << 16) +
+ (buf[40] << 8) + buf[39];
+ strncpy(info.label, buf + 43, 10);
+ info.label[10] = '\0';
+ }
+ else if (lseek(fd, 32767, SEEK_SET) >= 0) /* ISO9660 */
+ {
+ read(fd, buf, sizeof(buf));
+ strncpy(info.label, buf + 41, 32);
+ info.label[32] = '\0';
+ //info.Serial = (buf[128]<<24)+(buf[127]<<16)+(buf[126]<<8)+buf[125];
+ }
+ close(fd);
+ }
+ }
+ }
+ }
+ endmntent(fdfs);
+ #else
+ static FsInfoType info;
+
+ /* initialize */
+ memset(&info, 0, sizeof(info));
+ strcpy(info.label, "RDESKTOP");
+ strcpy(info.type, "RDPFS");
+
+ #endif
+ return &info;
+ }
+
+
NTSTATUS
disk_query_volume_information(HANDLE handle, uint32 info_class, STREAM out)
{
struct STATFS_T stat_fs;
struct fileinfo *pfinfo;
+ FsInfoType *fsinfo;
pfinfo = &(g_fileinfo[handle]);
if (STATFS_FN(pfinfo->path, &stat_fs) != 0)
***************
*** 721,724 ****
--- 802,807 ----
}
+ fsinfo = FsVolumeInfo(pfinfo->path);
+
switch (info_class)
{
***************
*** 727,734 ****
out_uint32_le(out, 0); /* volume creation time low */
out_uint32_le(out, 0); /* volume creation time high */
! out_uint32_le(out, 0); /* serial */
! out_uint32_le(out, 2 * strlen(volume)); /* length of string */
out_uint8(out, 0); /* support objects? */
! rdp_out_unistr(out, volume, 2 * strlen(volume) - 2);
break;
--- 810,819 ----
out_uint32_le(out, 0); /* volume creation time low */
out_uint32_le(out, 0); /* volume creation time high */
! out_uint32_le(out, fsinfo->serial); /* serial */
!
! out_uint32_le(out, 2 * strlen(fsinfo->label)); /* length of string */
!
out_uint8(out, 0); /* support objects? */
! rdp_out_unistr(out, fsinfo->label, 2 * strlen(fsinfo->label) - 2);
break;
***************
*** 747,752 ****
out_uint32_le(out, FS_CASE_SENSITIVE | FS_CASE_IS_PRESERVED); /* fs attributes */
out_uint32_le(out, F_NAMELEN(stat_fs)); /* max length of filename */
! out_uint32_le(out, 2 * strlen(fs_type)); /* length of fs_type */
! rdp_out_unistr(out, fs_type, 2 * strlen(fs_type) - 2);
break;
--- 832,838 ----
out_uint32_le(out, FS_CASE_SENSITIVE | FS_CASE_IS_PRESERVED); /* fs attributes */
out_uint32_le(out, F_NAMELEN(stat_fs)); /* max length of filename */
!
! out_uint32_le(out, 2 * strlen(fsinfo->type)); /* length of fs_type */
! rdp_out_unistr(out, fsinfo->type, 2 * strlen(fsinfo->type) - 2);
break;
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click