/[rdesktop]/sourceforge.net/trunk/rdesktop/disk.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/disk.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 570 by stargo, Wed Jan 21 18:02:38 2004 UTC revision 573 by stargo, Wed Jan 21 22:13:20 2004 UTC
# Line 64  Line 64 
64    
65  #define MAX_OPEN_FILES  0x100  #define MAX_OPEN_FILES  0x100
66    
67    #if (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
68    #define SOLARIS
69    #endif
70    
71    #ifdef SOLARIS
72    #define DIRFD(a) ((a)->dd_fd)
73    #else
74    #define DIRFD(a) (dirfd(a))
75    #endif
76    
77  #include <sys/types.h>  #include <sys/types.h>
78  #include <sys/stat.h>  #include <sys/stat.h>
 #include <sys/vfs.h>            /* linux statfs */  
79  #include <unistd.h>  #include <unistd.h>
80  #include <fcntl.h>              /* open, close */  #include <fcntl.h>              /* open, close */
81  #include <dirent.h>             /* opendir, closedir, readdir */  #include <dirent.h>             /* opendir, closedir, readdir */
82  #include <fnmatch.h>  #include <fnmatch.h>
83  #include <errno.h>              /* errno */  #include <errno.h>              /* errno */
84    
85    #if defined(SOLARIS)
86    #include <sys/statvfs.h>        /* solaris statvfs */
87    #define HAVE_STATVFS
88    #define F_NAMELEN(buf) ((buf).f_namemax)
89    
90    #elif defined(__OpenBSD__)
91    #include <sys/param.h>
92    #include <sys/mount.h>
93    #define HAVE_STATFS
94    #define F_NAMELEN(buf) (NAME_MAX)
95    
96    #else
97    #include <sys/vfs.h>            /* linux statfs */
98    #define HAVE_STATFS
99    #define F_NAMELEN(buf) ((buf).f_namelen)
100    #endif
101    
102  #include "rdesktop.h"  #include "rdesktop.h"
103    
104  extern RDPDR_DEVICE g_rdpdr_device[];  extern RDPDR_DEVICE g_rdpdr_device[];
# Line 87  struct fileinfo Line 114  struct fileinfo
114  }  }
115  g_fileinfo[MAX_OPEN_FILES];  g_fileinfo[MAX_OPEN_FILES];
116    
117    struct fsinfo
118    {
119            uint32 f_blocks, f_bfree, f_bsize, f_namelen;
120    };
121    
122  /* Convert seconds since 1970 to a filetime */  /* Convert seconds since 1970 to a filetime */
123  void  void
124  seconds_since_1970_to_filetime(time_t seconds, uint32 * high, uint32 * low)  seconds_since_1970_to_filetime(time_t seconds, uint32 * high, uint32 * low)
# Line 212  disk_create(uint32 device_id, uint32 acc Line 244  disk_create(uint32 device_id, uint32 acc
244                                          return STATUS_NO_SUCH_FILE;                                          return STATUS_NO_SUCH_FILE;
245                          }                          }
246                  }                  }
247                  handle = dirfd(dirp); /* FIXME: dirfd is not portable */                  handle = DIRFD(dirp);
248          }          }
249          else          else
250          {          {
# Line 472  disk_set_information(HANDLE handle, uint Line 504  disk_set_information(HANDLE handle, uint
504          return STATUS_SUCCESS;          return STATUS_SUCCESS;
505  }  }
506    
507    int fsstat(const char *path, struct fsinfo *buf)
508    {
509            int ret;
510    #if defined(HAVE_STATFS)
511            struct statfs statbuf;
512    #elif defined(HAVE_STATVFS)
513            struct statvfs statbuf;
514    #endif
515    
516    #if defined(HAVE_STATFS)
517            ret = statfs(path, &statbuf);
518    #elif defined(HAVE_STATVFS)
519            ret = statvfs(path, &statbuf);
520    #else
521            ret=-1;
522    #endif
523    
524            buf->f_blocks = statbuf.f_blocks;
525            buf->f_bfree = statbuf.f_bfree;
526            buf->f_bsize = statbuf.f_bsize;
527            buf->f_namelen = F_NAMELEN(statbuf);
528    
529            return ret;
530    }
531    
532  NTSTATUS  NTSTATUS
533  disk_query_volume_information(HANDLE handle, uint32 info_class, STREAM out)  disk_query_volume_information(HANDLE handle, uint32 info_class, STREAM out)
534  {  {
535          char *volume, *fs_type;          char *volume, *fs_type;
536          struct statfs stat_fs;          struct fsinfo stat_fs;
537          struct fileinfo *pfinfo;          struct fileinfo *pfinfo;
538    
539          pfinfo = &(g_fileinfo[handle]);          pfinfo = &(g_fileinfo[handle]);
540          volume = "RDESKTOP";          volume = "RDESKTOP";
541          fs_type = "RDPFS";          fs_type = "RDPFS";
542    
543          if (statfs(pfinfo->path, &stat_fs) != 0)        /* FIXME: statfs is not portable */          if (fsstat(pfinfo->path, &stat_fs) != 0)        /* FIXME: statfs is not portable */
544          {          {
545                  perror("statfs");                  perror("statfs");
546                  return STATUS_ACCESS_DENIED;                  return STATUS_ACCESS_DENIED;

Legend:
Removed from v.570  
changed lines
  Added in v.573

  ViewVC Help
Powered by ViewVC 1.1.26