Skip to content
This repository was archived by the owner on Mar 2, 2022. It is now read-only.

Commit 3476dc9

Browse files
committed
Depot des codes + rapports
0 parents  commit 3476dc9

File tree

8 files changed

+182
-0
lines changed

8 files changed

+182
-0
lines changed

Rapport/tp system d'exploitation.docx

42.5 KB
Binary file not shown.

afficher_attribut.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include<stdio.h>
2+
#include<unistd.h>
3+
#include<dirent.h>
4+
#include<sys/types.h>
5+
#include<stdlib.h>
6+
#include<sys/stat.h>
7+
8+
void afficher_contenu(struct stat *info)
9+
{
10+
if(S_ISBLK(info->st_mode))
11+
fprintf(stdout," fichier: block, <permission> : ");
12+
else if (S_ISCHR(info->st_mode))
13+
fprintf(stdout," fichier: caractere, <permission> : ");
14+
else if (S_ISDIR(info->st_mode))
15+
fprintf(stdout," fichier: repertoire, <permission> : ");
16+
else if (S_ISREG(info->st_mode))
17+
fprintf(stdout," fichier: regulier, <permission> : ");
18+
else if (S_ISLNK(info->st_mode))
19+
fprintf(stdout," fichier: lien, <permission> : ");
20+
else if (S_ISFIFO(info->st_mode))
21+
fprintf(stdout,"fichier: fifo, <permission> : ");
22+
else if(S_ISSOCK(info->st_mode))
23+
fprintf(stdout,"fichier: socket, <permission> : ");
24+
fprintf(stdout, " [utilisateur] :");
25+
fprintf(stdout, info->st_mode & S_IRUSR ? "r" :"-");
26+
fprintf(stdout, info->st_mode & S_IWUSR ? "w" :"-");
27+
fprintf(stdout, info->st_mode & S_IXUSR ? "x" :"-");
28+
fprintf(stdout, " [groupe] :");
29+
fprintf(stdout, info->st_mode & S_IRGRP ? "r" :"-");
30+
fprintf(stdout, info->st_mode & S_IWGRP ? "w" :"-");
31+
fprintf(stdout, info->st_mode & S_IXGRP ? "x" :"-");
32+
fprintf(stdout, " [other] :");
33+
fprintf(stdout, info->st_mode & S_IROTH ? "r" :"-");
34+
fprintf(stdout, info->st_mode & S_IWOTH ? "w" :"-");
35+
fprintf(stdout, info->st_mode & S_IXOTH ? "x" :"-");
36+
fprintf(stdout, "\n");
37+
}
38+
39+
int main(void)
40+
{
41+
struct stat etat_fichier;
42+
char fichier[512];//un fichier absolue
43+
44+
45+
printf("entrer le nom absolu du fichier :\n");
46+
scanf("%s",fichier);
47+
stat(fichier,&etat_fichier);
48+
afficher_contenu( &etat_fichier);
49+
50+
51+
52+
return 0;
53+
}
54+
55+

bi_direct

16.6 KB
Binary file not shown.

bi_direct.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include<stdio.h>
2+
#include<unistd.h>
3+
#include<stdlib.h>
4+
5+
int main(void)
6+
{
7+
8+
char tamponP1[20]="le pere ecrit \n",tamponF1[20]=" le fils ecrit \n";
9+
char tamponP2[20],tamponF2[20];
10+
int res,r=0;
11+
int p1[2],p2[2];
12+
13+
14+
if (pipe(p1)!=0)
15+
{
16+
fprintf(stdout," erreur pipe \n");
17+
exit(1);
18+
}
19+
else if(pipe(p2)!=0)
20+
{
21+
fprintf(stdout," erreur pipe \n");
22+
exit(1);
23+
}
24+
25+
close(p1[0]);
26+
write(p1[1],tamponP1, 20 );
27+
res=fork();
28+
29+
if(res==0)
30+
{
31+
32+
close(p2[0]); //fermer l'acces en ecriture du tube P2 au processus enfant
33+
read(p1[0],tamponP2,20);
34+
write(p2[1],tamponF1,20);
35+
}
36+
else
37+
{
38+
read(p2[0],tamponF2,20);
39+
40+
}
41+
42+
printf("le pere lit : %s \n",tamponF2);
43+
printf("le fils lit : %s \n",tamponP2);
44+
45+
return 0;
46+
}

cretion_de_processus.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include<stdio.h>
2+
#include<unistd.h>
3+
4+
int main(void)
5+
{
6+
int p_id,pep_id;
7+
printf("creation d'un processus enfant \n");
8+
pep_id=getpid();
9+
p_id=fork();
10+
printf("le numero du processus fils est: %d \n",p_id);
11+
printf("le numero du processus pere est :%d \n",pep_id);
12+
return 0;
13+
14+
}

date

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
gedit fic1
2+
gedit fic2
3+
gedit fic3
4+
gedit fic4
5+
6+
nous utilisons la commande system(" tar cvf toto.tar fic1 fic2 fic3 fic4")

listeBranche.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#include<stdio.h>
2+
#include<stdlib.h>
3+
#include<dirent.h>
4+
#include<sys/types.h>
5+
#include<sys/stat.h>
6+
#include<unistd.h>
7+
#include<string.h>
8+
9+
void showContent(char nom_rep[300])
10+
{
11+
DIR *rep_ouvert;
12+
struct dirent *entre;
13+
struct stat infoEntre;
14+
int nature=0;
15+
char *tmp;
16+
17+
18+
rep_ouvert= opendir(nom_rep);
19+
20+
21+
if (rep_ouvert==NULL)
22+
{
23+
24+
printf("le dossier n'existe pas ...\n");
25+
exit(1);
26+
27+
}
28+
while((entre=readdir(rep_ouvert))!=NULL)
29+
{
30+
31+
fprintf(stdout,"---%s \n",entre->d_name);
32+
if((strcmp(entre->d_name, ".")==0) || (strcmp(entre->d_name,"..") ==0))
33+
continue;
34+
35+
36+
stat(entre->d_name,&infoEntre);
37+
printf(" S_ISDIR =%d",S_ISDIR(infoEntre.st_mode));
38+
if (S_ISDIR(infoEntre.st_mode))
39+
{
40+
strcat(nom_rep,"/");
41+
strcat(nom_rep,entre->d_name);
42+
showContent(nom_rep);
43+
}
44+
45+
46+
}
47+
closedir(rep_ouvert);
48+
49+
}
50+
51+
int main(void)
52+
{
53+
char nom_repertoire[300];
54+
55+
printf(" entrez le nom du repertoire a scillonner : \n");
56+
scanf("%s",nom_repertoire);
57+
showContent(nom_repertoire);
58+
59+
60+
return 0;
61+
}

processus

16.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)