This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// complie hint: gcc xxx.c -lmount | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <libmount/libmount.h> | |
int main() | |
{ | |
const char *filename; | |
struct libmnt_monitor *mn = mnt_new_monitor(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compile hint: gcc xxx.c -lblkid | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdbool.h> | |
#include <errno.h> | |
#include <blkid/blkid.h> | |
int list_ext4_partitions(void) | |
{ | |
int res; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
int **malloc_2d(int row, int col) | |
{ | |
if (row < 0 || col < 0) | |
return NULL; | |
int *array = (int *)malloc(row * col * sizeof(int)); | |
int **p = (int **)malloc(row * sizeof(int *)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get sub process's output in parent process using pipe redirection | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <sys/types.h> | |
#include <sys/wait.h> | |
#include <stdlib.h> | |
#include <fcntl.h> | |
#include <error.h> | |
#define BUFFSIZE 4000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://ext4.wiki.kernel.org/index.php/Ext4_Disk_Layout#Extent_Tree | |
file:///home/jzc/Desktop/e2fsprogs-1.45.6/doc/aa.html | |
https://bean-li.github.io/EXT4-packet-meta-blocks/ | |
https://www.cnblogs.com/alantu2018/p/8461272.html | |
https://ext4.wiki.kernel.org/index.php/Ext4_Metadata_Checksums | |
https://metebalci.com/blog/a-minimum-complete-tutorial-of-linux-ext4-file-system/ | |
https://wiki.archlinux.org/index.php/ext4 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// monitor active window and its pid using X11 lib | |
// compile hint: install xlib-dev and then use g++ ./xxx.cpp -lX11 | |
#include <X11/Xlib.h> | |
#include <cstring> | |
#include <iostream> | |
#define MAXSTR 1000 | |
using namespace std; | |
Display *display; | |
unsigned char *prop; |