summaryrefslogtreecommitdiff
path: root/libfshelp-tests/README.new_tests
blob: b31b5034a9682944a27a56e498166092310df195 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
File: README.new_tests

C-code:
=======
test-fcntl.c
test-lockf.c
test-flock.c

Compile:
========
gcc -g -Wall -D_FILE_OFFSET_BITS=64 -o test-fcntl test-fcntl.c
gcc -g -Wall -D_FILE_OFFSET_BITS=64 -o test-lockf test-lockf.c
gcc -g -Wall -D_FILE_OFFSET_BITS=64 -o test-flock test-flock.c

./test-fcntl
./test-fcntl: Usage: ./test-fcntl file [flags] [cmd] [len] [sleep_time]
    file          : file name/device name
    flags         : r (O_RDONLY) | w (O_WRONLY) | rw (O_RDWR)      : [rw]
    cmd           : g (F_GETLK), s (F_SETLK), sw (F_SETLKW)        : [s]
    lock.l_type   : rl (F_RDLCK), wl (F_WRLCK), ul [F_UNLCK]       : [ul]
    lock.l_whence : ss (SEEK_SET), sc (SEEK_CUR), se (SEEK_END)    : [ss]
    lock.l_start  : b <number>                                     : [b 0]
    lock.l_len    : l <number>                                     : [l 0]
    sleep_time    : st <number>                                    : [st 10]

./test-lockf
./test-lockf: Usage: ./test-lockf file [flags] [cmd] [len] [sleep_time]
    file          : file name/device name
    flags         : r (O_RDONLY) | w (O_WRONLY) | rw (O_RDWR)      : [w]
    cmd           : x (F_LOCK), xt (F_TLOCK), u (F_ULOCK),
                    t (F_TEST)                                     : [x]
    len           : l <number>                                     : [0]
    sleep_time    : st <number>                                    : [st 10]

./test-flock
./test-flock: Usage: ./test-flock file [flags] [operation] [sleep_time]
    file          : file name/device name
    flags         : r (O_RDONLY) | w (O_WRONLY) | rw (O_RDWR)      : [w]
    operation     : s (LOCK_SH), x (LOCK_EX), u (LOCK_UN),
                    sn (LOCK_SH | LOCK_UN), xn (LOCK_EX | LOCK_UN) : [s]
    sleep_time    : st <number>                                    : [st 10]

Results:
========
New version of file_record_lock:
libdiskfs/file-lock.c(diskfs_S_file_lock): Commented out
libnetfs/file-lock.c(netfs_S_file_lock): Commented out
libtrivfs/file-lock.c(trivfs_S_file_lock): TODO: Add+comment out
libtrivfs/make-peropen.c(trivfs_S_file_lock): FIXME: po->openmodes = O_RDWR;
if (openstat & (O_RDONLY|O_WRONLY|O_EXEC)) openstat |= O_RDONLY|O_WRONLY;

libfshelp/rlock-tweak.c(fshelp_rlock_tweak): Removed
if (lock->l_type == F_RDLCK && !(open_mode & O_READ))
  return EACCES;
if (lock->l_type == F_WRLCK && !(open_mode & O_WRITE))
  return EACCES;
Added:
/* From POSIX-1003.1: A request for an exclusive lock shall fail if
   the file descriptor was not opened with write access. */
if ((cmd == F_SETLK64 || cmd == F_SETLKW64 )
    && lock->l_type == F_WRLCK && !(open_mode & O_WRITE))
  return EBADF;

test-fcntl:
===========
libdiskfs:
----------

touch foo
./test-fcntl foo {r,w} g {rl,wl}
./test-fcntl foo r {s,sw} wl
./test-fcntl: fcntl: Bad file descriptor
./test-fcntl foo r {s,sw} {rl,ul}

T1: T2:
./test-fcntl foo {r,w} {s,sw} {rl,wl}
./test-fcntl foo {r,w} {s,sw} {rl,wl}

libnetfs:
---------
Not applicable on GNU/Linux?

settrans -c ftp: /hurd/hostmux /hurd/ftpfs /
Check:
file ftp:
ftp:: directory
ls ftp://ftp.gnu.org/
less ftp://ftp.gnu.org/README

./test-fcntl ftp://ftp.gnu.org/README r g {rl,wl}
./test-fcntl ftp://ftp.gnu.org/README w g {rl,wl}
./test-fcntl: open: Permission denied

./test-fcntl ftp://ftp.gnu.org/README r {s,sw} {rl,ul}
./test-fcntl ftp://ftp.gnu.org/README r {s,sw} wl
./test-fcntl: fcntl: Bad file descriptor

settrans -fg ftp:
rm ftp:

libtrivs:
---------
BUG: ./test-fcntl /dev/null r s wl
GNU/Linux:
./test-fcntl: fcntl: Bad file descriptor

test-lockf:
===========
libdiskfs:
----------
touch foo
./test-lockf foo {r,w} {x,xt,u,t}
T1, T2:
./test-lockf foo {r,w} {x,xt,u,t}

libnetfs:
---------

libtrivfs:
----------

test-flock:
===========
libdiskfs:
----------
touch foo
./test-flock foo {r,w} {s,x,u,sn,xn}

GNU/Linux:
./test-flock foo r x

GNU/Hurd:
./test-flock foo r {x,xn}
./test-flock: flock: Bad file descriptor

T1: ./test-flock foo w s,x
T2: ./test-flock foo w x (waits for the first lock)

libnetfs:
---------

libtrivfs:
----------
GNU/Hurd
T1: ./test-flock /dev/null w s,x
BUG: T2: ./test-flock /dev/null w x (does not wait for the first lock)