LINUX: Return NULL for afs_linux_raw_open error
[openafs.git] / src / afs / LINUX / osi_file.c
index 0374c1c..7069297 100644 (file)
@@ -66,8 +66,12 @@ afs_linux_raw_open(afs_dcache_id_t *ainode)
 #else
     filp = dentry_open(dget(dp), mntget(afs_cacheMnt), O_RDWR);
 #endif
-    if (IS_ERR(filp))
-       osi_Panic("Can't open file: %d\n", (int) PTR_ERR(filp));
+    if (IS_ERR(filp)) {
+       afs_warn("afs: Cannot open cache file (code %d). Trying to continue, "
+                 "but AFS accesses may return errors or panic the system\n",
+                 (int) PTR_ERR(filp));
+        filp = NULL;
+    }
 
     dput(dp);
 
@@ -99,8 +103,16 @@ osi_UFSOpen(afs_dcache_id_t *ainode)
     memset(afile, 0, sizeof(struct osi_file));
 
     afile->filp = afs_linux_raw_open(ainode);
-    afile->size = i_size_read(FILE_INODE(afile->filp));
+    if (afile->filp) {
+        afile->size = i_size_read(FILE_INODE(afile->filp));
+    }
     AFS_GLOCK();
+
+    if (!afile->filp) {
+        osi_FreeLargeSpace(afile);
+        return NULL;
+    }
+
     afile->offset = 0;
     afile->proc = (int (*)())0;
     return (void *)afile;