Finish 4.

This commit is contained in:
Saturneric 2020-12-08 11:33:48 +08:00
parent c36f15dc80
commit 89e1c349ef
7 changed files with 39 additions and 2 deletions

2
.gitignore vendored
View File

@ -50,3 +50,5 @@ modules.order
Module.symvers Module.symvers
Mkfile.old Mkfile.old
dkms.conf dkms.conf
*.swp
*.swo

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,6 +1,15 @@
#include <unistd.h> #include <unistd.h>
#include <stdio.h>
int main(void) { 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; return 0;
} }

26
4/fileDirectory/dev.c Normal file
View File

@ -0,0 +1,26 @@
#include <sys/stat.h>
#include <stdio.h>
#include <sys/types.h>
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;
}

View File

@ -24,7 +24,7 @@
``` ```
2. 已加载的内核模块 2. 已加载的内核模块
``` ```
Module Size Used by Module Size Used by
ipt_MASQUERADE 16384 1 ipt_MASQUERADE 16384 1
nf_conntrack_netlink 49152 0 nf_conntrack_netlink 49152 0
xfrm_user 40960 1 xfrm_user 40960 1