From 89e1c349efb603ac8cf950315a913284fdd930e1 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Tue, 8 Dec 2020 11:33:48 +0800 Subject: [PATCH] Finish 4. --- .gitignore | 2 ++ 4/fileDirectory/.dirent.c.swp | Bin 12288 -> 0 bytes 4/fileDirectory/.filetime.c.swp | Bin 12288 -> 0 bytes 4/fileDirectory/.mkdir.c.swp | Bin 12288 -> 0 bytes 4/fileDirectory/chdir.c | 11 ++++++++++- 4/fileDirectory/dev.c | 26 ++++++++++++++++++++++++++ README.md | 2 +- 7 files changed, 39 insertions(+), 2 deletions(-) delete mode 100644 4/fileDirectory/.dirent.c.swp delete mode 100644 4/fileDirectory/.filetime.c.swp delete mode 100644 4/fileDirectory/.mkdir.c.swp create mode 100644 4/fileDirectory/dev.c diff --git a/.gitignore b/.gitignore index c6127b3..95f24b0 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,5 @@ modules.order Module.symvers Mkfile.old dkms.conf +*.swp +*.swo diff --git a/4/fileDirectory/.dirent.c.swp b/4/fileDirectory/.dirent.c.swp deleted file mode 100644 index 65e0b12835e446ec13bd6a98560402306b156854..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2O=}ZD7{{l*`!0C&Y1-gMnzvdpU{gVI2~-c36a=AecP8n;b~a3A)0PrFi)YcV zV14--p1kXK@G5xpKbv)FrKO$(@frAKb|=p~&ojSU$ZRz>x(}#TTM`%-g?Re@^X8A) z1+ns22xWETm(LpOp-Zjt(bbL`pC0|pht$_yD)+S+^o-u?8mDYOj8uKO-q*3}XsaTZ z*!{Z1lX0~_s(*S#{)P>(fy_Ya`qkDsacimB@bB}bIl6MW$8y*J8(;%$fDNz#Hoykh z02}y^47lNpc#iYV=4ZZ^&ojTx`72LsfDNz#Hoykh02^QfY=8~00XDz}*uXz%Ae2H} zIxoZv;Q#;s_51(Z1tGqIFW?h+2M)n2Fa`qwpIvU;}J`4X^<=zy{a=8(;%$fDQa@1CwG1qDhWb{+c&6?g~LsoQxFi zXa_@lRQ$?Bh;sAxh|0}YEU6r)PfTf%w2^9Wk$e=cb5~d8rU{GO#~)DT%nC#_wA#3S zP&%R5u_`<2r0Uuv=oV?>#0;k0QJb8K<0FTm-EG`O53;kNYXn#o$|9gbb8ULqTU)Cf zAd{exvuWgLdPKUJcY$3##;eH;7N@H=vj&QTBtvDemz1@Mg|w_c-Os91JFi3sK2N9n tXqq3%^KC(?=6Ape?S$F{<3!7fkDk{iic_g*W#ptzYTK(vmZrV>wV&Vs(B%LC diff --git a/4/fileDirectory/.filetime.c.swp b/4/fileDirectory/.filetime.c.swp deleted file mode 100644 index d1733e34430a66fcd886d92d362088b6b9d4e6b1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI2F>ljA6vwX}X$uH;bWNd3kmJN@kt*6Sb*TU$wJHcf6;k_LETwj^&w&U5f=>Vg zLJSNbX5bruL|4SXz$btWSYhM;&JIZmw5$~`(l72izdOJCy<4hyy?TD>temrJ0-u9I zynpnr@pbg5Shy&JiUXI1cl)d~bsC41U0zh3zh~d3l*)=uy>1Y0tcJmjrBJKbZ@Q{7 zTk(UIS`1?4>L~7-NC%tB{-+B5{!G5Z2G{@$q}ngfO^BJAQzai$g-Ln%&?>8818jf| zumLu}2G{@_U;}L6KQf@(BjOJBJDTr#HouN+yXGNZ*Z><~18jf|umLu}2G{@_U;}J` z4X}YdXrSo{(H+BY{o^PezyJ6C|NnA8h>zeccm-a97vKrd;2O9BPJn4p0F&Sd7z6vj zxBWtV09)V~r^CoP^L8$#=!B6R};4qOYj-&W;Sil@91Hah2fmIz#Qc_Zq3$j|0H|dFH z;F7Z@>(a&FG$|XZ(ooY3VJy*c>gw!PTe*2oZOzoVV_{KSg_7Q3&MK2yC3_x^|Z&g~<>~ptOhZZ$KZ%qVQrE=Sc60pPd)VCAepeXC+a2hqFpGA=+ z|IiC+Qa_C%i#oewR}$USzaJGE#W}I$G%CwZi8&;B_st~Sp;~u+!eHN{*qi`VhWFNo zdf#t7mc)5A%^&DJ9h_|1VDBkyvl)cNP84|N+=!_lbX%#X8$0HecW RNjIs`hK5IdH`FZ}`UyG=RMr3h diff --git a/4/fileDirectory/.mkdir.c.swp b/4/fileDirectory/.mkdir.c.swp deleted file mode 100644 index 37480d0a233f9da32d727ed0f94892c23eee770d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&KTq307zXec_WluU?a;$8Boc`OWk71ggrFG^$RUMFm5>{s;RHEH=QARrzyRN( z8xjlR161mORAxHz0T|&+^gSm;EfutD)#s!qw%>bmj(?k#`&fBbTM*ObN#gOG==kJv z?Rs#Gs_%)UQB7C=)2N3wGum~RX65$7-TSV^uiGr@D81g$YNw{HG;!FJ{*)i9Ejg=< zY}&+h{MKfqO!=>F|L_el0|5wh1u`3#rk~L3$%%?9jCvztc&Gs#2tWV=5P$##AOHaf zK;S}k_bvs`x>CQVG{H?g+D2&`7d+GA9ppk9lb8?M zE4oP)7xHSs^EZ-~^z;4bR;Jc>ANiJZuPCabQWU$y{oVEN7R={=TQILaw&1u3R#t +#include int main(void) { - // TODO + if(chdir("/home/eric") < 0) { + printf("chdir error\n"); + return -1; + } + + char buf[1024]; + + char *pbuf = getcwd(buf, 1024); + printf("CWD: %s\n", pbuf); return 0; } diff --git a/4/fileDirectory/dev.c b/4/fileDirectory/dev.c new file mode 100644 index 0000000..214558f --- /dev/null +++ b/4/fileDirectory/dev.c @@ -0,0 +1,26 @@ +#include +#include +#include + +int main(void) { + struct stat buf; + + if(stat("/dev/sda", &buf) < 0){ + printf("stat error for /dev/sda\n"); + return -1; + } + + printf("dev = %ld\nrdev = %ld\n", buf.st_dev, buf.st_rdev); + + if(S_ISCHR(buf.st_mode)){ + printf("character device\n"); + } + else if (S_ISBLK(buf.st_mode)){ + printf("block device\n"); + } + else { + printf("unkonwn device\n"); + } + + return 0; +} diff --git a/README.md b/README.md index fc153e5..f002ccb 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ ``` 2. 已加载的内核模块 ``` - Module Size Used by + Module Size Used by ipt_MASQUERADE 16384 1 nf_conntrack_netlink 49152 0 xfrm_user 40960 1