/[rdesktop]/jpeg/rdesktop/trunk/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 /jpeg/rdesktop/trunk/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 572 by stargo, Wed Jan 21 21:51:59 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    #ifdef SOLARIS
86    #include <sys/statvfs.h>        /* solaris statvfs */
87    #define HAVE_STATVFS
88    #else
89    #include <sys/vfs.h>            /* linux statfs */
90    #define HAVE_STATFS
91    #endif
92    
93  #include "rdesktop.h"  #include "rdesktop.h"
94    
95  extern RDPDR_DEVICE g_rdpdr_device[];  extern RDPDR_DEVICE g_rdpdr_device[];
# Line 87  struct fileinfo Line 105  struct fileinfo
105  }  }
106  g_fileinfo[MAX_OPEN_FILES];  g_fileinfo[MAX_OPEN_FILES];
107    
108    struct fsinfo
109    {
110            uint32 f_blocks, f_bfree, f_bsize, f_namelen;
111    };
112    
113  /* Convert seconds since 1970 to a filetime */  /* Convert seconds since 1970 to a filetime */
114  void  void
115  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 235  disk_create(uint32 device_id, uint32 acc
235                                          return STATUS_NO_SUCH_FILE;                                          return STATUS_NO_SUCH_FILE;
236                          }                          }
237                  }                  }
238                  handle = dirfd(dirp); /* FIXME: dirfd is not portable */                  handle = DIRFD(dirp);
239          }          }
240          else          else
241          {          {
# Line 472  disk_set_information(HANDLE handle, uint Line 495  disk_set_information(HANDLE handle, uint
495          return STATUS_SUCCESS;          return STATUS_SUCCESS;
496  }  }
497    
498    int fsstat(const char *path, struct fsinfo *buf)
499    {
500            int ret;
501    #if defined(HAVE_STATFS)
502            struct statfs statbuf;
503    #elif defined(HAVE_STATVFS)
504            struct statvfs statbuf;
505    #endif
506    
507    #if defined(HAVE_STATFS)
508            ret = statfs(path, &statbuf);
509            buf->f_namelen = statbuf.f_namelen;
510    #elif defined(HAVE_STATVFS)
511            ret = statvfs(path, &statbuf);
512            buf->f_namelen = statbuf.f_namemax;
513    #else
514            ret=-1;
515    #endif
516    
517            buf->f_blocks = statbuf.f_blocks;
518            buf->f_bfree = statbuf.f_bfree;
519            buf->f_bsize = statbuf.f_bsize;
520    
521            return ret;
522    }
523    
524  NTSTATUS  NTSTATUS
525  disk_query_volume_information(HANDLE handle, uint32 info_class, STREAM out)  disk_query_volume_information(HANDLE handle, uint32 info_class, STREAM out)
526  {  {
527          char *volume, *fs_type;          char *volume, *fs_type;
528          struct statfs stat_fs;          struct fsinfo stat_fs;
529          struct fileinfo *pfinfo;          struct fileinfo *pfinfo;
530    
531          pfinfo = &(g_fileinfo[handle]);          pfinfo = &(g_fileinfo[handle]);
532          volume = "RDESKTOP";          volume = "RDESKTOP";
533          fs_type = "RDPFS";          fs_type = "RDPFS";
534    
535          if (statfs(pfinfo->path, &stat_fs) != 0)        /* FIXME: statfs is not portable */          if (fsstat(pfinfo->path, &stat_fs) != 0)        /* FIXME: statfs is not portable */
536          {          {
537                  perror("statfs");                  perror("statfs");
538                  return STATUS_ACCESS_DENIED;                  return STATUS_ACCESS_DENIED;

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

  ViewVC Help
Powered by ViewVC 1.1.26