/[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 574 by stargo, Wed Jan 21 23:53:55 2004 UTC revision 612 by n-ki, Mon Feb 23 09:58:16 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 STATFS_FN(path, buf) (statvfs(path,buf))  #define STATFS_FN(path, buf) (statvfs(path,buf))
108  #define STATFS_T statvfs  #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 STATFS_FN(path, buf) (statfs(path,buf))  #define STATFS_FN(path, buf) (statfs(path,buf))
# Line 117  struct fileinfo Line 137  struct fileinfo
137  }  }
138  g_fileinfo[MAX_OPEN_FILES];  g_fileinfo[MAX_OPEN_FILES];
139    
140    time_t
141    get_create_time(struct stat *st)
142    {
143            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
156  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 128  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 163  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 172  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 216  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 246  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 265  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 272  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 323  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 0
401            /* 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          if (offset)          if (offset)
411                  lseek(handle, offset, SEEK_SET);                  lseek(handle, offset, SEEK_SET);
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 353  disk_write(HANDLE handle, uint8 * data, Line 443  disk_write(HANDLE handle, uint8 * data,
443          {          {
444                  perror("write");                  perror("write");
445                  *result = 0;                  *result = 0;
446                  return STATUS_ACCESS_DENIED;                  switch (errno)
447                    {
448                            case ENOSPC:
449                                    return STATUS_DISK_FULL;
450                            default:
451                                    return STATUS_ACCESS_DENIED;
452                    }
453          }          }
454    
455          *result = n;          *result = n;
# Line 381  disk_query_information(HANDLE handle, ui Line 477  disk_query_information(HANDLE handle, ui
477          // Set file attributes          // Set file attributes
478          file_attributes = 0;          file_attributes = 0;
479          if (S_ISDIR(filestat.st_mode))          if (S_ISDIR(filestat.st_mode))
         {  
480                  file_attributes |= FILE_ATTRIBUTE_DIRECTORY;                  file_attributes |= FILE_ATTRIBUTE_DIRECTORY;
481          }  
482          filename = 1 + strrchr(path, '/');          filename = 1 + strrchr(path, '/');
483          if (filename && filename[0] == '.')          if (filename && filename[0] == '.')
         {  
484                  file_attributes |= FILE_ATTRIBUTE_HIDDEN;                  file_attributes |= FILE_ATTRIBUTE_HIDDEN;
485          }  
486            if (!file_attributes)
487                    file_attributes |= FILE_ATTRIBUTE_NORMAL;
488    
489            if (!(filestat.st_mode & S_IWUSR))
490                    file_attributes |= FILE_ATTRIBUTE_READONLY;
491    
492          // Return requested data          // Return requested data
493          switch (info_class)          switch (info_class)
494          {          {
495                  case 4: /* FileBasicInformation */                  case 4: /* FileBasicInformation */
496                            seconds_since_1970_to_filetime(get_create_time(&filestat), &ft_high,
497                          out_uint8s(out, 8);     //create_time not available;                                                         &ft_low);
498                            out_uint32_le(out, ft_low);     //create_access_time
499                            out_uint32_le(out, ft_high);
500    
501                          seconds_since_1970_to_filetime(filestat.st_atime, &ft_high, &ft_low);                          seconds_since_1970_to_filetime(filestat.st_atime, &ft_high, &ft_low);
502                          out_uint32_le(out, ft_low);     //last_access_time                          out_uint32_le(out, ft_low);     //last_access_time
# Line 405  disk_query_information(HANDLE handle, ui Line 506  disk_query_information(HANDLE handle, ui
506                          out_uint32_le(out, ft_low);     //last_write_time                          out_uint32_le(out, ft_low);     //last_write_time
507                          out_uint32_le(out, ft_high);                          out_uint32_le(out, ft_high);
508    
509                          out_uint8s(out, 8);     //unknown zero                          seconds_since_1970_to_filetime(filestat.st_ctime, &ft_high, &ft_low);
510                            out_uint32_le(out, ft_low);     //last_change_time
511                            out_uint32_le(out, ft_high);
512    
513                          out_uint32_le(out, file_attributes);                          out_uint32_le(out, file_attributes);
514                          break;                          break;
515    
# Line 441  disk_set_information(HANDLE handle, uint Line 545  disk_set_information(HANDLE handle, uint
545          char newname[256], fullpath[256];          char newname[256], fullpath[256];
546          struct fileinfo *pfinfo;          struct fileinfo *pfinfo;
547    
548            int mode;
549            struct stat filestat;
550            time_t write_time, change_time, access_time, mod_time;
551            struct utimbuf tvs;
552            struct STATFS_T stat_fs;
553    
554          pfinfo = &(g_fileinfo[handle]);          pfinfo = &(g_fileinfo[handle]);
555    
556          switch (info_class)          switch (info_class)
557          {          {
558                  case 4: /* FileBasicInformation */                  case 4: /* FileBasicInformation */
559                            write_time = change_time = access_time = 0;
560    
561                            in_uint8s(in, 4);       /* Handle of root dir? */
562                            in_uint8s(in, 24);      /* unknown */
563    
564                            // CreationTime
565                            in_uint32_le(in, ft_low);
566                            in_uint32_le(in, ft_high);
567    
568                            // AccessTime
569                            in_uint32_le(in, ft_low);
570                            in_uint32_le(in, ft_high);
571                            if (ft_low || ft_high)
572                                    access_time = convert_1970_to_filetime(ft_high, ft_low);
573    
574                            // WriteTime
575                            in_uint32_le(in, ft_low);
576                            in_uint32_le(in, ft_high);
577                            if (ft_low || ft_high)
578                                    write_time = convert_1970_to_filetime(ft_high, ft_low);
579    
580                            // ChangeTime
581                            in_uint32_le(in, ft_low);
582                            in_uint32_le(in, ft_high);
583                            if (ft_low || ft_high)
584                                    change_time = convert_1970_to_filetime(ft_high, ft_low);
585    
586                            in_uint32_le(in, file_attributes);
587    
588                            if (fstat(handle, &filestat))
589                                    return STATUS_ACCESS_DENIED;
590    
591                            tvs.modtime = filestat.st_mtime;
592                            tvs.actime = filestat.st_atime;
593                            if (access_time)
594                                    tvs.actime = access_time;
595    
596    
597                            if (write_time || change_time)
598                                    mod_time = MIN(write_time, change_time);
599                            else
600                                    mod_time = write_time ? write_time : change_time;
601    
602                            if (mod_time)
603                                    tvs.modtime = mod_time;
604    
605    
606                            if (access_time || write_time || change_time)
607                            {
608    #if WITH_DEBUG_RDP5
609                                    printf("FileBasicInformation access       time %s",
610                                           ctime(&tvs.actime));
611                                    printf("FileBasicInformation modification time %s",
612                                           ctime(&tvs.modtime));
613    #endif
614                                    if (utime(pfinfo->path, &tvs))
615                                            return STATUS_ACCESS_DENIED;
616                            }
617    
618                            if (!file_attributes)
619                                    break;  // not valid
620    
621                            mode = filestat.st_mode;
622    
623                            if (file_attributes & FILE_ATTRIBUTE_READONLY)
624                                    mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
625                            else
626                                    mode |= S_IWUSR;
627    
628                            mode &= 0777;
629    #if WITH_DEBUG_RDP5
630                            printf("FileBasicInformation set access mode 0%o", mode);
631    #endif
632    
633                            if (fchmod(handle, mode))
634                                    return STATUS_ACCESS_DENIED;
635    
636                            /* prevents start of writing if not enough space left on device */
637                            if (STATFS_FN(g_rdpdr_device[pfinfo->device_id].local_path, &stat_fs) == 0)
638                                    if (stat_fs.f_bsize * stat_fs.f_bfree < length)
639                                            return STATUS_DISK_FULL;
640    
                         // Probably safe to ignore  
641                          break;                          break;
642    
643                  case 10:        /* FileRenameInformation */                  case 10:        /* FileRenameInformation */
# Line 479  disk_set_information(HANDLE handle, uint Line 669  disk_set_information(HANDLE handle, uint
669                  case 13:        /* FileDispositionInformation */                  case 13:        /* FileDispositionInformation */
670    
671                          //unimpl("IRP Set File Information class: FileDispositionInformation\n");                          //unimpl("IRP Set File Information class: FileDispositionInformation\n");
672                          // in_uint32_le(in, delete_on_close);  
673                            //in_uint32_le(in, delete_on_close);
674                          // disk_close(handle);                          // disk_close(handle);
675                          unlink(pfinfo->path);                          if ((pfinfo->flags_and_attributes & FILE_DIRECTORY_FILE))       // remove a directory
676                            {
677                                    if (rmdir(pfinfo->path) < 0)
678                                            return STATUS_ACCESS_DENIED;
679                            }
680                            else if (unlink(pfinfo->path) < 0)      // unlink a file
681                                    return STATUS_ACCESS_DENIED;
682    
683                          break;                          break;
684    
685                  case 19:        /* FileAllocationInformation */                  case 19:        /* FileAllocationInformation */
# Line 490  disk_set_information(HANDLE handle, uint Line 688  disk_set_information(HANDLE handle, uint
688                          break;                          break;
689    
690                  case 20:        /* FileEndOfFileInformation */                  case 20:        /* FileEndOfFileInformation */
691                            in_uint8s(in, 28);      /* unknown */
692                            in_uint32_le(in, length);       /* file size */
693    
694                            printf("FileEndOfFileInformation length = %d\n", length);
695                            // ????????????
696    
697                          unimpl("IRP Set File Information class: FileEndOfFileInformation\n");                          unimpl("IRP Set File Information class: FileEndOfFileInformation\n");
698                          break;                          break;
   
699                  default:                  default:
700    
701                          unimpl("IRP Set File Information class: 0x%x\n", info_class);                          unimpl("IRP Set File Information class: 0x%x\n", info_class);
# Line 513  disk_query_volume_information(HANDLE han Line 715  disk_query_volume_information(HANDLE han
715          volume = "RDESKTOP";          volume = "RDESKTOP";
716          fs_type = "RDPFS";          fs_type = "RDPFS";
717    
718          if (STATFS_FN(pfinfo->path, &stat_fs) != 0)     /* FIXME: statfs is not portable */          if (STATFS_FN(pfinfo->path, &stat_fs) != 0)
719          {          {
720                  perror("statfs");                  perror("statfs");
721                  return STATUS_ACCESS_DENIED;                  return STATUS_ACCESS_DENIED;
# Line 592  disk_query_directory(HANDLE handle, uint Line 794  disk_query_directory(HANDLE handle, uint
794                          // find next dirent matching pattern                          // find next dirent matching pattern
795                          pdirent = readdir(pdir);                          pdirent = readdir(pdir);
796                          while (pdirent && fnmatch(pfinfo->pattern, pdirent->d_name, 0) != 0)                          while (pdirent && fnmatch(pfinfo->pattern, pdirent->d_name, 0) != 0)
                         {  
797                                  pdirent = readdir(pdir);                                  pdirent = readdir(pdir);
                         }  
798    
799                          if (pdirent == NULL)                          if (pdirent == NULL)
                         {  
800                                  return STATUS_NO_MORE_FILES;                                  return STATUS_NO_MORE_FILES;
                         }  
801    
802                          // Get information for directory entry                          // Get information for directory entry
803                          sprintf(fullpath, "%s/%s", dirname, pdirent->d_name);                          sprintf(fullpath, "%s/%s", dirname, pdirent->d_name);
804                          /* JIF  
805                            /* JIF
806                             printf("Stat: %s\n", fullpath); */                             printf("Stat: %s\n", fullpath); */
807                          if (stat(fullpath, &fstat))                          if (stat(fullpath, &fstat))
808                          {                          {
# Line 616  disk_query_directory(HANDLE handle, uint Line 815  disk_query_directory(HANDLE handle, uint
815                                  file_attributes |= FILE_ATTRIBUTE_DIRECTORY;                                  file_attributes |= FILE_ATTRIBUTE_DIRECTORY;
816                          if (pdirent->d_name[0] == '.')                          if (pdirent->d_name[0] == '.')
817                                  file_attributes |= FILE_ATTRIBUTE_HIDDEN;                                  file_attributes |= FILE_ATTRIBUTE_HIDDEN;
818                            if (!file_attributes)
819                                    file_attributes |= FILE_ATTRIBUTE_NORMAL;
820                            if (!(fstat.st_mode & S_IWUSR))
821                                    file_attributes |= FILE_ATTRIBUTE_READONLY;
822    
823                          // Return requested information                          // Return requested information
824                          out_uint8s(out, 8);     //unknown zero                          out_uint8s(out, 8);     //unknown zero
825                          out_uint8s(out, 8);     //create_time not available in posix;  
826                            seconds_since_1970_to_filetime(get_create_time(&fstat), &ft_high, &ft_low);
827                            out_uint32_le(out, ft_low);     // create time
828                            out_uint32_le(out, ft_high);
829    
830                          seconds_since_1970_to_filetime(fstat.st_atime, &ft_high, &ft_low);                          seconds_since_1970_to_filetime(fstat.st_atime, &ft_high, &ft_low);
831                          out_uint32_le(out, ft_low);     //last_access_time                          out_uint32_le(out, ft_low);     //last_access_time
# Line 629  disk_query_directory(HANDLE handle, uint Line 835  disk_query_directory(HANDLE handle, uint
835                          out_uint32_le(out, ft_low);     //last_write_time                          out_uint32_le(out, ft_low);     //last_write_time
836                          out_uint32_le(out, ft_high);                          out_uint32_le(out, ft_high);
837    
838                          out_uint8s(out, 8);     //unknown zero                          seconds_since_1970_to_filetime(fstat.st_ctime, &ft_high, &ft_low);
839                            out_uint32_le(out, ft_low);     //change_write_time
840                            out_uint32_le(out, ft_high);
841    
842                          out_uint32_le(out, fstat.st_size);      //filesize low                          out_uint32_le(out, fstat.st_size);      //filesize low
843                          out_uint32_le(out, 0);  //filesize high                          out_uint32_le(out, 0);  //filesize high
844                          out_uint32_le(out, fstat.st_size);      //filesize low                          out_uint32_le(out, fstat.st_size);      //filesize low
# Line 651  disk_query_directory(HANDLE handle, uint Line 860  disk_query_directory(HANDLE handle, uint
860          return STATUS_SUCCESS;          return STATUS_SUCCESS;
861  }  }
862    
863    
864    
865    static NTSTATUS
866    disk_device_control(HANDLE handle, uint32 request, STREAM in, STREAM out)
867    {
868            uint32 result;
869    
870            if (((request >> 16) != 20) || ((request >> 16) != 9))
871                    return STATUS_INVALID_PARAMETER;
872    
873            /* extract operation */
874            request >>= 2;
875            request &= 0xfff;
876    
877            printf("DISK IOCTL %d\n", request);
878    
879            switch (request)
880            {
881                    case 25:        // ?
882                    case 42:        // ?
883                    default:
884                            unimpl("DISK IOCTL %d\n", request);
885                            return STATUS_INVALID_PARAMETER;
886            }
887    
888            return STATUS_SUCCESS;
889    }
890    
891  DEVICE_FNS disk_fns = {  DEVICE_FNS disk_fns = {
892          disk_create,          disk_create,
893          disk_close,          disk_close,
894          disk_read,          disk_read,
895          disk_write,          disk_write,
896          NULL                    /* device_control */          disk_device_control     /* device_control */
897  };  };

Legend:
Removed from v.574  
changed lines
  Added in v.612

  ViewVC Help
Powered by ViewVC 1.1.26