/[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 864 by stargo, Tue Mar 8 01:01:47 2005 UTC revision 865 by stargo, Tue Mar 15 11:25:50 2005 UTC
# Line 260  disk_enum_devices(uint32 * id, char *opt Line 260  disk_enum_devices(uint32 * id, char *opt
260          char *pos2;          char *pos2;
261          int count = 0;          int count = 0;
262    
263          // skip the first colon          /* skip the first colon */
264          optarg++;          optarg++;
265          while ((pos = next_arg(optarg, ',')) && *id < RDPDR_MAX_DEVICES)          while ((pos = next_arg(optarg, ',')) && *id < RDPDR_MAX_DEVICES)
266          {          {
# Line 306  disk_create(uint32 device_id, uint32 acc Line 306  disk_create(uint32 device_id, uint32 acc
306          {          {
307                  case CREATE_ALWAYS:                  case CREATE_ALWAYS:
308    
309                          // Delete existing file/link.                          /* Delete existing file/link. */
310                          unlink(path);                          unlink(path);
311                          flags |= O_CREAT;                          flags |= O_CREAT;
312                          break;                          break;
313    
314                  case CREATE_NEW:                  case CREATE_NEW:
315    
316                          // If the file already exists, then fail.                          /* If the file already exists, then fail. */
317                          flags |= O_CREAT | O_EXCL;                          flags |= O_CREAT | O_EXCL;
318                          break;                          break;
319    
320                  case OPEN_ALWAYS:                  case OPEN_ALWAYS:
321    
322                          // Create if not already exists.                          /* Create if not already exists. */
323                          flags |= O_CREAT;                          flags |= O_CREAT;
324                          break;                          break;
325    
326                  case OPEN_EXISTING:                  case OPEN_EXISTING:
327    
328                          // Default behaviour                          /* Default behaviour */
329                          break;                          break;
330    
331                  case TRUNCATE_EXISTING:                  case TRUNCATE_EXISTING:
332    
333                          // If the file does not exist, then fail.                          /* If the file does not exist, then fail. */
334                          flags |= O_TRUNC;                          flags |= O_TRUNC;
335                          break;                          break;
336          }          }
337    
338          //printf("Open: \"%s\"  flags: %X, accessmask: %X sharemode: %X create disp: %X\n", path, flags_and_attributes, accessmask, sharemode, create_disposition);          /*printf("Open: \"%s\"  flags: %X, accessmask: %X sharemode: %X create disp: %X\n", path, flags_and_attributes, accessmask, sharemode, create_disposition);*/
339    
340          // Get information about file and set that flag ourselfs          /* Get information about file and set that flag ourselfs */
341          if ((stat(path, &filestat) == 0) && (S_ISDIR(filestat.st_mode)))          if ((stat(path, &filestat) == 0) && (S_ISDIR(filestat.st_mode)))
342          {          {
343                  if (flags_and_attributes & FILE_NON_DIRECTORY_FILE)                  if (flags_and_attributes & FILE_NON_DIRECTORY_FILE)
# Line 568  disk_query_information(NTHANDLE handle, Line 568  disk_query_information(NTHANDLE handle,
568    
569          path = g_fileinfo[handle].path;          path = g_fileinfo[handle].path;
570    
571          // Get information about file          /* Get information about file */
572          if (fstat(handle, &filestat) != 0)          if (fstat(handle, &filestat) != 0)
573          {          {
574                  perror("stat");                  perror("stat");
# Line 576  disk_query_information(NTHANDLE handle, Line 576  disk_query_information(NTHANDLE handle,
576                  return STATUS_ACCESS_DENIED;                  return STATUS_ACCESS_DENIED;
577          }          }
578    
579          // Set file attributes          /* Set file attributes */
580          file_attributes = 0;          file_attributes = 0;
581          if (S_ISDIR(filestat.st_mode))          if (S_ISDIR(filestat.st_mode))
582                  file_attributes |= FILE_ATTRIBUTE_DIRECTORY;                  file_attributes |= FILE_ATTRIBUTE_DIRECTORY;
# Line 591  disk_query_information(NTHANDLE handle, Line 591  disk_query_information(NTHANDLE handle,
591          if (!(filestat.st_mode & S_IWUSR))          if (!(filestat.st_mode & S_IWUSR))
592                  file_attributes |= FILE_ATTRIBUTE_READONLY;                  file_attributes |= FILE_ATTRIBUTE_READONLY;
593    
594          // Return requested data          /* Return requested data */
595          switch (info_class)          switch (info_class)
596          {          {
597                  case FileBasicInformation:                  case FileBasicInformation:
598                          seconds_since_1970_to_filetime(get_create_time(&filestat), &ft_high,                          seconds_since_1970_to_filetime(get_create_time(&filestat), &ft_high,
599                                                         &ft_low);                                                         &ft_low);
600                          out_uint32_le(out, ft_low);     //create_access_time                          out_uint32_le(out, ft_low);     /* create_access_time */
601                          out_uint32_le(out, ft_high);                          out_uint32_le(out, ft_high);
602    
603                          seconds_since_1970_to_filetime(filestat.st_atime, &ft_high, &ft_low);                          seconds_since_1970_to_filetime(filestat.st_atime, &ft_high, &ft_low);
604                          out_uint32_le(out, ft_low);     //last_access_time                          out_uint32_le(out, ft_low);     /* last_access_time */
605                          out_uint32_le(out, ft_high);                          out_uint32_le(out, ft_high);
606    
607                          seconds_since_1970_to_filetime(filestat.st_mtime, &ft_high, &ft_low);                          seconds_since_1970_to_filetime(filestat.st_mtime, &ft_high, &ft_low);
608                          out_uint32_le(out, ft_low);     //last_write_time                          out_uint32_le(out, ft_low);     /* last_write_time */
609                          out_uint32_le(out, ft_high);                          out_uint32_le(out, ft_high);
610    
611                          seconds_since_1970_to_filetime(filestat.st_ctime, &ft_high, &ft_low);                          seconds_since_1970_to_filetime(filestat.st_ctime, &ft_high, &ft_low);
612                          out_uint32_le(out, ft_low);     //last_change_time                          out_uint32_le(out, ft_low);     /* last_change_time */
613                          out_uint32_le(out, ft_high);                          out_uint32_le(out, ft_high);
614    
615                          out_uint32_le(out, file_attributes);                          out_uint32_le(out, file_attributes);
# Line 617  disk_query_information(NTHANDLE handle, Line 617  disk_query_information(NTHANDLE handle,
617    
618                  case FileStandardInformation:                  case FileStandardInformation:
619    
620                          out_uint32_le(out, filestat.st_size);   //Allocation size                          out_uint32_le(out, filestat.st_size);   /* Allocation size */
621                          out_uint32_le(out, 0);                          out_uint32_le(out, 0);
622                          out_uint32_le(out, filestat.st_size);   //End of file                          out_uint32_le(out, filestat.st_size);   /* End of file */
623                          out_uint32_le(out, 0);                          out_uint32_le(out, 0);
624                          out_uint32_le(out, filestat.st_nlink);  //Number of links                          out_uint32_le(out, filestat.st_nlink);  /* Number of links */
625                          out_uint8(out, 0);      //Delete pending                          out_uint8(out, 0);      /* Delete pending */
626                          out_uint8(out, S_ISDIR(filestat.st_mode) ? 1 : 0);      //Directory                          out_uint8(out, S_ISDIR(filestat.st_mode) ? 1 : 0);      /* Directory */
627                          break;                          break;
628    
629                  case FileObjectIdInformation:                  case FileObjectIdInformation:
# Line 663  disk_set_information(NTHANDLE handle, ui Line 663  disk_set_information(NTHANDLE handle, ui
663                          in_uint8s(in, 4);       /* Handle of root dir? */                          in_uint8s(in, 4);       /* Handle of root dir? */
664                          in_uint8s(in, 24);      /* unknown */                          in_uint8s(in, 24);      /* unknown */
665    
666                          // CreationTime                          /* CreationTime */
667                          in_uint32_le(in, ft_low);                          in_uint32_le(in, ft_low);
668                          in_uint32_le(in, ft_high);                          in_uint32_le(in, ft_high);
669    
670                          // AccessTime                          /* AccessTime */
671                          in_uint32_le(in, ft_low);                          in_uint32_le(in, ft_low);
672                          in_uint32_le(in, ft_high);                          in_uint32_le(in, ft_high);
673                          if (ft_low || ft_high)                          if (ft_low || ft_high)
674                                  access_time = convert_1970_to_filetime(ft_high, ft_low);                                  access_time = convert_1970_to_filetime(ft_high, ft_low);
675    
676                          // WriteTime                          /* WriteTime */
677                          in_uint32_le(in, ft_low);                          in_uint32_le(in, ft_low);
678                          in_uint32_le(in, ft_high);                          in_uint32_le(in, ft_high);
679                          if (ft_low || ft_high)                          if (ft_low || ft_high)
680                                  write_time = convert_1970_to_filetime(ft_high, ft_low);                                  write_time = convert_1970_to_filetime(ft_high, ft_low);
681    
682                          // ChangeTime                          /* ChangeTime */
683                          in_uint32_le(in, ft_low);                          in_uint32_le(in, ft_low);
684                          in_uint32_le(in, ft_high);                          in_uint32_le(in, ft_high);
685                          if (ft_low || ft_high)                          if (ft_low || ft_high)
# Line 718  disk_set_information(NTHANDLE handle, ui Line 718  disk_set_information(NTHANDLE handle, ui
718                          }                          }
719    
720                          if (!file_attributes)                          if (!file_attributes)
721                                  break;  // not valid                                  break;  /* not valid */
722    
723                          mode = filestat.st_mode;                          mode = filestat.st_mode;
724    
# Line 835  disk_check_notify(NTHANDLE handle) Line 835  disk_check_notify(NTHANDLE handle)
835    
836          if (memcmp(&pfinfo->notify, &notify, sizeof(NOTIFY)))          if (memcmp(&pfinfo->notify, &notify, sizeof(NOTIFY)))
837          {          {
838                  //printf("disk_check_notify found changed event\n");                  /*printf("disk_check_notify found changed event\n");*/
839                  memcpy(&pfinfo->notify, &notify, sizeof(NOTIFY));                  memcpy(&pfinfo->notify, &notify, sizeof(NOTIFY));
840                  status = STATUS_NOTIFY_ENUM_DIR;                  status = STATUS_NOTIFY_ENUM_DIR;
841          }          }
# Line 970  FsVolumeInfo(char *fpath) Line 970  FsVolumeInfo(char *fpath)
970                                                  read(fd, buf, sizeof(buf));                                                  read(fd, buf, sizeof(buf));
971                                                  strncpy(info.label, buf + 41, 32);                                                  strncpy(info.label, buf + 41, 32);
972                                                  info.label[32] = '\0';                                                  info.label[32] = '\0';
973                                                  //info.Serial = (buf[128]<<24)+(buf[127]<<16)+(buf[126]<<8)+buf[125];                                                  /* info.Serial = (buf[128]<<24)+(buf[127]<<16)+(buf[126]<<8)+buf[125]; */
974                                          }                                          }
975                                          close(fd);                                          close(fd);
976                                  }                                  }
# Line 1073  disk_query_directory(NTHANDLE handle, ui Line 1073  disk_query_directory(NTHANDLE handle, ui
1073          {          {
1074                  case FileBothDirectoryInformation:                  case FileBothDirectoryInformation:
1075    
1076                          // If a search pattern is received, remember this pattern, and restart search                          /* If a search pattern is received, remember this pattern, and restart search */
1077                          if (pattern[0] != 0)                          if (pattern[0] != 0)
1078                          {                          {
1079                                  strncpy(pfinfo->pattern, 1 + strrchr(pattern, '/'), 64);                                  strncpy(pfinfo->pattern, 1 + strrchr(pattern, '/'), 64);
1080                                  rewinddir(pdir);                                  rewinddir(pdir);
1081                          }                          }
1082    
1083                          // find next dirent matching pattern                          /* find next dirent matching pattern */
1084                          pdirent = readdir(pdir);                          pdirent = readdir(pdir);
1085                          while (pdirent && fnmatch(pfinfo->pattern, pdirent->d_name, 0) != 0)                          while (pdirent && fnmatch(pfinfo->pattern, pdirent->d_name, 0) != 0)
1086                                  pdirent = readdir(pdir);                                  pdirent = readdir(pdir);
# Line 1088  disk_query_directory(NTHANDLE handle, ui Line 1088  disk_query_directory(NTHANDLE handle, ui
1088                          if (pdirent == NULL)                          if (pdirent == NULL)
1089                                  return STATUS_NO_MORE_FILES;                                  return STATUS_NO_MORE_FILES;
1090    
1091                          // Get information for directory entry                          /* Get information for directory entry */
1092                          sprintf(fullpath, "%s/%s", dirname, pdirent->d_name);                          sprintf(fullpath, "%s/%s", dirname, pdirent->d_name);
1093    
1094                          if (stat(fullpath, &fstat))                          if (stat(fullpath, &fstat))
# Line 1119  disk_query_directory(NTHANDLE handle, ui Line 1119  disk_query_directory(NTHANDLE handle, ui
1119                          if (!(fstat.st_mode & S_IWUSR))                          if (!(fstat.st_mode & S_IWUSR))
1120                                  file_attributes |= FILE_ATTRIBUTE_READONLY;                                  file_attributes |= FILE_ATTRIBUTE_READONLY;
1121    
1122                          // Return requested information                          /* Return requested information */
1123                          out_uint8s(out, 8);     //unknown zero                          out_uint8s(out, 8);     /* unknown zero */
1124    
1125                          seconds_since_1970_to_filetime(get_create_time(&fstat), &ft_high, &ft_low);                          seconds_since_1970_to_filetime(get_create_time(&fstat), &ft_high, &ft_low);
1126                          out_uint32_le(out, ft_low);     // create time                          out_uint32_le(out, ft_low);     /* create time */
1127                          out_uint32_le(out, ft_high);                          out_uint32_le(out, ft_high);
1128    
1129                          seconds_since_1970_to_filetime(fstat.st_atime, &ft_high, &ft_low);                          seconds_since_1970_to_filetime(fstat.st_atime, &ft_high, &ft_low);
1130                          out_uint32_le(out, ft_low);     //last_access_time                          out_uint32_le(out, ft_low);     /* last_access_time */
1131                          out_uint32_le(out, ft_high);                          out_uint32_le(out, ft_high);
1132    
1133                          seconds_since_1970_to_filetime(fstat.st_mtime, &ft_high, &ft_low);                          seconds_since_1970_to_filetime(fstat.st_mtime, &ft_high, &ft_low);
1134                          out_uint32_le(out, ft_low);     //last_write_time                          out_uint32_le(out, ft_low);     /* last_write_time */
1135                          out_uint32_le(out, ft_high);                          out_uint32_le(out, ft_high);
1136    
1137                          seconds_since_1970_to_filetime(fstat.st_ctime, &ft_high, &ft_low);                          seconds_since_1970_to_filetime(fstat.st_ctime, &ft_high, &ft_low);
1138                          out_uint32_le(out, ft_low);     //change_write_time                          out_uint32_le(out, ft_low);     /* change_write_time */
1139                          out_uint32_le(out, ft_high);                          out_uint32_le(out, ft_high);
1140    
1141                          out_uint32_le(out, fstat.st_size);      //filesize low                          out_uint32_le(out, fstat.st_size);      /* filesize low */
1142                          out_uint32_le(out, 0);  //filesize high                          out_uint32_le(out, 0);  /* filesize high */
1143                          out_uint32_le(out, fstat.st_size);      //filesize low                          out_uint32_le(out, fstat.st_size);      /* filesize low */
1144                          out_uint32_le(out, 0);  //filesize high                          out_uint32_le(out, 0);  /* filesize high */
1145                          out_uint32_le(out, file_attributes);                          out_uint32_le(out, file_attributes);
1146                          out_uint8(out, 2 * strlen(pdirent->d_name) + 2);        //unicode length                          out_uint8(out, 2 * strlen(pdirent->d_name) + 2);        /* unicode length */
1147                          out_uint8s(out, 7);     //pad?                          out_uint8s(out, 7);     /* pad? */
1148                          out_uint8(out, 0);      //8.3 file length                          out_uint8(out, 0);      /* 8.3 file length */
1149                          out_uint8s(out, 2 * 12);        //8.3 unicode length                          out_uint8s(out, 2 * 12);        /* 8.3 unicode length */
1150                          rdp_out_unistr(out, pdirent->d_name, 2 * strlen(pdirent->d_name));                          rdp_out_unistr(out, pdirent->d_name, 2 * strlen(pdirent->d_name));
1151                          break;                          break;
1152    
# Line 1178  disk_device_control(NTHANDLE handle, uin Line 1178  disk_device_control(NTHANDLE handle, uin
1178    
1179          switch (request)          switch (request)
1180          {          {
1181                  case 25:        // ?                  case 25:        /* ? */
1182                  case 42:        // ?                  case 42:        /* ? */
1183                  default:                  default:
1184                          unimpl("DISK IOCTL %d\n", request);                          unimpl("DISK IOCTL %d\n", request);
1185                          return STATUS_INVALID_PARAMETER;                          return STATUS_INVALID_PARAMETER;

Legend:
Removed from v.864  
changed lines
  Added in v.865

  ViewVC Help
Powered by ViewVC 1.1.26