| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: ops.c,v 1.86 2019/02/09 02:22:45 manu Exp $ */ | | 1 | /* $NetBSD: ops.c,v 1.86.2.1 2019/08/13 14:44:37 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. | | 4 | * Copyright (c) 2010-2011 Emmanuel Dreyfus. All rights reserved. |
5 | * | | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions | | 7 | * modification, are permitted provided that the following conditions |
8 | * are met: | | 8 | * are met: |
9 | * 1. Redistributions of source code must retain the above copyright | | 9 | * 1. Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * 2. Redistributions in binary form must reproduce the above copyright | | 11 | * 2. Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | | 13 | * documentation and/or other materials provided with the distribution. |
14 | * | | 14 | * |
| @@ -2966,44 +2966,35 @@ perfuse_node_advlock(struct puffs_usermo | | | @@ -2966,44 +2966,35 @@ perfuse_node_advlock(struct puffs_usermo |
2966 | struct fuse_out_header *foh; | | 2966 | struct fuse_out_header *foh; |
2967 | struct fuse_lk_out *flo; | | 2967 | struct fuse_lk_out *flo; |
2968 | uint32_t owner; | | 2968 | uint32_t owner; |
2969 | size_t len; | | 2969 | size_t len; |
2970 | int error; | | 2970 | int error; |
2971 | | | 2971 | |
2972 | node_ref(opc); | | 2972 | node_ref(opc); |
2973 | | | 2973 | |
2974 | /* | | 2974 | /* |
2975 | * Make sure we do have a filehandle, as the FUSE filesystem | | 2975 | * Make sure we do have a filehandle, as the FUSE filesystem |
2976 | * expect one. E.g.: if we provide none, GlusterFS logs an error | | 2976 | * expect one. E.g.: if we provide none, GlusterFS logs an error |
2977 | * "0-glusterfs-fuse: xl is NULL" | | 2977 | * "0-glusterfs-fuse: xl is NULL" |
2978 | * | | 2978 | * |
2979 | * There is one exception with directories where filehandle | | | |
2980 | * is not included, because libfuse uses different filehandle | | | |
2981 | * in opendir/releasedir/readdir/fsyncdir compared to other | | | |
2982 | * operations. Who locks a directory anyway? | | | |
2983 | * | | | |
2984 | * We need the read file handle if the file is open read only, | | 2979 | * We need the read file handle if the file is open read only, |
2985 | * in order to support shared locks on read-only files. | | 2980 | * in order to support shared locks on read-only files. |
2986 | * NB: The kernel always sends advlock for read-only | | 2981 | * NB: The kernel always sends advlock for read-only |
2987 | * files at exit time when the process used lock, see | | 2982 | * files at exit time when the process used lock, see |
2988 | * sys_exit -> exit1 -> fd_free -> fd_close -> VOP_ADVLOCK | | 2983 | * sys_exit -> exit1 -> fd_free -> fd_close -> VOP_ADVLOCK |
2989 | */ | | 2984 | */ |
2990 | if (!PN_ISDIR(opc)) { | | 2985 | if ((fh = perfuse_get_fh(opc, FREAD)) == FUSE_UNKNOWN_FH) { |
2991 | if ((fh = perfuse_get_fh(opc, FREAD)) == FUSE_UNKNOWN_FH) { | | 2986 | error = EBADF; |
2992 | error = EBADF; | | 2987 | goto out; |
2993 | goto out; | | | |
2994 | } | | | |
2995 | } else { | | | |
2996 | fh = FUSE_UNKNOWN_FH; | | | |
2997 | } | | 2988 | } |
2998 | | | 2989 | |
2999 | ps = puffs_getspecific(pu); | | 2990 | ps = puffs_getspecific(pu); |
3000 | | | 2991 | |
3001 | if (op == F_GETLK) | | 2992 | if (op == F_GETLK) |
3002 | fop = FUSE_GETLK; | | 2993 | fop = FUSE_GETLK; |
3003 | else | | 2994 | else |
3004 | fop = (flags & F_WAIT) ? FUSE_SETLKW : FUSE_SETLK; | | 2995 | fop = (flags & F_WAIT) ? FUSE_SETLKW : FUSE_SETLK; |
3005 | | | 2996 | |
3006 | /* | | 2997 | /* |
3007 | * XXX ps_new_msg() is called with NULL creds, which will | | 2998 | * XXX ps_new_msg() is called with NULL creds, which will |
3008 | * be interpreted as FUSE superuser. We have no way to | | 2999 | * be interpreted as FUSE superuser. We have no way to |
3009 | * know the requesting process' credential, but since advlock() | | 3000 | * know the requesting process' credential, but since advlock() |