/[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 576 by stargo, Thu Jan 22 20:31:59 2004 UTC revision 597 by n-ki, Thu Feb 5 15:41:56 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 163  disk_enum_devices(int *id, char *optarg) Line 179  disk_enum_devices(int *id, char *optarg)
179          return count;          return count;
180  }  }
181    
182  /* Opens of creates a file or directory */  /* Opens or creates a file or directory */
183  NTSTATUS  NTSTATUS
184  disk_create(uint32 device_id, uint32 accessmask, uint32 sharemode, uint32 create_disposition,  disk_create(uint32 device_id, uint32 accessmask, uint32 sharemode, uint32 create_disposition,
185              uint32 flags_and_attributes, char *filename, HANDLE * phandle)              uint32 flags_and_attributes, char *filename, HANDLE * phandle)
# Line 181  disk_create(uint32 device_id, uint32 acc Line 197  disk_create(uint32 device_id, uint32 acc
197          if (filename[strlen(filename) - 1] == '/')          if (filename[strlen(filename) - 1] == '/')
198                  filename[strlen(filename) - 1] = 0;                  filename[strlen(filename) - 1] = 0;
199          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);  
200    
201          switch (create_disposition)          switch (create_disposition)
202          {          {
# Line 216  disk_create(uint32 device_id, uint32 acc Line 231  disk_create(uint32 device_id, uint32 acc
231                          break;                          break;
232          }          }
233    
234            //printf("Open: \"%s\"  flags: %u, accessmask: %u sharemode: %u create disp: %u\n", path, flags_and_attributes, accessmask, sharemode, create_disposition);
235    
236            /* since we can't trust the FILE_DIRECTORY_FILE flag */
237            /* we need to double check that the file isn't a dir */
238            struct stat filestat;
239    
240            // Get information about file and set that flag ourselfs
241            if ((stat(path, &filestat) == 0) && (S_ISDIR(filestat.st_mode)))
242                    flags_and_attributes |= FILE_DIRECTORY_FILE;
243    
244          if (flags_and_attributes & FILE_DIRECTORY_FILE)          if (flags_and_attributes & FILE_DIRECTORY_FILE)
245          {          {
246                  if (flags & O_CREAT)                  if (flags & O_CREAT)
# Line 246  disk_create(uint32 device_id, uint32 acc Line 271  disk_create(uint32 device_id, uint32 acc
271          }          }
272          else          else
273          {          {
274    
275                  if (accessmask & GENERIC_ALL                  if (accessmask & GENERIC_ALL
276                      || (accessmask & GENERIC_READ && accessmask & GENERIC_WRITE))                      || (accessmask & GENERIC_READ && accessmask & GENERIC_WRITE))
277                  {                  {
# Line 272  disk_create(uint32 device_id, uint32 acc Line 298  disk_create(uint32 device_id, uint32 acc
298                                  case ENOENT:                                  case ENOENT:
299    
300                                          return STATUS_NO_SUCH_FILE;                                          return STATUS_NO_SUCH_FILE;
   
301                                  default:                                  default:
302    
303                                          perror("open");                                          perror("open");
304                                          return STATUS_NO_SUCH_FILE;                                          return STATUS_NO_SUCH_FILE;
305                          }                          }
306                  }                  }
307    
308                    /* all read and writes of files should be non blocking */
309                    if (fcntl(handle, F_SETFL, O_NONBLOCK) == -1)
310                            perror("fcntl");
311          }          }
312    
313          if (handle >= MAX_OPEN_FILES)          if (handle >= MAX_OPEN_FILES)
# Line 323  disk_read(HANDLE handle, uint8 * data, u Line 352  disk_read(HANDLE handle, uint8 * data, u
352  {  {
353          int n;          int n;
354    
355            /* browsing dir ????        */
356            /* each request is 24 bytes */
357            if (g_fileinfo[handle].flags_and_attributes & FILE_DIRECTORY_FILE)
358            {
359                    *result = 0;
360                    return STATUS_SUCCESS;
361            }
362    
363          if (offset)          if (offset)
364                  lseek(handle, offset, SEEK_SET);                  lseek(handle, offset, SEEK_SET);
365          n = read(handle, data, length);          n = read(handle, data, length);
# Line 603  disk_query_directory(HANDLE handle, uint Line 640  disk_query_directory(HANDLE handle, uint
640    
641                          // Get information for directory entry                          // Get information for directory entry
642                          sprintf(fullpath, "%s/%s", dirname, pdirent->d_name);                          sprintf(fullpath, "%s/%s", dirname, pdirent->d_name);
643                          /* JIF                          /* JIF
644                             printf("Stat: %s\n", fullpath); */                             printf("Stat: %s\n", fullpath); */
645                          if (stat(fullpath, &fstat))                          if (stat(fullpath, &fstat))
646                          {                          {

Legend:
Removed from v.576  
changed lines
  Added in v.597

  ViewVC Help
Powered by ViewVC 1.1.26