int Instance = 0;\r
int retval = 0;\r
\r
- Status = ParsePath(path, &NewPath, &Node, &Instance);\r
+ Status = ParsePath(path, &NewPath, &Node, &Instance, NULL);\r
if(Status == RETURN_SUCCESS) {\r
GenI = Node->InstanceList;\r
if(GenI == NULL) {\r
retval = -1;\r
}\r
else {\r
- GenI += (Instance * Node->InstanceSize);\r
+ //GenI += (Instance * Node->InstanceSize);\r
retval = ((GenericInstance *)GenI)->Abstraction.fo_mkdir( path, perms);\r
}\r
free(NewPath);\r
O_EXCL -- if O_CREAT is also set, open will fail if the file already exists.\r
**/\r
int\r
-open (const char *path, int oflags, int mode)\r
+open(\r
+ const char *path,\r
+ int oflags,\r
+ int mode\r
+ )\r
{\r
wchar_t *NewPath;\r
+ wchar_t *MPath;\r
DeviceNode *Node;\r
- char *GenI = NULL;\r
struct __filedes *filp;\r
int Instance = 0;\r
RETURN_STATUS Status;\r
int fd = -1;\r
int doresult;\r
\r
- Status = ParsePath(path, &NewPath, &Node, &Instance);\r
+ Status = ParsePath(path, &NewPath, &Node, &Instance, &MPath);\r
if(Status == RETURN_SUCCESS) {\r
- if((Node != NULL) &&\r
- ((GenI = Node->InstanceList) == NULL)) {\r
+ if((Node == NULL) ||\r
+ (Node->InstanceList == NULL)) {\r
errno = EPERM;\r
}\r
else {\r
if( fd < 0 ) {\r
// All available FDs are in use\r
errno = EMFILE;\r
- return -1;\r
}\r
+ else {\r
filp = &gMD->fdarray[fd];\r
// Save the flags and mode in the File Descriptor\r
filp->Oflags = oflags;\r
filp->Omode = mode;\r
\r
- GenI += (Instance * Node->InstanceSize);\r
- doresult = Node->OpenFunc(filp, GenI, NewPath, NULL);\r
+ doresult = Node->OpenFunc(Node, filp, Instance, NewPath, MPath);\r
if(doresult < 0) {\r
filp->f_iflags = 0; // Release this FD\r
fd = -1; // Indicate an error\r
FILE_SET_MATURE(filp);\r
}\r
}\r
+ }\r
+ if(NewPath != NULL) {\r
free(NewPath);\r
}\r
+ }\r
+ if(MPath != NULL) {\r
+ free(MPath); // We don't need this any more.\r
+ }\r
// return the fd of our now open file\r
return fd;\r
}\r
}\r
} while (( 0 == SelectedFDs )\r
&& ( EFI_SUCCESS == Status ));\r
+\r
//\r
// Stop the timer\r
//\r
}\r
\r
\r
-\r
/** The rename() function changes the name of a file.\r
The old argument points to the pathname of the file to be renamed. The new\r
argument points to the new pathname of the file.\r
shall be changed or created.\r
**/\r
int\r
-EFIAPI\r
rename(\r
const char *from,\r
const char *to\r
RETURN_STATUS Status;\r
int retval = -1;\r
\r
- Status = ParsePath(from, &FromPath, &FromNode, &Instance);\r
+ Status = ParsePath(from, &FromPath, &FromNode, &Instance, NULL);\r
if(Status == RETURN_SUCCESS) {\r
GenI = FromNode->InstanceList;\r
if(GenI == NULL) {\r
retval = -1;\r
}\r
else {\r
- GenI += (Instance * FromNode->InstanceSize);\r
+ //GenI += (Instance * FromNode->InstanceSize);\r
retval = ((GenericInstance *)GenI)->Abstraction.fo_rename( from, to);\r
}\r
free(FromPath);\r
/**\r
**/\r
int\r
-EFIAPI\r
rmdir(\r
const char *path\r
)\r
from a file associated with a terminal may return one typed line of data.\r
\r
If fildes does not refer to a directory, the function reads the requested\r
- number of bytes from the file at the file\92s current position and returns\r
+ number of bytes from the file at the file's current position and returns\r
them in buf. If the read goes beyond the end of the file, the read\r
- length is truncated to the end of the file. The file\92s current position is\r
+ length is truncated to the end of the file. The file's current position is\r
increased by the number of bytes returned.\r
\r
If fildes refers to a directory, the function reads the directory entry at\r
- the file\92s current position and returns the entry in buf. If buf\r
+ the file's current position and returns the entry in buf. If buf\r
is not large enough to hold the current directory entry, then\r
errno is set to EBUFSIZE, EFIerrno is set to EFI_BUFFER_TOO_SMALL, and the\r
current file position is not updated. The size of the buffer needed to read\r
\r
return (UnicodeStrToAsciiStr(Cwd, buf));\r
}\r
+\r
+/** Change the current working directory.\r
+\r
+ The chdir() function shall cause the directory named by the pathname\r
+ pointed to by the path argument to become the current working directory;\r
+ that is, the starting point for path searches for pathnames not beginning\r
+ with '/'.\r
+\r
+ @param[in] path The new path to set.\r
+\r
+ @todo Add non-shell CWD changing.\r
+**/\r
+int\r
+chdir (const char *path)\r
+{\r
+ CONST CHAR16 *Cwd;\r
+ EFI_STATUS Status;\r
+ CHAR16 *UnicodePath;\r
+\r
+ Cwd = ShellGetCurrentDir(NULL);\r
+ if (Cwd != NULL) {\r
+ /* We have shell support */\r
+ UnicodePath = AllocatePool(((AsciiStrLen (path) + 1) * sizeof (CHAR16)));\r
+ if (UnicodePath == NULL) {\r
+ errno = ENOMEM;\r
+ return -1;\r
+ }\r
+ AsciiStrToUnicodeStr(path, UnicodePath);\r
+ Status = gEfiShellProtocol->SetCurDir(NULL, UnicodePath);\r
+ FreePool(UnicodePath);\r
+ if (EFI_ERROR(Status)) {\r
+ errno = EACCES;\r
+ return -1;\r
+ } else {\r
+ return 0;\r
+ }\r
+ }\r
+\r
+ /* Add here for non-shell */\r
+ errno = EACCES;\r
+ return -1;\r
+}\r
+\r
+pid_t tcgetpgrp (int x)\r
+{\r
+ return ((pid_t)(UINTN)(gImageHandle));\r
+}\r
+\r
+pid_t getpgrp(void)\r
+{\r
+ return ((pid_t)(UINTN)(gImageHandle));\r
+}\r
+\r