cmd/9pfuse: ignore FMODE_EXEC open flag

Improved error message in case of unexpected open flags. The message

    unexpected open flags requested=0100040 unhandled=040

prompted me to clear the FMODE_EXEC flag, although I wonder if I
shouldn't have set OEXEC (0x3) instead.
This commit is contained in:
Nicola Girardi 2019-07-22 18:39:56 +00:00 committed by Russ Cox
parent ac6456a0cc
commit 93f9789c04

View file

@ -51,6 +51,14 @@
# endif # endif
#endif #endif
#ifndef FMODE_EXEC
# if defined(__linux__)
# define FMODE_EXEC 040
# else
# define FMODE_EXEC 0
# endif
#endif
int debug; int debug;
char *argv0; char *argv0;
char *aname = ""; char *aname = "";
@ -583,7 +591,7 @@ _fuseopen(FuseMsg *m, int isdir)
flags = in->flags; flags = in->flags;
openmode = flags&3; openmode = flags&3;
flags &= ~3; flags &= ~3;
flags &= ~(O_DIRECTORY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC); flags &= ~(O_DIRECTORY|O_NONBLOCK|O_LARGEFILE|O_CLOEXEC|FMODE_EXEC);
#ifdef O_NOFOLLOW #ifdef O_NOFOLLOW
flags &= ~O_NOFOLLOW; flags &= ~O_NOFOLLOW;
#endif #endif
@ -602,13 +610,14 @@ _fuseopen(FuseMsg *m, int isdir)
openmode |= OTRUNC; openmode |= OTRUNC;
flags &= ~O_TRUNC; flags &= ~O_TRUNC;
} }
/* /*
* Could translate but not standard 9P: * Could translate but not standard 9P:
* O_DIRECT -> ODIRECT * O_DIRECT -> ODIRECT
* O_NONBLOCK -> ONONBLOCK * O_NONBLOCK -> ONONBLOCK
*/ */
if(flags){ if(flags){
fprint(2, "unexpected open flags %#uo\n", (uint)in->flags); fprint(2, "unexpected open flags requested=%#uo unhandled=%#uo\n", (uint)in->flags, (uint)flags);
replyfuseerrno(m, EACCES); replyfuseerrno(m, EACCES);
return; return;
} }