/[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 573 by stargo, Wed Jan 21 22:13:20 2004 UTC revision 613 by n-ki, Mon Feb 23 10:34:18 2004 UTC
# Line 24  Line 24 
24  #define FILE_ATTRIBUTE_DIRECTORY                0x00000010  #define FILE_ATTRIBUTE_DIRECTORY                0x00000010
25  #define FILE_ATTRIBUTE_ARCHIVE                  0x00000020  #define FILE_ATTRIBUTE_ARCHIVE                  0x00000020
26  #define FILE_ATTRIBUTE_DEVICE                   0x00000040  #define FILE_ATTRIBUTE_DEVICE                   0x00000040
27    #define FILE_ATTRIBUTE_UNKNOWNXXX0              0x00000060      /* ??? ACTION i.e. 0x860 == compress this file ? */
28  #define FILE_ATTRIBUTE_NORMAL                   0x00000080  #define FILE_ATTRIBUTE_NORMAL                   0x00000080
29  #define FILE_ATTRIBUTE_TEMPORARY                0x00000100  #define FILE_ATTRIBUTE_TEMPORARY                0x00000100
30  #define FILE_ATTRIBUTE_SPARSE_FILE              0x00000200  #define FILE_ATTRIBUTE_SPARSE_FILE              0x00000200
# Line 33  Line 34 
34  #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED      0x00002000  #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED      0x00002000
35  #define FILE_ATTRIBUTE_ENCRYPTED                0x00004000  #define FILE_ATTRIBUTE_ENCRYPTED                0x00004000
36    
37    #define FILE_FLAG_OPEN_NO_RECALL                0x00100000
38    #define FILE_FLAG_OPEN_REPARSE_POINT            0x00200000
39    #define FILE_FLAG_POSIX_SEMANTICS               0x01000000
40    #define FILE_FLAG_BACKUP_SEMANTICS              0x02000000      /* sometimes used to create a directory */
41    #define FILE_FLAG_DELETE_ON_CLOSE               0x04000000
42    #define FILE_FLAG_SEQUENTIAL_SCAN               0x08000000
43    #define FILE_FLAG_RANDOM_ACCESS                 0x10000000
44    #define FILE_FLAG_NO_BUFFERING                  0x20000000
45    #define FILE_FLAG_OVERLAPPED                    0x40000000
46    #define FILE_FLAG_WRITE_THROUGH                 0x80000000
47    
48    #define FILE_SHARE_READ                         0x01
49    #define FILE_SHARE_WRITE                        0x02
50    #define FILE_SHARE_DELETE                       0x04
51    
52  #define FILE_BASIC_INFORMATION                  0x04  #define FILE_BASIC_INFORMATION                  0x04
53  #define FILE_STANDARD_INFORMATION               0x05  #define FILE_STANDARD_INFORMATION               0x05
54    
# Line 68  Line 84 
84  #define SOLARIS  #define SOLARIS
85  #endif  #endif
86    
87  #ifdef SOLARIS  #if (defined(SOLARIS) || defined(__hpux))
88  #define DIRFD(a) ((a)->dd_fd)  #define DIRFD(a) ((a)->dd_fd)
89  #else  #else
90  #define DIRFD(a) (dirfd(a))  #define DIRFD(a) (dirfd(a))
# Line 82  Line 98 
98  #include <fnmatch.h>  #include <fnmatch.h>
99  #include <errno.h>              /* errno */  #include <errno.h>              /* errno */
100    
101  #if defined(SOLARIS)  #include <utime.h>
102    #include <time.h>               /* ctime */
103    
104    
105    #if (defined(SOLARIS) || defined (__hpux) || defined(__BEOS__))
106  #include <sys/statvfs.h>        /* solaris statvfs */  #include <sys/statvfs.h>        /* solaris statvfs */
107  #define HAVE_STATVFS  #define STATFS_FN(path, buf) (statvfs(path,buf))
108    #define STATFS_T statvfs
109  #define F_NAMELEN(buf) ((buf).f_namemax)  #define F_NAMELEN(buf) ((buf).f_namemax)
110    
111  #elif defined(__OpenBSD__)  #elif (defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__))
112  #include <sys/param.h>  #include <sys/param.h>
113  #include <sys/mount.h>  #include <sys/mount.h>
114  #define HAVE_STATFS  #define STATFS_FN(path, buf) (statfs(path,buf))
115    #define STATFS_T statfs
116  #define F_NAMELEN(buf) (NAME_MAX)  #define F_NAMELEN(buf) (NAME_MAX)
117    
118  #else  #else
119  #include <sys/vfs.h>            /* linux statfs */  #include <sys/vfs.h>            /* linux statfs */
120  #define HAVE_STATFS  #define STATFS_FN(path, buf) (statfs(path,buf))
121    #define STATFS_T statfs
122  #define F_NAMELEN(buf) ((buf).f_namelen)  #define F_NAMELEN(buf) ((buf).f_namelen)
123  #endif  #endif
124    
# Line 114  struct fileinfo Line 137  struct fileinfo
137  }  }
138  g_fileinfo[MAX_OPEN_FILES];  g_fileinfo[MAX_OPEN_FILES];
139    
140  struct fsinfo  time_t
141    get_create_time(struct stat *st)
142  {  {
143          uint32 f_blocks, f_bfree, f_bsize, f_namelen;          time_t ret, ret1;
144  };  
145            ret = MIN(st->st_ctime, st->st_mtime);
146            ret1 = MIN(ret, st->st_atime);
147    
148            if (ret1 != (time_t) 0)
149                    return ret1;
150    
151            return ret;
152    }
153    
154  /* Convert seconds since 1970 to a filetime */  /* Convert seconds since 1970 to a filetime */
155  void  void
# Line 130  seconds_since_1970_to_filetime(time_t se Line 162  seconds_since_1970_to_filetime(time_t se
162          *high = (uint32) (ticks >> 32);          *high = (uint32) (ticks >> 32);
163  }  }
164    
165    /* Convert seconds since 1970 back to filetime */
166    time_t
167    convert_1970_to_filetime(uint32 high, uint32 low)
168    {
169            unsigned long long ticks;
170            time_t val;
171    
172            ticks = low + (((unsigned long long) high) << 32);
173            ticks /= 10000000;
174            ticks -= 11644473600LL;
175    
176            val = (time_t) ticks;
177            return (val);
178    
179    }
180    
181    
182  /* Enumeration of devices from rdesktop.c        */  /* Enumeration of devices from rdesktop.c        */
183  /* returns numer of units found and initialized. */  /* returns numer of units found and initialized. */
184  /* optarg looks like ':h:=/mnt/floppy,b:=/mnt/usbdevice1' */  /* optarg looks like ':h=/mnt/floppy,b=/mnt/usbdevice1' */
185  /* when it arrives to this function.             */  /* when it arrives to this function.             */
186  int  int
187  disk_enum_devices(int *id, char *optarg)  disk_enum_devices(uint32 * id, char *optarg)
188  {  {
189          char *pos = optarg;          char *pos = optarg;
190          char *pos2;          char *pos2;
# Line 165  disk_enum_devices(int *id, char *optarg) Line 214  disk_enum_devices(int *id, char *optarg)
214          return count;          return count;
215  }  }
216    
217  /* Opens of creates a file or directory */  /* Opens or creates a file or directory */
218  NTSTATUS  NTSTATUS
219  disk_create(uint32 device_id, uint32 accessmask, uint32 sharemode, uint32 create_disposition,  disk_create(uint32 device_id, uint32 accessmask, uint32 sharemode, uint32 create_disposition,
220              uint32 flags_and_attributes, char *filename, HANDLE * phandle)              uint32 flags_and_attributes, char *filename, HANDLE * phandle)
# Line 174  disk_create(uint32 device_id, uint32 acc Line 223  disk_create(uint32 device_id, uint32 acc
223          DIR *dirp;          DIR *dirp;
224          int flags, mode;          int flags, mode;
225          char path[256];          char path[256];
226            struct stat filestat;
227    
228          handle = 0;          handle = 0;
229          dirp = NULL;          dirp = NULL;
230          flags = 0;          flags = 0;
231          mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;          mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
232    
233    
234          if (filename[strlen(filename) - 1] == '/')          if (filename[strlen(filename) - 1] == '/')
235                  filename[strlen(filename) - 1] = 0;                  filename[strlen(filename) - 1] = 0;
236          sprintf(path, "%s%s", g_rdpdr_device[device_id].local_path, filename);          sprintf(path, "%s%s", g_rdpdr_device[device_id].local_path, filename);
         //printf("Open: %s\n", path);  
237    
238          switch (create_disposition)          switch (create_disposition)
239          {          {
# Line 218  disk_create(uint32 device_id, uint32 acc Line 268  disk_create(uint32 device_id, uint32 acc
268                          break;                          break;
269          }          }
270    
271            //printf("Open: \"%s\"  flags: %u, accessmask: %u sharemode: %u create disp: %u\n", path, flags_and_attributes, accessmask, sharemode, create_disposition);
272    
273            // Get information about file and set that flag ourselfs
274            if ((stat(path, &filestat) == 0) && (S_ISDIR(filestat.st_mode)))
275            {
276                    if (flags_and_attributes & FILE_NON_DIRECTORY_FILE)
277                            return STATUS_FILE_IS_A_DIRECTORY;
278                    else
279                            flags_and_attributes |= FILE_DIRECTORY_FILE;
280            }
281    
282          if (flags_and_attributes & FILE_DIRECTORY_FILE)          if (flags_and_attributes & FILE_DIRECTORY_FILE)
283          {          {
284                  if (flags & O_CREAT)                  if (flags & O_CREAT)
# Line 248  disk_create(uint32 device_id, uint32 acc Line 309  disk_create(uint32 device_id, uint32 acc
309          }          }
310          else          else
311          {          {
312    
313                  if (accessmask & GENERIC_ALL                  if (accessmask & GENERIC_ALL
314                      || (accessmask & GENERIC_READ && accessmask & GENERIC_WRITE))                      || (accessmask & GENERIC_READ && accessmask & GENERIC_WRITE))
315                  {                  {
# Line 267  disk_create(uint32 device_id, uint32 acc Line 329  disk_create(uint32 device_id, uint32 acc
329                  {                  {
330                          switch (errno)                          switch (errno)
331                          {                          {
332                                    case EISDIR:
333    
334                                            return STATUS_FILE_IS_A_DIRECTORY;
335    
336                                  case EACCES:                                  case EACCES:
337    
338                                          return STATUS_ACCESS_DENIED;                                          return STATUS_ACCESS_DENIED;
# Line 274  disk_create(uint32 device_id, uint32 acc Line 340  disk_create(uint32 device_id, uint32 acc
340                                  case ENOENT:                                  case ENOENT:
341    
342                                          return STATUS_NO_SUCH_FILE;                                          return STATUS_NO_SUCH_FILE;
343                                    case EEXIST:
344    
345                                            return STATUS_OBJECT_NAME_COLLISION;
346                                  default:                                  default:
347    
348                                          perror("open");                                          perror("open");
349                                          return STATUS_NO_SUCH_FILE;                                          return STATUS_NO_SUCH_FILE;
350                          }                          }
351                  }                  }
352    
353                    /* all read and writes of files should be non blocking */
354                    if (fcntl(handle, F_SETFL, O_NONBLOCK) == -1)
355                            perror("fcntl");
356          }          }
357    
358          if (handle >= MAX_OPEN_FILES)          if (handle >= MAX_OPEN_FILES)
# Line 325  disk_read(HANDLE handle, uint8 * data, u Line 397  disk_read(HANDLE handle, uint8 * data, u
397  {  {
398          int n;          int n;
399    
400          if (offset)  #if 0
401                  lseek(handle, offset, SEEK_SET);          /* browsing dir ????        */
402            /* each request is 24 bytes */
403            if (g_fileinfo[handle].flags_and_attributes & FILE_DIRECTORY_FILE)
404            {
405                    *result = 0;
406                    return STATUS_SUCCESS;
407            }
408    #endif
409    
410            lseek(handle, offset, SEEK_SET);
411    
412          n = read(handle, data, length);          n = read(handle, data, length);
413    
414          if (n < 0)          if (n < 0)
415          {          {
                 perror("read");  
416                  *result = 0;                  *result = 0;
417                  return STATUS_INVALID_PARAMETER;                  switch (errno)
418                    {
419                            case EISDIR:
420                                    return STATUS_FILE_IS_A_DIRECTORY;
421                            default:
422                                    perror("read");
423                                    return STATUS_INVALID_PARAMETER;
424                    }
425          }          }
426    
427          *result = n;          *result = n;
# Line 346  disk_write(HANDLE handle, uint8 * data, Line 434  disk_write(HANDLE handle, uint8 * data,
434  {  {
435          int n;          int n;
436    
437          if (offset)          lseek(handle, offset, SEEK_SET);
                 lseek(handle, offset, SEEK_SET);  
438    
439          n = write(handle, data, length);          n = write(handle, data, length);
440    
# Line 355  disk_write(HANDLE handle, uint8 * data, Line 442  disk_write(HANDLE handle, uint8 * data,
442          {          {
443                  perror("write");                  perror("write");
444                  *result = 0;                  *result = 0;
445                  return STATUS_ACCESS_DENIED;                  switch (errno)
446                    {
447                            case ENOSPC:
448                                    return STATUS_DISK_FULL;
449                            default:
450                                    return STATUS_ACCESS_DENIED;
451                    }
452          }          }
453    
454          *result = n;          *result = n;
# Line 383  disk_query_information(HANDLE handle, ui Line 476  disk_query_information(HANDLE handle, ui
476          // Set file attributes          // Set file attributes
477          file_attributes = 0;          file_attributes = 0;
478          if (S_ISDIR(filestat.st_mode))          if (S_ISDIR(filestat.st_mode))
         {  
479                  file_attributes |= FILE_ATTRIBUTE_DIRECTORY;                  file_attributes |= FILE_ATTRIBUTE_DIRECTORY;
480          }  
481          filename = 1 + strrchr(path, '/');          filename = 1 + strrchr(path, '/');
482          if (filename && filename[0] == '.')          if (filename && filename[0] == '.')
         {  
483                  file_attributes |= FILE_ATTRIBUTE_HIDDEN;                  file_attributes |= FILE_ATTRIBUTE_HIDDEN;
484          }  
485            if (!file_attributes)
486                    file_attributes |= FILE_ATTRIBUTE_NORMAL;
487    
488            if (!(filestat.st_mode & S_IWUSR))
489                    file_attributes |= FILE_ATTRIBUTE_READONLY;
490    
491          // Return requested data          // Return requested data
492          switch (info_class)          switch (info_class)
493          {          {
494                  case 4: /* FileBasicInformation */                  case 4: /* FileBasicInformation */
495                            seconds_since_1970_to_filetime(get_create_time(&filestat), &ft_high,
496                          out_uint8s(out, 8);     //create_time not available;                                                         &ft_low);
497                            out_uint32_le(out, ft_low);     //create_access_time
498                            out_uint32_le(out, ft_high);
499    
500                          seconds_since_1970_to_filetime(filestat.st_atime, &ft_high, &ft_low);                          seconds_since_1970_to_filetime(filestat.st_atime, &ft_high, &ft_low);
501                          out_uint32_le(out, ft_low);     //last_access_time                          out_uint32_le(out, ft_low);     //last_access_time
# Line 407  disk_query_information(HANDLE handle, ui Line 505  disk_query_information(HANDLE handle, ui
505                          out_uint32_le(out, ft_low);     //last_write_time                          out_uint32_le(out, ft_low);     //last_write_time
506                          out_uint32_le(out, ft_high);                          out_uint32_le(out, ft_high);
507    
508                          out_uint8s(out, 8);     //unknown zero                          seconds_since_1970_to_filetime(filestat.st_ctime, &ft_high, &ft_low);
509                            out_uint32_le(out, ft_low);     //last_change_time
510                            out_uint32_le(out, ft_high);
511    
512                          out_uint32_le(out, file_attributes);                          out_uint32_le(out, file_attributes);
513                          break;                          break;
514    
# Line 443  disk_set_information(HANDLE handle, uint Line 544  disk_set_information(HANDLE handle, uint
544          char newname[256], fullpath[256];          char newname[256], fullpath[256];
545          struct fileinfo *pfinfo;          struct fileinfo *pfinfo;
546    
547            int mode;
548            struct stat filestat;
549            time_t write_time, change_time, access_time, mod_time;
550            struct utimbuf tvs;
551            struct STATFS_T stat_fs;
552    
553          pfinfo = &(g_fileinfo[handle]);          pfinfo = &(g_fileinfo[handle]);
554    
555          switch (info_class)          switch (info_class)
556          {          {
557                  case 4: /* FileBasicInformation */                  case 4: /* FileBasicInformation */
558                            write_time = change_time = access_time = 0;
559    
560                            in_uint8s(in, 4);       /* Handle of root dir? */
561                            in_uint8s(in, 24);      /* unknown */
562    
563                            // CreationTime
564                            in_uint32_le(in, ft_low);
565                            in_uint32_le(in, ft_high);
566    
567                            // AccessTime
568                            in_uint32_le(in, ft_low);
569                            in_uint32_le(in, ft_high);
570                            if (ft_low || ft_high)
571                                    access_time = convert_1970_to_filetime(ft_high, ft_low);
572    
573                            // WriteTime
574                            in_uint32_le(in, ft_low);
575                            in_uint32_le(in, ft_high);
576                            if (ft_low || ft_high)
577                                    write_time = convert_1970_to_filetime(ft_high, ft_low);
578    
579                            // ChangeTime
580                            in_uint32_le(in, ft_low);
581                            in_uint32_le(in, ft_high);
582                            if (ft_low || ft_high)
583                                    change_time = convert_1970_to_filetime(ft_high, ft_low);
584    
585                            in_uint32_le(in, file_attributes);
586    
587                            if (fstat(handle, &filestat))
588                                    return STATUS_ACCESS_DENIED;
589    
590                            tvs.modtime = filestat.st_mtime;
591                            tvs.actime = filestat.st_atime;
592                            if (access_time)
593                                    tvs.actime = access_time;
594    
595    
596                            if (write_time || change_time)
597                                    mod_time = MIN(write_time, change_time);
598                            else
599                                    mod_time = write_time ? write_time : change_time;
600    
601                            if (mod_time)
602                                    tvs.modtime = mod_time;
603    
604    
605                            if (access_time || write_time || change_time)
606                            {
607    #if WITH_DEBUG_RDP5
608                                    printf("FileBasicInformation access       time %s",
609                                           ctime(&tvs.actime));
610                                    printf("FileBasicInformation modification time %s",
611                                           ctime(&tvs.modtime));
612    #endif
613                                    if (utime(pfinfo->path, &tvs))
614                                            return STATUS_ACCESS_DENIED;
615                            }
616    
617                            if (!file_attributes)
618                                    break;  // not valid
619    
620                            mode = filestat.st_mode;
621    
622                            if (file_attributes & FILE_ATTRIBUTE_READONLY)
623                                    mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
624                            else
625                                    mode |= S_IWUSR;
626    
627                            mode &= 0777;
628    #if WITH_DEBUG_RDP5
629                            printf("FileBasicInformation set access mode 0%o", mode);
630    #endif
631    
632                            if (fchmod(handle, mode))
633                                    return STATUS_ACCESS_DENIED;
634    
635                            /* prevents start of writing if not enough space left on device */
636                            if (STATFS_FN(g_rdpdr_device[pfinfo->device_id].local_path, &stat_fs) == 0)
637                                    if (stat_fs.f_bsize * stat_fs.f_bfree < length)
638                                            return STATUS_DISK_FULL;
639    
                         // Probably safe to ignore  
640                          break;                          break;
641    
642                  case 10:        /* FileRenameInformation */                  case 10:        /* FileRenameInformation */
# Line 481  disk_set_information(HANDLE handle, uint Line 668  disk_set_information(HANDLE handle, uint
668                  case 13:        /* FileDispositionInformation */                  case 13:        /* FileDispositionInformation */
669    
670                          //unimpl("IRP Set File Information class: FileDispositionInformation\n");                          //unimpl("IRP Set File Information class: FileDispositionInformation\n");
671                          // in_uint32_le(in, delete_on_close);  
672                            //in_uint32_le(in, delete_on_close);
673                          // disk_close(handle);                          // disk_close(handle);
674                          unlink(pfinfo->path);                          if ((pfinfo->flags_and_attributes & FILE_DIRECTORY_FILE))       // remove a directory
675                            {
676                                    if (rmdir(pfinfo->path) < 0)
677                                            return STATUS_ACCESS_DENIED;
678                            }
679                            else if (unlink(pfinfo->path) < 0)      // unlink a file
680                                    return STATUS_ACCESS_DENIED;
681    
682                          break;                          break;
683    
684                  case 19:        /* FileAllocationInformation */                  case 19:        /* FileAllocationInformation */
# Line 492  disk_set_information(HANDLE handle, uint Line 687  disk_set_information(HANDLE handle, uint
687                          break;                          break;
688    
689                  case 20:        /* FileEndOfFileInformation */                  case 20:        /* FileEndOfFileInformation */
690                            in_uint8s(in, 28);      /* unknown */
691                            in_uint32_le(in, length);       /* file size */
692    
693                            printf("FileEndOfFileInformation length = %d\n", length);
694                            // ????????????
695    
696                          unimpl("IRP Set File Information class: FileEndOfFileInformation\n");                          unimpl("IRP Set File Information class: FileEndOfFileInformation\n");
697                          break;                          break;
   
698                  default:                  default:
699    
700                          unimpl("IRP Set File Information class: 0x%x\n", info_class);                          unimpl("IRP Set File Information class: 0x%x\n", info_class);
# Line 504  disk_set_information(HANDLE handle, uint Line 703  disk_set_information(HANDLE handle, uint
703          return STATUS_SUCCESS;          return STATUS_SUCCESS;
704  }  }
705    
 int fsstat(const char *path, struct fsinfo *buf)  
 {  
         int ret;  
 #if defined(HAVE_STATFS)  
         struct statfs statbuf;  
 #elif defined(HAVE_STATVFS)  
         struct statvfs statbuf;  
 #endif  
   
 #if defined(HAVE_STATFS)  
         ret = statfs(path, &statbuf);  
 #elif defined(HAVE_STATVFS)  
         ret = statvfs(path, &statbuf);  
 #else  
         ret=-1;  
 #endif  
   
         buf->f_blocks = statbuf.f_blocks;  
         buf->f_bfree = statbuf.f_bfree;  
         buf->f_bsize = statbuf.f_bsize;  
         buf->f_namelen = F_NAMELEN(statbuf);  
   
         return ret;  
 }  
   
706  NTSTATUS  NTSTATUS
707  disk_query_volume_information(HANDLE handle, uint32 info_class, STREAM out)  disk_query_volume_information(HANDLE handle, uint32 info_class, STREAM out)
708  {  {
709          char *volume, *fs_type;          char *volume, *fs_type;
710          struct fsinfo stat_fs;          struct STATFS_T stat_fs;
711          struct fileinfo *pfinfo;          struct fileinfo *pfinfo;
712    
713          pfinfo = &(g_fileinfo[handle]);          pfinfo = &(g_fileinfo[handle]);
714          volume = "RDESKTOP";          volume = "RDESKTOP";
715          fs_type = "RDPFS";          fs_type = "RDPFS";
716    
717          if (fsstat(pfinfo->path, &stat_fs) != 0)        /* FIXME: statfs is not portable */          if (STATFS_FN(pfinfo->path, &stat_fs) != 0)
718          {          {
719                  perror("statfs");                  perror("statfs");
720                  return STATUS_ACCESS_DENIED;                  return STATUS_ACCESS_DENIED;
# Line 571  disk_query_volume_information(HANDLE han Line 745  disk_query_volume_information(HANDLE han
745                  case 5: /* FileFsAttributeInformation */                  case 5: /* FileFsAttributeInformation */
746    
747                          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 */
748                          out_uint32_le(out, stat_fs.f_namelen);  /* max length of filename */                          out_uint32_le(out, F_NAMELEN(stat_fs)); /* max length of filename */
749                          out_uint32_le(out, 2 * strlen(fs_type));        /* length of fs_type */                          out_uint32_le(out, 2 * strlen(fs_type));        /* length of fs_type */
750                          rdp_out_unistr(out, fs_type, 2 * strlen(fs_type) - 2);                          rdp_out_unistr(out, fs_type, 2 * strlen(fs_type) - 2);
751                          break;                          break;
# Line 619  disk_query_directory(HANDLE handle, uint Line 793  disk_query_directory(HANDLE handle, uint
793                          // find next dirent matching pattern                          // find next dirent matching pattern
794                          pdirent = readdir(pdir);                          pdirent = readdir(pdir);
795                          while (pdirent && fnmatch(pfinfo->pattern, pdirent->d_name, 0) != 0)                          while (pdirent && fnmatch(pfinfo->pattern, pdirent->d_name, 0) != 0)
                         {  
796                                  pdirent = readdir(pdir);                                  pdirent = readdir(pdir);
                         }  
797    
798                          if (pdirent == NULL)                          if (pdirent == NULL)
                         {  
799                                  return STATUS_NO_MORE_FILES;                                  return STATUS_NO_MORE_FILES;
                         }  
800    
801                          // Get information for directory entry                          // Get information for directory entry
802                          sprintf(fullpath, "%s/%s", dirname, pdirent->d_name);                          sprintf(fullpath, "%s/%s", dirname, pdirent->d_name);
803                          /* JIF  
804                            /* JIF
805                             printf("Stat: %s\n", fullpath); */                             printf("Stat: %s\n", fullpath); */
806                          if (stat(fullpath, &fstat))                          if (stat(fullpath, &fstat))
807                          {                          {
# Line 643  disk_query_directory(HANDLE handle, uint Line 814  disk_query_directory(HANDLE handle, uint
814                                  file_attributes |= FILE_ATTRIBUTE_DIRECTORY;                                  file_attributes |= FILE_ATTRIBUTE_DIRECTORY;
815                          if (pdirent->d_name[0] == '.')                          if (pdirent->d_name[0] == '.')
816                                  file_attributes |= FILE_ATTRIBUTE_HIDDEN;                                  file_attributes |= FILE_ATTRIBUTE_HIDDEN;
817                            if (!file_attributes)
818                                    file_attributes |= FILE_ATTRIBUTE_NORMAL;
819                            if (!(fstat.st_mode & S_IWUSR))
820                                    file_attributes |= FILE_ATTRIBUTE_READONLY;
821    
822                          // Return requested information                          // Return requested information
823                          out_uint8s(out, 8);     //unknown zero                          out_uint8s(out, 8);     //unknown zero
824                          out_uint8s(out, 8);     //create_time not available in posix;  
825                            seconds_since_1970_to_filetime(get_create_time(&fstat), &ft_high, &ft_low);
826                            out_uint32_le(out, ft_low);     // create time
827                            out_uint32_le(out, ft_high);
828    
829                          seconds_since_1970_to_filetime(fstat.st_atime, &ft_high, &ft_low);                          seconds_since_1970_to_filetime(fstat.st_atime, &ft_high, &ft_low);
830                          out_uint32_le(out, ft_low);     //last_access_time                          out_uint32_le(out, ft_low);     //last_access_time
# Line 656  disk_query_directory(HANDLE handle, uint Line 834  disk_query_directory(HANDLE handle, uint
834                          out_uint32_le(out, ft_low);     //last_write_time                          out_uint32_le(out, ft_low);     //last_write_time
835                          out_uint32_le(out, ft_high);                          out_uint32_le(out, ft_high);
836    
837                          out_uint8s(out, 8);     //unknown zero                          seconds_since_1970_to_filetime(fstat.st_ctime, &ft_high, &ft_low);
838                            out_uint32_le(out, ft_low);     //change_write_time
839                            out_uint32_le(out, ft_high);
840    
841                          out_uint32_le(out, fstat.st_size);      //filesize low                          out_uint32_le(out, fstat.st_size);      //filesize low
842                          out_uint32_le(out, 0);  //filesize high                          out_uint32_le(out, 0);  //filesize high
843                          out_uint32_le(out, fstat.st_size);      //filesize low                          out_uint32_le(out, fstat.st_size);      //filesize low
# Line 678  disk_query_directory(HANDLE handle, uint Line 859  disk_query_directory(HANDLE handle, uint
859          return STATUS_SUCCESS;          return STATUS_SUCCESS;
860  }  }
861    
862    
863    
864    static NTSTATUS
865    disk_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out)
866    {
867            uint32 result;
868    
869            if (((request >> 16) != 20) || ((request >> 16) != 9))
870                    return STATUS_INVALID_PARAMETER;
871    
872            /* extract operation */
873            request >>= 2;
874            request &= 0xfff;
875    
876            printf("DISK IOCTL %d\n", request);
877    
878            switch (request)
879            {
880                    case 25:        // ?
881                    case 42:        // ?
882                    default:
883                            unimpl("DISK IOCTL %d\n", request);
884                            return STATUS_INVALID_PARAMETER;
885            }
886    
887            return STATUS_SUCCESS;
888    }
889    
890  DEVICE_FNS disk_fns = {  DEVICE_FNS disk_fns = {
891          disk_create,          disk_create,
892          disk_close,          disk_close,
893          disk_read,          disk_read,
894          disk_write,          disk_write,
895          NULL                    /* device_control */          disk_device_control     /* device_control */
896  };  };

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

  ViewVC Help
Powered by ViewVC 1.1.26