Whamcloud - gitweb
mds_open() better to check permission even it's open request for device
authorericm <ericm>
Sun, 10 Jul 2005 05:17:51 +0000 (05:17 +0000)
committerericm <ericm>
Sun, 10 Jul 2005 05:17:51 +0000 (05:17 +0000)
files, otherwise client vfs will check that and failed siliently which
cause request leak. (client's interaction with vfs seems not perfect --
can't handle all error cases)

lustre/mds/mds_open.c

index 46d9591..7dd38da 100644 (file)
@@ -1287,7 +1287,17 @@ got_child:
         if ((rec->ur_flags & MDS_OPEN_DIRECTORY) &&
             !S_ISDIR(dchild->d_inode->i_mode))
                 GOTO(cleanup, rc = -ENOTDIR);
-               
+
+        /* check permission even it's special files */
+        if (S_ISCHR(dchild->d_inode->i_mode) ||
+            S_ISBLK(dchild->d_inode->i_mode) ||
+            S_ISFIFO(dchild->d_inode->i_mode) ||
+            S_ISSOCK(dchild->d_inode->i_mode)) {
+                rc = ll_permission(dchild->d_inode, acc_mode, NULL);
+                if (rc != 0)
+                        GOTO(cleanup, rc);
+        }
+
        if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OPEN_CREATE)) {
                obd_fail_loc = OBD_FAIL_LDLM_REPLY | OBD_FAIL_ONCE;
                GOTO(cleanup, rc = -EAGAIN);