Пример #1
0
//! @brief This function mount a drive
//!
void ushell_cmd_mount( void )
{
   uint8_t u8_drive_lun;
   Fs_index sav_index;

   if( g_s_arg[0][0] == 0 )
      return;

   // Compute the logical unit number of drive
   u8_drive_lun=g_s_arg[0][0]-'a';
   // Check lun number
   if( u8_drive_lun >= nav_drive_nb() )
   {
      fputs(MSG_ER_DRIVE, stdout);
      return;
   }

   // Mount drive
   sav_index = nav_getindex();      // Save previous position
   if( nav_drive_set(u8_drive_lun))
   {
      if( nav_partition_mount() )
         return;                    // Here, drive mounted
   }
   fputs(MSG_ER_MOUNT, stdout);
   nav_gotoindex(&sav_index);       // Restore previous position
}
Пример #2
0
//! @brief This function displays the free space of each drive present
//!
void ushell_cmd_free_space( void )
{
   uint8_t u8_tmp;
   Fs_index sav_index = nav_getindex();      // Save current position
   for( u8_tmp=0; u8_tmp<nav_drive_nb(); u8_tmp++ )
   {
      nav_drive_set( u8_tmp );      // Select drive
      if( !nav_partition_mount() )  // Mount drive
         continue;

      // Display drive letter name (a, b...)
      printf("%c: %s\r\n", 'a'+u8_tmp, mem_name(u8_tmp) );
      if( g_s_arg[0][0]=='l' )        // Choose command option
      {
         // Long and exact function
         printf("Free space: %llu Bytes / %llu Bytes\n\r",
                   (uint64_t)(nav_partition_freespace() << FS_SHIFT_B_TO_SECTOR),
                   (uint64_t)(nav_partition_space() << FS_SHIFT_B_TO_SECTOR));
      }
      else
      {
         // Otherwise use fast command
         printf("Free space: %u %%\n\r", nav_partition_freespace_percent() );
      }
   }
   nav_gotoindex(&sav_index);       // Restore position
}
Пример #3
0
//! @brief This function display all drives present
//!
void ushell_cmd_nb_drive( void )
{
   uint8_t u8_tmp;

   printf("Memory interface available:\r\n");
   for( u8_tmp=0; u8_tmp<nav_drive_nb(); u8_tmp++ )
   {
      // Display drive letter name (a, b...)
      printf("%c: %s\r\n", 'a'+u8_tmp, mem_name(u8_tmp) );
   }
}
static __inline__ uint8_t navauto_mov_ok_loop(bool b_direction, navauto_mov_options_t options)
{
  bool b_ok_loop = false;

  // If mode Disks, it should go to the next/previous disk
  if (g_navauto_exp_mode == NAVAUTO_MODE_DISKS)
  {
    // Mount the next/previous disk
    do
    {
      if (b_direction == FS_FIND_NEXT)
      {
        // Go to the next drive
        if (!nav_drive_set(nav_drive_get() + 1))
        {
          nav_drive_set(0);
          b_ok_loop = true;
        }
      }
      else // direction PREVIOUS
      {
        // Go to the previous drive
        if (!nav_drive_set(nav_drive_get() - 1))
        {
          nav_drive_set(nav_drive_nb() - 1);
          b_ok_loop = true;
        }
      }
    }while(!nav_partition_mount());

    // If it reached a limit
    if (b_ok_loop)
    {
      navauto_mov_explorer_rec(b_direction, options);
      return NAVAUTO_MOV_OK_LOOP;
    }

    // Else return the result of the recursive function
    return navauto_mov_explorer_rec(b_direction, options);
  }

  return NAVAUTO_MOV_OK_LOOP;
}