fscmds.h File Reference


Detailed Description

AVR32 UC3 Control Panel file system basic & shell commands interface.

This module provides commands interface to the file system.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file fscmds.h.

#include "fs_com.h"

Go to the source code of this file.

Enumerations

enum  eFsCmdsStatus {
  FSCMDS_STATUS_OK, FSCMDS_STATUS_KO, FSCMDS_STATUS_ERR_DRIVE, FSCMDS_STATUS_ERR_MOUNT,
  FSCMDS_STATUS_ERR_NOMOUNT, FSCMDS_STATUS_ERR_UNKNOWNDIR, FSCMDS_STATUS_ERR_HW, FSCMDS_STATUS_ERR_FS,
  FSCMDS_STATUS_ERR_NOFORMAT, FSCMDS_STATUS_ERR_MEMDEVMISSING, FSCMDS_STATUS_ERR_NOPARTITION, FSCMDS_STATUS_ERR_FSNOTSUPPORTED,
  FSCMDS_STATUS_ERR_FILENOTFOUND, FSCMDS_STATUS_ERR_NOTFOUND, FSCMDS_STATUS_ERR_NOTAFILE, FSCMDS_STATUS_ERR_FILEWR,
  FSCMDS_STATUS_ERR_READONLY, FSCMDS_STATUS_ERR_BADSIZEFAT, FSCMDS_STATUS_ERR_OUTOFMEM, FSCMDS_STATUS_ERR_INCORRECTNAME,
  FSCMDS_STATUS_ERR_ISROOTDIR, FSCMDS_STATUS_ERR_DIRNOTEMPTY, FSCMDS_STATUS_ERR_MEMALLOC, FSCMDS_STATUS_ERR_UNKNOWN
}

Functions

eFsCmdsStatus e_fscmds_cd (signed short FsNavId, FS_STRING pcStringDirName)
 The cd basic command.
eFsCmdsStatus e_fscmds_CheckNavError (void)
 Check the FAT module global var fs_g_status to get the error that occured in the FAT module.
eFsCmdsStatus e_fscmds_format (signed short FsNavId, unsigned short u8DriveId)
 The format basic command: format a disk.
eFsCmdsStatus e_fscmds_mount (signed short FsNavId, unsigned short u8DriveId)
 The mount basic command: mount a disk.
eExecStatus e_fscmds_shell_append (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
eExecStatus e_fscmds_shell_cat (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The cat command: Print the content of a file. Takes one parameter, that is the filename to cat. Format: cat filename.
eExecStatus e_fscmds_shell_cd (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The cd command: Change directory. Takes one parameter, that is the dest directory. Format: cd dirname.
eExecStatus e_fscmds_shell_cp (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The cp command: copy a specified file to the bookmarked directory. Takes one parameter, that is the file to copy. Format: cp filename WARNING: paths are not supported; i.e. the parameter must be a filename without path.
eExecStatus e_fscmds_shell_df (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
eExecStatus e_fscmds_shell_disk (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
eExecStatus e_fscmds_shell_fat (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
eExecStatus e_fscmds_shell_format (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The format command: format the specified drive. Takes one parameter, that is the drive to format. Format: format drive.
eExecStatus e_fscmds_shell_goto (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The goto command: goto the bookmarked directory. Format: goto.
eExecStatus e_fscmds_shell_goto_a_drive (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
eExecStatus e_fscmds_shell_goto_b_drive (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
eExecStatus e_fscmds_shell_goto_c_drive (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
eExecStatus e_fscmds_shell_goto_d_drive (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
eExecStatus e_fscmds_shell_help (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
eExecStatus e_fscmds_shell_ls (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The ls command: list current directory content. Format: ls.
eExecStatus e_fscmds_shell_mark (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
eExecStatus e_fscmds_shell_mkdir (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
eExecStatus e_fscmds_shell_mount (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The mount command: mount a disk. Takes one parameter, that is the disk letter. Format: mount {a,b,c,d}.
eExecStatus e_fscmds_shell_mv (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The mv command: rename a file or a directory. Takes two parameters, the file to rename as the first parameter and the new name as second parameter. Format: mv src dst WARNING: paths are not supported; i.e. parameters must be filenames without path.
eExecStatus e_fscmds_shell_pwd (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The pwd command: return current path. Format: pwd.
eExecStatus e_fscmds_shell_rm (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
 The rm command: remove a specified file or a specified directory or all files and directories. Takes up to two parameters, first an optional parameter to recursively delete directories(i.e. non empty directories may be deleted), and always the parameter which is the file to delete or the directory to delete or *. Format: rm {-R} {file,directory,*} NOTE: file and directory names can be used with a path. WARNING: paths are not supported with *; i.e. the command may only be rm -R * or rm *.
eExecStatus e_fscmds_shell_touch (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply)
void v_fscmds_GetStrMsgFromErr (eFsCmdsStatus ErrStatus, signed portCHAR **ppcStringReply)
 Map a string message to an error.


Enumeration Type Documentation

The exec command return status.

Enumerator:
FSCMDS_STATUS_OK 
FSCMDS_STATUS_KO 
FSCMDS_STATUS_ERR_DRIVE 
FSCMDS_STATUS_ERR_MOUNT 
FSCMDS_STATUS_ERR_NOMOUNT 
FSCMDS_STATUS_ERR_UNKNOWNDIR 
FSCMDS_STATUS_ERR_HW 
FSCMDS_STATUS_ERR_FS 
FSCMDS_STATUS_ERR_NOFORMAT 
FSCMDS_STATUS_ERR_MEMDEVMISSING 
FSCMDS_STATUS_ERR_NOPARTITION 
FSCMDS_STATUS_ERR_FSNOTSUPPORTED 
FSCMDS_STATUS_ERR_FILENOTFOUND 
FSCMDS_STATUS_ERR_NOTFOUND 
FSCMDS_STATUS_ERR_NOTAFILE 
FSCMDS_STATUS_ERR_FILEWR 
FSCMDS_STATUS_ERR_READONLY 
FSCMDS_STATUS_ERR_BADSIZEFAT 
FSCMDS_STATUS_ERR_OUTOFMEM 
FSCMDS_STATUS_ERR_INCORRECTNAME 
FSCMDS_STATUS_ERR_ISROOTDIR 
FSCMDS_STATUS_ERR_DIRNOTEMPTY 
FSCMDS_STATUS_ERR_MEMALLOC 
FSCMDS_STATUS_ERR_UNKNOWN 

Definition at line 71 of file fscmds.h.

00071              {
00072    FSCMDS_STATUS_OK,                // The operation succeeded.
00073    FSCMDS_STATUS_KO,                // The operation failed.
00074    FSCMDS_STATUS_ERR_DRIVE,         // Wrong drive number.
00075    FSCMDS_STATUS_ERR_MOUNT,         // The mount operation failed.
00076    FSCMDS_STATUS_ERR_NOMOUNT,       // Partition not mounted.
00077    FSCMDS_STATUS_ERR_UNKNOWNDIR,    // Directory not found.
00078    FSCMDS_STATUS_ERR_HW,            // Hw driver error.
00079    FSCMDS_STATUS_ERR_FS,            // File system error.
00080    FSCMDS_STATUS_ERR_NOFORMAT,      // Selected drive is not formatted.
00081    FSCMDS_STATUS_ERR_MEMDEVMISSING, // Memory device is missing.
00082    FSCMDS_STATUS_ERR_NOPARTITION,   // The selected partition doesn't exist.
00083    FSCMDS_STATUS_ERR_FSNOTSUPPORTED,// The selected partition file system is not supported.
00084    FSCMDS_STATUS_ERR_FILENOTFOUND,  // File not found.
00085    FSCMDS_STATUS_ERR_NOTFOUND,      // File or directory not found.
00086    FSCMDS_STATUS_ERR_NOTAFILE,      // Not a file.
00087    FSCMDS_STATUS_ERR_FILEWR,        // The file is already opened in write-mode.
00088    FSCMDS_STATUS_ERR_READONLY,      // The drive is read-only.
00089    FSCMDS_STATUS_ERR_BADSIZEFAT,    // The disk size is smaller than 4,1MB, or not supported by file system selected
00090    FSCMDS_STATUS_ERR_OUTOFMEM,      // Out of memory
00091    FSCMDS_STATUS_ERR_INCORRECTNAME, // Incorrect name, this must be not contain char \/:*?"<>|
00092    FSCMDS_STATUS_ERR_ISROOTDIR,     // Cannot go up in the dir tree because the current dir is a root dir
00093    FSCMDS_STATUS_ERR_DIRNOTEMPTY,   // Directory not empty
00094    FSCMDS_STATUS_ERR_MEMALLOC,      // Memory alloc failure
00095 
00096    FSCMDS_STATUS_ERR_UNKNOWN        // Unexpected error.
00097 } eFsCmdsStatus;


Function Documentation

eFsCmdsStatus e_fscmds_cd ( signed short  FsNavId,
FS_STRING  pxStringDirName 
)

The cd basic command.

Parameters:
FsNavId Input. The file system navigator id to use.
pxStringDirName Input. The directory name.
Returns:
the status of the operation.

Definition at line 369 of file fscmds.c.

References e_fscmds_CheckNavError(), and FSCMDS_STATUS_OK.

Referenced by e_fscmds_shell_cd().

00370 {
00371    eFsCmdsStatus   eFsStatus = FSCMDS_STATUS_OK;
00372 
00373 
00374    fsaccess_take_mutex();
00375    nav_select(FsNavId);
00376 
00377    // try to enter the directory
00378    if(nav_setcwd(pxStringDirName, TRUE, FALSE)==FALSE)
00379    {
00380       eFsStatus = e_fscmds_CheckNavError();
00381    }
00382 
00383    fsaccess_give_mutex();
00384    return( eFsStatus );
00385 }

eFsCmdsStatus e_fscmds_CheckNavError ( void   ) 

Check the FAT module global var fs_g_status to get the error that occured in the FAT module.

Returns:
a status translation of the FAT module error status.

Definition at line 1779 of file fscmds.c.

References FSCMDS_STATUS_ERR_BADSIZEFAT, FSCMDS_STATUS_ERR_DIRNOTEMPTY, FSCMDS_STATUS_ERR_FILENOTFOUND, FSCMDS_STATUS_ERR_FILEWR, FSCMDS_STATUS_ERR_FS, FSCMDS_STATUS_ERR_FSNOTSUPPORTED, FSCMDS_STATUS_ERR_HW, FSCMDS_STATUS_ERR_INCORRECTNAME, FSCMDS_STATUS_ERR_ISROOTDIR, FSCMDS_STATUS_ERR_MEMDEVMISSING, FSCMDS_STATUS_ERR_NOFORMAT, FSCMDS_STATUS_ERR_NOMOUNT, FSCMDS_STATUS_ERR_NOPARTITION, FSCMDS_STATUS_ERR_NOTAFILE, FSCMDS_STATUS_ERR_OUTOFMEM, FSCMDS_STATUS_ERR_READONLY, FSCMDS_STATUS_ERR_UNKNOWN, and NAKED_TRACE_COM2.

Referenced by e_fscmds_cd(), e_fscmds_format(), e_fscmds_mount(), e_fscmds_rm(), e_fscmds_rm_all(), e_fscmds_shell_mkdir(), e_fscmds_shell_mv(), e_fscmds_shell_pwd(), prv_df(), and prvCommonErrorLeave().

01780 {
01781    switch(fs_g_status)
01782    {
01783       case FS_ERR_HW:              // hw driver error
01784          return( FSCMDS_STATUS_ERR_HW );
01785       case FS_ERR_FS:              // File system error
01786          return( FSCMDS_STATUS_ERR_FS );
01787       case FS_ERR_NO_MOUNT:        // The partition is not mounted.
01788          return( FSCMDS_STATUS_ERR_NOMOUNT );
01789       case FS_ERR_NO_FORMAT:       // The selected drive isn't formatted
01790          return( FSCMDS_STATUS_ERR_NOFORMAT );
01791       case FS_ERR_HW_NO_PRESENT:   // Memory device is missing.
01792          return( FSCMDS_STATUS_ERR_MEMDEVMISSING );
01793       case FS_ERR_NO_PART:         // The partition selected doesn't exist
01794          return( FSCMDS_STATUS_ERR_NOPARTITION );
01795       case FS_ERR_NO_SUPPORT_PART: // The selected partition file system isn't supported
01796          return( FSCMDS_STATUS_ERR_FSNOTSUPPORTED );
01797       case FS_ERR_NO_FIND:         // File not found.
01798          return( FSCMDS_STATUS_ERR_FILENOTFOUND );
01799       case FS_ERR_NO_FILE:         // Not a file.
01800          return( FSCMDS_STATUS_ERR_NOTAFILE );
01801       case FS_ERR_FILE_OPEN_WR:    // The file is already opened in write-mode.
01802          return( FSCMDS_STATUS_ERR_FILEWR );
01803       case FS_LUN_WP:              // The drive is read-only
01804          return( FSCMDS_STATUS_ERR_READONLY );
01805       case FS_ERR_BAD_SIZE_FAT:    // The disk size is smaller than 4,1MB, or not supported by file system selected
01806          return( FSCMDS_STATUS_ERR_BADSIZEFAT );
01807       case FS_ERR_OUT_LIST:        // NOTE: Too specific message; we include it in the out-of-memory category.
01808       case FS_ERR_NO_FREE_SPACE:   // Out of memory
01809          return( FSCMDS_STATUS_ERR_OUTOFMEM );
01810       case FS_ERR_INCORRECT_NAME:  // Incorrect name, this must be not contain char \/:*?"<>|
01811          return( FSCMDS_STATUS_ERR_INCORRECTNAME );
01812       case FS_ERR_IS_ROOT:         // Cannot go up in the dir tree because the current dir is a root dir.
01813          return( FSCMDS_STATUS_ERR_ISROOTDIR );
01814       case FS_ERR_DIR_NOT_EMPTY:   // Directory not empty.
01815          return( FSCMDS_STATUS_ERR_DIRNOTEMPTY );
01816 
01817       default:                     // Should never happen.
01818          NAKED_TRACE_COM2( "Unexpected fs_g_status:%d", fs_g_status );
01819          return( FSCMDS_STATUS_ERR_UNKNOWN );
01820    }
01821 }

eFsCmdsStatus e_fscmds_format ( signed short  FsNavId,
unsigned short  u8DriveId 
)

The format basic command: format a disk.

Parameters:
FsNavId Input. The file system navigator id to use.
u8DriveId Input. The target drive id.
Returns:
the status of the operation.

Definition at line 1498 of file fscmds.c.

References e_fscmds_CheckNavError(), FSCMDS_STATUS_ERR_DRIVE, and FSCMDS_STATUS_OK.

Referenced by b_mmi_format_a(), b_mmi_format_b(), and e_fscmds_shell_format().

01499 {
01500    eFsCmdsStatus   eFsStatus = FSCMDS_STATUS_OK;
01501    unsigned short  u8CurrentDriveId;
01502 
01503 
01504    if( u8DriveId >= nav_drive_nb() )
01505    {
01506       eFsStatus = FSCMDS_STATUS_ERR_DRIVE;
01507    }
01508    else
01509    {
01510       fsaccess_take_mutex();  // Take the fs resource.
01511       nav_select(FsNavId); // Select the navigator.
01512       u8CurrentDriveId = nav_drive_get(); // Save the current drive.
01513       nav_drive_set(u8DriveId); // Select the drive to format.
01514       if( FALSE == nav_drive_format( FS_FORMAT_DEFAULT ) )
01515       {   // The operation failed.
01516          eFsStatus = e_fscmds_CheckNavError();
01517          nav_drive_set( u8CurrentDriveId ); // Restore the current drive.
01518       }
01519       else if( u8DriveId == u8CurrentDriveId )
01520       {  // The format operation succeeded and it was done on the current drive.
01521          // Since the format operation was done on the currently mounted drive,
01522          // we reset the navigator & re-mount that drive.
01523          nav_filelist_reset();
01524          nav_drive_set(u8DriveId);
01525          if (FALSE == nav_partition_mount())
01526          {   // The operation failed.
01527             eFsStatus = e_fscmds_CheckNavError();
01528          }
01529       }
01530       else // The format operation succeeded and it was done on another drive
01531            // than the currently selected one.
01532          nav_drive_set( u8CurrentDriveId ); // Restore the current drive.
01533       fsaccess_give_mutex(); // Release the fs resource.
01534    }
01535    return( eFsStatus );
01536 }

eFsCmdsStatus e_fscmds_mount ( signed short  FsNavId,
unsigned short  u8DriveId 
)

The mount basic command: mount a disk.

Parameters:
FsNavId Input. The file system navigator id to use.
u8DriveId Input. The target drive id.
Returns:
the status of the operation.

Definition at line 272 of file fscmds.c.

References e_fscmds_CheckNavError(), FSCMDS_STATUS_ERR_DRIVE, and FSCMDS_STATUS_OK.

Referenced by e_fscmds_goto_drive(), and e_fscmds_shell_mount().

00273 {
00274    eFsCmdsStatus   eFsStatus = FSCMDS_STATUS_OK;
00275 
00276 
00277    if( u8DriveId >= nav_drive_nb() )
00278    {
00279       eFsStatus = FSCMDS_STATUS_ERR_DRIVE;
00280    }
00281    else
00282    {
00283       fsaccess_take_mutex();
00284       nav_select(FsNavId);
00285       nav_drive_set(u8DriveId);
00286       if (FALSE == nav_partition_mount())
00287       {   // The operation failed.
00288          eFsStatus = e_fscmds_CheckNavError();
00289       }
00290       fsaccess_give_mutex();
00291    }
00292    return( eFsStatus );
00293 }

eExecStatus e_fscmds_shell_append ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

Definition at line 665 of file fscmds.c.

References FSCMDS_ERRMSG_APPEND_SYNTAXERROR, FSCMDS_STATUS_OK, prv_append(), SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_fscmds_GetStrMsgFromErr().

00668 {
00669    eFsCmdsStatus eFsStatus;
00670    eExecStatus   eRetStatus = SHELL_EXECSTATUS_KO;
00671 
00672 
00673    // 1) Check the input.
00674    //  i) Exactly one argument.
00675    if( 1 != ac )
00676    {   // Syntax error.
00677       if(ppcStringReply != NULL)
00678          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_APPEND_SYNTAXERROR;
00679       return( eRetStatus );
00680    }
00681 
00682    // 2) Perform the command.
00683    eFsStatus = prv_append( xModId, FsNavId, (FS_STRING)av[0] );
00684 
00685    if( FSCMDS_STATUS_OK == eFsStatus )
00686    {
00687       if(ppcStringReply != NULL)
00688          *ppcStringReply = NULL;   // Nothing to display in case of success.
00689       eRetStatus = SHELL_EXECSTATUS_OK;
00690    }
00691    else if( ppcStringReply != NULL )
00692    {
00693       v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
00694    }
00695 
00696    return( eRetStatus );
00697 }

eExecStatus e_fscmds_shell_cat ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The cat command: Print the content of a file. Takes one parameter, that is the filename to cat. Format: cat filename.

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
FsNavId Input. The file system navigator id to use.
ac Input. The argument counter. Should be 1.
av Input. The argument vector.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 609 of file fscmds.c.

References FSCMDS_ERRMSG_CAT_SYNTAXERROR, FSCMDS_STATUS_OK, prv_cat(), SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_fscmds_GetStrMsgFromErr().

00612 {
00613    eFsCmdsStatus eFsStatus;
00614    eExecStatus   eRetStatus = SHELL_EXECSTATUS_KO;
00615 
00616    // 1) Check the input.
00617    //  i) Exactly one argument.
00618    if( 1 != ac )
00619    {   // Syntax error.
00620       if(ppcStringReply != NULL)
00621          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_CAT_SYNTAXERROR;
00622       return( eRetStatus );
00623    }
00624 
00625    // 2) Perform the command.
00626    eFsStatus = prv_cat( xModId, FsNavId, (FS_STRING)av[0] );
00627 
00628    if( FSCMDS_STATUS_OK == eFsStatus )
00629    {
00630       if(ppcStringReply != NULL)
00631          *ppcStringReply = NULL;   // Nothing to display in case of success.
00632       eRetStatus = SHELL_EXECSTATUS_OK;
00633    }
00634    else if( ppcStringReply != NULL )
00635    {
00636       v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
00637    }
00638 
00639    return( eRetStatus );
00640 }

eExecStatus e_fscmds_shell_cd ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The cd command: Change directory. Takes one parameter, that is the dest directory. Format: cd dirname.

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
FsNavId Input. The file system navigator id to use.
ac Input. The argument counter. For this command, should be 1.
av Input. The argument vector. For this command, only av[0] is considered.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 405 of file fscmds.c.

References e_fscmds_cd(), FSCMDS_ERRMSG_CD_SYNTAXERROR, FSCMDS_STATUS_OK, SHELL_ERRMSG_MEMALLOC, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_fscmds_GetStrMsgFromErr().

00408 {
00409    eFsCmdsStatus eFsStatus = FSCMDS_STATUS_OK;
00410    eExecStatus   eRetStatus = SHELL_EXECSTATUS_KO;
00411    FS_STRING     pxDirName;
00412 
00413 
00414    // 1) Check the input.
00415    //  i) One argument only.
00416    if( 1 != ac )
00417    {   // Syntax error.
00418       if(ppcStringReply != NULL)
00419          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_CD_SYNTAXERROR;
00420       return( SHELL_EXECSTATUS_KO );
00421    }
00422 
00423    // Go to a sub-directory == cd dirname
00424    // Alloc the string. need 2 bytes more : one for \ and one for \0
00425    pxDirName = (FS_STRING)pvPortMalloc( ( strlen( (char *)av[0] ) +2 ) * sizeof( FS_STRING ) );
00426    if( NULL == pxDirName )
00427    {
00428       if(ppcStringReply != NULL)
00429          *ppcStringReply = (signed portCHAR *)SHELL_ERRMSG_MEMALLOC;
00430       return( SHELL_EXECSTATUS_KO );
00431    }
00432    strcpy((char *)pxDirName, (char *)av[0]);
00433    strcat((char *)pxDirName, "\\");
00434 
00435    eFsStatus = e_fscmds_cd( FsNavId, pxDirName );
00436    // Free the string.
00437    vPortFree( pxDirName );
00438 
00439    if( FSCMDS_STATUS_OK == eFsStatus )
00440    {
00441       if(ppcStringReply != NULL)
00442          *ppcStringReply = NULL;   // Nothing to display in case of success.
00443       eRetStatus = SHELL_EXECSTATUS_OK;
00444    }
00445    else if( ppcStringReply != NULL )
00446    {
00447       v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
00448    }
00449 
00450    return( eRetStatus );
00451 }

eExecStatus e_fscmds_shell_cp ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The cp command: copy a specified file to the bookmarked directory. Takes one parameter, that is the file to copy. Format: cp filename WARNING: paths are not supported; i.e. the parameter must be a filename without path.

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
FsNavId Input. The file system navigator id to use.
ac Input. The argument counter. Should be 1.
av Input. The argument vector.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 1623 of file fscmds.c.

References FSCMDS_ERRMSG_CP_SYNTAXERROR, FSCMDS_STATUS_OK, prv_cp(), SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_fscmds_GetStrMsgFromErr().

01626 {
01627    eFsCmdsStatus eFsStatus;
01628    eExecStatus   eRetStatus = SHELL_EXECSTATUS_KO;
01629 
01630    // 1) Check the input.
01631    if( 1 != ac )
01632    {
01633       // Syntax error.
01634       if(ppcStringReply != NULL)
01635          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_CP_SYNTAXERROR;
01636       return( eRetStatus );
01637    }
01638 
01639    // 2) Perform the command.
01640    eFsStatus = prv_cp( xModId, FsNavId, (FS_STRING)av[0] );
01641 
01642    if( FSCMDS_STATUS_OK == eFsStatus )
01643    {
01644       if(ppcStringReply != NULL)
01645          *ppcStringReply = NULL;   // Nothing to display in case of success.
01646       eRetStatus = SHELL_EXECSTATUS_OK;
01647    }
01648    else if( ppcStringReply != NULL )
01649    {
01650       v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
01651    }
01652 
01653    return( eRetStatus );
01654 }

eExecStatus e_fscmds_shell_df ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

Definition at line 970 of file fscmds.c.

References FSCMDS_ERRMSG_DF_SYNTAXERROR, prv_df(), SHELL_EXECSTATUS_KO, and SHELL_EXECSTATUS_OK.

00973 {
00974    // 1) Check the input.
00975    //  i) No argument.
00976    if( 0 != ac )
00977    {   // Syntax error.
00978       if(ppcStringReply != NULL)
00979          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_DF_SYNTAXERROR;
00980       return( SHELL_EXECSTATUS_KO );
00981    }
00982 
00983    // 2) Perform the command.
00984    prv_df( xModId, FsNavId );
00985 
00986    if(ppcStringReply != NULL)
00987       *ppcStringReply = NULL; // Nothing to display in case of success.
00988    return( SHELL_EXECSTATUS_OK );
00989 }

eExecStatus e_fscmds_shell_disk ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

Definition at line 921 of file fscmds.c.

References CRLF, FSCMDS_ERRMSG_DISK_SYNTAXERROR, SHELL_ERRMSG_MEMALLOC, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, SHELL_MAX_MSGOUT_LEN, and sprintf().

00924 {
00925    // 1) If the way to reply is unavailable, it's no use to continue.
00926    if( ppcStringReply == NULL )
00927       return( SHELL_EXECSTATUS_KO );
00928 
00929    // 2) Check the input.
00930    //  i) No argument.
00931    if( 0 != ac )
00932    {   // Syntax error.
00933       *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_DISK_SYNTAXERROR;
00934       return( SHELL_EXECSTATUS_KO );
00935    }
00936 
00937    // 3) Perform the command.
00938    *ppcStringReply = (signed portCHAR *)pvPortMalloc( SHELL_MAX_MSGOUT_LEN ); // Alloc
00939    if( NULL == *ppcStringReply )
00940    {
00941       *ppcStringReply = (signed portCHAR *)SHELL_ERRMSG_MEMALLOC;
00942       return( SHELL_EXECSTATUS_KO );
00943    }
00944    sprintf((char *)*ppcStringReply, "Nb Drive(s): %d"CRLF, nav_drive_nb());
00945 
00946    return( SHELL_EXECSTATUS_OK );
00947 }

eExecStatus e_fscmds_shell_fat ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

Definition at line 1180 of file fscmds.c.

References CRLF, FSCMDS_ERRMSG_FAT_SYNTAXERROR, FSCMDS_ERRMSG_NOMOUNT, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_shell_Print_String_To_Requester_Stream().

01183 {
01184    int i=0;
01185 
01186 
01187    // 1) Check the input.
01188    //  i) No argument.
01189    if( 0 != ac )
01190    {   // Syntax error.
01191       if(ppcStringReply != NULL)
01192          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_FAT_SYNTAXERROR;
01193       return( SHELL_EXECSTATUS_KO );
01194    }
01195 
01196    fsaccess_take_mutex(); // Take the fs resource.
01197    nav_select( FsNavId ); // Select the navigator.
01198 
01199    // 2) Perform the command.
01200 #if FS_FAT_12 == ENABLED
01201    if( Is_fat12 )
01202       v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)"Drive uses FAT12"CRLF );
01203    else i++;
01204 #endif
01205 #if FS_FAT_16 == ENABLED
01206    if( Is_fat16 )
01207       v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)"Drive uses FAT16"CRLF );
01208    else i++;
01209 #endif
01210 #if FS_FAT_32 == ENABLED
01211    if( Is_fat32 )
01212       v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)"Drive uses FAT32"CRLF );
01213    else i++;
01214 #endif
01215 
01216    if(3 == i)
01217       v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)FSCMDS_ERRMSG_NOMOUNT );
01218 
01219    fsaccess_give_mutex(); // Release the fs resource.
01220 
01221    if(ppcStringReply != NULL)
01222       *ppcStringReply = NULL; // Nothing to display in case of success.
01223    return( SHELL_EXECSTATUS_OK );
01224 }

eExecStatus e_fscmds_shell_format ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The format command: format the specified drive. Takes one parameter, that is the drive to format. Format: format drive.

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
FsNavId Input. The file system navigator id to use.
ac Input. The argument counter. Should be 1.
av Input. The argument vector.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 1557 of file fscmds.c.

References e_fscmds_format(), FSCMDS_ERRMSG_FORMAT_SYNTAXERROR, FSCMDS_ERRMSG_MOUNT_DRIVENOTFOUND, FSCMDS_STATUS_OK, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_fscmds_GetStrMsgFromErr().

01560 {
01561    unsigned int  u8DriveId;
01562    eFsCmdsStatus eFsStatus;
01563    eExecStatus   eRetStatus = SHELL_EXECSTATUS_KO;
01564 
01565 
01566    // 1) Check the input.
01567    //  i) One argument only.
01568    if( 1 != ac )
01569    {   // Syntax error.
01570       if(ppcStringReply != NULL)
01571          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_FORMAT_SYNTAXERROR;
01572       return( SHELL_EXECSTATUS_KO );
01573    }
01574    //  ii) The arg must be one of {a,b,c,d}. Accept the ':' char after the drive letter.
01575    u8DriveId = av[0][0] - 'a';
01576    if( ( av[0][1] != '\0' ) && ( av[0][1] != ':' ) )
01577    {
01578       if(ppcStringReply != NULL)
01579          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_MOUNT_DRIVENOTFOUND;
01580       return( SHELL_EXECSTATUS_KO );
01581    }
01582 
01583    // 2) Perform the command.
01584    eFsStatus = e_fscmds_format(FsNavId, u8DriveId);
01585    if( FSCMDS_STATUS_OK == eFsStatus )
01586    {
01587       if(ppcStringReply != NULL)
01588          *ppcStringReply = NULL;   // Nothing to display in case of success.
01589       eRetStatus = SHELL_EXECSTATUS_OK;
01590    }
01591    else if( ppcStringReply != NULL )
01592    {
01593       v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
01594    }
01595 
01596    return( eRetStatus );
01597 }

eExecStatus e_fscmds_shell_goto ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The goto command: goto the bookmarked directory. Format: goto.

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
FsNavId Input. The file system navigator id to use.
ac Input. The argument counter. Should be 0.
av Input. The argument vector.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 1452 of file fscmds.c.

References ax_mark_index, FSCMDS_ERRMSG_GOTO_SYNTAXERROR, prv_i_GetIdxFromModid(), prvCommonErrorLeave(), SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_fscmds_GetStrMsgFromErr().

01455 {
01456 eFsCmdsStatus   eFsStatus;
01457    // 1) Check the input.
01458    //  i) No argument.
01459    if( 0 != ac )
01460    {   // Syntax error.
01461       if(ppcStringReply != NULL)
01462          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_GOTO_SYNTAXERROR;
01463       return( SHELL_EXECSTATUS_KO );
01464    }
01465 
01466    // 2) Perform the command.
01467    fsaccess_take_mutex(); // Take the fs resource.
01468    nav_select( FsNavId ); // Select the navigator.
01469    if( FALSE == nav_gotoindex( &(ax_mark_index[prv_i_GetIdxFromModid( xModId )]) ) )
01470    {
01471      eFsStatus = prvCommonErrorLeave();
01472      if( ppcStringReply != NULL )
01473      {
01474        v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
01475      }
01476      return( SHELL_EXECSTATUS_KO );
01477    }
01478    else
01479       fsaccess_give_mutex(); // Release the fs resource.
01480 
01481    if(ppcStringReply != NULL)
01482       *ppcStringReply = NULL; // Nothing to display in case of success.
01483    return( SHELL_EXECSTATUS_OK );
01484 }

eExecStatus e_fscmds_shell_goto_a_drive ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

Definition at line 1293 of file fscmds.c.

References e_fscmds_goto_drive().

01296 {
01297    return( e_fscmds_goto_drive( 'a'-'a', FsNavId, ac, ppcStringReply ) );
01298 }

eExecStatus e_fscmds_shell_goto_b_drive ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

Definition at line 1316 of file fscmds.c.

References e_fscmds_goto_drive().

01319 {
01320    return( e_fscmds_goto_drive( 'b'-'a', FsNavId, ac, ppcStringReply ) );
01321 }

eExecStatus e_fscmds_shell_goto_c_drive ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

Definition at line 1339 of file fscmds.c.

References e_fscmds_goto_drive().

01342 {
01343    return( e_fscmds_goto_drive( 'c'-'a', FsNavId, ac, ppcStringReply ) );
01344 }

eExecStatus e_fscmds_shell_goto_d_drive ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

Definition at line 1362 of file fscmds.c.

References e_fscmds_goto_drive().

01365 {
01366    return( e_fscmds_goto_drive( 'd'-'a', FsNavId, ac, ppcStringReply ) );
01367 }

eExecStatus e_fscmds_shell_help ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

Definition at line 720 of file fscmds.c.

References FSCMDS_MSG_HELP, SHELL_EXECSTATUS_KO, and SHELL_EXECSTATUS_OK_NO_FREE.

Referenced by e_Shell_help().

00723 {
00724    // 1) If the way to reply is unavailable, it's no use to continue.
00725    if( ppcStringReply == NULL )
00726       return( SHELL_EXECSTATUS_KO );
00727 
00728    // 2) Perform the command.
00729    *ppcStringReply = (signed portCHAR *)FSCMDS_MSG_HELP;
00730 
00731    return( SHELL_EXECSTATUS_OK_NO_FREE );
00732 }

eExecStatus e_fscmds_shell_ls ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The ls command: list current directory content. Format: ls.

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
FsNavId Input. The file system navigator id to use.
ac Input. The argument counter. Should be 0.
av Input. The argument vector. Ignored.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 553 of file fscmds.c.

References FSCMDS_ERRMSG_LS_SYNTAXERROR, FSCMDS_STATUS_OK, prv_ls(), SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_fscmds_GetStrMsgFromErr().

00556 {
00557    eFsCmdsStatus eFsStatus;
00558    eExecStatus   eRetStatus = SHELL_EXECSTATUS_KO;
00559 
00560 
00561    // 1) Check the input.
00562    //  i) No argument.
00563    if( 0 != ac )
00564    {   // Syntax error.
00565       if(ppcStringReply != NULL)
00566          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_LS_SYNTAXERROR;
00567       return( eRetStatus );
00568    }
00569 
00570    // 2) Perform the command.
00571    eFsStatus = prv_ls( xModId, FsNavId );
00572    if( FSCMDS_STATUS_OK == eFsStatus )
00573    {
00574       if(ppcStringReply != NULL)
00575          *ppcStringReply = NULL;   // Nothing to display in case of success.
00576       eRetStatus = SHELL_EXECSTATUS_OK;
00577    }
00578    else if( ppcStringReply != NULL )
00579    {
00580       v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
00581    }
00582 
00583    return( eRetStatus );
00584 }

eExecStatus e_fscmds_shell_mark ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

Definition at line 1406 of file fscmds.c.

References ax_mark_index, FSCMDS_ERRMSG_MARK_SYNTAXERROR, prv_i_GetIdxFromModid(), SHELL_EXECSTATUS_KO, and SHELL_EXECSTATUS_OK.

01409 {
01410    // 1) Check the input.
01411    //  i) No argument.
01412    if( 0 != ac )
01413    {   // Syntax error.
01414       if(ppcStringReply != NULL)
01415          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_MARK_SYNTAXERROR;
01416       return( SHELL_EXECSTATUS_KO );
01417    }
01418 
01419    // 2) Perform the command.
01420    fsaccess_take_mutex(); // Take the fs resource.
01421    nav_select( FsNavId ); // Select the navigator.
01422 
01423    ax_mark_index[prv_i_GetIdxFromModid(xModId)] = nav_getindex();
01424 
01425    fsaccess_give_mutex(); // Release the fs resource.
01426    if(ppcStringReply != NULL)
01427       *ppcStringReply = NULL; // Nothing to display in case of success.
01428    return( SHELL_EXECSTATUS_OK );
01429 }

eExecStatus e_fscmds_shell_mkdir ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

Definition at line 849 of file fscmds.c.

References e_fscmds_CheckNavError(), FSCMDS_ERRMSG_MKDIR_NAMEEXISTS, FSCMDS_ERRMSG_MKDIR_SYNTAXERROR, pcTempoDate, prv_NameExists(), SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, v_cptime_GetDateInFatStringFormat(), and v_fscmds_GetStrMsgFromErr().

Referenced by b_mmi_mkdir_aLOG(), and b_mmi_mkdir_bLOG().

00852 {
00853    eFsCmdsStatus eFsStatus;
00854    eExecStatus   eRetStatus = SHELL_EXECSTATUS_KO;
00855    char          pcTempoDate[17];
00856 
00857    // 1) Check the input.
00858    //  i) One argument only.
00859    //  ii) Check that there is no path in the filename.
00860    if( ( 1 != ac ) || ( NULL != strchr( (char *)av[0], '/' ) ) )
00861    {   // Syntax error.
00862       if(ppcStringReply != NULL)
00863          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_MKDIR_SYNTAXERROR;
00864       return( SHELL_EXECSTATUS_KO );
00865    }
00866 
00867    // 2) Perform the command.
00868    fsaccess_take_mutex(); // Take the fs resource.
00869    nav_select(FsNavId);
00870    // Check if a file with that name already exists.
00871    if( TRUE == prv_NameExists( (FS_STRING)av[0] ) )
00872    {
00873       *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_MKDIR_NAMEEXISTS;
00874    }
00875    else if( FALSE == nav_dir_make( (FS_STRING)av[0]) ) // Create the directory.
00876    {
00877       eFsStatus = e_fscmds_CheckNavError();
00878       if( ppcStringReply != NULL )
00879       {
00880          v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
00881       }
00882    }
00883    else
00884    {
00885       // Get the current time in the "YYYYMMDDHHMMSSMS" string format.
00886       v_cptime_GetDateInFatStringFormat( pcTempoDate );
00887       // Set the directory date.
00888       nav_file_dateset( (FS_STRING)pcTempoDate, FS_DATE_LAST_WRITE );
00889                
00890       if(ppcStringReply != NULL)
00891          *ppcStringReply = NULL;   // Nothing to display in case of success.
00892       eRetStatus = SHELL_EXECSTATUS_OK;
00893    }
00894 
00895    fsaccess_give_mutex(); // Release the fs resource.
00896 
00897    return( eRetStatus );
00898 }

eExecStatus e_fscmds_shell_mount ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The mount command: mount a disk. Takes one parameter, that is the disk letter. Format: mount {a,b,c,d}.

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
FsNavId Input. The file system navigator id to use.
ac Input. The argument counter. For this command, should be 1.
av Input. The argument vector. For this command, only av[0] is considered.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 314 of file fscmds.c.

References e_fscmds_mount(), FSCMDS_ERRMSG_MOUNT_DRIVENOTFOUND, FSCMDS_ERRMSG_MOUNT_SYNTAXERROR, FSCMDS_STATUS_OK, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_fscmds_GetStrMsgFromErr().

00317 {
00318    unsigned int  u8DriveId;
00319    eFsCmdsStatus eFsStatus;
00320    eExecStatus   eRetStatus = SHELL_EXECSTATUS_KO;
00321 
00322 
00323    // 1) Check the input.
00324    //  i) One argument only.
00325    if( 1 != ac )
00326    {   // Syntax error.
00327       if(ppcStringReply != NULL)
00328          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_MOUNT_SYNTAXERROR;
00329       return( SHELL_EXECSTATUS_KO );
00330    }
00331    //  ii) The arg must be one of {a,b,c,d}. Accept the ':' char after the drive letter.
00332    u8DriveId = av[0][0] - 'a';
00333    if( ( av[0][1] != '\0' ) && ( av[0][1] != ':' ) )
00334    {
00335       if(ppcStringReply != NULL)
00336          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_MOUNT_DRIVENOTFOUND;
00337       return( SHELL_EXECSTATUS_KO );
00338    }
00339 
00340    // 2) Perform the command.
00341    eFsStatus = e_fscmds_mount(FsNavId, u8DriveId);
00342    if( FSCMDS_STATUS_OK == eFsStatus )
00343    {
00344       if(ppcStringReply != NULL)
00345          *ppcStringReply = NULL;   // Nothing to display in case of success.
00346       eRetStatus = SHELL_EXECSTATUS_OK;
00347    }
00348    else if( ppcStringReply != NULL )
00349    {
00350       v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
00351    }
00352 
00353    return( eRetStatus );
00354 }

eExecStatus e_fscmds_shell_mv ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The mv command: rename a file or a directory. Takes two parameters, the file to rename as the first parameter and the new name as second parameter. Format: mv src dst WARNING: paths are not supported; i.e. parameters must be filenames without path.

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
FsNavId Input. The file system navigator id to use.
ac Input. The argument counter. Should be 2.
av Input. The argument vector.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 1681 of file fscmds.c.

References e_fscmds_CheckNavError(), e_fscmds_rm(), FSCMDS_ERRMSG_MV_SYNTAXERROR, FSCMDS_ERRMSG_MV_TYPEDIFFER, FSCMDS_STATUS_KO, FSCMDS_STATUS_OK, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_fscmds_GetStrMsgFromErr().

01684 {
01685    eFsCmdsStatus eFsStatus = FSCMDS_STATUS_OK;
01686    eExecStatus   eRetStatus = SHELL_EXECSTATUS_KO;
01687    Fs_index      sav_index;
01688    Bool          bSrcType, bDstType;
01689 
01690 
01691    // 1) Check the input.
01692    //  i) Two arguments exactly.
01693    if( 2 != ac )
01694    {   // Syntax error.
01695       if(ppcStringReply != NULL)
01696          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_MV_SYNTAXERROR;
01697       return( SHELL_EXECSTATUS_KO );
01698    }
01699 
01700    // 2) Perform the command.
01701    fsaccess_take_mutex(); // Take the fs resource.
01702    nav_select(FsNavId);
01703 
01704    sav_index = nav_getindex(); // Save the current nav position.
01705 
01706    // Set the navigator on the src file.
01707    if( FALSE == nav_setcwd((FS_STRING)av[0], TRUE, FALSE))
01708    {
01709       eFsStatus = e_fscmds_CheckNavError();
01710       if( ppcStringReply != NULL )
01711       {
01712          v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
01713       }
01714    }
01715    else
01716    {
01717       // First we want to forbid the cases "mv srcfile dstdir-that-already-exists"
01718       // and "mv srcdir dstfile-that-already-exists"
01719       bSrcType = nav_file_isdir();
01720       if( TRUE == nav_setcwd((FS_STRING)av[1], TRUE, FALSE))
01721       {   // The dst already exists.
01722          bDstType = nav_file_isdir();
01723          if( bSrcType != bDstType )
01724          {
01725             eFsStatus = FSCMDS_STATUS_KO;
01726             if( ppcStringReply != NULL )
01727                *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_MV_TYPEDIFFER;
01728          }
01729          else
01730          {
01731             fsaccess_give_mutex(); // Release the fs resource.
01732             eFsStatus = e_fscmds_rm( FsNavId, (FS_STRING)av[1], TRUE );
01733             fsaccess_take_mutex(); // Take the fs resource.
01734             if( FSCMDS_STATUS_OK != eFsStatus )
01735             {
01736                if( ppcStringReply != NULL )
01737                {
01738                   v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
01739                }
01740             }
01741          }
01742       }
01743 
01744       if( FSCMDS_STATUS_OK == eFsStatus )
01745       {
01746          // Rename the pxSrcName to pxDstName.
01747          if( FALSE == nav_file_rename( (FS_STRING)av[1] ) )
01748          {
01749             eFsStatus = e_fscmds_CheckNavError();
01750             if( ppcStringReply != NULL )
01751             {
01752                v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
01753             }
01754          }
01755          else
01756          {
01757             if(ppcStringReply != NULL)
01758                *ppcStringReply = NULL;   // Nothing to display in case of success.
01759             eRetStatus = SHELL_EXECSTATUS_OK;
01760          }
01761       }
01762 
01763    }
01764    // The previous check was successfull.
01765    nav_gotoindex( &sav_index ); // Restore the nav to point on the src.
01766 
01767    fsaccess_give_mutex(); // Release the fs resource.
01768 
01769    return( eRetStatus );
01770 }

eExecStatus e_fscmds_shell_pwd ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The pwd command: return current path. Format: pwd.

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
FsNavId Input. The file system navigator id to use.
ac Input. The argument counter. Should be 0.
av Input. The argument vector. Ignored.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 473 of file fscmds.c.

References CRLF, e_fscmds_CheckNavError(), FSCMDS_ERRMSG_LS_SYNTAXERROR, FSCMDS_STATUS_OK, prv_Print_String_To_Requester_Stream(), SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, SHELL_MAX_MSGOUT_LEN, v_fscmds_GetStrMsgFromErr(), and v_shell_Print_String_To_Requester_Stream().

00476 {
00477    eFsCmdsStatus eFsStatus = FSCMDS_STATUS_OK;
00478    eExecStatus   eRetStatus = SHELL_EXECSTATUS_KO;
00479    signed portCHAR *pcStringToPrint;
00480 
00481 
00482    // 1) Check the input.
00483    //  i) No argument.
00484    if( 0 != ac )
00485    {   // Syntax error.
00486       if(ppcStringReply != NULL)
00487          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_LS_SYNTAXERROR;
00488       return( eRetStatus );
00489    }
00490 
00491    // Take mutex on fs module.
00492    fsaccess_take_mutex();
00493    nav_select( FsNavId );
00494 
00495    pcStringToPrint = (signed portCHAR *)pvPortMalloc( SHELL_MAX_MSGOUT_LEN ); // Alloc
00496    if( NULL == pcStringToPrint )
00497    {
00498       fsaccess_give_mutex(); // Release the fs resource.
00499       return( SHELL_EXECSTATUS_KO );
00500    }
00501 
00502    // 2) Perform the command.
00503    if (FALSE == nav_getcwd((FS_STRING)pcStringToPrint, SHELL_MAX_MSGOUT_LEN, FALSE))
00504    {
00505       // The operation failed.
00506       eFsStatus = e_fscmds_CheckNavError();
00507    }
00508    else
00509    {
00510       prv_Print_String_To_Requester_Stream( xModId, (portCHAR *)pcStringToPrint );
00511       v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)CRLF );
00512    }
00513 
00514    vPortFree( pcStringToPrint ); // Free.
00515    // Release mutex on fs module.
00516    fsaccess_give_mutex();
00517 
00518    if( FSCMDS_STATUS_OK == eFsStatus )
00519    {
00520       if(ppcStringReply != NULL)
00521          *ppcStringReply = NULL;   // Nothing to display in case of success.
00522       eRetStatus = SHELL_EXECSTATUS_OK;
00523    }
00524    else if( ppcStringReply != NULL )
00525    {
00526       v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
00527    }
00528 
00529    return( eRetStatus );
00530 }

eExecStatus e_fscmds_shell_rm ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

The rm command: remove a specified file or a specified directory or all files and directories. Takes up to two parameters, first an optional parameter to recursively delete directories(i.e. non empty directories may be deleted), and always the parameter which is the file to delete or the directory to delete or *. Format: rm {-R} {file,directory,*} NOTE: file and directory names can be used with a path. WARNING: paths are not supported with *; i.e. the command may only be rm -R * or rm *.

Note:
This function must be of the type pfShellCmd defined by the shell module.
Parameters:
xModId Input. The module that is calling this function.
FsNavId Input. The file system navigator id to use.
ac Input. The argument counter. Should be 1 or 2.
av Input. The argument vector.
ppcStringReply Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string.
Returns:
the status of the command execution.

Definition at line 1104 of file fscmds.c.

References e_fscmds_rm(), e_fscmds_rm_all(), FSCMDS_ERRMSG_RM_SYNTAXERROR, FSCMDS_STATUS_OK, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_fscmds_GetStrMsgFromErr().

01107 {
01108    eFsCmdsStatus eFsStatus;
01109    eExecStatus   eRetStatus = SHELL_EXECSTATUS_KO;
01110 
01111    // 1) Check the input.
01112    //  i) One argument only.
01113    if (( 1 != ac ) && ( 2 != ac ))
01114    {   // Syntax error.
01115       if(ppcStringReply != NULL)
01116          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_RM_SYNTAXERROR;
01117       return( SHELL_EXECSTATUS_KO );
01118    }
01119 
01120    // 2) Perform the command.
01121    if (!strcmp((char *)av[0], "-R"))
01122    {
01123       if( '*' == av[1][0] )
01124       {
01125          // Remove all files or directories in current directory == rm -R *
01126          eFsStatus = e_fscmds_rm_all( FsNavId, FALSE );
01127       }
01128       else
01129       {
01130          // Remove a specified file or directory.
01131          eFsStatus = e_fscmds_rm( FsNavId, (FS_STRING)av[1], FALSE );
01132       }
01133    }
01134    else if( '*' == av[0][0] )
01135    {
01136       // Remove all files or empty directories in current directory == rm *
01137       eFsStatus = e_fscmds_rm_all( FsNavId, TRUE );
01138    }
01139    else
01140    {
01141        // Remove a specified file or a specified empty directory.
01142        eFsStatus = e_fscmds_rm( FsNavId, (FS_STRING)av[0], TRUE );
01143    }
01144 
01145    if( FSCMDS_STATUS_OK == eFsStatus )
01146    {
01147       if(ppcStringReply != NULL)
01148          *ppcStringReply = NULL;   // Nothing to display in case of success.
01149       eRetStatus = SHELL_EXECSTATUS_OK;
01150    }
01151    else if( ppcStringReply != NULL )
01152    {
01153       v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
01154    }
01155 
01156    return( eRetStatus );
01157 }

eExecStatus e_fscmds_shell_touch ( eModId  xModId,
signed short  FsNavId,
int  ac,
signed portCHAR *  av[],
signed portCHAR **  ppcStringReply 
)

Definition at line 791 of file fscmds.c.

References e_fscmds_touch(), FSCMDS_ERRMSG_TOUCH_SYNTAXERROR, FSCMDS_STATUS_OK, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_fscmds_GetStrMsgFromErr().

00794 {
00795    eFsCmdsStatus eFsStatus;
00796    eExecStatus   eRetStatus = SHELL_EXECSTATUS_KO;
00797 
00798 
00799    // 1) Check the input.
00800    //  i) One argument only.
00801    if( 1 != ac )
00802    {   // Syntax error.
00803       if(ppcStringReply != NULL)
00804          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_TOUCH_SYNTAXERROR;
00805       return( SHELL_EXECSTATUS_KO );
00806    }
00807 
00808    // 2) Perform the command.
00809    eFsStatus = e_fscmds_touch( FsNavId, (FS_STRING)av[0] );
00810 
00811    if( FSCMDS_STATUS_OK == eFsStatus )
00812    {
00813       if(ppcStringReply != NULL)
00814          *ppcStringReply = NULL;   // Nothing to display in case of success.
00815       eRetStatus = SHELL_EXECSTATUS_OK;
00816    }
00817    else if( ppcStringReply != NULL )
00818    {
00819       v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply);
00820    }
00821 
00822    return( eRetStatus );
00823 }

void v_fscmds_GetStrMsgFromErr ( eFsCmdsStatus  ErrStatus,
signed portCHAR **  ppcStringReply 
)

Map a string message to an error.

Parameters:
ErrStatus Input. The error status.
ppcStringReply Input/Output. The response string. The input is not NULL.

Definition at line 1830 of file fscmds.c.

References FSCMDS_ERRMSG_BADSIZEFAT, FSCMDS_ERRMSG_CD_UNKNOWNDIR, FSCMDS_ERRMSG_DIRNOTEMPTY, FSCMDS_ERRMSG_FILENOTFOUND, FSCMDS_ERRMSG_FILEWR, FSCMDS_ERRMSG_FS, FSCMDS_ERRMSG_FSNOTSUPPORTED, FSCMDS_ERRMSG_HW, FSCMDS_ERRMSG_INCORRECTNAME, FSCMDS_ERRMSG_ISROOTDIR, FSCMDS_ERRMSG_MEMDEVMISSING, FSCMDS_ERRMSG_MOUNT_DRIVENOTFOUND, FSCMDS_ERRMSG_MOUNT_FAILED, FSCMDS_ERRMSG_NOFORMAT, FSCMDS_ERRMSG_NOMOUNT, FSCMDS_ERRMSG_NOPARTITION, FSCMDS_ERRMSG_NOTAFILE, FSCMDS_ERRMSG_NOTFOUND, FSCMDS_ERRMSG_OUTOFMEM, FSCMDS_ERRMSG_READONLYDRIVE, FSCMDS_ERRMSG_UNEXPECTED, FSCMDS_STATUS_ERR_BADSIZEFAT, FSCMDS_STATUS_ERR_DIRNOTEMPTY, FSCMDS_STATUS_ERR_DRIVE, FSCMDS_STATUS_ERR_FILENOTFOUND, FSCMDS_STATUS_ERR_FILEWR, FSCMDS_STATUS_ERR_FS, FSCMDS_STATUS_ERR_FSNOTSUPPORTED, FSCMDS_STATUS_ERR_HW, FSCMDS_STATUS_ERR_INCORRECTNAME, FSCMDS_STATUS_ERR_ISROOTDIR, FSCMDS_STATUS_ERR_MEMALLOC, FSCMDS_STATUS_ERR_MEMDEVMISSING, FSCMDS_STATUS_ERR_MOUNT, FSCMDS_STATUS_ERR_NOFORMAT, FSCMDS_STATUS_ERR_NOMOUNT, FSCMDS_STATUS_ERR_NOPARTITION, FSCMDS_STATUS_ERR_NOTAFILE, FSCMDS_STATUS_ERR_NOTFOUND, FSCMDS_STATUS_ERR_OUTOFMEM, FSCMDS_STATUS_ERR_READONLY, FSCMDS_STATUS_ERR_UNKNOWN, FSCMDS_STATUS_ERR_UNKNOWNDIR, and SHELL_ERRMSG_MEMALLOC.

Referenced by e_fscmds_goto_drive(), e_fscmds_shell_append(), e_fscmds_shell_cat(), e_fscmds_shell_cd(), e_fscmds_shell_cp(), e_fscmds_shell_format(), e_fscmds_shell_goto(), e_fscmds_shell_ls(), e_fscmds_shell_mkdir(), e_fscmds_shell_mount(), e_fscmds_shell_mv(), e_fscmds_shell_pwd(), e_fscmds_shell_rm(), e_fscmds_shell_touch(), and prv_df().

01831 {
01832    switch( ErrStatus )
01833    {
01834       case FSCMDS_STATUS_ERR_DRIVE:
01835          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_MOUNT_DRIVENOTFOUND;
01836          break;
01837       case FSCMDS_STATUS_ERR_MOUNT:
01838          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_MOUNT_FAILED;
01839          break;
01840       case FSCMDS_STATUS_ERR_UNKNOWNDIR:
01841          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_CD_UNKNOWNDIR;
01842          break;
01843       case FSCMDS_STATUS_ERR_HW:
01844          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_HW;
01845          break;
01846       case FSCMDS_STATUS_ERR_FS:
01847          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_FS;
01848          break;
01849       case FSCMDS_STATUS_ERR_NOFORMAT:
01850          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_NOFORMAT;
01851          break;
01852       case FSCMDS_STATUS_ERR_NOMOUNT:
01853          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_NOMOUNT;
01854          break;
01855       case FSCMDS_STATUS_ERR_MEMDEVMISSING:
01856          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_MEMDEVMISSING;
01857          break;
01858       case FSCMDS_STATUS_ERR_NOPARTITION:
01859          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_NOPARTITION;
01860          break;
01861       case FSCMDS_STATUS_ERR_FSNOTSUPPORTED:
01862          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_FSNOTSUPPORTED;
01863          break;
01864       case FSCMDS_STATUS_ERR_FILENOTFOUND:
01865          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_FILENOTFOUND;
01866          break;
01867       case FSCMDS_STATUS_ERR_NOTFOUND:
01868          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_NOTFOUND;
01869          break;
01870       case FSCMDS_STATUS_ERR_NOTAFILE:
01871          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_NOTAFILE;
01872          break;
01873       case FSCMDS_STATUS_ERR_FILEWR:
01874          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_FILEWR;
01875          break;
01876       case FSCMDS_STATUS_ERR_READONLY:
01877          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_READONLYDRIVE;
01878          break;
01879       case FSCMDS_STATUS_ERR_BADSIZEFAT:
01880          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_BADSIZEFAT;
01881          break;
01882       case FSCMDS_STATUS_ERR_OUTOFMEM:
01883          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_OUTOFMEM;
01884          break;
01885       case FSCMDS_STATUS_ERR_INCORRECTNAME:
01886          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_INCORRECTNAME;
01887          break;
01888       case FSCMDS_STATUS_ERR_ISROOTDIR:
01889          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_ISROOTDIR;
01890          break;
01891       case FSCMDS_STATUS_ERR_DIRNOTEMPTY:
01892          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_DIRNOTEMPTY;
01893          break;
01894       case FSCMDS_STATUS_ERR_MEMALLOC:
01895          *ppcStringReply = (signed portCHAR *)SHELL_ERRMSG_MEMALLOC;
01896          break;
01897 
01898       case FSCMDS_STATUS_ERR_UNKNOWN:
01899          *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_UNEXPECTED;
01900          break;
01901 
01902       default: // SHOULD NEVER HAPPEN.
01903          break;
01904    }
01905 }


Generated on Fri Feb 19 02:22:45 2010 for AVR32 - Control Panel demonstration. by  doxygen 1.5.5