[freenos] r288 committed - Added a File::open() virtual function....

  • From: codesite-noreply@xxxxxxxxxx
  • To: freenos@xxxxxxxxxxxxx
  • Date: Sun, 02 Aug 2009 13:51:50 +0000

Revision: 288
Author: nieklinnenbank
Date: Sun Aug  2 05:25:43 2009
Log: Added a File::open() virtual function.
The Special class uses this function to override the ProcessID and
identity of the final FileDescriptor created later on in FileSystem.h.
Additionally, removed deprecated this->referenceCount and removed
references to obselete fields in FileSystemMessage.

http://code.google.com/p/freenos/source/detail?r=288

Modified:
 /trunk/srv/filesystem/File.h
 /trunk/srv/filesystem/FileStat.h

=======================================
--- /trunk/srv/filesystem/File.h        Mon Jun 29 00:56:11 2009
+++ /trunk/srv/filesystem/File.h        Sun Aug  2 05:25:43 2009
@@ -23,9 +23,12 @@
 #include <Types.h>
 #include <Error.h>
 #include "FileSystemMessage.h"
+#include "FileType.h"
+#include "FileMode.h"

 /**
- * Abstracts a file which is opened by a process.
+ * @brief Abstracts a file present on a FileSystem.
+ * @see FileSystem
  */
 class File
 {
@@ -38,8 +41,8 @@
         * @param g Group identity.
         */
        File(FileType t = RegularFile, UserID u = ZERO, GroupID g = ZERO)
-           : type(t), size(ZERO), refCount(ZERO), openCount(ZERO),
-             uid(u), gid(g)
+           : type(t), access(OwnerRWX), size(ZERO),
+             openCount(ZERO), uid(u), gid(g)
        {
        }

@@ -58,35 +61,6 @@
        {
            return type;
        }
-
-       /**
-        * Get the number of times we are referenced internally.
-        * @return Reference count.
-        * @see refCount
-        */
-       Size getRefCount()
-       {
-           return refCount;
-       }
-
-       /**
-        * Enlarge the number of times we are referenced by one.
-        * @see refCount
-        */
-       void incrementRefCount()
-       {
-           refCount++;
-       }
-
-       /**
-        * Shrink the number of times we are referenced by one.
-        * @see refCount
-        */
-       void decrementRefCount()
-       {
-           if (refCount > 0) refCount--;
-       }
-

        /**
         * Get the number of times we are opened by a process.
@@ -97,32 +71,30 @@
        {
            return openCount;
        }
-
+
        /**
-        * Enlarge the number of times we are opened by one.
-        * @see openCount
+        * Attempt to open a file.
+        * @param msg Describes the open request.
+        * @param pid Process Identity to serve us from. May be changed
+        *            to redirect to other servers.
+        * @param ident Identity to be filled in the FileDescriptor.
+        * @return Error code status.
         */
-       void incrementOpenCount()
+       virtual Error open(FileSystemMessage *msg,
+                          ProcessID *pid, Address *ident)
        {
            openCount++;
+           return ESUCCESS;
        }

        /**
-        * Shrink the number of times we are opened by one.
-        * @see openCount
-        */
-       void decrementOpenCount()
-       {
-           if (openCount > 0) openCount--;
-       }
-
-       /**
-        * Attempt to open a file.
-        * @param msg Describes the open request.
+        * @brief Attempt to close a file.
+        * @param msg Describes the closing request.
         * @return Error code status.
         */
-       virtual Error open(FileSystemMessage *msg)
-       {
+       virtual Error close(FileSystemMessage *msg)
+       {
+           openCount--;
            return ESUCCESS;
        }

@@ -157,12 +129,13 @@

            /* Fill in the status structure. */
            st.type     = type;
+           st.access   = access;
            st.size     = size;
            st.userID   = uid;
            st.groupID  = gid;

            /* Copy to the remote process. */
-           if ((e = VMCopy(msg->procID, Write, (Address) &st,
+           if ((e = VMCopy(msg->from, Write, (Address) &st,
                           (Address) msg->stat, sizeof(st)) > 0))
            {
                return ESUCCESS;
@@ -173,15 +146,15 @@

     protected:

-       /** File of this file. */
+       /** Type of this file. */
        FileType type;

+       /** Access permissions. */
+       FileModes access;
+
        /** Size of the file, in bytes. */
        Size size;

-       /** Number of times the File is referenced internally. */
-       Size refCount;
-
        /** Number of times the File has been opened by a process. */
        Size openCount;

=======================================
--- /trunk/srv/filesystem/FileStat.h    Tue Jul  7 02:24:01 2009
+++ /trunk/srv/filesystem/FileStat.h    Sun Aug  2 05:25:43 2009
@@ -30,7 +30,7 @@
     FileType type;

     /** File access permission bits. */
-    FileMode access;
+    FileModes access;

     /** Size of the file in bytes. */
     Size size;

Other related posts:

  • » [freenos] r288 committed - Added a File::open() virtual function.... - codesite-noreply