日期:2014-05-16  浏览次数:20562 次

问个关于fcntl函数的问题


为了方便大家回答,特把原文给贴出来。

上面讲的关于fcntl大部分都明白,但是参数:F_GETLK不明白

问题:
1> This command returns the first lock that is covered by the flock structure specified.
问题:这句话的意思就是说,只能返回由flock函数锁定的段?不能返回别的函数(例如:lockf)锁定的段?
2> This command returns the first lock that is covered by the flock structure specified.
问题:fcntl的返回值是int类型的,怎么它说returns the first lock ... 啊?
3> The information that is retrieved overwrites the fields of the structure passed.
问题:这句话也不明白,刚才还说返回的是一个“lock”,现在又说是一个structure了,不懂,大家给详细解释下。
  非常感谢大家。
   



------解决方案--------------------
fcntl函数有5种功能:
1.复制一个现有的描述符(cmd=F_DUPFD).
2.获得/设置文件描述符标记(cmd=F_GETFD或F_SETFD).
3.获得/设置文件状态标记(cmd=F_GETFL或F_SETFL).
4.获得/设置异步I/O所有权(cmd=F_GETOWN或F_SETOWN).
5.获得/设置记录锁(cmd=F_GETLK,F_SETLK或F_SETLKW).

http://blog.csai.cn/user1/27828/archives/2007/14604.html
------解决方案--------------------
2 > This command returns the first lock that is covered by the flock structure specified. 
问题:fcntl的返回值是int类型的,怎么它说returns the first lock ... 啊? 
========================================================================
"第三个参数总是一个整数,与上面所示函数原型中的注释部分相对应。但是在作为记录锁用时,第三个参数则是指向一个结构的指针。"
我觉得指针结构是可以返回的

------解决方案--------------------
别的哥们都休假了吧..
不过老兵不懂英文,汗呀..
交流不了就不去糟蹋你那个帖子了