免费注册 查看新帖 |

Chinaunix

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

linux中的文件都连接在一起么 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-07-28 09:57 |只看该作者 |倒序浏览
1.同学今儿告诉我说linux中的文件都是通过双向循环链表连接在一起了的。。。

是不是啊?

2.如果我需要对某个用户的某些文件进行保护,我依次建立了一张链表
此时有用户来访问文件时,需要知道这个文件有没有被保护起来,应该怎么检查?

3.如果通过文件的inode信息可以判断这个文件在哪个链表中么?

论坛徽章:
0
2 [报告]
发表于 2011-07-28 10:11 |只看该作者

论坛徽章:
22
丑牛
日期:2014-08-15 14:32:0015-16赛季CBA联赛之同曦
日期:2017-12-14 15:28:14黑曼巴
日期:2017-08-10 08:14:342017金鸡报晓
日期:2017-02-08 10:39:42黑曼巴
日期:2016-11-15 15:48:38CU十四周年纪念徽章
日期:2016-11-09 13:19:1015-16赛季CBA联赛之同曦
日期:2016-04-08 18:00:03平安夜徽章
日期:2015-12-26 00:06:30程序设计版块每日发帖之星
日期:2015-12-03 06:20:002015七夕节徽章
日期:2015-08-21 11:06:17IT运维版块每日发帖之星
日期:2015-08-09 06:20:002015亚冠之吉达阿赫利
日期:2015-07-03 08:39:42
3 [报告]
发表于 2011-07-28 10:16 |只看该作者
回复 1# smallQ_nj


    我给你装到内核版去

论坛徽章:
0
4 [报告]
发表于 2011-07-28 10:56 |只看该作者
回复 2# taojie2000


谢谢啦~~

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
5 [报告]
发表于 2011-07-28 11:08 |只看该作者
回复 1# smallQ_nj
你指的是 inode ?

论坛徽章:
0
6 [报告]
发表于 2011-07-28 12:00 |只看该作者
回复 5# Godbach


恩恩~~
但好像不可以,inode信息里面貌似没有可以用来判断这个文件属于哪个链表的吧。。。只可以知道这个文件的属主,然后查看这个属主需要保护的文件链表里有没有这个文件

是不是这个样子的?

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
7 [报告]
发表于 2011-07-28 12:22 |只看该作者
本帖最后由 T-Bagwell 于 2011-07-28 12:25 编辑

include/linux/fs.h
可以看到

  1. struct inode {
  2.     /* RCU path lookup touches following: */
  3.     umode_t         i_mode;
  4.     uid_t           i_uid;
  5.     gid_t           i_gid;
  6.     const struct inode_operations   *i_op;
  7.     struct super_block  *i_sb;

  8.     spinlock_t      i_lock; /* i_blocks, i_bytes, maybe i_size */
  9.     unsigned int        i_flags;
  10.     unsigned long       i_state;
  11. #ifdef CONFIG_SECURITY
  12.     void            *i_security;
  13. #endif
  14.     struct mutex        i_mutex;


  15.     unsigned long       dirtied_when;   /* jiffies of first dirtying */

  16.     struct hlist_node   i_hash;
  17.     struct list_head    i_wb_list;  /* backing dev IO list */
  18.     struct list_head    i_lru;      /* inode LRU list */
  19.     struct list_head    i_sb_list;
  20.     union {
  21.         struct list_head    i_dentry;
  22.         struct rcu_head     i_rcu;
  23.     };
  24.     unsigned long       i_ino;
  25.     atomic_t        i_count;
  26.     unsigned int        i_nlink;
  27.     dev_t           i_rdev;
  28.     unsigned int        i_blkbits;
  29.     u64         i_version;
  30.     loff_t          i_size;
  31. #ifdef __NEED_I_SIZE_ORDERED
  32.     seqcount_t      i_size_seqcount;
  33.     seqcount_t      i_size_seqcount;
  34. #endif
  35.     struct timespec     i_atime;
  36.     struct timespec     i_mtime;
  37.     struct timespec     i_ctime;
  38.     blkcnt_t        i_blocks;
  39.     unsigned short          i_bytes;
  40.     atomic_t        i_dio_count;
  41.     const struct file_operations    *i_fop; /* former ->i_op->default_file_ops */
  42.     struct file_lock    *i_flock;
  43.     struct address_space    *i_mapping;
  44.     struct address_space    i_data;
  45. #ifdef CONFIG_QUOTA
  46.     struct dquot        *i_dquot[MAXQUOTAS];
  47. #endif
  48.     struct list_head    i_devices;
  49.     union {
  50.         struct pipe_inode_info  *i_pipe;
  51.         struct block_device *i_bdev;
  52.         struct cdev     *i_cdev;
  53.     };

  54.     __u32           i_generation;

  55. #ifdef CONFIG_FSNOTIFY
  56.     __u32           i_fsnotify_mask; /* all events this inode cares about */
  57.     struct hlist_head   i_fsnotify_marks;
  58. #endif

  59. #ifdef CONFIG_IMA
  60.     atomic_t        i_readcount; /* struct files open RO */
  61. #endif
  62.     atomic_t        i_writecount;
  63. #ifdef CONFIG_FS_POSIX_ACL
  64.     struct posix_acl    *i_acl;
  65.    struct posix_acl    *i_acl;
  66.     struct posix_acl    *i_default_acl;
  67. #endif
  68.     void            *i_private; /* fs or device private pointer */
  69. };
  70. 其中list head的定义
  71. struct list_head {
  72.     struct list_head *next, *prev;
  73. };



复制代码
肯定要挂到链表上的,该节点的地址,就是通过typeof获得结构的地址的
地址都有了,就随便你怎么玩了

至于你说的属主
一般就是inode->i_uid吧?

评分

参与人数 1可用积分 +6 收起 理由
Godbach + 6 感谢分享

查看全部评分

论坛徽章:
36
IT运维版块每日发帖之星
日期:2016-04-10 06:20:00IT运维版块每日发帖之星
日期:2016-04-16 06:20:0015-16赛季CBA联赛之广东
日期:2016-04-16 19:59:32IT运维版块每日发帖之星
日期:2016-04-18 06:20:00IT运维版块每日发帖之星
日期:2016-04-19 06:20:00每日论坛发贴之星
日期:2016-04-19 06:20:00IT运维版块每日发帖之星
日期:2016-04-25 06:20:00IT运维版块每日发帖之星
日期:2016-05-06 06:20:00IT运维版块每日发帖之星
日期:2016-05-08 06:20:00IT运维版块每日发帖之星
日期:2016-05-13 06:20:00IT运维版块每日发帖之星
日期:2016-05-28 06:20:00每日论坛发贴之星
日期:2016-05-28 06:20:00
8 [报告]
发表于 2011-07-28 12:26 |只看该作者
回复 7# T-Bagwell

TB 版主是文件系统的大牛啊

论坛徽章:
0
9 [报告]
发表于 2011-07-28 13:51 |只看该作者
回复 7# T-Bagwell


是不是可以通过节点地址来知道文件在哪个链表上?

论坛徽章:
5
摩羯座
日期:2014-07-22 09:03:552015元宵节徽章
日期:2015-03-06 15:50:392015亚冠之大阪钢巴
日期:2015-06-12 16:01:352015年中国系统架构师大会
日期:2015-06-29 16:11:2815-16赛季CBA联赛之四川
日期:2018-12-17 14:10:21
10 [报告]
发表于 2011-07-28 14:56 |只看该作者
本帖最后由 T-Bagwell 于 2011-07-28 14:57 编辑
回复  T-Bagwell


是不是可以通过节点地址来知道文件在哪个链表上?
smallQ_nj 发表于 2011-07-28 13:51


貌似树和链表还是有差别的

不过你说了这么多,我不知道你想干什么
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP