Changeset c8522fd in rtems


Ignore:
Timestamp:
May 17, 2010, 8:08:30 AM (9 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.10, 4.11, master
Children:
377c0cb0
Parents:
5dc9c96
Message:

2010-05-17 Oleg Kravtsov <Oleg.Kravtsov@…>

PR 1449/cpukit

  • libblock/src/diskdevs.c: rtems_disk_next() will now implicitly obtain the returned disk.
  • libblock/include/rtems/diskdevs.h: Documentation.
Location:
cpukit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/ChangeLog

    r5dc9c96 rc8522fd  
     12010-05-17      Oleg Kravtsov <Oleg.Kravtsov@oktetlabs.ru>
     2
     3        PR 1449/cpukit
     4        * libblock/src/diskdevs.c: rtems_disk_next() will now implicitly
     5        obtain the returned disk.
     6        * libblock/include/rtems/diskdevs.h: Documentation.
     7
    182010-05-15      Chris Johns <chrisj@rtems.org>
    29
  • cpukit/libblock/include/rtems/diskdevs.h

    r5dc9c96 rc8522fd  
    324324 *
    325325 * @code
    326  * rtems_disk_device *dd = rtems_disk_next((dev_t) -1);
    327  *
    328  * while (dd != NULL) {
    329  *   dd = rtems_disk_next(dd->dev);
     326 * rtems_status_code sc = RTEMS_SUCCESSFUL;
     327 * rtems_disk_device *dd = (dev_t) -1;
     328 *
     329 * while (sc == RTEMS_SUCCESSFUL && (dd = rtems_disk_next(dev)) != NULL) {
     330 *   dev = rtems_disk_get_device_identifier(dd);
     331 *   sc = rtems_disk_release(dd);
    330332 * }
    331333 * @endcode
  • cpukit/libblock/src/diskdevs.c

    r5dc9c96 rc8522fd  
    463463rtems_disk_next(dev_t dev)
    464464{
    465     rtems_device_major_number major;
    466     rtems_device_minor_number minor;
    467     rtems_disk_device_table *dtab;
    468 
    469     dev++;
    470     rtems_filesystem_split_dev_t (dev, major, minor);
    471 
    472     if (major >= disktab_size)
     465  rtems_status_code sc = RTEMS_SUCCESSFUL;
     466  rtems_disk_device_table *dtab = NULL;
     467  rtems_device_major_number major = 0;
     468  rtems_device_minor_number minor = 0;
     469
     470  if (dev != (dev_t) -1) {
     471    rtems_filesystem_split_dev_t(dev, major, minor);
     472
     473    /* If minor wraps around */
     474    if ((minor + 1) < minor) {
     475      /* If major wraps around */
     476      if ((major + 1) < major) {
    473477        return NULL;
    474 
    475     dtab = disktab + major;
    476     while (true)
    477     {
    478         if ((dtab == NULL) || (minor >= dtab->size))
    479         {
    480              major++; minor = 0;
    481              if (major >= disktab_size)
    482                  return NULL;
    483              dtab = disktab + major;
    484         }
    485         else if (dtab->minor[minor] == NULL)
    486         {
    487             minor++;
    488         }
    489         else
    490             return dtab->minor[minor];
    491     }
     478      }
     479      ++major;
     480      minor = 0;
     481    } else {
     482      ++minor;
     483    }
     484  }
     485
     486  sc = disk_lock();
     487  if (sc != RTEMS_SUCCESSFUL) {
     488    return NULL;
     489  }
     490
     491  if (major >= disktab_size) {
     492    disk_unlock();
     493
     494    return NULL;
     495  }
     496
     497  dtab = disktab + major;
     498  while (true) {
     499    if (dtab->minor == NULL || minor >= dtab->size) {
     500       minor = 0;
     501       ++major;
     502       if (major >= disktab_size) {
     503         disk_unlock();
     504
     505         return NULL;
     506       }
     507       dtab = disktab + major;
     508    } else if (dtab->minor [minor] == NULL) {
     509      ++minor;
     510    } else {
     511      ++dtab->minor [minor]->uses;
     512      disk_unlock();
     513
     514      return dtab->minor [minor];
     515    }
     516  }
    492517}
    493518
Note: See TracChangeset for help on using the changeset viewer.