git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Kernel/VFS - Added warning (instead of LOG) when GetNodeFromInode is unsupported
[tpg/acess2.git]
/
Usermode
/
Applications
/
CLIShell_src
/
main.c
diff --git
a/Usermode/Applications/CLIShell_src/main.c
b/Usermode/Applications/CLIShell_src/main.c
index
be621c4
..
1a501ad
100644
(file)
--- a/
Usermode/Applications/CLIShell_src/main.c
+++ b/
Usermode/Applications/CLIShell_src/main.c
@@
-8,6
+8,7
@@
#include <string.h>
\r
#include "header.h"
\r
#include <readline.h>
\r
#include <string.h>
\r
#include "header.h"
\r
#include <readline.h>
\r
+#include <errno.h>
\r
\r
#define _stdin 0
\r
#define _stdout 1
\r
\r
#define _stdin 0
\r
#define _stdout 1
\r
@@
-75,10
+76,15
@@
int main(int argc, char *argv[], char **envp)
if(saArgs[0]) free(saArgs[0]);
\r
\r
printf("%s$ ", gsCurrentDirectory);
\r
if(saArgs[0]) free(saArgs[0]);
\r
\r
printf("%s$ ", gsCurrentDirectory);
\r
+ fflush(stdout);
\r
\r
// Read Command line
\r
sCommandStr = Readline( readline_state );
\r
printf("\n");
\r
\r
// Read Command line
\r
sCommandStr = Readline( readline_state );
\r
printf("\n");
\r
+ if( !sCommandStr ) {
\r
+ perror("Readline");
\r
+ return 1;
\r
+ }
\r
\r
// Parse Command Line into arguments
\r
iArgCount = Parse_Args(sCommandStr, saArgs);
\r
\r
// Parse Command Line into arguments
\r
iArgCount = Parse_Args(sCommandStr, saArgs);
\r
@@
-206,19
+212,14
@@
void CallCommand(char **Args)
}
\r
\r
// Create new process
\r
}
\r
\r
// Create new process
\r
- pid = clone(CLONE_VM, 0);
\r
- // Start Task
\r
- if(pid == 0) {
\r
- execve(sTmpBuffer, Args, gasEnvironment);
\r
- printf("Execve returned, ... oops\n");
\r
- exit(-1);
\r
- }
\r
+ int fds[] = {0, 1, 2};
\r
+ pid = _SysSpawn(sTmpBuffer, (const char **)Args, (const char **)gasEnvironment, 3, fds, NULL);
\r
if(pid <= 0) {
\r
printf("Unable to create process: `%s'\n", sTmpBuffer); // Error Message
\r
}
\r
else {
\r
int status;
\r
if(pid <= 0) {
\r
printf("Unable to create process: `%s'\n", sTmpBuffer); // Error Message
\r
}
\r
else {
\r
int status;
\r
-
waittid
(pid, &status);
\r
+
_SysWaitTID
(pid, &status);
\r
}
\r
}
\r
\r
}
\r
}
\r
\r
@@
-304,27
+305,23
@@
void Command_Cd(int argc, char **argv)
*/
\r
void Command_Dir(int argc, char **argv)
\r
{
\r
*/
\r
void Command_Dir(int argc, char **argv)
\r
{
\r
- int dp, fp
, dirLen
;
\r
+ int dp, fp;
\r
char modeStr[11] = "RWXrwxRWX ";
\r
char modeStr[11] = "RWXrwxRWX ";
\r
- char tmpPath[1024];
\r
- char *fileName;
\r
+ char fileName[256];
\r
t_sysFInfo info;
\r
t_sysACL acl;
\r
\r
t_sysFInfo info;
\r
t_sysACL acl;
\r
\r
+
\r
+ // -- Generate and open directory --
\r
// Generate Directory Path
\r
// Generate Directory Path
\r
+ char tmpPath[1024];
\r
if(argc > 1)
\r
if(argc > 1)
\r
-
dirLen =
GeneratePath(argv[1], gsCurrentDirectory, tmpPath);
\r
+ GeneratePath(argv[1], gsCurrentDirectory, tmpPath);
\r
else
\r
else
\r
- {
\r
strcpy(tmpPath, gsCurrentDirectory);
\r
strcpy(tmpPath, gsCurrentDirectory);
\r
- }
\r
- dirLen = strlen(tmpPath);
\r
-
\r
// Open Directory
\r
dp = _SysOpen(tmpPath, OPENFLAG_READ);
\r
// Open Directory
\r
dp = _SysOpen(tmpPath, OPENFLAG_READ);
\r
- // Check if file opened
\r
- if(dp == -1)
\r
- {
\r
+ if(dp == -1) {
\r
printf("Unable to open directory `%s', File cannot be found\n", tmpPath);
\r
return;
\r
}
\r
printf("Unable to open directory `%s', File cannot be found\n", tmpPath);
\r
return;
\r
}
\r
@@
-343,15
+340,7
@@
void Command_Dir(int argc, char **argv)
return;
\r
}
\r
\r
return;
\r
}
\r
\r
- // Append Shash for file paths
\r
- if(tmpPath[dirLen-1] != '/')
\r
- {
\r
- tmpPath[dirLen++] = '/';
\r
- tmpPath[dirLen] = '\0';
\r
- }
\r
-
\r
- fileName = (char*)(tmpPath+dirLen);
\r
- // Read Directory Content
\r
+ // -- Read Directory Contents --
\r
while( (fp = _SysReadDir(dp, fileName)) )
\r
{
\r
if(fp < 0)
\r
while( (fp = _SysReadDir(dp, fileName)) )
\r
{
\r
if(fp < 0)
\r
@@
-361,7
+350,7
@@
void Command_Dir(int argc, char **argv)
break;
\r
}
\r
// Open File
\r
break;
\r
}
\r
// Open File
\r
- fp = _SysOpen
(tmpPath
, 0);
\r
+ fp = _SysOpen
Child(dp, fileName
, 0);
\r
if(fp == -1) continue;
\r
// Get File Stats
\r
_SysFInfo(fp, &info, 0);
\r
if(fp == -1) continue;
\r
// Get File Stats
\r
_SysFInfo(fp, &info, 0);
\r
UCC
git Repository :: git.ucc.asn.au