/[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 659 by astrand, Fri Apr 16 11:37:24 2004 UTC revision 745 by stargo, Mon Aug 9 11:40:41 2004 UTC
# Line 20  Line 20 
20    
21  #include "disk.h"  #include "disk.h"
22    
 #if (defined(sun) && (defined(__svr4__) || defined(__SVR4)))  
 #define SOLARIS  
 #endif  
   
 #if (defined(SOLARIS) || defined(__hpux))  
 #define DIRFD(a) ((a)->dd_fd)  
 #else  
 #define DIRFD(a) (dirfd(a))  
 #endif  
   
23  #include <sys/types.h>  #include <sys/types.h>
24  #include <sys/stat.h>  #include <sys/stat.h>
25  #include <unistd.h>  #include <unistd.h>
# Line 41  Line 31 
31  #include <utime.h>  #include <utime.h>
32  #include <time.h>               /* ctime */  #include <time.h>               /* ctime */
33    
34    #if defined(HAVE_DIRFD)
35    #define DIRFD(a) (dirfd(a))
36    #else
37    #define DIRFD(a) ((a)->DIR_FD_MEMBER_NAME)
38    #endif
39    
40    /* TODO: let autoconf figure out everything below... */
41    #if (defined(sun) && (defined(__svr4__) || defined(__SVR4)))
42    #define SOLARIS
43    #endif
44    
45  #if (defined(SOLARIS) || defined (__hpux) || defined(__BEOS__))  #if (defined(SOLARIS) || defined (__hpux) || defined(__BEOS__))
46  #include <sys/statvfs.h>        /* solaris statvfs */  #include <sys/statvfs.h>        /* solaris statvfs */
47  #include <sys/mntent.h>  /* TODO: Fix mntent-handling for solaris/hpux
48  /* TODO: Fix mntent-handling for solaris */   * #include <sys/mntent.h> */
49  #undef HAVE_MNTENT_H  #undef HAVE_MNTENT_H
50  #define MNTENT_PATH "/etc/mnttab"  #define MNTENT_PATH "/etc/mnttab"
51  #define STATFS_FN(path, buf) (statvfs(path,buf))  #define STATFS_FN(path, buf) (statvfs(path,buf))
# Line 59  Line 59 
59  #define STATFS_T statfs  #define STATFS_T statfs
60  #define F_NAMELEN(buf) (NAME_MAX)  #define F_NAMELEN(buf) (NAME_MAX)
61    
62    #elif (defined(__SGI_IRIX__))
63    #include <sys/types.h>
64    #include <sys/statvfs.h>
65    #define STATFS_FN(path, buf) (statvfs(path,buf))
66    #define STATFS_T statvfs
67    #define F_NAMELEN(buf) ((buf).f_namemax)
68    
69  #else  #else
70  #include <sys/vfs.h>            /* linux statfs */  #include <sys/vfs.h>            /* linux statfs */
71  #include <mntent.h>  #include <mntent.h>
# Line 84  typedef struct Line 91  typedef struct
91  } FsInfoType;  } FsInfoType;
92    
93    
94  time_t  static time_t
95  get_create_time(struct stat *st)  get_create_time(struct stat *st)
96  {  {
97          time_t ret, ret1;          time_t ret, ret1;
# Line 99  get_create_time(struct stat *st) Line 106  get_create_time(struct stat *st)
106  }  }
107    
108  /* Convert seconds since 1970 to a filetime */  /* Convert seconds since 1970 to a filetime */
109  void  static void
110  seconds_since_1970_to_filetime(time_t seconds, uint32 * high, uint32 * low)  seconds_since_1970_to_filetime(time_t seconds, uint32 * high, uint32 * low)
111  {  {
112          unsigned long long ticks;          unsigned long long ticks;
# Line 110  seconds_since_1970_to_filetime(time_t se Line 117  seconds_since_1970_to_filetime(time_t se
117  }  }
118    
119  /* Convert seconds since 1970 back to filetime */  /* Convert seconds since 1970 back to filetime */
120  time_t  static time_t
121  convert_1970_to_filetime(uint32 high, uint32 low)  convert_1970_to_filetime(uint32 high, uint32 low)
122  {  {
123          unsigned long long ticks;          unsigned long long ticks;
# Line 162  disk_enum_devices(uint32 * id, char *opt Line 169  disk_enum_devices(uint32 * id, char *opt
169  }  }
170    
171  /* Opens or creates a file or directory */  /* Opens or creates a file or directory */
172  NTSTATUS  static NTSTATUS
173  disk_create(uint32 device_id, uint32 accessmask, uint32 sharemode, uint32 create_disposition,  disk_create(uint32 device_id, uint32 accessmask, uint32 sharemode, uint32 create_disposition,
174              uint32 flags_and_attributes, char *filename, HANDLE * phandle)              uint32 flags_and_attributes, char *filename, HANDLE * phandle)
175  {  {
# Line 319  disk_create(uint32 device_id, uint32 acc Line 326  disk_create(uint32 device_id, uint32 acc
326          return STATUS_SUCCESS;          return STATUS_SUCCESS;
327  }  }
328    
329  NTSTATUS  static NTSTATUS
330  disk_close(HANDLE handle)  disk_close(HANDLE handle)
331  {  {
332          struct fileinfo *pfinfo;          struct fileinfo *pfinfo;
# Line 339  disk_close(HANDLE handle) Line 346  disk_close(HANDLE handle)
346          return STATUS_SUCCESS;          return STATUS_SUCCESS;
347  }  }
348    
349  NTSTATUS  static NTSTATUS
350  disk_read(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)  disk_read(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
351  {  {
352          int n;          int n;
# Line 376  disk_read(HANDLE handle, uint8 * data, u Line 383  disk_read(HANDLE handle, uint8 * data, u
383          return STATUS_SUCCESS;          return STATUS_SUCCESS;
384  }  }
385    
386  NTSTATUS  static NTSTATUS
387  disk_write(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)  disk_write(HANDLE handle, uint8 * data, uint32 length, uint32 offset, uint32 * result)
388  {  {
389          int n;          int n;
# Line 638  disk_set_information(HANDLE handle, uint Line 645  disk_set_information(HANDLE handle, uint
645                          break;                          break;
646    
647                  case FileAllocationInformation:                  case FileAllocationInformation:
648                            /* Fall through to FileEndOfFileInformation,
649                          unimpl("IRP Set File Information class: FileAllocationInformation\n");                             which uses ftrunc. This is like Samba with
650                          break;                             "strict allocation = false", and means that
651                               we won't detect out-of-quota errors, for
652                               example. */
653    
654                  case FileEndOfFileInformation:                  case FileEndOfFileInformation:
655                          in_uint8s(in, 28);      /* unknown */                          in_uint8s(in, 28);      /* unknown */
# Line 651  disk_set_information(HANDLE handle, uint Line 660  disk_set_information(HANDLE handle, uint
660                                  if (stat_fs.f_bsize * stat_fs.f_bfree < length)                                  if (stat_fs.f_bsize * stat_fs.f_bfree < length)
661                                          return STATUS_DISK_FULL;                                          return STATUS_DISK_FULL;
662    
663                          //printf("FileEndOfFileInformation length = %d\n", length);                          /* FIXME: Growing file with ftruncate doesn't
664                          // ????????????                             work with Linux FAT fs */
665                          //unimpl("IRP Set File Information class: FileEndOfFileInformation\n");                          if (ftruncate(handle, length) != 0)
666                            {
667                                    perror("ftruncate");
668                                    return STATUS_DISK_FULL;
669                            }
670    
671                          break;                          break;
672                  default:                  default:
673    
# Line 663  disk_set_information(HANDLE handle, uint Line 677  disk_set_information(HANDLE handle, uint
677          return STATUS_SUCCESS;          return STATUS_SUCCESS;
678  }  }
679    
680  FsInfoType *  static FsInfoType *
681  FsVolumeInfo(char *fpath)  FsVolumeInfo(char *fpath)
682  {  {
683    
# Line 813  disk_query_directory(HANDLE handle, uint Line 827  disk_query_directory(HANDLE handle, uint
827    
828          switch (info_class)          switch (info_class)
829          {          {
830                  case 3: //FIXME: Why 3?                  case FileBothDirectoryInformation:
831    
832                          // If a search pattern is received, remember this pattern, and restart search                          // If a search pattern is received, remember this pattern, and restart search
833                          if (pattern[0] != 0)                          if (pattern[0] != 0)
# Line 833  disk_query_directory(HANDLE handle, uint Line 847  disk_query_directory(HANDLE handle, uint
847                          // Get information for directory entry                          // Get information for directory entry
848                          sprintf(fullpath, "%s/%s", dirname, pdirent->d_name);                          sprintf(fullpath, "%s/%s", dirname, pdirent->d_name);
849    
                         /* JIF  
                            printf("Stat: %s\n", fullpath); */  
850                          if (stat(fullpath, &fstat))                          if (stat(fullpath, &fstat))
851                          {                          {
852                                  perror("stat");                                  switch (errno)
853                                  out_uint8(out, 0);                                  {
854                                  return STATUS_ACCESS_DENIED;                                          case ENOENT:
855                                            case ELOOP:
856                                            case EACCES:
857                                                    /* These are non-fatal errors. */
858                                                    memset(&fstat, 0, sizeof(fstat));
859                                                    break;
860                                            default:
861                                                    /* Fatal error. By returning STATUS_NO_SUCH_FILE,
862                                                       the directory list operation will be aborted */
863                                                    perror(fullpath);
864                                                    out_uint8(out, 0);
865                                                    return STATUS_NO_SUCH_FILE;
866                                    }
867                          }                          }
868    
869                          if (S_ISDIR(fstat.st_mode))                          if (S_ISDIR(fstat.st_mode))
# Line 883  disk_query_directory(HANDLE handle, uint Line 907  disk_query_directory(HANDLE handle, uint
907                          break;                          break;
908    
909                  default:                  default:
910                            /* FIXME: Support FileDirectoryInformation,
911                               FileFullDirectoryInformation, and
912                               FileNamesInformation */
913    
914                          unimpl("IRP Query Directory sub: 0x%x\n", info_class);                          unimpl("IRP Query Directory sub: 0x%x\n", info_class);
915                          return STATUS_INVALID_PARAMETER;                          return STATUS_INVALID_PARAMETER;

Legend:
Removed from v.659  
changed lines
  Added in v.745

  ViewVC Help
Powered by ViewVC 1.1.26