Changeset b152d33 in rtems


Ignore:
Timestamp:
Aug 6, 2018, 4:26:50 AM (16 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
0b038bd4
Parents:
ab96aec
git-author:
Sebastian Huber <sebastian.huber@…> (08/06/18 04:26:50)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/07/18 05:17:19)
Message:

fileio: Avoid deprecated rtems_disk_obtain()

Update #3358.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/samples/fileio/init.c

    rab96aec rb152d33  
    237237
    238238static int
    239 disk_test_write_blocks (dev_t dev, int start, int count, size_t size)
     239disk_test_write_blocks (const char *name, int start, int count, size_t size)
    240240{
    241241  int                 block;
     
    246246  rtems_status_code   sc;
    247247  int                 rv = 0;
    248   rtems_disk_device* dd;
    249  
    250   dd = rtems_disk_obtain (dev);
    251   if (!dd)
     248  rtems_disk_device*  dd;
     249  int                 fd;
     250
     251  fd = open(name, O_RDWR);
     252  if (fd < 0) {
     253    printf ("error: cannot open disk\n");
     254    rv = 1;
     255  }
     256
     257  if (rv == 0 && rtems_disk_fd_get_disk_device(fd, &dd) != 0)
    252258  {
    253259    printf ("error: cannot obtain disk\n");
    254260    rv = 1;
    255261  }
    256  
     262
     263  if (fd >= 0 && close (fd) != 0)
     264  {
     265    printf ("error: close disk failed\n");
     266    rv = 1;
     267  }
     268
    257269  if (rv == 0 && disk_test_set_block_size (dd, size) < 0)
    258270  {
     
    286298  }
    287299
    288   rtems_disk_release (dd);
    289 
    290300  return rv;
    291301}
     
    294304disk_test_block_sizes (int argc, char *argv[])
    295305{
    296   struct stat st;
    297   char*       name;
    298   int         start;
    299   int         count;
    300   int         size;
    301  
     306  char* name;
     307  int   start;
     308  int   count;
     309  int   size;
     310
    302311  if (argc != (4 + 1))
    303312  {
     
    307316
    308317  name = argv[1];
    309  
    310   if (stat (name, &st) < 0)
    311   {
    312     printf ("error: stat '%s' failed: %s\n", name, strerror (errno));
    313     return 1;
    314   }
    315318
    316319  start = strtoul (argv[2], 0, 0);
    317320  count = strtoul (argv[3], 0, 0);
    318321  size  = strtoul (argv[4], 0, 0);
    319  
    320   return disk_test_write_blocks (st.st_rdev, start, count, size);
     322
     323  return disk_test_write_blocks (name, start, count, size);
    321324}
    322325
Note: See TracChangeset for help on using the changeset viewer.