TianoCore EDK2 master
Loading...
Searching...
No Matches
Mv.c File Reference

Go to the source code of this file.

Functions

BOOLEAN IsBetweenFileSystem (IN CONST CHAR16 *FullName, IN CONST CHAR16 *Cwd, IN CONST CHAR16 *DestPath)
 
BOOLEAN IsSoucePathValid (IN CONST CHAR16 *SrcPath, IN CONST CHAR16 *CwdPath)
 
BOOLEAN IsValidMove (IN CONST CHAR16 *SourcePath, IN CONST CHAR16 *Cwd, IN CONST CHAR16 *DestPath, IN CONST UINT64 Attribute, IN CONST UINT64 DestAttr, IN CONST EFI_STATUS FileStatus)
 
SHELL_STATUS GetDestinationLocation (IN CONST CHAR16 *DestParameter, IN OUT CHAR16 **DestPathPointer, IN CONST CHAR16 *Cwd, IN CONST BOOLEAN SingleSource, IN OUT UINT64 *DestAttr)
 
EFI_STATUS MoveBetweenFileSystems (IN EFI_SHELL_FILE_INFO *Node, IN CONST CHAR16 *DestPath, OUT VOID **Resp)
 
EFI_STATUS CreateFullDestPath (IN CONST CHAR16 **DestPath, OUT CHAR16 **FullDestPath, IN CONST CHAR16 *FileName)
 
EFI_STATUS MoveWithinFileSystems (IN EFI_SHELL_FILE_INFO *Node, IN CHAR16 *DestPath, OUT VOID **Resp)
 
SHELL_STATUS ValidateAndMoveFiles (IN EFI_SHELL_FILE_INFO *FileList, OUT VOID **Resp, IN CONST CHAR16 *DestParameter)
 
SHELL_STATUS EFIAPI ShellCommandRunMv (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Detailed Description

Main file for mv shell level 2 function.

(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Mv.c.

Function Documentation

◆ CreateFullDestPath()

EFI_STATUS CreateFullDestPath ( IN CONST CHAR16 **  DestPath,
OUT CHAR16 **  FullDestPath,
IN CONST CHAR16 *  FileName 
)

Function to take the destination path and target file name to generate the full destination path.

Parameters
[in]DestPathA pointer to the destination file path string.
[out]FullDestPathA pointer to the full destination path string.
[in]FileNameName string of the targe file.
Return values
SHELL_SUCCESSthe files were all moved.
SHELL_INVALID_PARAMETERa parameter was invalid
SHELL_OUT_OF_RESOURCESa memory allocation failed

Definition at line 412 of file Mv.c.

◆ GetDestinationLocation()

SHELL_STATUS GetDestinationLocation ( IN CONST CHAR16 *  DestParameter,
IN OUT CHAR16 **  DestPathPointer,
IN CONST CHAR16 *  Cwd,
IN CONST BOOLEAN  SingleSource,
IN OUT UINT64 *  DestAttr 
)

Function to take a destination path that might contain wildcards and verify that there is only a single possible target (IE we cant have wildcards that have 2 possible destination).

if the result is successful the caller must free *DestPathPointer.

Parameters
[in]DestParameterThe original path to the destination.
[in,out]DestPathPointerA pointer to the callee allocated final path.
[in]CwdA pointer to the current working directory.
[in]SingleSourceTRUE to have only one source file.
[in,out]DestAttrA pointer to the destination information attribute.
Return values
SHELL_INVALID_PARAMETERThe DestParameter could not be resolved to a location.
SHELL_INVALID_PARAMETERThe DestParameter could be resolved to more than 1 location.
SHELL_INVALID_PARAMETERCwd is required and is NULL.
SHELL_SUCCESSThe operation was successful.

Definition at line 233 of file Mv.c.

◆ IsBetweenFileSystem()

BOOLEAN IsBetweenFileSystem ( IN CONST CHAR16 *  FullName,
IN CONST CHAR16 *  Cwd,
IN CONST CHAR16 *  DestPath 
)

function to determine if a move is between file systems.

Parameters
FullName[in] The name of the file to move.
Cwd[in] The current working directory
DestPath[in] The target location to move to
Return values
TRUEThe move is across file system.
FALSEThe move is within a file system.

Definition at line 23 of file Mv.c.

◆ IsSoucePathValid()

BOOLEAN IsSoucePathValid ( IN CONST CHAR16 *  SrcPath,
IN CONST CHAR16 *  CwdPath 
)

function to determine if SrcPath is valid to mv.

if SrcPath equal CWD then it's invalid. if SrcPath is the parent path of CWD then it's invalid. is SrcPath is NULL return FALSE.

if CwdPath is NULL then ASSERT()

Parameters
SrcPath[in] The source path.
CwdPath[in] The current working directory.
Return values
TRUEThe source path is valid.
FALSEThe source path is invalid.

Definition at line 73 of file Mv.c.

◆ IsValidMove()

BOOLEAN IsValidMove ( IN CONST CHAR16 *  SourcePath,
IN CONST CHAR16 *  Cwd,
IN CONST CHAR16 *  DestPath,
IN CONST UINT64  Attribute,
IN CONST UINT64  DestAttr,
IN CONST EFI_STATUS  FileStatus 
)

Function to validate that moving a specific file (FileName) to a specific location (DestPath) is valid.

This function will verify that the destination is not a subdirectory of FullName, that the Current working Directory is not being moved, and that the directory is not read only.

if the move is invalid this function will report the error to StdOut.

Parameters
SourcePath[in] The name of the file to move.
Cwd[in] The current working directory
DestPath[in] The target location to move to
Attribute[in] The Attribute of the file
DestAttr[in] The Attribute of the destination
FileStatus[in] The Status of the file when opened
Return values
TRUEThe move is valid
FALSEThe move is not

Definition at line 146 of file Mv.c.

◆ MoveBetweenFileSystems()

EFI_STATUS MoveBetweenFileSystems ( IN EFI_SHELL_FILE_INFO Node,
IN CONST CHAR16 *  DestPath,
OUT VOID **  Resp 
)

Function to do a move across file systems.

Parameters
[in]NodeA pointer to the file to be removed.
[in]DestPathA pointer to the destination file path.
[out]RespA pointer to response from question. Pass back on looped calling
Return values
SHELL_SUCCESSThe source file was moved to the destination.

Definition at line 365 of file Mv.c.

◆ MoveWithinFileSystems()

EFI_STATUS MoveWithinFileSystems ( IN EFI_SHELL_FILE_INFO Node,
IN CHAR16 *  DestPath,
OUT VOID **  Resp 
)

Function to do a move within a file system.

Parameters
[in]NodeA pointer to the file to be removed.
[in]DestPathA pointer to the destination file path.
[out]RespA pointer to response from question. Pass back on looped calling.
Return values
SHELL_SUCCESSThe source file was moved to the destination.
SHELL_OUT_OF_RESOURCESA memory allocation failed.

Definition at line 452 of file Mv.c.

◆ ShellCommandRunMv()

SHELL_STATUS EFIAPI ShellCommandRunMv ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Function for 'mv' command.

Parameters
[in]ImageHandleHandle to the Image (NULL if Internal).
[in]SystemTablePointer to the System Table (NULL if Internal).
Todo:
make sure this works with error half way through and continues...

Definition at line 751 of file Mv.c.

◆ ValidateAndMoveFiles()

SHELL_STATUS ValidateAndMoveFiles ( IN EFI_SHELL_FILE_INFO FileList,
OUT VOID **  Resp,
IN CONST CHAR16 *  DestParameter 
)

function to take a list of files to move and a destination location and do the verification and moving of those files to that location. This function will report any errors to the user and continue to move the rest of the files.

Parameters
[in]FileListA LIST_ENTRY* based list of files to move
[out]Resppointer to response from question. Pass back on looped calling
[in]DestParameterthe originally specified destination location
Return values
SHELL_SUCCESSthe files were all moved.
SHELL_INVALID_PARAMETERa parameter was invalid
SHELL_SECURITY_VIOLATIONa security violation ocurred
SHELL_WRITE_PROTECTEDthe destination was write protected
SHELL_OUT_OF_RESOURCESa memory allocation failed

Definition at line 537 of file Mv.c.