From 9c06a382e0ddb07ed4996bc548978330e544cdf2 Mon Sep 17 00:00:00 2001 From: zeus Date: Wed, 21 Apr 2021 01:12:20 +0300 Subject: [PATCH] add getfiles --- .../project/courses/pthread/getfiles/Makefile | 4 + .../courses/pthread/getfiles/get-longest-path | Bin 0 -> 13504 bytes .../courses/pthread/getfiles/getfiles-simple | Bin 0 -> 13176 bytes .../courses/pthread/getfiles/getfiles-size | Bin 0 -> 13312 bytes .../courses/pthread/getfiles/getfiles-size.c | 110 ++++++++++++++++ .../courses/pthread/getfiles/getfiles.c | 103 +++++++++++++++ .../courses/pthread/getfiles/longest_path.c | 120 ++++++++++++++++++ 7 files changed, 337 insertions(+) create mode 100644 install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/Makefile create mode 100755 install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/get-longest-path create mode 100755 install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles-simple create mode 100755 install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles-size create mode 100644 install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles-size.c create mode 100644 install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles.c create mode 100644 install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/longest_path.c diff --git a/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/Makefile b/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/Makefile new file mode 100644 index 0000000..aaf986e --- /dev/null +++ b/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/Makefile @@ -0,0 +1,4 @@ +all: + gcc -pthread ./getfiles.c -o getfiles-simple ; + gcc -pthread ./getfiles-size.c -o getfiles-size ; + gcc -pthread ./longest_path.c -o get-longest-path ; diff --git a/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/get-longest-path b/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/get-longest-path new file mode 100755 index 0000000000000000000000000000000000000000..e73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}obH^_U)ooc1`F=XEI4US&`5lMctPU_tK()TV6D>s6-HN|DQFd#?Xu%DzMC z@w%2N@B5HFomVWk|1>aa6N--#?|U)j{UJ+g#maf2SzJzgUMDk^-h%NfPF8xV z%%0cNOgUb5!93H?mf7=rAk)KKG39{EWq*HNX3y($rsd22^6~$?vgiKe_hqKkzRpx` z|Mw75`>}ob{|)pxjgc?6|9YAIoZ1&)Do-jpd~mxl^a?UqUCVojFkUb6{}Yt!Gtcy2 zVAJ5R=Y59e>&aVbyjfg{XZ!zzfVzn8VM@G?<^R{`3ziiL+hmbh!?e&yqnQ%GmfbE!{M}{yiU(+-xYP5)WuFQdgr4IdA>u&1|wGAS} z_FJ4F@)Rp2C*`qYNvz*?&7$|Jfay8&VO$(P&mT0tId;p!`aRKX(Tin5E|+y_xRt3$ Q(IZqC(p8JtzvcG-2l1FL=Kufz literal 0 HcmV?d00001 diff --git a/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles-simple b/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles-simple new file mode 100755 index 0000000000000000000000000000000000000000..36dd16c56666bd664ee1fba5ee81ae970110c62a GIT binary patch literal 13176 zcmeHOdvF`Y8DCj(;=E)#Zy;%|0hgo@#m);uNUkwNJK?1|_J!RAoRKM7@}d`vNgv zOawncVwSwYB9K~XRJmqap>Q`S+0~a>fRoNwdQ7>7M9Y<|7#XRwP^Lm?5+FOOYr_J` zf@(6u^q8tgEmce=P2LG6yLM&QuI!i!Wyh4;M{T34L&=@A2{KAdNtaUln`V&m*Lx&; z4sEkw!IbT;h8@-O^QJ1LxLK7~DlS8+{!F^w*>x33H-Ja_}@z4e<*=ZLVz^LoXG@GtX)r( zz<*okUQ8)Gz`&{YFW_qP z4apLEdWnSM@feAzbn+ZGjUGR0v%amhah6qY$e&1uwz&twp^ zTj7(C$0L(Vy*8Yp$7!bx=Q);SyKT7rJ#>!^x6i|SZ8(+9Y0!pqj7av74OgL*CXd_j zY3u~_X&a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*|DkXTn19Ug3?#%#hdD*t*p8Z&Td1 zXwthi8OE8(a8P)O>-HzQg*Uh>3V#+g@FS;54_WM+Z=_v{h5-pP{%l5o3z7`l>2|0US?=a={ zJXB;-?wA!fAxCRvE}z#$O!+;_^=Cb%+hI>@Z{~UZ#I#+NMD-^fuD^oCt;kSJ*`C)~ zOox;rm(TXx{yoaRQR!vWegae8k0ARwxSaO)0i&2Gv)sCk*KfRU0Tr2?{htDAx99a8 zQ+c*P*%HAoEt!~pADrEu*MUsAzRE0Df5snh*z@lxrVl$R%;mDbM;!LNu4L+1F3G-P zTcW>E_S}E`JCf=3c4g!p)e*E#q4u-A^SnEq9kC~;{RiVXeq zrDuo|uYdR)yi=cfrhkGBEy>uP*IW7m@|GWO7MJJQ{xt|_?6Ezs%lQ8cI50du*^c{> z){)f2oW0tQYhMTu>1m7P?rhKWZAk3)xpjtSnQ%GmfbEzcL546cpV#kInx)Zhk=$Lu zIsPN$sQlU-VrAHVi32BHN_NU)$C6n02F;>_YNL_fGqlFw`t$rj?vdw;CCTiWIF<3!1a6sHoHa-xKWVqW}N^ literal 0 HcmV?d00001 diff --git a/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles-size b/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles-size new file mode 100755 index 0000000000000000000000000000000000000000..c92688dffb1eb2c91da038f0c0f59ecba8c3e535 GIT binary patch literal 13312 zcmeHOdvH|M89$pP5HW1R8wKT7qy?1)5lmw!iP(^X=Zf?AA`( zKXWqoe&_prk8{p<&OP^@vnStaXlg8TxdbP-__`pj|1t}yRf2&VR0gD0)QHP)ze-FK zBf*c5m?f{Z2&7gzuUs>&P`DeE>}tv^z)7bmJ*HekqUB0fjGU;pP^Lm?5+FOOYt2=X z1=VDR=?PVjJE>waY4T1m+3CtoS9VN=vSZ5aqqfo2tmIBw4;dw%V_#@6`LrmM>)g zr6TYI!6U4K@2)A|XpwRH9rM0XQ;4g4z3G;V6|5Am58c(o6*6T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H{LiCbTN=`9Vz&ezqPB=Lg z3QjFys3c=XyFVI~XSUYBG8m2;DIB&!Eama1LVI-}s}QvH0(G)Fe^saxpkE6^3DJ=< zL!I;a#8#os>SldigRlM$6y1_cs#eIOSoixQn+Xv*7? z3ghHvI4HctwfmFp!W-Ngg+Gg$2}`migh3UH7BB{6iBQB(1}Ybin8GWA?nTzy76Xd_ z<4%tng!{Yi)GuVAqa8Hy>}^LmfzfKuf0 z*`C|~h_bI!db}=V%KIZ^KM9x9{s~|d6SXapTR-wTlJ`-dB9pWK(?IR^yv}6m9I(6| zVEO~6y;?uP=N$IDzGdoI&dI)FTcST!_S}E` z9m+IdS4Q3$KRT~W@nd`Ex%=iXv46#3&+BTYn;Zk4*0a>aoW0r~)TaYP z+G~;Ao$Z-^0Eyi`w@%S46E24xupRSfkRgoA*ECIvsx2bolFQ!|oC7{Xj>?~xL#zzj z&vxLXOUX`o>{t@(UaML3yxRDr_sk8rxc)qU(D>%MTNc*6W|l>}96~Oab;ly(P?4fv Ns)f%GD=O-={}*>bHoX7< literal 0 HcmV?d00001 diff --git a/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles-size.c b/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles-size.c new file mode 100644 index 0000000..6e80a8f --- /dev/null +++ b/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles-size.c @@ -0,0 +1,110 @@ + +#include +#include + +#include +#include +#include +#include +#include + +int NTHREADS; +int counter; +unsigned long long size=0; +void *listFilesRecursively(void* path); +pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; + +int main(int argc,char** argv) { + DIR *d; + struct dirent *dir; + char* path=argv[1]; + /* + d = opendir("node_modules"); + if (d) { + while ((dir = readdir(d)) != NULL) { + if (dir->d_type == DT_DIR) { + printf("D %s\n", dir->d_name); + }else if (dir->d_type == DT_REG) { + printf("F %s\n", dir->d_name); + } + } + closedir(d); + } + */ + listFilesRecursively(path); + printf("count %d\n", counter); + + printf("size %lld\n", size); + return(0); +} + + +int walk_dir(char *dname, char *pattern, int spec) +{ +} + +/** + * Lists all files and sub-directories recursively + * considering path as base path. + */ +void *listFilesRecursively(void *basePath_pass) +{ + char* basePath=(char*) basePath_pass; + char path[1000]; + struct dirent *dp; + DIR *dir = opendir(basePath); + + pthread_t tid[2]; + + int i = 0; + int err; + pthread_t* thread_id=(pthread_t*)malloc(1); + int ret1,ret2; + + NTHREADS = 0; + + // Unable to open directory stream + if (!dir) + return(0); + + while ((dp = readdir(dir)) != NULL) + { + if (strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0) + { + //printf("%s\n", dp->d_name); + if (dp->d_type == DT_DIR) { + printf("D %s\n", dp->d_name); + // Construct new path from our base path + strcpy(path, basePath); + strncat(path, "/",1); + strcat(path, dp->d_name); + + thread_id=(pthread_t*) realloc(thread_id,(NTHREADS+1)*sizeof(pthread_t)); + err = pthread_create(&thread_id[NTHREADS], NULL, listFilesRecursively, path ); + if (err != 0) + printf("\ncan't create thread :[%s]", strerror(err)); + else + printf("\n Thread created successfully\n"); + pthread_join( thread_id[NTHREADS], NULL); + NTHREADS++; + // listFilesRecursively(path); + }else if (dp->d_type == DT_REG) { + printf("F %s\n", dp->d_name); + struct stat st; + stat(basePath, &st); + size += st.st_size; + counter++; + } + + } + } +/* + for(int j=0; j < NTHREADS; j++) + { + pthread_join( thread_id[j], NULL); + } +*/ + closedir(dir); + //printf("count %d\n", counter); +} + diff --git a/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles.c b/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles.c new file mode 100644 index 0000000..0410cb1 --- /dev/null +++ b/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/getfiles.c @@ -0,0 +1,103 @@ + +#include +#include + +#include +#include +#include +#include + +int NTHREADS; +int counter; +void *listFilesRecursively(void* path); +pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; + +int main(int argc,char** argv) { + DIR *d; + struct dirent *dir; + char* path=argv[1]; + /* + d = opendir("node_modules"); + if (d) { + while ((dir = readdir(d)) != NULL) { + if (dir->d_type == DT_DIR) { + printf("D %s\n", dir->d_name); + }else if (dir->d_type == DT_REG) { + printf("F %s\n", dir->d_name); + } + } + closedir(d); + } + */ + listFilesRecursively(path); + printf("count %d\n", counter); + return(0); +} + + +int walk_dir(char *dname, char *pattern, int spec) +{ +} + +/** + * Lists all files and sub-directories recursively + * considering path as base path. + */ +void *listFilesRecursively(void *basePath_pass) +{ + char* basePath=(char*) basePath_pass; + char path[1000]; + struct dirent *dp; + DIR *dir = opendir(basePath); + + pthread_t tid[2]; + + int i = 0; + int err; + pthread_t* thread_id=(pthread_t*)malloc(1); + int ret1,ret2; + + NTHREADS = 0; + + // Unable to open directory stream + if (!dir) + return(0); + + while ((dp = readdir(dir)) != NULL) + { + if (strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0) + { + //printf("%s\n", dp->d_name); + if (dp->d_type == DT_DIR) { + printf("D %s\n", dp->d_name); + // Construct new path from our base path + strcpy(path, basePath); + strncat(path, "/",1); + strcat(path, dp->d_name); + + thread_id=(pthread_t*) realloc(thread_id,(NTHREADS+1)*sizeof(pthread_t)); + err = pthread_create(&thread_id[NTHREADS], NULL, listFilesRecursively, path ); + if (err != 0) + printf("\ncan't create thread :[%s]", strerror(err)); + else + printf("\n Thread created successfully\n"); + pthread_join( thread_id[NTHREADS], NULL); + NTHREADS++; + // listFilesRecursively(path); + }else if (dp->d_type == DT_REG) { + printf("F %s\n", dp->d_name); + counter++; + } + + } + } +/* + for(int j=0; j < NTHREADS; j++) + { + pthread_join( thread_id[j], NULL); + } +*/ + closedir(dir); + //printf("count %d\n", counter); +} + diff --git a/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/longest_path.c b/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/longest_path.c new file mode 100644 index 0000000..638a9f9 --- /dev/null +++ b/install/usr/share/swarmlab.io/sec/project/courses/pthread/getfiles/longest_path.c @@ -0,0 +1,120 @@ + +#include +#include + +#include +#include +#include +#include +#include +#define PATH_MAX 4096 + +int NTHREADS; +int counter; +//ftiaxnoume metavliti gia to megalytero path me megethos oso to max path size poy sto linux einai 4096 +char longest_path[PATH_MAX+1]; +//ftiaxnoume metavliti gia na apothikeuei to megethos tona arxeion +unsigned long long size=0; +void *listFilesRecursively(void* path); +//kanoume initialize to mutex gia na kleidosoume tous workers +pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; + +int main(int argc,char** argv) { + DIR *d; + struct dirent *dir; + //diavazoume to arxeio san parametro + //prosoxh einai sth thesi 1 kai oxi 0 + char* path=argv[1]; + listFilesRecursively(path); + printf("count %d\n", counter); + + printf("size %lld\n", size); + + printf("longest path is %s\n",longest_path); + return(0); +} + + +int walk_dir(char *dname, char *pattern, int spec) +{ +} + +/** + * Lists all files and sub-directories recursively + * considering path as base path. + */ +void *listFilesRecursively(void *basePath_pass) +{ + char* basePath=(char*) basePath_pass; + char path[1000]; + struct dirent *dp; + DIR *dir = opendir(basePath); + + pthread_t tid[2]; + + int i = 0; + int err; + pthread_t* thread_id=(pthread_t*)malloc(1); + pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; + int ret1,ret2; + + NTHREADS = 0; + + // Unable to open directory stream + if (!dir) + return(0); + + //diavazoume oso yparxoyn katalogoi + while ((dp = readdir(dir)) != NULL) + { + if (strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0) + { + if (dp->d_type == DT_DIR) { + printf("D %s\n", dp->d_name); + // Construct new path from our base path + printf("path %s\n",path); + strcpy(path, basePath); + printf("path %s\n",path); + strncat(path, "/",1); + printf("path %s\n",path); + strcat(path, dp->d_name); + printf("path %s\n",path); + + + printf("path %s\n",path); + printf("base path %s\n",basePath); + + thread_id=(pthread_t*) realloc(thread_id,(NTHREADS+1)*sizeof(pthread_t)); + err = pthread_create(&thread_id[NTHREADS], NULL, listFilesRecursively, path ); + if (err != 0) + printf("\ncan't create thread :[%s]", strerror(err)); + else + printf("\n Thread created successfully\n"); + pthread_join( thread_id[NTHREADS], NULL); + NTHREADS++; + }else if (dp->d_type == DT_REG) { + printf("F %s\n", dp->d_name); + //kaloume stat gia na paroyme to size + struct stat st; + stat(basePath, &st); + //prosthtoume to size sthn global metavliti + size += st.st_size; + + //kleidonoyme prin tin sygrisi gia na apofygoyme lathi + pthread_mutex_lock( &mutex1 ); + //sygrinoyme to current path me to longest path + //kai an einai megalytero to allazoyme + if(strlen(longest_path)<=strlen(basePath)) + strcpy(longest_path,path); + //anoigoyme pali to mutex gia na mpoyn oi alloi + pthread_mutex_unlock( &mutex1 ); + + + counter++; + } + + } + } + closedir(dir); +} +