]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Add O_NONBLOCK option to xfs_io open command.
authorNathan Scott <nathans@sgi.com>
Fri, 3 Jun 2005 06:11:20 +0000 (06:11 +0000)
committerNathan Scott <nathans@sgi.com>
Fri, 3 Jun 2005 06:11:20 +0000 (06:11 +0000)
Merge of master-melb:xfs-cmds:22799a by kenmcd.

io/file.c
io/init.c
io/io.h
io/open.c

index bb23109a2ac972eae14b9ecd9ab591b925f8cf44..037abef34a3379cfb8ecf708010938f8d8110851 100644 (file)
--- a/io/file.c
+++ b/io/file.c
@@ -50,14 +50,15 @@ print_fileio(
        int             index,
        int             braces)
 {
-       printf(_("%c%03d%c %-14s (%s,%s,%s,%s%s%s)\n"),
+       printf(_("%c%03d%c %-14s (%s,%s,%s,%s%s%s%s)\n"),
                braces? '[' : ' ', index, braces? ']' : ' ', file->name,
                file->flags & IO_FOREIGN ? _("foreign") : _("xfs"),
                file->flags & IO_OSYNC ? _("sync") : _("non-sync"),
                file->flags & IO_DIRECT ? _("direct") : _("non-direct"),
                file->flags & IO_READONLY ? _("read-only") : _("read-write"),
                file->flags & IO_REALTIME ? _(",real-time") : "",
-               file->flags & IO_APPEND ? _(",append-only") : "");
+               file->flags & IO_APPEND ? _(",append-only") : "",
+               file->flags & IO_NONBLOCK ? _(",non-block") : "");
 }
 
 int
index 0f92b3da6709cc9029445b76424a2a41823204b9..d1947d6304695953c58fb35a96eb161645509eae 100644 (file)
--- a/io/init.c
+++ b/io/init.c
@@ -140,12 +140,12 @@ init(
        pagesize = getpagesize();
        gettimeofday(&stopwatch, NULL);
 
-       while ((c = getopt(argc, argv, "ac:dFfmp:rRstVx")) != EOF) {
+       while ((c = getopt(argc, argv, "ac:dFfmp:nrRstVx")) != EOF) {
                switch (c) {
-               case 'a':       /* append */
+               case 'a':
                        flags |= IO_APPEND;
                        break;
-               case 'c':       /* commands */
+               case 'c':
                        add_user_command(optarg);
                        break;
                case 'd':
@@ -165,6 +165,9 @@ init(
                                exit(1);
                        }
                        break;
+               case 'n':
+                       flags |= IO_NONBLOCK;
+                       break;
                case 'p':
                        progname = optarg;
                        break;
diff --git a/io/io.h b/io/io.h
index c5cdd463589a8a1517dd90c842ac264400572cac..656fb243bc9566ca4286e9239e9fc4a77940bf6b 100644 (file)
--- a/io/io.h
+++ b/io/io.h
@@ -38,6 +38,7 @@
 #define IO_CREAT       (1<<5)
 #define IO_TRUNC       (1<<6)
 #define IO_FOREIGN     (1<<7)
+#define IO_NONBLOCK    (1<<8)
 
 /*
  * Regular file I/O control
index 9c837912c8164111911a73e0ce00d581251be3f0..11b694b385f7344a61f9bbcff6a3fb214facd09c 100644 (file)
--- a/io/open.c
+++ b/io/open.c
@@ -90,12 +90,13 @@ stat_f(
        int             verbose = (argc == 2 && !strcmp(argv[1], "-v"));
 
        printf(_("fd.path = \"%s\"\n"), file->name);
-       printf(_("fd.flags = %s,%s,%s%s%s\n"),
+       printf(_("fd.flags = %s,%s,%s%s%s%s\n"),
                file->flags & IO_OSYNC ? _("sync") : _("non-sync"),
                file->flags & IO_DIRECT ? _("direct") : _("non-direct"),
                file->flags & IO_READONLY ? _("read-only") : _("read-write"),
                file->flags & IO_REALTIME ? _(",real-time") : "",
-               file->flags & IO_APPEND ? _(",append-only") : "");
+               file->flags & IO_APPEND ? _(",append-only") : "",
+               file->flags & IO_NONBLOCK ? _(",non-block") : "");
        if (fstat64(file->fd, &st) < 0) {
                perror("fstat64");
        } else {
@@ -143,6 +144,8 @@ openfile(
                oflags |= O_SYNC;
        if (flags & IO_TRUNC)
                oflags |= O_TRUNC;
+       if (flags & IO_NONBLOCK)
+               oflags |= O_NONBLOCK;
 
        fd = open(path, oflags, mode);
        if (fd < 0) {
@@ -240,10 +243,11 @@ open_help(void)
 " -d -- open with O_DIRECT (non-buffered IO, note alignment constraints)\n"
 " -f -- open with O_CREAT (create the file if it doesn't exist)\n"
 " -m -- permissions to use in case a new file is created (default 0600)\n"
+" -n -- open with O_NONBLOCK\n"
 " -r -- open with O_RDONLY, the default is O_RDWR\n"
 " -s -- open with O_SYNC\n"
 " -t -- open with O_TRUNC (truncate the file to zero length if it exists)\n"
-" -x -- mark the file as a realtime XFS file immediately after opening it\n"
+" -R -- mark the file as a realtime XFS file immediately after opening it\n"
 " Note1: usually read/write direct IO requests must be blocksize aligned;\n"
 "        some kernels, however, allow sectorsize alignment for direct IO.\n"
 " Note2: the bmap for non-regular files can be obtained provided the file\n"
@@ -268,7 +272,7 @@ open_f(
                return 0;
        }
 
-       while ((c = getopt(argc, argv, "Facdfm:rstx")) != EOF) {
+       while ((c = getopt(argc, argv, "FRacdfm:nrstx")) != EOF) {
                switch (c) {
                case 'F':
                        flags |= IO_FOREIGN;
@@ -290,6 +294,9 @@ open_f(
                                return 0;
                        }
                        break;
+               case 'n':
+                       flags |= IO_NONBLOCK;
+                       break;
                case 'r':
                        flags |= IO_READONLY;
                        break;
@@ -299,7 +306,8 @@ open_f(
                case 't':
                        flags |= IO_TRUNC;
                        break;
-               case 'x':
+               case 'R':
+               case 'x':       /* backwards compatibility */
                        flags |= IO_REALTIME;
                        break;
                default: