![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Linux C
Configure-Handler
这个作者很懒,什么都没留下…
展开
-
df 根据文件名找到挂载点原理
df 根据文件名找到挂载点原理一、shell命令查看特定文件挂载点#根据文件名找到对应的挂载点rlk@rlk:vfs$ df ./stat.c Filesystem 1K-blocks Used Available Use% Mounted on/dev/sda5 1029518584 18451556 958700644 2% /#遍历当前系统所有的挂载点相关的信息rlk@rlk:vfs$ df -hFilesystem Size Used Av原创 2021-09-05 13:03:15 · 4553 阅读 · 0 评论 -
Linux ring3内存泄漏检测工具使用
Linux ring3内存泄漏检测工具使用一、内存泄漏测试代码/* gcc backtrace_symbols.c -o backtrace_symbols -rdynamic */#include <stdio.h>#include <execinfo.h>#define STORE_STACK_MAX_SIZE 10 static int print_stack(void){ int size = 0, i = 0; void *buffer[STORE_原创 2021-08-19 16:10:58 · 1144 阅读 · 0 评论 -
Linux ring3内存泄漏检测工具使用
Linux ring3内存泄漏检测工具使用一、内存泄漏测试代码/* gcc backtrace_symbols.c -o backtrace_symbols -rdynamic */#include <stdio.h>#include <execinfo.h>#define STORE_STACK_MAX_SIZE 10 static int print_stack(void){ int size = 0, i = 0; void *buffer[STORE_原创 2021-06-16 10:45:10 · 95 阅读 · 0 评论 -
C语言内联汇编使用方法
C语言内联汇编使用方法原创 2021-06-10 14:31:09 · 7122 阅读 · 0 评论 -
C 内存池的简单实现
内存池可以优化内存分配的效率,这里在单链表的基础上增加内存池功能:pool.c#include <stdio.h>#include <stdlib.h>#include <string.h>#define MAX 1024struct node *pool = NULL;static int count = 0;struct node { int value; struct node *next;};void insert_node(str原创 2021-04-16 10:07:35 · 197 阅读 · 0 评论 -
C 指针勘误
首先看看一个看着没有什么问题的代码:这个程序看起来人畜无害,指针ptr将指向mymolloc()的malloc()函数分配的地址,因为main()函数传入的就是指针ptr的值,它表示的不就是一个地址,但是看看输出的结果,看看对不对。#include <stdio.h>#include <stdlib.h>int mymolloc(int *ptr){ printf("%s: the ptr address is 0x%lx\n", __func__, (unsigned原创 2021-04-15 20:17:02 · 138 阅读 · 0 评论 -
C 语言中单链表实现
直接上代码list.c#include <stdio.h>#include <stdlib.h>#include <string.h>struct node { int value; struct node *next;};void insert_node(struct node **head, int value);struct node *find_node(struct node *head, int target);void delete_原创 2021-04-08 11:45:53 · 97 阅读 · 0 评论 -
Linux GDB调试常见指令
Ring3程序编译时添加-g参数编译命令说明break(b)设置断点,可以是代码所在行,函数名 b line / b funcinfo break查看所有断点信息list(l)从第一行开始例出原码(实测没有显示头文件)回车键直接回车表示,重复上一次命令run(r )运行程序nest(n)单条语句执行,不进入函数step(s)单条语句执行,进入函数continue(c)继续运行程序print(p)打印变量的值bt原创 2020-12-28 16:48:01 · 1070 阅读 · 0 评论 -
Linux Ring3 设置当前进程cpu亲和性
最近在研究设置进程cpu亲和性的相关工作,这里一起分享一下,这个主要还是参考博客大佬;主要还是使用以下几个函数,具体的使用方法,这里就不多加说明,大佬们说的比较清楚,我这里直接分享写的代码;sched_setaffinity(0, sizeof(cpu_set_t), &mask);sched_getaffinity(0, sizeof(cpu_set_t), &get);sysconf(_SC_NPROCESSORS_CONF);CPU_ZERO(&mask);CPU_原创 2020-11-12 15:20:18 · 510 阅读 · 0 评论 -
Linux C Hook动态链接过程
Linux 下GCC的编译可分为4个步骤:预处理 --> 编译 --> 汇编 -->链接这里讲一讲劫持GCC编译的链接过程,这里我们需要了解一下动态链接的一个环境变量,LD_PRELOAD;LD_PRELOAD 环境变量可以定义在程序运行前优先加载的动态链接库。这使得我们可以有选择性地加载不同动态链接库中的相同函数,即通过设置该变量,在主程序和其动态链接库中间加载别的动态链接库,甚至覆盖原本的库,这就有可能出现劫持程序执行的安全问题。“ldpreload.c”#include<原创 2020-10-28 19:41:40 · 2245 阅读 · 3 评论 -
Linux 内核驱动之话说C语言(一)
得到原创 2020-10-17 10:46:01 · 809 阅读 · 2 评论 -
Linux ring3 文件夹相关操作
Ring 3对文件的打开,读取,关闭操作opendir.c#include <stdio.h>#include <sys/types.h>#include <dirent.h>int main(int argc,char *argv[]){ struct dirent *p; //打开指定的文件夹 DIR *dirp=opendir(argv[1]); if(dirp==NULL){ perror("opendir"); return 1; }原创 2020-10-12 15:35:08 · 588 阅读 · 0 评论 -
Linux C遍历文件夹
0x01:首先讲一讲遍历文件夹必须要知道的一个结构体struct dirent{};struct dirent{ ino_t d_ino; /* inode number */ off_t d_off; /* offset to next dirent */ unsigned short d_reclen; /* length of record */ unsigned char d_tpye; /*type of file;not support by all file syst原创 2020-09-29 16:16:46 · 1157 阅读 · 0 评论