This module provides a shell commands interface to the file system.
Definition in file fscmds.c.
#include <string.h>
#include <math.h>
#include "compiler.h"
#include "board.h"
#include "shell.h"
#include "sensor.h"
#include "actuator.h"
#include "fsaccess.h"
#include "fscmds.h"
#include "supervisor.h"
#include "com1shell.h"
#include "tracedump.h"
Go to the source code of this file.
Functions | |
eFsCmdsStatus | e_fscmds_cd (signed short FsNavId, FS_STRING pxStringDirName) |
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. | |
eExecStatus | e_fscmds_goto_drive (unsigned int u8DriveId, signed short FsNavId, int ac, signed portCHAR **ppcStringReply) |
Shared mount drive command. | |
eFsCmdsStatus | e_fscmds_mount (signed short FsNavId, unsigned short u8DriveId) |
The mount basic command: mount a disk. | |
eFsCmdsStatus | e_fscmds_rm (signed short FsNavId, const FS_STRING pxStringName, Bool bOnlyEmpty) |
The rm basic command. Remove a specified file or a specified directory == rm {-R} {filename,dirname} NOTE: file and directory names can be used with a path. | |
eFsCmdsStatus | e_fscmds_rm_all (signed short FsNavId, Bool bOnlyEmpty) |
The rm all basic command. Remove all files and directories in current directory == rm {-R} *. | |
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) |
eFsCmdsStatus | e_fscmds_touch (signed short FsNavId, const FS_STRING pxStringFilename) |
static eFsCmdsStatus | prv_append (eModId xModId, signed short FsNavId, const FS_STRING pxStringFilename) |
The append basic command. | |
static eFsCmdsStatus | prv_cat (eModId xModId, signed short FsNavId, const FS_STRING pStringFilename) |
The cat basic command. | |
static eFsCmdsStatus | prv_cp (eModId xModId, signed short FsNavId, const FS_STRING pStringFilename) |
The cp basic command. | |
static eFsCmdsStatus | prv_df (eModId xModId, signed short FsNavId) |
The df basic command Display free space information for all connected drives. | |
static signed portCHAR | prv_GetChar_From_Requester_Stream (eModId xModId) |
Get a char from the input stream of a module. | |
static int | prv_i_GetIdxFromModid (eModId xModId) |
return x from a 2powx number. | |
static eFsCmdsStatus | prv_ls (eModId xModId, signed short FsNavId) |
The ls basic command. | |
static Bool | prv_NameExists (const FS_STRING pxStringName) |
Check if a file and/or directory already exists in the current directory. | |
static void | prv_Print_String_To_Requester_Stream (eModId xModId, const portCHAR *pStringToPrint) |
Print a string directly to the output stream of a module. | |
static void | prv_PutChar_To_Requester_Stream (eModId xModId, signed portCHAR c) |
Put a char to the output stream of a module. | |
static eFsCmdsStatus | prvCommonErrorLeave (void) |
Common upon-error-prologue of several functions. | |
void | v_fscmds_GetStrMsgFromErr (eFsCmdsStatus ErrStatus, signed portCHAR **ppcStringReply) |
Map a string message to an error. | |
Variables | |
static Fs_index | ax_mark_index [SYS_NB_MOD] |
const signed portCHAR *const | FSCMDS_ERRMSG_APPEND_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: append filename"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_BADSIZEFAT = (signed portCHAR *)ERROR_CRLF"Unsupported drive size"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_CAT_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: cat filename"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_CD_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: cd dirname"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_CD_UNKNOWNDIR = (signed portCHAR *)ERROR_CRLF"Unknown directory"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_CP_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: cp filename"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_DF_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: df"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_DIRNOTEMPTY = (signed portCHAR *)ERROR_CRLF"Directory not empty."CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_DISK_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: disk"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_FAT_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: fat"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_FILENOTFOUND = (signed portCHAR *)ERROR_CRLF"File not found"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_FILEWR = (signed portCHAR *)ERROR_CRLF"File currently opened in write-mode"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_FORMAT_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: format {a,b,c,d}"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_FS = (signed portCHAR *)ERROR_CRLF"File system error"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_FSNOTSUPPORTED = (signed portCHAR *)ERROR_CRLF"Unsupported file system"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_GOTO_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: goto"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_HELP_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: help"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_HW = (signed portCHAR *)ERROR_CRLF"Hardware error"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_INCORRECTNAME = (signed portCHAR *)ERROR_CRLF"Incorrect name, this must be not contain char \\/:*?\"<>|"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_ISROOTDIR = (signed portCHAR *)ERROR_CRLF"Current dir is a root dir."CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_LS_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: ls"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_MAINTENANCE = (signed portCHAR *)ERROR_CRLF"File system access forbidden(Maintenance mode)"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_MARK_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: mark"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_MEMDEVMISSING = (signed portCHAR *)ERROR_CRLF"Memory device is missing"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_MKDIR_NAMEEXISTS = (signed portCHAR *)ERROR_CRLF"Name already used."CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_MKDIR_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: mkdir dirname"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_MOUNT_DRIVENOTFOUND = (signed portCHAR *)ERROR_CRLF"Drive not found."CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_MOUNT_FAILED = (signed portCHAR *)ERROR_CRLF"Unable to mount drive"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_MOUNT_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: mount {a,b,c,d}"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_MOUNTSHORT_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: {a:,b:,c:,d:}"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_MV_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: mv src dst"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_MV_TYPEDIFFER = (signed portCHAR *)ERROR_CRLF"Src & dst must be of the same type."CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_NOFORMAT = (signed portCHAR *)ERROR_CRLF"Current drive is not formatted"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_NOMOUNT = (signed portCHAR *)ERROR_CRLF"No drive mounted"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_NOPARTITION = (signed portCHAR *)ERROR_CRLF"The selected partition doesn't exist"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_NOTAFILE = (signed portCHAR *)ERROR_CRLF"Not a file"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_NOTFOUND = (signed portCHAR *)ERROR_CRLF"File or directory not found"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_OUTOFMEM = (signed portCHAR *)ERROR_CRLF"Operation canceled: out of memory"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_READONLYDRIVE = (signed portCHAR *)ERROR_CRLF"Drive is read-only"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_RM_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: rm {-R} {filename,dirname,*}"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_TOUCH_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: touch filename"CRLF |
const signed portCHAR *const | FSCMDS_ERRMSG_UNEXPECTED = (signed portCHAR *)ERROR_CRLF"Unexpected error"CRLF |
const signed portCHAR *const | FSCMDS_MSG_APPEND_WELCOME = (signed portCHAR *)CRLF"Simple text editor, enter char to append, ^q to exit and save"CRLF |
const signed portCHAR *const | FSCMDS_MSG_HELP |
static portCHAR | str_ascii [MAX_FILE_PATH_LENGTH] |
eFsCmdsStatus e_fscmds_cd | ( | signed short | FsNavId, | |
FS_STRING | pxStringDirName | |||
) |
The cd basic command.
FsNavId | Input. The file system navigator id to use. | |
pxStringDirName | Input. The directory name. |
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.
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.
FsNavId | Input. The file system navigator id to use. | |
u8DriveId | Input. The target drive id. |
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 }
eExecStatus e_fscmds_goto_drive | ( | unsigned int | u8DriveId, | |
signed short | FsNavId, | |||
int | ac, | |||
signed portCHAR ** | ppcStringReply | |||
) |
Shared mount drive command.
u8DriveId | Input. The drive id to mount. | |
FsNavId | Input. The file system navigator id to use. | |
ac | Input. The argument counter. Should be 0. | |
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. |
Definition at line 1245 of file fscmds.c.
References e_fscmds_mount(), FSCMDS_ERRMSG_MOUNTSHORT_SYNTAXERROR, FSCMDS_STATUS_OK, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, and v_fscmds_GetStrMsgFromErr().
Referenced by e_fscmds_shell_goto_a_drive(), e_fscmds_shell_goto_b_drive(), e_fscmds_shell_goto_c_drive(), and e_fscmds_shell_goto_d_drive().
01247 { 01248 eFsCmdsStatus eFsStatus; 01249 eExecStatus eRetStatus = SHELL_EXECSTATUS_KO; 01250 01251 01252 // 1) Check the input. 01253 // i) No argument. 01254 if( 0 != ac ) 01255 { // Syntax error. 01256 if(ppcStringReply != NULL) 01257 *ppcStringReply = (signed portCHAR *)FSCMDS_ERRMSG_MOUNTSHORT_SYNTAXERROR; 01258 return( SHELL_EXECSTATUS_KO ); 01259 } 01260 01261 // 2) Perform the command. 01262 eFsStatus = e_fscmds_mount(FsNavId, u8DriveId); 01263 if( FSCMDS_STATUS_OK == eFsStatus ) 01264 { 01265 if(ppcStringReply != NULL) 01266 *ppcStringReply = NULL; // Nothing to display in case of success. 01267 eRetStatus = SHELL_EXECSTATUS_OK; 01268 } 01269 else if( ppcStringReply != NULL ) 01270 { 01271 v_fscmds_GetStrMsgFromErr(eFsStatus, ppcStringReply); 01272 } 01273 01274 return( eRetStatus ); 01275 }
eFsCmdsStatus e_fscmds_mount | ( | signed short | FsNavId, | |
unsigned short | u8DriveId | |||
) |
The mount basic command: mount a disk.
FsNavId | Input. The file system navigator id to use. | |
u8DriveId | Input. The target drive id. |
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 }
eFsCmdsStatus e_fscmds_rm | ( | signed short | FsNavId, | |
const FS_STRING | pxStringName, | |||
Bool | bOnlyEmpty | |||
) |
The rm basic command.
Remove a specified file or a specified directory == rm {-R} {filename,dirname} NOTE: file and directory names can be used with a path.
FsNavId | Input. The file system navigator id to use. | |
pxStringName | Input. The name. | |
bOnlyEmpty | Input. Boolean switch between: FALSE(=="non-empty directories can be deleted") and TRUE(=="non-empty directories cannot be deleted") |
Definition at line 1051 of file fscmds.c.
References e_fscmds_CheckNavError(), FSCMDS_STATUS_ERR_NOTFOUND, and FSCMDS_STATUS_OK.
Referenced by e_fscmds_shell_mv(), and e_fscmds_shell_rm().
01053 { 01054 eFsCmdsStatus eFsStatus = FSCMDS_STATUS_OK; 01055 Fs_index sav_index; 01056 01057 01058 fsaccess_take_mutex(); // Take the fs resource. 01059 nav_select( FsNavId ); // Select the navigator. 01060 01061 sav_index = nav_getindex(); // Save the current nav position. 01062 // Set the navigator to the corresponding file or directory. 01063 if( FALSE == nav_setcwd(pxStringName, TRUE, FALSE)) 01064 { 01065 eFsStatus = FSCMDS_STATUS_ERR_NOTFOUND; 01066 } 01067 else if( FALSE == nav_file_del(bOnlyEmpty) ) // Delete the file or directory. 01068 { 01069 eFsStatus = e_fscmds_CheckNavError(); 01070 } 01071 nav_gotoindex( &sav_index ); // Restore the initial nav position. 01072 01073 fsaccess_give_mutex(); // Release the fs resource. 01074 01075 return( eFsStatus ); 01076 }
eFsCmdsStatus e_fscmds_rm_all | ( | signed short | FsNavId, | |
Bool | bOnlyEmpty | |||
) |
The rm all basic command.
Remove all files and directories in current directory == rm {-R} *.
FsNavId | Input. The file system navigator id to use. | |
bOnlyEmpty | Input. Boolean switch between: FALSE(=="non-empty directories can be deleted") and TRUE(=="non-empty directories cannot be deleted") WARNING: paths are not supported with *; i.e. the command may only be rm -R * or rm * |
Definition at line 1009 of file fscmds.c.
References e_fscmds_CheckNavError(), and FSCMDS_STATUS_OK.
Referenced by e_fscmds_shell_rm().
01010 { 01011 eFsCmdsStatus eFsStatus = FSCMDS_STATUS_OK; 01012 01013 01014 fsaccess_take_mutex(); // Take the fs resource. 01015 nav_select(FsNavId); // Select the navigator. 01016 01017 if( FALSE == nav_filelist_first( FS_DIR ) ) 01018 { 01019 nav_filelist_first( FS_FILE ); 01020 } 01021 01022 nav_filelist_reset(); 01023 01024 while ( nav_filelist_set(0,FS_FIND_NEXT) ) 01025 { 01026 if( FALSE == nav_file_del(bOnlyEmpty) ) 01027 { 01028 eFsStatus = e_fscmds_CheckNavError(); 01029 break; 01030 } 01031 } 01032 fsaccess_give_mutex(); // Release the fs resource. 01033 01034 return( eFsStatus ); 01035 }
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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.
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. |
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}.
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. |
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.
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. |
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.
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. |
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 *.
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. |
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 }
eFsCmdsStatus e_fscmds_touch | ( | signed short | FsNavId, | |
const FS_STRING | pxStringFilename | |||
) |
Definition at line 746 of file fscmds.c.
References FSCMDS_STATUS_OK, pcTempoDate, and v_cptime_GetDateInFatStringFormat().
Referenced by e_fscmds_shell_touch().
00747 { 00748 eFsCmdsStatus eFsStatus = FSCMDS_STATUS_OK; 00749 Fs_index sav_index; 00750 char pcTempoDate[17]; 00751 00752 fsaccess_take_mutex(); 00753 nav_select(FsNavId); 00754 sav_index = nav_getindex(); // Save the current nav position. 00755 00756 // Set the navigator to the corresponding file, create the file if it doesn't exist. 00757 if( FALSE == nav_setcwd(pxStringFilename, TRUE, TRUE)) 00758 { 00759 file_close(); // Close the file. 00760 } 00761 // Get the current time in the "YYYYMMDDHHMMSSMS" string format. 00762 v_cptime_GetDateInFatStringFormat( pcTempoDate ); 00763 // Set the file date. 00764 nav_file_dateset( (FS_STRING)pcTempoDate, FS_DATE_LAST_WRITE ); 00765 00766 nav_gotoindex( &sav_index ); // Restore the initial nav position. 00767 fsaccess_give_mutex(); 00768 return( eFsStatus ); 00769 }
static eFsCmdsStatus prv_append | ( | eModId | xModId, | |
signed short | FsNavId, | |||
const FS_STRING | pxStringFilename | |||
) | [static] |
The append basic command.
xModId | Input. The module associated with the target output stream. | |
FsNavId | Input. The file system navigator id to use. | |
pxStringFilename | Input. The filename. |
Definition at line 2168 of file fscmds.c.
References CR, CRLF, FSCMDS_MSG_APPEND_WELCOME, FSCMDS_STATUS_ERR_FILENOTFOUND, FSCMDS_STATUS_OK, LF, pcTempoDate, prv_GetChar_From_Requester_Stream(), prv_PutChar_To_Requester_Stream(), prvCommonErrorLeave(), QUIT_APPEND, v_cptime_GetDateInFatStringFormat(), and v_shell_Print_String_To_Requester_Stream().
Referenced by e_fscmds_shell_append().
02169 { 02170 signed portCHAR cTempoChar; 02171 signed portCHAR cPrevChar=0; 02172 Fs_index sav_index; 02173 char pcTempoDate[17]; 02174 02175 02176 // Take mutex on fs module. 02177 fsaccess_take_mutex(); 02178 nav_select(FsNavId); 02179 02180 sav_index = nav_getindex(); // Save the current nav position. 02181 02182 /* 1) Set the nav to point on the target file. */ 02183 if(nav_setcwd((FS_STRING)pxStringFilename, TRUE, FALSE)==FALSE) 02184 { 02185 fsaccess_give_mutex(); // Release the fs mutex. 02186 return( FSCMDS_STATUS_ERR_FILENOTFOUND ); 02187 } 02188 02189 /* 2) Open the target file. */ 02190 if( FALSE == file_open( FOPEN_MODE_APPEND ) ) 02191 { 02192 nav_gotoindex( &sav_index ); // Restore the initial nav position. 02193 return( prvCommonErrorLeave() ); 02194 } 02195 02196 /* 3) Switch to editor mode. */ 02197 // Print a welcome banner to the output stream associated with xModId. 02198 v_shell_Print_String_To_Requester_Stream( xModId, FSCMDS_MSG_APPEND_WELCOME ); 02199 // Editor loop: get a char, echo it, write it at the end of the file. 02200 while( 1 ) 02201 { 02202 cTempoChar = prv_GetChar_From_Requester_Stream( xModId ); 02203 if( cTempoChar == QUIT_APPEND ) 02204 { 02205 v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)CRLF ); 02206 break; 02207 } 02208 if( ( cTempoChar == LF ) && ( cPrevChar != CR ) ) 02209 { 02210 prv_PutChar_To_Requester_Stream( xModId, CR ); 02211 file_putc( CR ); 02212 } 02213 prv_PutChar_To_Requester_Stream( xModId, cTempoChar ); // Echo. 02214 // Write to file 02215 if( FALSE == file_putc( cTempoChar ) ) 02216 { 02217 file_close(); 02218 nav_gotoindex( &sav_index ); // Restore the initial nav position. 02219 return( prvCommonErrorLeave() ); 02220 } 02221 if( cTempoChar == CR ) // Special for CRLF. 02222 { 02223 prv_PutChar_To_Requester_Stream( xModId, LF ); 02224 file_putc( LF ); 02225 } 02226 cPrevChar = cTempoChar; 02227 } 02228 02229 // Get the current time in the "YYYYMMDDHHMMSSMS" string format. 02230 v_cptime_GetDateInFatStringFormat( pcTempoDate ); 02231 // Set the file date. 02232 nav_file_dateset( (FS_STRING)pcTempoDate, FS_DATE_LAST_WRITE ); 02233 02234 /* 4) Close the file. */ 02235 file_close(); 02236 02237 nav_gotoindex( &sav_index ); // Restore the initial nav position. 02238 02239 // Release mutex on fs module. 02240 fsaccess_give_mutex(); 02241 02242 return( FSCMDS_STATUS_OK ); 02243 }
static eFsCmdsStatus prv_cat | ( | eModId | xModId, | |
signed short | FsNavId, | |||
const FS_STRING | pStringFilename | |||
) | [static] |
The cat basic command.
xModId | Input. The module associated with the target output stream. | |
FsNavId | Input. The file system navigator id to use. | |
pStringFilename | Input. The filename. |
Definition at line 2064 of file fscmds.c.
References CRLF, FSCMDS_STATUS_ERR_FILENOTFOUND, FSCMDS_STATUS_ERR_MEMALLOC, FSCMDS_STATUS_OK, prvCommonErrorLeave(), TRACE_COM2, and v_shell_Print_String_To_Requester_Stream().
Referenced by e_fscmds_shell_cat().
02065 { 02066 signed portCHAR *pcOutString; 02067 size_t filesize; 02068 size_t RequestedSize; 02069 size_t ReadSize; 02070 Fs_index sav_index; 02071 02072 // Take mutex on fs module. 02073 fsaccess_take_mutex(); 02074 nav_select(FsNavId); 02075 02076 sav_index = nav_getindex(); // Save the current nav position. 02077 02078 /* 1) Set the nav to point on the target file. */ 02079 if ( FALSE == nav_setcwd(pStringFilename, TRUE, FALSE) ) 02080 { 02081 fsaccess_give_mutex(); // Release the fs mutex. 02082 return( FSCMDS_STATUS_ERR_FILENOTFOUND ); 02083 } 02084 02085 /* 2) Open the target file. */ 02086 if( FALSE == file_open( FOPEN_MODE_R ) ) 02087 { 02088 nav_gotoindex( &sav_index ); // Restore the initial nav position. 02089 return( prvCommonErrorLeave() ); 02090 } 02091 02092 /* 3) Print the content of the file. */ 02093 // The fsaccess functions need the fs mutex => we have to release it. 02094 fsaccess_give_mutex(); 02095 // Get the file size. 02096 filesize = fsaccess_file_get_size( FsNavId ); 02097 // Malloc the output string. 02098 if(filesize < FS_SIZE_OF_SECTOR) 02099 { 02100 pcOutString = (signed portCHAR *)pvPortMalloc( filesize +1 ); 02101 if( NULL == pcOutString ) 02102 { 02103 return( FSCMDS_STATUS_ERR_MEMALLOC ); 02104 } 02105 RequestedSize = filesize; 02106 } 02107 else 02108 { 02109 pcOutString = (signed portCHAR *)pvPortMalloc( FS_SIZE_OF_SECTOR +1 ); 02110 if( NULL == pcOutString ) 02111 { 02112 return( FSCMDS_STATUS_ERR_MEMALLOC ); 02113 } 02114 RequestedSize = FS_SIZE_OF_SECTOR; 02115 } 02116 // Read and print the file content. 02117 while( filesize ) 02118 { 02119 // Read a chunk of characters. 02120 ReadSize = read( FsNavId, pcOutString, RequestedSize ); 02121 if( ReadSize != RequestedSize ) 02122 { 02123 TRACE_COM2(""); 02124 vPortFree( pcOutString ); 02125 // Take mutex on fs module. 02126 fsaccess_take_mutex(); 02127 nav_select( FsNavId ); 02128 file_close(); 02129 nav_gotoindex( &sav_index ); // Restore the initial nav position. 02130 return( prvCommonErrorLeave() ); 02131 } 02132 else 02133 filesize -= ReadSize; // Update the remaining nb of characters to read. 02134 // Update the size of the next chunk request. 02135 RequestedSize = (filesize < FS_SIZE_OF_SECTOR) ? filesize : FS_SIZE_OF_SECTOR; 02136 // Print the chunk to the stream associated with xModId. 02137 *(pcOutString +ReadSize) = '\0'; // NULL-terminate the chunk to make a string. 02138 v_shell_Print_String_To_Requester_Stream( xModId, pcOutString ); 02139 } 02140 v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)CRLF ); 02141 02142 vPortFree( pcOutString ); 02143 02144 /* Close the file. */ 02145 // Take mutex on fs module. 02146 fsaccess_take_mutex(); 02147 nav_select( FsNavId ); 02148 file_close(); 02149 02150 nav_gotoindex( &sav_index ); // Restore the initial nav position. 02151 02152 // Release mutex on fs module. 02153 fsaccess_give_mutex(); 02154 02155 return( FSCMDS_STATUS_OK ); 02156 }
static eFsCmdsStatus prv_cp | ( | eModId | xModId, | |
signed short | FsNavId, | |||
const FS_STRING | pStringFilename | |||
) | [static] |
The cp basic command.
xModId | Input. The module associated with the target output stream. | |
FsNavId | Input. The file system navigator id to use. | |
pStringFilename | Input. The filename to copy. |
Definition at line 2328 of file fscmds.c.
References ax_mark_index, FSCMDS_STATUS_ERR_FILENOTFOUND, FSCMDS_STATUS_OK, MAX_FILE_PATH_LENGTH, prv_i_GetIdxFromModid(), and prvCommonErrorLeave().
Referenced by e_fscmds_shell_cp().
02329 { 02330 U16 file_size; 02331 Fs_index sav_index; 02332 02333 02334 // Take mutex on fs module. 02335 fsaccess_take_mutex(); 02336 nav_select(FsNavId); 02337 02338 // Set the nav to point on the target file. 02339 if(nav_setcwd(pStringFilename, TRUE, FALSE)==FALSE) 02340 { 02341 fsaccess_give_mutex(); // Release the fs mutex. 02342 return( FSCMDS_STATUS_ERR_FILENOTFOUND ); 02343 } 02344 else 02345 { 02346 // Get name of source to be used as same destination name 02347 if( FALSE == nav_file_name( pStringFilename, MAX_FILE_PATH_LENGTH, FS_NAME_GET, TRUE) ) 02348 { 02349 return( prvCommonErrorLeave() ); 02350 } 02351 // Get file size 02352 file_size = nav_file_lgtsector(); 02353 // Mark source 02354 nav_file_copy(); 02355 // Save current source position 02356 sav_index = nav_getindex(); 02357 // Goto destination 02358 nav_gotoindex( &(ax_mark_index[prv_i_GetIdxFromModid( xModId )]) ); 02359 // free space check 02360 if (nav_partition_space() > file_size) 02361 { 02362 // Paste 02363 nav_file_paste_start( pStringFilename ); 02364 // Restore previous nav position 02365 nav_gotoindex( &sav_index ); 02366 // Perform copy 02367 while(nav_file_paste_state( FALSE ) == COPY_BUSY); 02368 // Restore previous nav position 02369 } 02370 nav_gotoindex(&sav_index); 02371 } 02372 fsaccess_give_mutex(); // Release the fs mutex. 02373 return( FSCMDS_STATUS_OK ); 02374 }
static eFsCmdsStatus prv_df | ( | eModId | xModId, | |
signed short | FsNavId | |||
) | [static] |
The df basic command
Display free space information for all connected drives.
xModId | Input. The module that is calling this function. | |
FsNavId | Input. The file system navigator id to use. |
Definition at line 2256 of file fscmds.c.
References CRLF, e_fscmds_CheckNavError(), FSCMDS_STATUS_ERR_MEMALLOC, FSCMDS_STATUS_OK, SHELL_MAX_MSGOUT_LEN, sprintf(), v_fscmds_GetStrMsgFromErr(), and v_shell_Print_String_To_Requester_Stream().
Referenced by e_fscmds_shell_df().
02257 { 02258 signed portCHAR *pcStringToPrint; 02259 signed portCHAR *pcStringErrMsg; 02260 int i,NbDrive; 02261 Fs_index sav_index; 02262 eFsCmdsStatus eFsStatus; 02263 02264 02265 fsaccess_take_mutex(); // Take mutex on fs module. 02266 nav_select( FsNavId ); 02267 02268 pcStringToPrint = (signed portCHAR *)pvPortMalloc( SHELL_MAX_MSGOUT_LEN ); // Alloc 02269 if( NULL == pcStringToPrint ) 02270 { 02271 fsaccess_give_mutex(); // Release mutex on fs module. 02272 return( FSCMDS_STATUS_ERR_MEMALLOC ); 02273 } 02274 02275 sav_index = nav_getindex(); // Save current nav position 02276 NbDrive = nav_drive_nb(); // Get the number of drives. 02277 // Display free space information for each connected drive. 02278 for( i = 0; i < NbDrive; i++ ) 02279 { 02280 if( FALSE == nav_drive_set( i ) ) // Select drive 02281 { 02282 eFsStatus = e_fscmds_CheckNavError(); 02283 v_fscmds_GetStrMsgFromErr( eFsStatus, &pcStringErrMsg ); 02284 sprintf( (char *)pcStringToPrint, "%s (%c:) %s"CRLF, 02285 mem_name(i), 02286 (char)('a' + i), 02287 pcStringErrMsg ); 02288 v_shell_Print_String_To_Requester_Stream( xModId, pcStringToPrint ); 02289 } 02290 else if( FALSE == nav_partition_mount() ) // Mount the drive 02291 { 02292 eFsStatus = e_fscmds_CheckNavError(); 02293 v_fscmds_GetStrMsgFromErr( eFsStatus, &pcStringErrMsg ); 02294 sprintf( (char *)pcStringToPrint, "%s (%c:) %s"CRLF, 02295 mem_name(i), 02296 (char)('a' + i), 02297 pcStringErrMsg ); 02298 v_shell_Print_String_To_Requester_Stream( xModId, pcStringToPrint ); 02299 } 02300 else 02301 { 02302 sprintf( (char *)pcStringToPrint, "%s (%c:) Free Space: %llu Bytes / %llu Bytes"CRLF, 02303 mem_name(i), 02304 (char)('a' + i), 02305 (unsigned long long int)(nav_partition_freespace() << FS_SHIFT_B_TO_SECTOR), 02306 (unsigned long long int)(nav_partition_space() << FS_SHIFT_B_TO_SECTOR) ); 02307 v_shell_Print_String_To_Requester_Stream( xModId, pcStringToPrint ); 02308 } 02309 } 02310 nav_gotoindex( &sav_index ); // Restore nav position 02311 02312 vPortFree( pcStringToPrint ); // Free. 02313 02314 fsaccess_give_mutex(); // Release mutex on fs module. 02315 return( FSCMDS_STATUS_OK ); 02316 }
static signed portCHAR prv_GetChar_From_Requester_Stream | ( | eModId | xModId | ) | [static] |
Get a char from the input stream of a module.
xModId | Input. The module associated with the target input stream. |
Definition at line 1964 of file fscmds.c.
References com1shell_GetChar(), SYS_MODID_COM1SHELL, SYS_MODID_USB, and TRACE_COM2.
Referenced by prv_append().
01965 { 01966 signed portCHAR cByte; 01967 01968 01969 switch( xModId ) 01970 { 01971 case SYS_MODID_COM1SHELL: 01972 while( pdFALSE == com1shell_GetChar( &cByte ) ); 01973 break; 01974 case SYS_MODID_USB: 01975 TRACE_COM2((char *)"Unimplemented stream redirection (from USB to fscmds)"); 01976 break; 01977 default: // SHOULD NEVER HAPPEN 01978 TRACE_COM2((char *)"Unexpected stream redirection"); 01979 break; 01980 } 01981 return( cByte ); 01982 }
static int prv_i_GetIdxFromModid | ( | eModId | xModId | ) | [static] |
return x from a 2powx number.
xModId | Module id, which is a 2powx number. |
Definition at line 1381 of file fscmds.c.
Referenced by e_fscmds_shell_goto(), e_fscmds_shell_mark(), and prv_cp().
static eFsCmdsStatus prv_ls | ( | eModId | xModId, | |
signed short | FsNavId | |||
) | [static] |
The ls basic command.
xModId | Input. The module that is calling this function. | |
FsNavId | Input. The file system navigator id to use. |
Definition at line 1993 of file fscmds.c.
References CRLF, FSCMDS_STATUS_ERR_MEMALLOC, FSCMDS_STATUS_OK, MAX_FILE_PATH_LENGTH, prv_Print_String_To_Requester_Stream(), prvCommonErrorLeave(), SHELL_MAX_MSGOUT_LEN, sprintf(), str_ascii, and v_shell_Print_String_To_Requester_Stream().
Referenced by e_fscmds_shell_ls().
01994 { 01995 eFsCmdsStatus eFsStatus = FSCMDS_STATUS_OK; 01996 signed portCHAR *pcStringToPrint; 01997 01998 01999 // Take mutex on fs module. 02000 fsaccess_take_mutex(); 02001 nav_select( FsNavId ); 02002 02003 if( FALSE == nav_dir_name( (FS_STRING) str_ascii, MAX_FILE_PATH_LENGTH ) ) // Get the current dir name 02004 { 02005 return( prvCommonErrorLeave() ); 02006 } 02007 02008 pcStringToPrint = (signed portCHAR *)pvPortMalloc( SHELL_MAX_MSGOUT_LEN ); // Alloc 02009 if( NULL == pcStringToPrint ) 02010 { 02011 fsaccess_give_mutex(); // Release the fs resource. 02012 return( FSCMDS_STATUS_ERR_MEMALLOC ); 02013 } 02014 02015 // 1) Print info on the current directory. 02016 sprintf( (char *)pcStringToPrint, CRLF"Volume is %c: (%s)"CRLF"Dir name is ", 02017 'A'+nav_drive_get(), mem_name( nav_drive_get() ) ); 02018 v_shell_Print_String_To_Requester_Stream( xModId, pcStringToPrint ); 02019 prv_Print_String_To_Requester_Stream( xModId, str_ascii ); 02020 v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)CRLF ); 02021 02022 // 2) Print size and name info for each file and directory in the current directory. 02023 if( FALSE == nav_filelist_first( FS_DIR ) ) 02024 { 02025 nav_filelist_first( FS_FILE ); 02026 } 02027 v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)"\tSize (Bytes)\tName"CRLF ); 02028 nav_filelist_reset(); 02029 while ( nav_filelist_set(0,FS_FIND_NEXT) ) 02030 { 02031 sprintf( (char *)pcStringToPrint, "%3s\t%u\t\t", 02032 (nav_file_isdir()) ? "Dir" : "", 02033 (unsigned int)nav_file_lgt() ); 02034 v_shell_Print_String_To_Requester_Stream( xModId, pcStringToPrint ); 02035 nav_file_name( (FS_STRING)str_ascii, MAX_FILE_PATH_LENGTH, FS_NAME_GET, FALSE ); 02036 prv_Print_String_To_Requester_Stream( xModId, str_ascii ); 02037 v_shell_Print_String_To_Requester_Stream( xModId, (signed portCHAR *)CRLF ); 02038 } 02039 02040 // 3) Print the number of files and subdirectories in the current directory. 02041 sprintf( (char *)pcStringToPrint, "%d Files"CRLF"%d Dir"CRLF, 02042 nav_filelist_nb( FS_FILE ), 02043 nav_filelist_nb( FS_DIR ) ); 02044 v_shell_Print_String_To_Requester_Stream( xModId, pcStringToPrint ); 02045 02046 vPortFree( pcStringToPrint ); // Free. 02047 02048 // Release mutex on fs module. 02049 fsaccess_give_mutex(); 02050 return( eFsStatus ); 02051 }
static Bool prv_NameExists | ( | const FS_STRING | pxStringName | ) | [static] |
Check if a file and/or directory already exists in the current directory.
pxStringName | Input. The filename to compare against. |
Definition at line 2401 of file fscmds.c.
References MAX_FILE_PATH_LENGTH, and str_ascii.
Referenced by e_fscmds_shell_mkdir().
02402 { 02403 int i; 02404 02405 02406 if( FALSE == nav_filelist_first( FS_DIR ) ) 02407 { 02408 nav_filelist_first( FS_FILE ); 02409 } 02410 i = nav_filelist_nb( FS_DIR ) + nav_filelist_nb( FS_FILE ); 02411 while ( i ) 02412 { 02413 nav_file_name( (FS_STRING)str_ascii, MAX_FILE_PATH_LENGTH, FS_NAME_GET, TRUE ); 02414 if( 0 == strcmp( (char *)str_ascii, (char *)pxStringName ) ) 02415 return( TRUE ); 02416 nav_filelist_set( 0, FS_FIND_NEXT ); 02417 i--; 02418 } 02419 return( FALSE ); 02420 }
static void prv_Print_String_To_Requester_Stream | ( | eModId | xModId, | |
const portCHAR * | pStringToPrint | |||
) | [static] |
Print a string directly to the output stream of a module.
xModId | Input. The module associated with the target output stream. | |
pStringToPrint | Input. The string to print. |
Definition at line 1917 of file fscmds.c.
References SYS_MODID_COM1SHELL, SYS_MODID_USB, TRACE_COM2, and vcom1shell_PrintMsg().
Referenced by e_fscmds_shell_pwd(), and prv_ls().
01918 { 01919 switch( xModId ) 01920 { 01921 case SYS_MODID_COM1SHELL: 01922 vcom1shell_PrintMsg((signed portCHAR *) pStringToPrint ); 01923 break; 01924 case SYS_MODID_USB: 01925 TRACE_COM2((char *)"Unimplemented stream redirection (from fscmds to USB)"); 01926 break; 01927 default: // SHOULD NEVER HAPPEN 01928 TRACE_COM2((char *)"Unexpected stream redirection"); 01929 break; 01930 } 01931 }
static void prv_PutChar_To_Requester_Stream | ( | eModId | xModId, | |
signed portCHAR | c | |||
) | [static] |
Put a char to the output stream of a module.
xModId | Input. The module associated with the target output stream. | |
c | Input. The char to put to the target output stream. |
Definition at line 1940 of file fscmds.c.
References SYS_MODID_COM1SHELL, SYS_MODID_USB, TRACE_COM2, and vcom1shell_PutChar().
Referenced by prv_append().
01941 { 01942 switch( xModId ) 01943 { 01944 case SYS_MODID_COM1SHELL: 01945 vcom1shell_PutChar( c ); 01946 break; 01947 case SYS_MODID_USB: 01948 TRACE_COM2((char *)"Unimplemented stream redirection (from fscmds to USB)"); 01949 break; 01950 default: // SHOULD NEVER HAPPEN 01951 TRACE_COM2((char *)"Unexpected stream redirection"); 01952 break; 01953 } 01954 }
static eFsCmdsStatus prvCommonErrorLeave | ( | void | ) | [static] |
Common upon-error-prologue of several functions.
Definition at line 2382 of file fscmds.c.
References e_fscmds_CheckNavError().
Referenced by e_fscmds_shell_goto(), prv_append(), prv_cat(), prv_cp(), and prv_ls().
02383 { 02384 eFsCmdsStatus eFsStatus; 02385 02386 eFsStatus = e_fscmds_CheckNavError(); // Get the fs error. 02387 fsaccess_give_mutex(); // Release the fs mutex. 02388 return( eFsStatus ); 02389 }
void v_fscmds_GetStrMsgFromErr | ( | eFsCmdsStatus | ErrStatus, | |
signed portCHAR ** | ppcStringReply | |||
) |
Map a string message to an error.
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 }
Fs_index ax_mark_index[SYS_NB_MOD] [static] |
Array of index for each possible fs shell clients.
Definition at line 240 of file fscmds.c.
Referenced by e_fscmds_shell_goto(), e_fscmds_shell_mark(), and prv_cp().
const signed portCHAR* const FSCMDS_ERRMSG_APPEND_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: append filename"CRLF |
Error msg upon append syntax error.
Definition at line 176 of file fscmds.c.
Referenced by e_fscmds_shell_append().
const signed portCHAR* const FSCMDS_ERRMSG_BADSIZEFAT = (signed portCHAR *)ERROR_CRLF"Unsupported drive size"CRLF |
Error msg if the disk size is smaller than 4,1MB, or not supported by file system selected.
Definition at line 162 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_CAT_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: cat filename"CRLF |
Error msg upon cat syntax error.
Definition at line 173 of file fscmds.c.
Referenced by e_fscmds_shell_cat().
const signed portCHAR* const FSCMDS_ERRMSG_CD_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: cd dirname"CRLF |
Error msg upon cd syntax error.
Definition at line 165 of file fscmds.c.
Referenced by e_fscmds_shell_cd().
const signed portCHAR* const FSCMDS_ERRMSG_CD_UNKNOWNDIR = (signed portCHAR *)ERROR_CRLF"Unknown directory"CRLF |
Error msg upon unknown directory.
Definition at line 167 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_CP_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: cp filename"CRLF |
Error msg upon cp syntax error.
Definition at line 233 of file fscmds.c.
Referenced by e_fscmds_shell_cp().
const signed portCHAR* const FSCMDS_ERRMSG_DF_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: df"CRLF |
Error msg upon df syntax error.
Definition at line 215 of file fscmds.c.
Referenced by e_fscmds_shell_df().
const signed portCHAR* const FSCMDS_ERRMSG_DIRNOTEMPTY = (signed portCHAR *)ERROR_CRLF"Directory not empty."CRLF |
Error msg upon rm of a non-empty directory error.
Definition at line 209 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_DISK_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: disk"CRLF |
Error msg upon disk syntax error.
Definition at line 212 of file fscmds.c.
Referenced by e_fscmds_shell_disk().
const signed portCHAR* const FSCMDS_ERRMSG_FAT_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: fat"CRLF |
Error msg upon fat syntax error.
Definition at line 218 of file fscmds.c.
Referenced by e_fscmds_shell_fat().
const signed portCHAR* const FSCMDS_ERRMSG_FILENOTFOUND = (signed portCHAR *)ERROR_CRLF"File not found"CRLF |
Error msg upon file not found.
Definition at line 147 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_FILEWR = (signed portCHAR *)ERROR_CRLF"File currently opened in write-mode"CRLF |
Error msg if we try to read from or write to a file that is currently already opened in write mode.
Definition at line 156 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_FORMAT_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: format {a,b,c,d}"CRLF |
Error msg upon format syntax error.
Definition at line 185 of file fscmds.c.
Referenced by e_fscmds_shell_format().
const signed portCHAR* const FSCMDS_ERRMSG_FS = (signed portCHAR *)ERROR_CRLF"File system error"CRLF |
Error msg upon file system error.
Definition at line 126 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_FSNOTSUPPORTED = (signed portCHAR *)ERROR_CRLF"Unsupported file system"CRLF |
Error msg upon unsupported file system error.
Definition at line 138 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_GOTO_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: goto"CRLF |
Error msg upon goto syntax error.
Definition at line 230 of file fscmds.c.
Referenced by e_fscmds_shell_goto().
const signed portCHAR* const FSCMDS_ERRMSG_HELP_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: help"CRLF |
const signed portCHAR* const FSCMDS_ERRMSG_HW = (signed portCHAR *)ERROR_CRLF"Hardware error"CRLF |
Error msg upon hardware error.
Definition at line 123 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_INCORRECTNAME = (signed portCHAR *)ERROR_CRLF"Incorrect name, this must be not contain char \\/:*?\"<>|"CRLF |
Error msg upon incorrect file name format error.
Definition at line 194 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_ISROOTDIR = (signed portCHAR *)ERROR_CRLF"Current dir is a root dir."CRLF |
Error msg upon mkdir syntax error.
Definition at line 203 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_LS_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: ls"CRLF |
Error msg upon ls syntax error.
Definition at line 170 of file fscmds.c.
Referenced by e_fscmds_shell_ls(), and e_fscmds_shell_pwd().
const signed portCHAR* const FSCMDS_ERRMSG_MAINTENANCE = (signed portCHAR *)ERROR_CRLF"File system access forbidden(Maintenance mode)"CRLF |
const signed portCHAR* const FSCMDS_ERRMSG_MARK_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: mark"CRLF |
Error msg upon mark syntax error.
Definition at line 227 of file fscmds.c.
Referenced by e_fscmds_shell_mark().
const signed portCHAR* const FSCMDS_ERRMSG_MEMDEVMISSING = (signed portCHAR *)ERROR_CRLF"Memory device is missing"CRLF |
Error msg upon memory device miss error.
Definition at line 132 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_MKDIR_NAMEEXISTS = (signed portCHAR *)ERROR_CRLF"Name already used."CRLF |
Error msg upon mkdir syntax error.
Definition at line 200 of file fscmds.c.
Referenced by e_fscmds_shell_mkdir().
const signed portCHAR* const FSCMDS_ERRMSG_MKDIR_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: mkdir dirname"CRLF |
Error msg upon mkdir syntax error.
Definition at line 197 of file fscmds.c.
Referenced by e_fscmds_shell_mkdir().
const signed portCHAR* const FSCMDS_ERRMSG_MOUNT_DRIVENOTFOUND = (signed portCHAR *)ERROR_CRLF"Drive not found."CRLF |
Error msg upon mount of an unknown drive.
Definition at line 117 of file fscmds.c.
Referenced by e_fscmds_shell_format(), e_fscmds_shell_mount(), and v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_MOUNT_FAILED = (signed portCHAR *)ERROR_CRLF"Unable to mount drive"CRLF |
Error msg upon mount failure.
Definition at line 120 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_MOUNT_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: mount {a,b,c,d}"CRLF |
String error messages.
Error msg upon mount syntax error.
Definition at line 111 of file fscmds.c.
Referenced by e_fscmds_shell_mount().
const signed portCHAR* const FSCMDS_ERRMSG_MOUNTSHORT_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: {a:,b:,c:,d:}"CRLF |
Error msg upon {a:,b:,c:,d:} syntax error.
Definition at line 114 of file fscmds.c.
Referenced by e_fscmds_goto_drive().
const signed portCHAR* const FSCMDS_ERRMSG_MV_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: mv src dst"CRLF |
Error msg upon mv syntax error.
Definition at line 221 of file fscmds.c.
Referenced by e_fscmds_shell_mv().
const signed portCHAR* const FSCMDS_ERRMSG_MV_TYPEDIFFER = (signed portCHAR *)ERROR_CRLF"Src & dst must be of the same type."CRLF |
Error msg upon mv of different file types.
Definition at line 224 of file fscmds.c.
Referenced by e_fscmds_shell_mv().
const signed portCHAR* const FSCMDS_ERRMSG_NOFORMAT = (signed portCHAR *)ERROR_CRLF"Current drive is not formatted"CRLF |
Error msg upon unformatted drive error.
Definition at line 129 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_NOMOUNT = (signed portCHAR *)ERROR_CRLF"No drive mounted"CRLF |
Error msg if no drive is currently mounted.
Definition at line 144 of file fscmds.c.
Referenced by e_fscmds_shell_fat(), and v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_NOPARTITION = (signed portCHAR *)ERROR_CRLF"The selected partition doesn't exist"CRLF |
Error msg upon selected partition not found error.
Definition at line 135 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_NOTAFILE = (signed portCHAR *)ERROR_CRLF"Not a file"CRLF |
Error msg if a file was expected and it's not.
Definition at line 153 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_NOTFOUND = (signed portCHAR *)ERROR_CRLF"File or directory not found"CRLF |
Error msg upon file or directory not found.
Definition at line 150 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_OUTOFMEM = (signed portCHAR *)ERROR_CRLF"Operation canceled: out of memory"CRLF |
Error msg upon out of memory event.
Definition at line 191 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_READONLYDRIVE = (signed portCHAR *)ERROR_CRLF"Drive is read-only"CRLF |
Error msg if a drive we wanted to write to is read-only .
Definition at line 159 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_ERRMSG_RM_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: rm {-R} {filename,dirname,*}"CRLF |
Error msg upon rm syntax error.
Definition at line 206 of file fscmds.c.
Referenced by e_fscmds_shell_rm().
const signed portCHAR* const FSCMDS_ERRMSG_TOUCH_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: touch filename"CRLF |
Error msg upon touch syntax error.
Definition at line 188 of file fscmds.c.
Referenced by e_fscmds_shell_touch().
const signed portCHAR* const FSCMDS_ERRMSG_UNEXPECTED = (signed portCHAR *)ERROR_CRLF"Unexpected error"CRLF |
Unexpected error msg: SHOULD NEVER HAPPEN.
Definition at line 141 of file fscmds.c.
Referenced by v_fscmds_GetStrMsgFromErr().
const signed portCHAR* const FSCMDS_MSG_APPEND_WELCOME = (signed portCHAR *)CRLF"Simple text editor, enter char to append, ^q to exit and save"CRLF |
const signed portCHAR* const FSCMDS_MSG_HELP |
Initial value:
(signed portCHAR *)"\ "CRLF"disk: get the number of drives"CRLF"\ a:, b:, etc.: go to selected drive"CRLF"\ mount drivename (a, b, etc.): go to selected drive"CRLF"\ format drivename (a, b, etc.): format selected drive"CRLF"\ fat: get FAT type used by current drive"CRLF"\ df: get free space information for all connected drives"CRLF"\ cd dirname: go to selected directory"CRLF"\ cd ..: go to upper directory"CRLF"\ mark: bookmark current directory"CRLF"\ goto: go to bookmarked directory"CRLF"\ ls: list files and directories in current directory"CRLF"\ pwd: get current path"CRLF"\ rm filename: remove selected file or empty directory"CRLF"\ rm -R foldername: remove selected directory and its content"CRLF"\ rm *: remove all files or empty directories in current directory"CRLF"\ cp filename: copy filename to bookmarked directory"CRLF"\ mv src dst: rename selected file or directory"CRLF"\ mkdir dirname: make directory"CRLF"\ touch filename: create file"CRLF"\ append filename: append to selected file from terminal input"CRLF"\ cat filename: list file contents"CRLF
Definition at line 83 of file fscmds.c.
Referenced by e_fscmds_shell_help().
portCHAR str_ascii[MAX_FILE_PATH_LENGTH] [static] |
Temporary buffer holding a string.
Definition at line 237 of file fscmds.c.
Referenced by prv_ls(), and prv_NameExists().