Compare commits
No commits in common. "master" and "systemy-operacyjne-niestacjonarne-2018-rozwiazania" have entirely different histories.
master
...
systemy-op
@ -8,11 +8,11 @@ Indywidualna lista obecności prowadzona jest samodzielnie przez każdego studen
|
||||
| ------- | -------- |
|
||||
| 1 | |
|
||||
| 2 | |
|
||||
| 3 | o |
|
||||
| 3 | |
|
||||
| 4 | |
|
||||
| 5 | |
|
||||
| 6 | |
|
||||
| 7 | o |
|
||||
| 7 | |
|
||||
| 8 | |
|
||||
| 9 | |
|
||||
| 10 | |
|
||||
|
@ -1,11 +0,0 @@
|
||||
default: all
|
||||
|
||||
microshell.o: microshell.c
|
||||
gcc -c microshell.c -o microshell.o
|
||||
|
||||
all: microshell.o
|
||||
gcc microshell.o -o microshell
|
||||
|
||||
clean:
|
||||
-rm -f microshell.o
|
||||
-rm -f microshell
|
@ -1,106 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <pwd.h>
|
||||
#include <string.h>
|
||||
#include <wait.h>
|
||||
|
||||
#define space " \n"
|
||||
#define max_c 500
|
||||
#define BRIGHT 1
|
||||
#define RED 31
|
||||
#define GREEN 32
|
||||
#define YELLOW 33
|
||||
#define BLUE 34
|
||||
#define PINK 35
|
||||
#define CYAN 36
|
||||
#define WHITE 37
|
||||
|
||||
int help() {
|
||||
printf ("microshell v1.0. © 2018 Krystian Rzepa\n");
|
||||
printf("Obslugiwane polecenia:\n\
|
||||
help - pomoc\n\
|
||||
exit - wyjscie\n\
|
||||
cd - zmiana aktualnego katalogu\n\
|
||||
pwd - wyswietla aktualny katalog\n\
|
||||
obsluga programow z parametrami\n");
|
||||
}
|
||||
|
||||
|
||||
const char *getUserName()
|
||||
{
|
||||
uid_t uid = geteuid();
|
||||
struct passwd *pw = getpwuid(uid);
|
||||
|
||||
return pw->pw_name;
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
char cwd[1000], hostName[100], *pwd[1000];
|
||||
register struct passwd *pw;
|
||||
register uid_t uid;
|
||||
uid = geteuid ();
|
||||
pw = getpwuid (uid);
|
||||
|
||||
char line[max_c], lend[max_c], * commands[max_c], ** command;
|
||||
|
||||
void domyslny_kolor()
|
||||
{
|
||||
printf("%c[%dm",0x1B,0);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
gethostname(hostName, 99);
|
||||
getcwd(cwd, 999);
|
||||
|
||||
printf("%c[%dm%s",0x1B, YELLOW, pw->pw_name);
|
||||
domyslny_kolor();
|
||||
printf("@");
|
||||
printf("%c[%dm%s ",0x1B, YELLOW, hostName);
|
||||
printf("%c[%dm%s",0x1B, CYAN, cwd);
|
||||
printf("%c[%dm $ ",0x1B, GREEN);
|
||||
domyslny_kolor();
|
||||
|
||||
fflush(stdout);
|
||||
if (fgets(line, max_c, stdin )) {
|
||||
|
||||
command = commands;
|
||||
*command++ = strtok(line,space);
|
||||
while ((*command++ = strtok(NULL,space)));
|
||||
|
||||
|
||||
if (strcmp(commands[0], "help")==0) help();
|
||||
|
||||
else if (strcmp(commands[0], "exit")==0) {
|
||||
if (commands[1]==0) exit(0);
|
||||
else exit(atoi(commands[1]));
|
||||
}
|
||||
|
||||
else if (strcmp(commands[0], "cd")==0) {
|
||||
if (commands[1]==0) printf("Wymagany argument\n");
|
||||
int ret;
|
||||
ret = chdir(commands[1]);
|
||||
strcpy(lend, "pwd");
|
||||
}
|
||||
|
||||
else if (strcmp(commands[0], "pwd")==0) printf ("%s\n", cwd);
|
||||
|
||||
else {
|
||||
pid_t x;
|
||||
x = fork();
|
||||
|
||||
if (x==0) {
|
||||
if (commands[1] == 0) execlp(commands[0], commands[0], (char *)NULL);
|
||||
else execlp(commands[0], commands[0], commands[1], (char *)NULL);
|
||||
printf("Nie ma takiego polecenia. Wpisz help aby wyswietlic dostepne polecenia.\n");
|
||||
}
|
||||
else waitpid(x, NULL, 0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
19
punktacja.md
19
punktacja.md
@ -6,15 +6,14 @@ Ten plik uzupełniasz tylko na wyraźne polecenie **prowadzącego zajęcia**.
|
||||
| ---: | :-------: | :-------: | :-------: | :-------: |
|
||||
| 1 | | | | |
|
||||
| 2 | | | | |
|
||||
| 3 | 1 | 1 | 1 | 1 |
|
||||
| 4 | 1 | 1 | 1 | 1 |
|
||||
| 5 | 0 | 1 | 0 | 0 |
|
||||
| 6 | 0 | 0 | 1 | 1 |
|
||||
| 7 | 1 | 1 | 1 | 1 |
|
||||
| 8 | 1 | 1 | 1 | 1 |
|
||||
| 9 | 1 | 1 | 1 | 1 |
|
||||
| 10 | 1 | 1 | 1 | 1 |
|
||||
| 11 | 1 | 1 | 1 | 1 |
|
||||
| 3 | | | | |
|
||||
| 4 | | | | |
|
||||
| 6 | | | | |
|
||||
| 7 | | | | |
|
||||
| 8 | | | | |
|
||||
| 9 | | | | |
|
||||
| 10 | | | | |
|
||||
| 11 | | | | |
|
||||
| 12 | | | | |
|
||||
| 13 | | | | |
|
||||
| 14 | | | | |
|
||||
@ -23,4 +22,4 @@ Ten plik uzupełniasz tylko na wyraźne polecenie **prowadzącego zajęcia**.
|
||||
|
||||
| Temat | Punkty |
|
||||
| ---------- | :-------: |
|
||||
| Microshell | 6 |
|
||||
| Microshell | |
|
||||
|
@ -1,8 +0,0 @@
|
||||
Zadanie 1
|
||||
cat abc.txt | tr 'abcde' '12345'
|
||||
Zadanie 2
|
||||
sed s/txt/TXT/g
|
||||
Zadanie 3
|
||||
kill -KILL 592
|
||||
Zadanie 4
|
||||
cat /etc/passwd
|
@ -1,9 +0,0 @@
|
||||
Zadanie 1
|
||||
10.100.5.240/16
|
||||
Zadanie 2
|
||||
scp plik.txt snumer_indexu@lts.wmi.amu.edu.pl
|
||||
Zadanie 3
|
||||
root
|
||||
Zadanie 4
|
||||
systemctl restart apache2
|
||||
sudo systemctl restart apache2
|
@ -1,8 +0,0 @@
|
||||
Zadanie 1
|
||||
|
||||
Zadanie 2
|
||||
150.254.79.101 afe80::9a90:96ff:fecc:e0a9
|
||||
Zadanie 3
|
||||
|
||||
Zadanie 4
|
||||
96-97ms
|
@ -1,9 +0,0 @@
|
||||
Zadanie 1
|
||||
signal(ready); 8
|
||||
wait(ready); 12, 13
|
||||
Zadanie 2
|
||||
0, 3, 7, 10
|
||||
Zadanie 3
|
||||
3
|
||||
Zadanie 4
|
||||
Trzeba zdeklarowac zmienna int i przed petla for
|
@ -1,9 +0,0 @@
|
||||
Zadanie 1-2
|
||||
wait(nowy); 21
|
||||
signal(pusty); 22
|
||||
wait(pusty); 15
|
||||
signal(nowy); 16
|
||||
Zadanie 3
|
||||
Taki problem nigdy nie wystąpi, ponieważ zawsze jeden z nich będzie mógł kontynuować
|
||||
Zadanie 4
|
||||
2
|
@ -1,8 +0,0 @@
|
||||
Zadanie 1
|
||||
zawsze 12
|
||||
Zadanie 2
|
||||
Nie
|
||||
Zadanie 3-4
|
||||
3 (values[3]), 7 (if (( index >= 0 || index < 3 )),
|
||||
10 (==3), 16 (==3),
|
||||
35 (proces_gen( 2 );)
|
@ -1,8 +0,0 @@
|
||||
Zadanie 1
|
||||
i915 (1740800); bluetooth (41)
|
||||
Zadanie 2
|
||||
2 (libresolv.so.2)
|
||||
Zadanie 3
|
||||
3
|
||||
Zadania 4
|
||||
4
|
@ -1,8 +0,0 @@
|
||||
Zadanie 1
|
||||
8
|
||||
Zadanie 2
|
||||
(1) i (4)
|
||||
Zadanie 3
|
||||
4
|
||||
Zadania 4
|
||||
nazwa pliku, który uruchamiamy
|
@ -1,8 +0,0 @@
|
||||
Zadanie 1
|
||||
-----w-rw-
|
||||
Zadanie 2
|
||||
gdy chcemy odczytać więcej bajtów niż zostało do końca pliku
|
||||
Zadanie 3
|
||||
pokazuje zawartość bieżącego katalogu
|
||||
Zadania 4
|
||||
/proc/1234/
|
Loading…
Reference in New Issue
Block a user