@@ -169,7 +169,18 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)
169
169
170
170
/* convert posix lock to p9 tlock args */
171
171
memset (& flock , 0 , sizeof (flock ));
172
- flock .type = fl -> fl_type ;
172
+ /* map the lock type */
173
+ switch (fl -> fl_type ) {
174
+ case F_RDLCK :
175
+ flock .type = P9_LOCK_TYPE_RDLCK ;
176
+ break ;
177
+ case F_WRLCK :
178
+ flock .type = P9_LOCK_TYPE_WRLCK ;
179
+ break ;
180
+ case F_UNLCK :
181
+ flock .type = P9_LOCK_TYPE_UNLCK ;
182
+ break ;
183
+ }
173
184
flock .start = fl -> fl_start ;
174
185
if (fl -> fl_end == OFFSET_MAX )
175
186
flock .length = 0 ;
@@ -245,7 +256,7 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl)
245
256
246
257
/* convert posix lock to p9 tgetlock args */
247
258
memset (& glock , 0 , sizeof (glock ));
248
- glock .type = fl -> fl_type ;
259
+ glock .type = P9_LOCK_TYPE_UNLCK ;
249
260
glock .start = fl -> fl_start ;
250
261
if (fl -> fl_end == OFFSET_MAX )
251
262
glock .length = 0 ;
@@ -257,17 +268,26 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl)
257
268
res = p9_client_getlock_dotl (fid , & glock );
258
269
if (res < 0 )
259
270
return res ;
260
- if (glock .type != F_UNLCK ) {
261
- fl -> fl_type = glock .type ;
271
+ /* map 9p lock type to os lock type */
272
+ switch (glock .type ) {
273
+ case P9_LOCK_TYPE_RDLCK :
274
+ fl -> fl_type = F_RDLCK ;
275
+ break ;
276
+ case P9_LOCK_TYPE_WRLCK :
277
+ fl -> fl_type = F_WRLCK ;
278
+ break ;
279
+ case P9_LOCK_TYPE_UNLCK :
280
+ fl -> fl_type = F_UNLCK ;
281
+ break ;
282
+ }
283
+ if (glock .type != P9_LOCK_TYPE_UNLCK ) {
262
284
fl -> fl_start = glock .start ;
263
285
if (glock .length == 0 )
264
286
fl -> fl_end = OFFSET_MAX ;
265
287
else
266
288
fl -> fl_end = glock .start + glock .length - 1 ;
267
289
fl -> fl_pid = glock .proc_id ;
268
- } else
269
- fl -> fl_type = F_UNLCK ;
270
-
290
+ }
271
291
return res ;
272
292
}
273
293
0 commit comments