[S390] vmur: add "top of queue" sanity check for reader open
authorMichael Holzheu <holzheu@de.ibm.com>
Fri, 10 Aug 2007 12:32:33 +0000 (14:32 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Fri, 10 Aug 2007 12:32:38 +0000 (14:32 +0200)
If the z/VM reader is already open, it can happen that after opening the
Linux reader device, not the topmost file is processed. According the
semantics of the Linux z/VM unit record device driver, always the topmost
file has to be processed. With this fix an error is returned if that is
not the case.

Signed-off-by: Michael Holzheu <holzheu@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/char/vmur.c
drivers/s390/char/vmur.h

index 04395c0f99d8900b5e0b7249673e3836e0b0c272..a9d58629e7954f66b23bca2db1ed02792ae27fdb 100644 (file)
@@ -565,9 +565,14 @@ static int verify_device(struct urdev *urd)
                        return -ENOMEM;
                rc = diag_read_file(urd->dev_id.devno, buf);
                kfree(buf);
-
                if ((rc != 0) && (rc != -ENODATA)) /* EOF does not hurt */
                        return rc;
+               /* check if the file on top of the queue is open now */
+               rc = diag_read_next_file_info(&fcb, 0);
+               if (rc)
+                       return rc;
+               if (!(fcb.file_stat & FLG_IN_USE))
+                       return -EMFILE;
                return 0;
        default:
                return -ENOTSUPP;
index 522a9dfaa27556d59a212ba15f3e4a08d72dd5df..2b3c564e04728f133d527a2d95a94ddbacd3fb7c 100644 (file)
@@ -53,6 +53,7 @@ struct file_control_block {
 #define FLG_SYSTEM_HOLD        0x04
 #define FLG_CP_DUMP    0x10
 #define FLG_USER_HOLD  0x20
+#define FLG_IN_USE     0x80
 
 /*
  * A struct urdev is created for each ur device that is made available