]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
HGFS: Clean up and improve Linux client logging
authorVMware, Inc <>
Wed, 18 Sep 2013 03:34:19 +0000 (20:34 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Sep 2013 05:24:38 +0000 (22:24 -0700)
Enhancing existing log statements to be useful, moving open flags utility function
into the utility file as in the future it should be used by open and create
entry points.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/modules/linux/vmhgfs/file.c
open-vm-tools/modules/linux/vmhgfs/fsutil.c
open-vm-tools/modules/linux/vmhgfs/fsutil.h

index 0b69be1a71892c1e8585e0929f6f7b4c685530ea..3ba58e27e18730a6451c763a243f1fbb00e89609 100644 (file)
@@ -56,7 +56,6 @@ static int HgfsUnpackOpenReply(HgfsReq *req,
                                HgfsOp opUsed,
                                HgfsHandle *file,
                                HgfsLockType *lock);
-static int HgfsGetOpenFlags(uint32 flags);
 
 /* HGFS file operations for files. */
 static int HgfsOpen(struct inode *inode,
@@ -433,94 +432,6 @@ HgfsUnpackOpenReply(HgfsReq *req,          // IN: Packet with reply inside
 }
 
 
-/*
- *----------------------------------------------------------------------
- *
- * HgfsGetOpenFlags --
- *
- *    Based on the flags requested by the process making the open()
- *    syscall, determine which flags to send to the server to open the
- *    file.
- *
- * Results:
- *    Returns the correct HgfsOpenFlags enumeration to send to the
- *    server, or -1 on failure.
- *
- * Side effects:
- *    None
- *
- *----------------------------------------------------------------------
- */
-
-static int
-HgfsGetOpenFlags(uint32 flags) // IN: Open flags
-{
-   uint32 mask = O_CREAT | O_TRUNC | O_EXCL;
-   int result = -1;
-
-   LOG(6, (KERN_DEBUG "VMware hgfs: HgfsGetOpenFlags: entered\n"));
-
-   /*
-    * Mask the flags to only look at O_CREAT, O_EXCL, and O_TRUNC.
-    */
-
-   flags &= mask;
-
-   /* O_EXCL has no meaning if O_CREAT is not set. */
-   if (!(flags & O_CREAT)) {
-      flags &= ~O_EXCL;
-   }
-
-   /* Pick the right HgfsOpenFlags. */
-   switch (flags) {
-
-   case 0:
-      /* Regular open; fails if file nonexistant. */
-      result = HGFS_OPEN;
-      break;
-
-   case O_CREAT:
-      /* Create file; if it exists already just open it. */
-      result = HGFS_OPEN_CREATE;
-      break;
-
-   case O_TRUNC:
-      /* Truncate existing file; fails if nonexistant. */
-      result = HGFS_OPEN_EMPTY;
-      break;
-
-   case (O_CREAT | O_EXCL):
-      /* Create file; fail if it exists already. */
-      result = HGFS_OPEN_CREATE_SAFE;
-      break;
-
-   case (O_CREAT | O_TRUNC):
-      /* Create file; if it exists already, truncate it. */
-      result = HGFS_OPEN_CREATE_EMPTY;
-      break;
-
-   default:
-      /*
-       * This can only happen if all three flags are set, which
-       * conceptually makes no sense because O_EXCL and O_TRUNC are
-       * mutually exclusive if O_CREAT is set.
-       *
-       * However, the open(2) man page doesn't say you can't set all
-       * three flags, and certain apps (*cough* Nautilus *cough*) do
-       * so. To be friendly to those apps, we just silenty drop the
-       * O_TRUNC flag on the assumption that it's safer to honor
-       * O_EXCL.
-       */
-      LOG(4, (KERN_DEBUG "VMware hgfs: HgfsGetOpenFlags: invalid open "
-              "flags %o. Ignoring the O_TRUNC flag.\n", flags));
-      result = HGFS_OPEN_CREATE_SAFE;
-      break;
-   }
-
-   return result;
-}
-
-
 /*
  * HGFS file operations for files.
  */
index 4ce77ab7c2eb66e820367e9b94d3d1e2d6bbb7b3..f298b8d7fd102e59b2b2019143cac3c2911e9c0d 100644 (file)
@@ -1313,7 +1313,7 @@ HgfsGetOpenMode(uint32 flags) // IN: Open flags
    uint32 mask = O_RDONLY|O_WRONLY|O_RDWR;
    int result = -1;
 
-   LOG(6, (KERN_DEBUG "VMware hgfs: HgfsGetOpenMode: entered\n"));
+   LOG(6, (KERN_DEBUG "VMware hgfs: %s: (%u) entered\n", __func__, flags));
 
 
    /*
@@ -1347,6 +1347,96 @@ HgfsGetOpenMode(uint32 flags) // IN: Open flags
       break;
    }
 
+   LOG(6, (KERN_DEBUG "VMware hgfs: %s: return %d\n", __func__, result));
+   return result;
+}
+
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * HgfsGetOpenFlags --
+ *
+ *    Based on the flags requested by the process making the open()
+ *    syscall, determine which flags to send to the server to open the
+ *    file.
+ *
+ * Results:
+ *    Returns the correct HgfsOpenFlags enumeration to send to the
+ *    server, or -1 on failure.
+ *
+ * Side effects:
+ *    None
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+HgfsGetOpenFlags(uint32 flags) // IN: Open flags
+{
+   uint32 mask = O_CREAT | O_TRUNC | O_EXCL;
+   int result = -1;
+
+   LOG(6, (KERN_DEBUG "VMware hgfs: %s: (%u) entered\n", __func__, flags));
+
+   /*
+    * Mask the flags to only look at O_CREAT, O_EXCL, and O_TRUNC.
+    */
+
+   flags &= mask;
+
+   /* O_EXCL has no meaning if O_CREAT is not set. */
+   if (!(flags & O_CREAT)) {
+      flags &= ~O_EXCL;
+   }
+
+   /* Pick the right HgfsOpenFlags. */
+   switch (flags) {
+
+   case 0:
+      /* Regular open; fails if file nonexistant. */
+      result = HGFS_OPEN;
+      break;
+
+   case O_CREAT:
+      /* Create file; if it exists already just open it. */
+      result = HGFS_OPEN_CREATE;
+      break;
+
+   case O_TRUNC:
+      /* Truncate existing file; fails if nonexistant. */
+      result = HGFS_OPEN_EMPTY;
+      break;
+
+   case (O_CREAT | O_EXCL):
+      /* Create file; fail if it exists already. */
+      result = HGFS_OPEN_CREATE_SAFE;
+      break;
+
+   case (O_CREAT | O_TRUNC):
+      /* Create file; if it exists already, truncate it. */
+      result = HGFS_OPEN_CREATE_EMPTY;
+      break;
+
+   default:
+      /*
+       * This can only happen if all three flags are set, which
+       * conceptually makes no sense because O_EXCL and O_TRUNC are
+       * mutually exclusive if O_CREAT is set.
+       *
+       * However, the open(2) man page doesn't say you can't set all
+       * three flags, and certain apps (*cough* Nautilus *cough*) do
+       * so. To be friendly to those apps, we just silenty drop the
+       * O_TRUNC flag on the assumption that it's safer to honor
+       * O_EXCL.
+       */
+      LOG(4, (KERN_DEBUG "VMware hgfs: HgfsGetOpenFlags: invalid open "
+              "flags %o. Ignoring the O_TRUNC flag.\n", flags));
+      result = HGFS_OPEN_CREATE_SAFE;
+      break;
+   }
+
+   LOG(6, (KERN_DEBUG "VMware hgfs: %s: return %d\n", __func__, result));
    return result;
 }
 
index da5c5a119390123b6ed4ddf77e637fdd663b4745..f332fb6d8c147b00476d46083b022c6bed185d22 100644 (file)
@@ -82,6 +82,7 @@ int HgfsBuildPath(char *buffer,
 void HgfsDentryAgeReset(struct dentry *dentry);
 void HgfsDentryAgeForce(struct dentry *dentry);
 int HgfsGetOpenMode(uint32 flags);
+int HgfsGetOpenFlags(uint32 flags);
 int HgfsCreateFileInfo(struct file *file,
                        HgfsHandle handle);
 void HgfsReleaseFileInfo(struct file *file);