summaryrefslogtreecommitdiffstats
path: root/03_exercise/srv/shell.c
diff options
context:
space:
mode:
Diffstat (limited to '03_exercise/srv/shell.c')
-rw-r--r--03_exercise/srv/shell.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/03_exercise/srv/shell.c b/03_exercise/srv/shell.c
index aea1a68..5d7d33d 100644
--- a/03_exercise/srv/shell.c
+++ b/03_exercise/srv/shell.c
@@ -12,6 +12,8 @@
#include "prompt_utils.h"
#include "builtins.h"
+char *get_current_dir_name(void);
+
#define BUF_SIZE 2048
process *processes;
@@ -51,7 +53,9 @@ void receive_file(int sock, char *path, int size) {
received += nread;
}
- write_all(file_fd, buffer, strlen(buffer) + 1);
+ if (write_all(file_fd, buffer, strlen(buffer) + 1) == strlen(buffer) + 1) {
+ printf("successfully wrote to remote file \"%s/%s\"\n", get_current_dir_name(), path);
+ }
close(file_fd);
}
@@ -120,7 +124,7 @@ int shell(int in_fd) {
"And with `|` you can pipe the output from one process to the input of another\n"
);
- char const *const original_wd = ".";//get_current_dir_name();
+ char const *const original_wd = get_current_dir_name();
//char const *prompt = relative_path(original_wd, original_wd);
bool done = false;
@@ -172,7 +176,7 @@ int shell(int in_fd) {
if (ret)
printf("[%i] ", ret);
else
- printf("%s\n", "."/*get_current_dir_name()*/);
+ printf("%s\n", get_current_dir_name());
} else if (strcmp(processes[0].argv[0], "exit") == 0) {
done = true;
@@ -197,7 +201,7 @@ int shell(int in_fd) {
printf("Disconnecting...");
- //free((void *) original_wd);
+ free((void *) original_wd);
return 0;
}