里面不能这样初始化吧?
static const struct flock lck_set={F_WRLCK,SEEK_SET,0,0,0};
static const struct flock lck_clr={F_UNLCK,SEEK_SET,0,0,0};
因FreeBSD里struct flock跟linux下的结构成员的顺序是不一样
FreeBSD里是:
struct flock {
off_t l_start; /* starting offset */
off_t l_len; /* len = 0 means until end of file */
pid_t l_pid; /* lock owner */
short l_type; /* lock type: read/write, etc. */
short l_whence; /* type of l_start */
};
Linux下是:
struct flock {
...
short l_type; /* Type of lock: F_RDLCK,
F_WRLCK, F_UNLCK */
short l_whence; /* How to interpret l_start:
SEEK_SET, SEEK_CUR, SEEK_END */
off_t l_start; /* Starting offset for lock */
off_t l_len; /* Number of bytes to lock */
pid_t l_pid; /* PID of process blocking our lock
(F_GETLK only) */
...
};
--
FROM 58.60.63.*