]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Changes in shared code that don't affect open-vm-tools functionality.
authorVMware, Inc <>
Tue, 24 Aug 2010 18:18:12 +0000 (11:18 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 24 Aug 2010 18:18:12 +0000 (11:18 -0700)
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/file/fileIOPosix.c
open-vm-tools/lib/include/fileIO.h

index 6f4a0591dc912f05c38f4f4ee635af36f882dc81..ba28bc8baa574d571b8ba816749c8b752e2923b5 100644 (file)
@@ -2176,9 +2176,9 @@ FileIO_PrivilegedPosixOpen(ConstUnicode pathName,  // IN:
 /*
  *-----------------------------------------------------------------------------
  *
- * FileIO_FDToStream
+ * FileIO_DescriptorToStream
  *
- *      Return a FILE * stream equivalent to the given (POSIX) file descriptor.
+ *      Return a FILE * stream equivalent to the given FileIODescriptor.
  *      This is the logical equivalent of Posix dup() then fdopen().
  *
  *      Caller should fclose the returned descriptor when finished.
@@ -2193,58 +2193,20 @@ FileIO_PrivilegedPosixOpen(ConstUnicode pathName,  // IN:
  *-----------------------------------------------------------------------------
  */
 
-
 FILE *
-FileIO_FDToStream(int fd,            // IN:
-                  const char *mode,  // IN:
-                  Bool textMode)     // IN: unused
+FileIO_DescriptorToStream(FileIODescriptor *fdesc,  // IN:
+                          Bool textMode)            // IN: unused
 {
    int dupFD;
+   const char *mode;
+   int tmpFlags;
    FILE *stream;
 
-   dupFD = dup(fd);
-
+   dupFD = dup(fdesc->posix);
    if (dupFD == -1) {
       return NULL;
    }
 
-   stream = fdopen(dupFD, mode);
-
-   if (stream == NULL) {
-      close(dupFD);
-   }
-
-   return stream;
-}
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * FileIO_DescriptorToStream
- *
- *      Return a FILE * stream equivalent to the given FileIODescriptor.
- *      This is the logical equivalent of Posix dup() then fdopen().
- *
- *      Caller should fclose the returned descriptor when finished.
- *
- * Results:
- *      !NULL  A FILE * associated with the file associated with the fd
- *      NULL   Failure
- *
- * Side effects:
- *      New fd allocated.
- *
- *-----------------------------------------------------------------------------
- */
-
-FILE *
-FileIO_DescriptorToStream(FileIODescriptor *fdesc,  // IN:
-                          Bool textMode)            // IN: unused
-{
-   int tmpFlags;
-   const char *mode;
-
    /* The file you pass us should be valid and opened for *something* */
    ASSERT(FileIO_IsValid(fdesc));
    ASSERT((fdesc->flags & (FILEIO_OPEN_ACCESS_READ | FILEIO_OPEN_ACCESS_WRITE)) != 0);
@@ -2258,7 +2220,13 @@ FileIO_DescriptorToStream(FileIODescriptor *fdesc,  // IN:
       mode = "r";
    }
 
-   return FileIO_FDToStream(fdesc->posix, mode, textMode);
+   stream = fdopen(dupFD, mode);
+
+   if (stream == NULL) {
+      close(dupFD);
+   }
+
+   return stream;
 }
 
 
index bb3ab1129c5506f4882db6458706cc7e1bf988ab..51003c5f64133bec6db4d42f9a3335c273b4128c 100644 (file)
@@ -371,10 +371,6 @@ int FileIO_PrivilegedPosixOpen(ConstUnicode pathName,
                                int flags);
 #endif
 
-FILE *FileIO_FDToStream(int fd,
-                        const char *mode,
-                        Bool textMode);
-
 FILE *FileIO_DescriptorToStream(FileIODescriptor *fd,
                                 Bool textMode);