Commit 54daec18 authored by Andrei Vagin's avatar Andrei Vagin

test/file_locks: use struct flock instead of struct flock64

If we want to use flock64, we have to use fcntl64. Otherwise we will get
errors like this:
ERR: file_locks07.c:49: Can't set ofd lock (errno = 22 (Invalid argument))

Reported-by: Mr Jenkins
Signed-off-by: 's avatarAndrei Vagin <avagin@gmail.com>
parent e2bd7af9
......@@ -22,7 +22,7 @@ char file1[PATH_MAX];
static int lock_reg(int fd, int cmd, int type, int whence,
off_t offset, off_t len)
{
struct flock64 lock;
struct flock lock;
lock.l_type = type; /* F_RDLCK, F_WRLCK, F_UNLCK */
lock.l_whence = whence; /* SEEK_SET, SEEK_CUR, SEEK_END */
......@@ -40,7 +40,7 @@ static int lock_reg(int fd, int cmd, int type, int whence,
static int check_read_lock(int fd, int whence, off_t offset, off_t len)
{
struct flock64 lock;
struct flock lock;
int ret;
lock.l_type = F_RDLCK; /* F_RDLCK, F_WRLCK, F_UNLCK */
......@@ -67,7 +67,7 @@ static int check_read_lock(int fd, int whence, off_t offset, off_t len)
static int check_write_lock(int fd, int whence, off_t offset, off_t len)
{
struct flock64 lock;
struct flock lock;
int ret;
pid_t ppid = getppid();
......
......@@ -12,7 +12,7 @@ char *filename;
TEST_OPTION(filename, string, "file name", 1);
int init_lock(int *fd, struct flock64 *lck)
int init_lock(int *fd, struct flock *lck)
{
*fd = open(filename, O_RDWR | O_CREAT, 0666);
if (*fd < 0) {
......@@ -45,7 +45,7 @@ void cleanup(int *fd)
int main(int argc, char **argv)
{
int fd;
struct flock64 lck;
struct flock lck;
test_init(argc, argv);
if (init_lock(&fd, &lck))
......
......@@ -14,12 +14,12 @@ TEST_OPTION(filename, string, "file name", 1);
#define FILE_NUM 4
static int fds[FILE_NUM];
static struct flock64 lcks[FILE_NUM];
static struct flock lcks[FILE_NUM];
static short types[] = {F_RDLCK, F_RDLCK, F_RDLCK, F_RDLCK};
static off_t starts[] = {0, 10, 0, 70};
static off_t lens[] = {20, 30, 100, 200};
void fill_lock(struct flock64 *lock, off_t start, off_t len, short int type)
void fill_lock(struct flock *lock, off_t start, off_t len, short int type)
{
lock->l_start = start;
lock->l_len = len;
......
......@@ -14,7 +14,7 @@ char *filename;
TEST_OPTION(filename, string, "file name", 1);
int init_file_lock(int *fd, struct flock64 *lck)
int init_file_lock(int *fd, struct flock *lck)
{
*fd = open(filename, O_RDWR | O_CREAT, 0666);
if (*fd < 0) {
......@@ -51,7 +51,7 @@ int main(int argc, char **argv)
int status;
int ret = 0;
task_waiter_t tw;
struct flock64 lck;
struct flock lck;
test_init(argc, argv);
if (init_file_lock(&fd, &lck))
......
......@@ -7,7 +7,7 @@
#include "fs.h"
#include "ofd_file_locks.h"
static int parse_ofd_lock(char *buf, struct flock64 *lck)
static int parse_ofd_lock(char *buf, struct flock *lck)
{
char fl_flag[10], fl_type[15], fl_option[10], fl_end[32];
long long start;
......@@ -48,7 +48,7 @@ static int parse_ofd_lock(char *buf, struct flock64 *lck)
return 0;
}
static int read_fd_ofd_lock(int pid, int fd, struct flock64 *lck)
static int read_fd_ofd_lock(int pid, int fd, struct flock *lck)
{
char path[PATH_MAX];
char buf[100];
......@@ -77,7 +77,7 @@ static int read_fd_ofd_lock(int pid, int fd, struct flock64 *lck)
return num;
}
int check_lock_exists(const char *filename, struct flock64 *lck)
int check_lock_exists(const char *filename, struct flock *lck)
{
int ret = -1;
int fd;
......@@ -116,16 +116,16 @@ out:
return ret;
}
static int check_file_locks_match(struct flock64 *orig_lck, struct flock64 *lck)
static int check_file_locks_match(struct flock *orig_lck, struct flock *lck)
{
return orig_lck->l_start == lck->l_start &&
orig_lck->l_len == lck->l_len &&
orig_lck->l_type == lck->l_type;
}
int check_file_lock_restored(int pid, int fd, struct flock64 *lck)
int check_file_lock_restored(int pid, int fd, struct flock *lck)
{
struct flock64 lck_restored;
struct flock lck_restored;
if (read_fd_ofd_lock(pid, fd, &lck_restored))
return -1;
......
......@@ -14,7 +14,7 @@
* from procfs and checking them after restoring.
*/
extern int check_lock_exists(const char *filename, struct flock64 *lck);
extern int check_file_lock_restored(int pid, int fd, struct flock64 *lck);
extern int check_lock_exists(const char *filename, struct flock *lck);
extern int check_file_lock_restored(int pid, int fd, struct flock *lck);
#endif /* ZDTM_OFD_FILE_LOCKS_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment