Skip to content

Commit

Permalink
Set O_NONBLOCK on fd passed to kernel
Browse files Browse the repository at this point in the history
Also make debug=0x1 (errors to dmesg) the default in mount.diod,
and don't abort if debug mask option was specified in hex.
  • Loading branch information
garlick committed Jun 7, 2011
1 parent 38d655c commit 3a6d3e8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions utils/diodmount.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/wait.h>
Expand Down Expand Up @@ -190,7 +191,7 @@ main (int argc, char *argv[])
/* Set debug level.
*/
if (!opt_find (o, "debug"))
opt_addf (o, "debug=%d", 0);
opt_addf (o, "debug=%d", 0x1); /* send errors to dmesg */

/* Server is on an inherited file descriptor.
* For testing, we start server on a socketpair duped to fd 0.
Expand Down Expand Up @@ -232,7 +233,7 @@ main (int argc, char *argv[])
assert (opt_find (o, "trans=fd"));
assert (opt_scanf (o, "msize=%d", &i));
assert (opt_find (o, "version=9p2000.L"));
assert (opt_scanf (o, "debug=%d", &i));
assert (opt_scanf (o, "debug=%d", &i) || opt_scanf (o, "debug=%x", &i));
assert (opt_scanf (o, "wfdno=%d", &i) && opt_scanf (o, "rfdno=%d", &i));
assert ((opt_find (o, "access=user") && opt_find(o, "uname=root"))
|| (opt_scanf (o, "access=%d", &i) && opt_find(o, "uname")));
Expand Down Expand Up @@ -489,8 +490,11 @@ _diod_mount (Opt o, int fd, char *spec, char *dir, int vopt, int fopt, int nopt)
errn_exit (np_rerror (), "clunk root");
if (vopt)
msg ("mount -t 9p %s %s -o%s", spec, dir, options);
if (!fopt)
if (!fopt) {
if (fcntl (fd, F_SETFL, O_NONBLOCK) < 0)
err_exit ("setting O_NONBLOCK flag");
_mount (spec, dir, mountflags, options9p);
}
npc_finish (fs); /* closes fd */

if (!nopt) {
Expand Down

0 comments on commit 3a6d3e8

Please sign in to comment.