Finish 4.
This commit is contained in:
parent
c36f15dc80
commit
89e1c349ef
2
.gitignore
vendored
2
.gitignore
vendored
@ -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.
@ -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
26
4/fileDirectory/dev.c
Normal 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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user