diff options
Diffstat (limited to 'tests/bugs/glusterfs')
| -rw-r--r-- | tests/bugs/glusterfs/bug-1482528.t | 100 | ||||
| -rwxr-xr-x | tests/bugs/glusterfs/bug-844688.t | 45 | ||||
| -rw-r--r-- | tests/bugs/glusterfs/bug-848251.t | 1 | ||||
| -rwxr-xr-x | tests/bugs/glusterfs/bug-853690.t | 1 | ||||
| -rw-r--r-- | tests/bugs/glusterfs/bug-856455.t | 3 | ||||
| -rw-r--r-- | tests/bugs/glusterfs/bug-867253.t | 6 | ||||
| -rwxr-xr-x | tests/bugs/glusterfs/bug-872923.t | 2 | ||||
| -rw-r--r-- | tests/bugs/glusterfs/bug-873962-spb.t | 1 | ||||
| -rwxr-xr-x | tests/bugs/glusterfs/bug-879490.t | 2 | ||||
| -rwxr-xr-x | tests/bugs/glusterfs/bug-879494.t | 2 | ||||
| -rwxr-xr-x | tests/bugs/glusterfs/bug-892730.t | 1 | ||||
| -rw-r--r-- | tests/bugs/glusterfs/bug-893338.t | 2 | ||||
| -rwxr-xr-x | tests/bugs/glusterfs/bug-893378.t | 4 | ||||
| -rwxr-xr-x | tests/bugs/glusterfs/bug-896431.t | 37 | ||||
| -rwxr-xr-x | tests/bugs/glusterfs/bug-902610.t | 7 | ||||
| -rw-r--r-- | tests/bugs/glusterfs/bug-906646.t | 10 | ||||
| -rw-r--r-- | tests/bugs/glusterfs/getlk_owner.c | 96 |
17 files changed, 210 insertions, 110 deletions
diff --git a/tests/bugs/glusterfs/bug-1482528.t b/tests/bugs/glusterfs/bug-1482528.t new file mode 100644 index 00000000000..3adf260bdcd --- /dev/null +++ b/tests/bugs/glusterfs/bug-1482528.t @@ -0,0 +1,100 @@ +#!/bin/bash + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup +#Basic checks +TEST glusterd +TEST pidof glusterd + +#Create a distributed volume +TEST $CLI volume create $V0 $H0:$B0/${V0}{1..2} +TEST $CLI volume start $V0 + +# Mount FUSE without selinux: +TEST glusterfs -s $H0 --volfile-id $V0 $@ $M0 + +TEST touch $M0/default.txt +EXPECT "644" stat -c %a $M0/default.txt + +TEST chmod 0444 $M0/default.txt +EXPECT "444" stat -c %a $M0/default.txt + +TEST mkdir $M0/default +EXPECT "755" stat -c %a $M0/default + +TEST chmod 0444 $M0/default +EXPECT "444" stat -c %a $M0/default + +TEST mkfifo $M0/mkfifo +EXPECT "644" stat -c %a $M0/mkfifo + +TEST mknod $M0/dmknod b 4 5 +EXPECT "644" stat -c %a $M0/dmknod + +#Set the create-directory-mask and create-mask options +TEST $CLI volume set $V0 storage.create-directory-mask 0444 +TEST $CLI volume set $V0 storage.create-mask 0444 + +TEST mkdir $M0/create-directory +EXPECT "444" stat -c %a $M0/create-directory + +TEST touch $M0/create-mask.txt +EXPECT "444" stat -c %a $M0/create-mask.txt + +TEST chmod 0777 $M0/create-mask.txt +EXPECT "444" stat -c %a $M0/create-mask.txt + +TEST chmod 0400 $M0/create-mask.txt +EXPECT "400" stat -c %a $M0/create-mask.txt + +TEST chmod 0777 $M0/create-directory +EXPECT "444" stat -c %a $M0/create-directory + +TEST chmod 0400 $M0/create-directory +EXPECT "400" stat -c %a $M0/create-directory + +TEST mkfifo $M0/cfifo +EXPECT "444" stat -c %a $M0/cfifo + +TEST chmod 0777 $M0/cfifo +EXPECT "444" stat -c %a $M0/cfifo + +TEST mknod $M0/cmknod b 4 5 +EXPECT "444" stat -c %a $M0/cmknod + +#set force-create-mode and force-directory-mode options +TEST $CLI volume set $V0 storage.force-create-mode 0777 +TEST $CLI volume set $V0 storage.force-directory-mode 0333 + +TEST touch $M0/force-create-mode.txt +EXPECT "777" stat -c %a $M0/force-create-mode.txt + +TEST mkdir $M0/force-directory +EXPECT "777" stat -c %a $M0/force-directory + +TEST chmod 0222 $M0/force-create-mode.txt +EXPECT "777" stat -c %a $M0/force-create-mode.txt + +TEST chmod 0222 $M0/force-directory +EXPECT "333" stat -c %a $M0/force-directory + +TEST mkdir $M0/link +TEST ln -s $M0/force-create-mode.txt $M0/link +EXPECT "777" stat -c %a $M0/link/force-create-mode.txt + +TEST ln $M0/force-create-mode.txt $M0/link/fc.txt +EXPECT "777" stat -c %a $M0/link/fc.txt + +TEST setfacl -m o:r $M0/force-create-mode.txt +EXPECT "777" stat -c %a $M0/force-create-mode.txt + +TEST ln -s $M0/force-directory $M0/link +EXPECT "777" stat -c %a $M0/link/force-directory + +TEST mkfifo $M0/ffifo +EXPECT "777" stat -c %a $M0/ffifo + +TEST mknod $M0/mknod b 4 5 +EXPECT "777" stat -c %a $M0/mknod diff --git a/tests/bugs/glusterfs/bug-844688.t b/tests/bugs/glusterfs/bug-844688.t index a1b0b15f5ed..65f41b342a5 100755 --- a/tests/bugs/glusterfs/bug-844688.t +++ b/tests/bugs/glusterfs/bug-844688.t @@ -3,6 +3,17 @@ . $(dirname $0)/../../include.rc . $(dirname $0)/../../volume.rc +function check_callstack_log { + local text=$1 + statedump_file=$(generate_mount_statedump $V0); + grep $text $statedump_file 2>/dev/null 1>/dev/null; + if [ $? -eq 0 ]; then + echo "1"; + else + echo "0"; + fi; +} + cleanup; TEST glusterd @@ -13,21 +24,31 @@ TEST glusterfs -s $H0 --volfile-id $V0 $M0 mount_pid=$(get_mount_process_pid $V0); # enable dumping of call stack creation and frame creation times in statedump -kill -USR2 $mount_pid; +# monitoring is enabled by default + +# We want to make sure that there is a pending frame in gluster stack. +# For that we are creating a blocking lock scenario. + +TEST touch $M0/lockfile; +# Open two fd's on the same file +exec 8>$M0/lockfile; +exec 9>$M0/lockfile; + +# First flock will succeed and the second one will block, hence the background run. +flock -x 8 ; +flock -x 9 & + +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" check_callstack_log "callstack-creation-time"; +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" check_callstack_log "frame-creation-time"; -TEST touch $M0/touchfile; -(dd if=/dev/urandom of=$M0/file bs=5k 2>/dev/null 1>/dev/null)& -back_pid=$!; -statedump_file=$(generate_mount_statedump $V0); -grep "callstack-creation-time" $statedump_file 2>/dev/null 1>/dev/null; -TEST [ $? -eq 0 ]; -grep "frame-creation-time" $statedump_file 2>/dev/null 1>/dev/null; -TEST [ $? -eq 0 ]; +flock -u 8 +flock -u 9; -kill -SIGTERM $back_pid; -wait >/dev/null 2>&1; +# Closing the fd's +exec 8>&- +exec 9>&- -TEST rm -f $M0/touchfile $M0/file; +TEST rm -f $M0/lockfile; EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0 rm -f $statedumpdir/glusterdump.$mount_pid.*; diff --git a/tests/bugs/glusterfs/bug-848251.t b/tests/bugs/glusterfs/bug-848251.t index ed3caa34b01..69ffe680f7f 100644 --- a/tests/bugs/glusterfs/bug-848251.t +++ b/tests/bugs/glusterfs/bug-848251.t @@ -48,6 +48,5 @@ EXPECT "80%" quota_list EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $MOUNTDIR TEST rm -rf $MOUNTDIR TEST $CLI volume stop $V0 -EXPECT "1" get_aux cleanup; diff --git a/tests/bugs/glusterfs/bug-853690.t b/tests/bugs/glusterfs/bug-853690.t index 7880b64488f..59facfcddb0 100755 --- a/tests/bugs/glusterfs/bug-853690.t +++ b/tests/bugs/glusterfs/bug-853690.t @@ -53,7 +53,6 @@ end-volume volume test-replicate-0 type cluster/replicate - option afr-pending-xattr test-locks-0,test-locks-1 option background-self-heal-count 0 subvolumes test-locks-0 test-locks-1 end-volume diff --git a/tests/bugs/glusterfs/bug-856455.t b/tests/bugs/glusterfs/bug-856455.t index 25a30bfda48..d02b39bda8e 100644 --- a/tests/bugs/glusterfs/bug-856455.t +++ b/tests/bugs/glusterfs/bug-856455.t @@ -1,6 +1,7 @@ #!/bin/bash . $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc cleanup; @@ -35,7 +36,7 @@ EXPECT $BRICK_COUNT query_pathinfo $M0/f00d; # Kill a brick process and then query for pathinfo # for directories pathinfo should list backend patch from available (up) subvolumes -kill -9 `cat $GLUSTERD_WORKDIR/vols/$V0/run/$H0-d-backends-${V0}1.pid`; +kill_brick $V0 $H0 ${B0}/${V0}1 EXPECT `expr $BRICK_COUNT - 1` query_pathinfo $M0/f00d; diff --git a/tests/bugs/glusterfs/bug-867253.t b/tests/bugs/glusterfs/bug-867253.t index acbbdf8c1e7..8c3c39baace 100644 --- a/tests/bugs/glusterfs/bug-867253.t +++ b/tests/bugs/glusterfs/bug-867253.t @@ -4,6 +4,8 @@ . $(dirname $0)/../../volume.rc . $(dirname $0)/../../nfs.rc +#G_TESTDEF_TEST_STATUS_CENTOS6=NFS_TEST + cleanup; function file_count() @@ -36,7 +38,7 @@ TEST mount_nfs $H0:/$V0 $M0 nolock,noac; touch $M0/files{1..1000}; # Kill a brick process -kill -9 `cat $GLUSTERD_WORKDIR/vols/$V0/run/$H0-d-backends-${V0}0.pid`; +kill_brick $V0 $H0 $B0/${V0}0 drop_cache $M0 @@ -47,7 +49,7 @@ NEW_FILE_COUNT=`echo $?`; TEST $CLI volume start $V0 force # Kill a brick process -kill -9 `cat $GLUSTERD_WORKDIR/vols/$V0/run/$H0-d-backends-${V0}1.pid`; +kill_brick $V0 $H0 $B0/${V0}1 drop_cache $M0 diff --git a/tests/bugs/glusterfs/bug-872923.t b/tests/bugs/glusterfs/bug-872923.t index 72e8f230864..00e02c89cbe 100755 --- a/tests/bugs/glusterfs/bug-872923.t +++ b/tests/bugs/glusterfs/bug-872923.t @@ -4,6 +4,8 @@ . $(dirname $0)/../../volume.rc . $(dirname $0)/../../nfs.rc +#G_TESTDEF_TEST_STATUS_CENTOS6=NFS_TEST + cleanup; TEST glusterd diff --git a/tests/bugs/glusterfs/bug-873962-spb.t b/tests/bugs/glusterfs/bug-873962-spb.t index db84a223089..db71cc0f6fe 100644 --- a/tests/bugs/glusterfs/bug-873962-spb.t +++ b/tests/bugs/glusterfs/bug-873962-spb.t @@ -14,6 +14,7 @@ TEST $CLI volume set $V0 performance.io-cache off TEST $CLI volume set $V0 performance.write-behind off TEST $CLI volume set $V0 performance.stat-prefetch off TEST $CLI volume set $V0 performance.read-ahead off +TEST $CLI volume set $V0 performance.open-behind off TEST $CLI volume set $V0 cluster.background-self-heal-count 0 TEST $CLI volume start $V0 TEST glusterfs --entry-timeout=0 --attribute-timeout=0 -s $H0 --volfile-id=$V0 $M0 --direct-io-mode=enable diff --git a/tests/bugs/glusterfs/bug-879490.t b/tests/bugs/glusterfs/bug-879490.t index c254b4f59eb..fb8d4263919 100755 --- a/tests/bugs/glusterfs/bug-879490.t +++ b/tests/bugs/glusterfs/bug-879490.t @@ -10,7 +10,7 @@ TEST glusterd; TEST pidof glusterd; TEST $CLI volume info; -TEST $CLI volume create $V0 replica 2 stripe 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8}; +TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{1,2,3,4,5,6}; ## Verify volume is is created EXPECT "$V0" volinfo_field $V0 'Volume Name'; diff --git a/tests/bugs/glusterfs/bug-879494.t b/tests/bugs/glusterfs/bug-879494.t index 06a5e5d876d..12ee466b33a 100755 --- a/tests/bugs/glusterfs/bug-879494.t +++ b/tests/bugs/glusterfs/bug-879494.t @@ -10,7 +10,7 @@ TEST glusterd; TEST pidof glusterd; TEST $CLI volume info; -TEST $CLI volume create $V0 replica 2 stripe 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8}; +TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{1,2,3,4,5,6}; ## Verify volume is is created EXPECT "$V0" volinfo_field $V0 'Volume Name'; diff --git a/tests/bugs/glusterfs/bug-892730.t b/tests/bugs/glusterfs/bug-892730.t index 1fa0ff3bfb4..a76961134c5 100755 --- a/tests/bugs/glusterfs/bug-892730.t +++ b/tests/bugs/glusterfs/bug-892730.t @@ -53,7 +53,6 @@ end-volume volume test-replicate-0 type cluster/replicate - option afr-pending-xattr test-locks-0,test-locks-1 option background-self-heal-count 0 subvolumes test-locks-0 test-locks-1 end-volume diff --git a/tests/bugs/glusterfs/bug-893338.t b/tests/bugs/glusterfs/bug-893338.t index 0df1b9af2fe..b915d3e791e 100644 --- a/tests/bugs/glusterfs/bug-893338.t +++ b/tests/bugs/glusterfs/bug-893338.t @@ -10,7 +10,7 @@ TEST glusterd; TEST pidof glusterd; TEST $CLI volume info; -TEST $CLI volume create $V0 stripe 2 $H0:$B0/${V0}{1,2,3,4}; +TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{1,2,3,4,5,6}; ## Verify volume is is created EXPECT "$V0" volinfo_field $V0 'Volume Name'; diff --git a/tests/bugs/glusterfs/bug-893378.t b/tests/bugs/glusterfs/bug-893378.t index 72a23f99e26..444dafb44bc 100755 --- a/tests/bugs/glusterfs/bug-893378.t +++ b/tests/bugs/glusterfs/bug-893378.t @@ -1,6 +1,8 @@ #!/bin/bash . $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + cleanup; BRICK_COUNT=3 @@ -59,7 +61,7 @@ then get_cached_brick CACHED=$? # Kill a brick process - kill -9 `cat $GLUSTERD_WORKDIR/vols/$V0/run/$H0-d-backends-${V0}$CACHED.pid`; + kill_brick $V0 $H0 $B0/${V0}$CACHED fi ## trigger a lookup diff --git a/tests/bugs/glusterfs/bug-896431.t b/tests/bugs/glusterfs/bug-896431.t index 7764a88d896..61f71141713 100755 --- a/tests/bugs/glusterfs/bug-896431.t +++ b/tests/bugs/glusterfs/bug-896431.t @@ -8,7 +8,7 @@ cleanup; ## Start and create a volume TEST glusterd; TEST pidof glusterd; -TEST $CLI volume create $V0 replica 2 stripe 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8}; +TEST $CLI volume create $V0 replica 3 $H0:$B0/${V0}{1,2,3,4,5,6}; ## Verify volume is created EXPECT "$V0" volinfo_field $V0 'Volume Name'; @@ -87,38 +87,3 @@ TEST $CLI volume delete $V0; TEST ! $CLI volume info $V0; cleanup; - -## Start and create a pure stripe volume -TEST glusterd; -TEST pidof glusterd; -TEST $CLI volume create $V0 stripe 8 $H0:$B0/${V0}{1,2,3,4,5,6,7,8}; - -## Verify volume is created -EXPECT "$V0" volinfo_field $V0 'Volume Name'; -EXPECT 'Created' volinfo_field $V0 'Status'; -EXPECT 'Stripe' volinfo_field $V0 'Type'; - -## Start volume and verify -TEST $CLI volume start $V0; -EXPECT 'Started' volinfo_field $V0 'Status'; - -## Setting cluster.subvols-per-directory as 8 for a stripe volume -TEST ! $CLI volume set $V0 cluster.subvols-per-directory 8 -EXPECT '' volinfo_field $V0 'cluster.subvols-per-directory'; -TEST ! $CLI volume set $V0 subvols-per-directory 8 -EXPECT '' volinfo_field $V0 'cluster.subvols-per-directory'; - -## Setting cluster.subvols-per-directory as 1 for a stripe volume -TEST $CLI volume set $V0 cluster.subvols-per-directory 1 -EXPECT '1' volinfo_field $V0 'cluster.subvols-per-directory'; -TEST $CLI volume set $V0 subvols-per-directory 1 -EXPECT '1' volinfo_field $V0 'cluster.subvols-per-directory'; - -## Finish up -TEST $CLI volume stop $V0; -EXPECT 'Stopped' volinfo_field $V0 'Status'; - -TEST $CLI volume delete $V0; -TEST ! $CLI volume info $V0; - -cleanup; diff --git a/tests/bugs/glusterfs/bug-902610.t b/tests/bugs/glusterfs/bug-902610.t index 656bf50137e..112c947e116 100755 --- a/tests/bugs/glusterfs/bug-902610.t +++ b/tests/bugs/glusterfs/bug-902610.t @@ -1,6 +1,7 @@ #!/bin/bash . $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc cleanup; @@ -27,7 +28,7 @@ function get_layout() fi # Figure out where the join point is. - target=$( $PYTHON -c "print '%08x' % (0x$layout1_e + 1)") + target=$( $PYTHON -c "print('%08x' % (0x$layout1_e + 1))") #echo "target for layout2 = $target" > /dev/tty # The second layout should cover everything that the first doesn't. @@ -54,8 +55,8 @@ TEST glusterfs -s $H0 --volfile-id $V0 $M0 --entry-timeout=0 --attribute-timeout TEST ls -l $M0 ## kill 2 bricks to bring down available subvol < spread count -kill -9 `cat $GLUSTERD_WORKDIR/vols/$V0/run/$H0-d-backends-${V0}2.pid`; -kill -9 `cat $GLUSTERD_WORKDIR/vols/$V0/run/$H0-d-backends-${V0}3.pid`; +kill_brick $V0 $H0 $B0/${V0}2 +kill_brick $V0 $H0 $B0/${V0}3 mkdir $M0/dir1 2>/dev/null diff --git a/tests/bugs/glusterfs/bug-906646.t b/tests/bugs/glusterfs/bug-906646.t index 45c85d9f67c..37b8fe5c8eb 100644 --- a/tests/bugs/glusterfs/bug-906646.t +++ b/tests/bugs/glusterfs/bug-906646.t @@ -13,7 +13,6 @@ TEST pidof glusterd TEST $CLI volume create $V0 replica $REPLICA $H0:$B0/${V0}-00 $H0:$B0/${V0}-01 $H0:$B0/${V0}-10 $H0:$B0/${V0}-11 TEST $CLI volume start $V0 -TEST $CLI volume set $V0 cluster.self-heal-daemon off TEST $CLI volume set $V0 cluster.background-self-heal-count 0 ## Mount FUSE with caching disabled @@ -82,10 +81,15 @@ EXPECT 1 xattr_query_check ${backend_paths_array[1]} "trusted.name" # restart the brick process TEST $CLI volume start $V0 force -EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 `expr $brick_id - 1` +EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 1 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 2 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status_in_shd $V0 3 -cat $pth >/dev/null +TEST $CLI volume heal $V0 +EXPECT_WITHIN $HEAL_TIMEOUT "0" get_pending_heal_count $V0 # check backends - xattr should not be present anywhere EXPECT 1 xattr_query_check ${backend_paths_array[0]} "trusted.name" EXPECT 1 xattr_query_check ${backend_paths_array[1]} "trusted.name" diff --git a/tests/bugs/glusterfs/getlk_owner.c b/tests/bugs/glusterfs/getlk_owner.c index 85fd1042496..cbe277318c1 100644 --- a/tests/bugs/glusterfs/getlk_owner.c +++ b/tests/bugs/glusterfs/getlk_owner.c @@ -3,24 +3,24 @@ #include <fcntl.h> #include <string.h> -#define GETLK_OWNER_CHECK(f, cp, label) \ - do { \ - switch (f.l_type) { \ - case F_RDLCK: \ - case F_WRLCK: \ - ret = 1; \ - goto label; \ - case F_UNLCK: \ - if (!are_flocks_sane (&f, &cp)) { \ - ret = 1; \ - goto label; \ - } \ - break; \ - } \ +#define GETLK_OWNER_CHECK(f, cp, label) \ + do { \ + switch (f.l_type) { \ + case F_RDLCK: \ + case F_WRLCK: \ + ret = 1; \ + goto label; \ + case F_UNLCK: \ + if (!are_flocks_sane(&f, &cp)) { \ + ret = 1; \ + goto label; \ + } \ + break; \ + } \ } while (0) void -flock_init (struct flock *f, short int type, off_t start, off_t len) +flock_init(struct flock *f, short int type, off_t start, off_t len) { f->l_type = type; f->l_start = start; @@ -28,17 +28,16 @@ flock_init (struct flock *f, short int type, off_t start, off_t len) } int -flock_cp (struct flock *dst, struct flock *src) +flock_cp(struct flock *dst, struct flock *src) { - memcpy ((void *) dst, (void *) src, sizeof (struct flock)); + memcpy((void *)dst, (void *)src, sizeof(struct flock)); } int -are_flocks_sane (struct flock *src, struct flock *cpy) +are_flocks_sane(struct flock *src, struct flock *cpy) { return ((src->l_whence == cpy->l_whence) && - (src->l_start == cpy->l_start) && - (src->l_len == cpy->l_len)); + (src->l_start == cpy->l_start) && (src->l_len == cpy->l_len)); } /* @@ -53,68 +52,73 @@ are_flocks_sane (struct flock *src, struct flock *cpy) * * */ -int main (int argc, char **argv) +int +main(int argc, char **argv) { int fd = -1; int ret = 1; char *fname = NULL; - struct flock f = {0,}; - struct flock cp = {0,}; + struct flock f = { + 0, + }; + struct flock cp = { + 0, + }; if (argc < 2) goto out; fname = argv[1]; - fd = open (fname, O_RDWR); + fd = open(fname, O_RDWR); if (fd == -1) { - perror ("open"); + perror("open"); goto out; } - flock_init (&f, F_WRLCK, 0, 3); - flock_cp (&cp, &f); - ret = fcntl (fd, F_SETLK, &f); + flock_init(&f, F_WRLCK, 0, 3); + flock_cp(&cp, &f); + ret = fcntl(fd, F_SETLK, &f); if (ret) { - perror ("fcntl"); + perror("fcntl"); goto out; } - if (!are_flocks_sane (&f, &cp)) { + if (!are_flocks_sane(&f, &cp)) { ret = 1; goto out; } - flock_init (&f, F_WRLCK, 3, 3); - flock_cp (&cp, &f); - ret = fcntl (fd, F_SETLK, &f); + flock_init(&f, F_WRLCK, 3, 3); + flock_cp(&cp, &f); + ret = fcntl(fd, F_SETLK, &f); if (ret) { - perror ("fcntl"); + perror("fcntl"); goto out; } - if (!are_flocks_sane (&f, &cp)) { + if (!are_flocks_sane(&f, &cp)) { ret = 1; goto out; } - flock_init (&f, F_WRLCK, 3, 3); - flock_cp (&cp, &f); - ret = fcntl (fd, F_GETLK, &f); + flock_init(&f, F_WRLCK, 3, 3); + flock_cp(&cp, &f); + ret = fcntl(fd, F_GETLK, &f); if (ret) { - perror ("fcntl"); + perror("fcntl"); return 1; } - GETLK_OWNER_CHECK (f, cp, out); + GETLK_OWNER_CHECK(f, cp, out); - flock_init (&f, F_RDLCK, 3, 3); - flock_cp (&cp, &f); - ret = fcntl (fd, F_GETLK, &f); + flock_init(&f, F_RDLCK, 3, 3); + flock_cp(&cp, &f); + ret = fcntl(fd, F_GETLK, &f); if (ret) { - perror ("fcntl"); + perror("fcntl"); return 1; } - GETLK_OWNER_CHECK (f, cp, out); + GETLK_OWNER_CHECK(f, cp, out); out: if (fd != -1) - close (fd); + close(fd); return ret; } |
