[freenos] [freenos commit] r201 - Moved FileType, FileMode, FileStat into separate header files.

  • From: codesite-noreply@xxxxxxxxxx
  • To: freenos@xxxxxxxxxxxxx
  • Date: Mon, 06 Jul 2009 18:42:43 +0000

Author: nieklinnenbank
Date: Mon Jul  6 11:14:22 2009
New Revision: 201

Added:
   trunk/srv/filesystem/FileMode.h
   trunk/srv/filesystem/FileStat.h
   trunk/srv/filesystem/FileType.h
Modified:
   trunk/lib/libposix/dirent.cpp
   trunk/lib/libposix/sys/stat.cpp
   trunk/srv/filesystem/FileSystemMessage.h
   trunk/srv/serial/SerialServer.cpp
   trunk/srv/terminal/TerminalServer.cpp

Log:
Moved FileType, FileMode, FileStat into separate header files.
Additionally, FileMode is now an enumeration with human readable values.


Modified: trunk/lib/libposix/dirent.cpp
==============================================================================
--- trunk/lib/libposix/dirent.cpp       (original)
+++ trunk/lib/libposix/dirent.cpp       Mon Jul  6 11:14:22 2009
@@ -18,7 +18,7 @@
 #include <API/IPCMessage.h>
 #include <Allocator.h>
 #include <Config.h>
-#include <FileSystemMessage.h>
+#include <FileType.h>
 #include <Directory.h>
 #include <errno.h>
 #include "dirent.h"

Modified: trunk/lib/libposix/sys/stat.cpp
==============================================================================
--- trunk/lib/libposix/sys/stat.cpp     (original)
+++ trunk/lib/libposix/sys/stat.cpp     Mon Jul  6 11:14:22 2009
@@ -55,7 +55,7 @@
     msg.buffer   = (char *) path;
     msg.deviceID = dev;
     msg.filetype = CharacterDeviceFile;
-    msg.mode     = mode;
+    msg.mode     = (FileMode) mode;

     /* Ask VFS to create the file for us. */
     IPCMessage(VFSSRV_PID, SendReceive, &msg, sizeof(msg));

Added: trunk/srv/filesystem/FileMode.h
==============================================================================
--- (empty file)
+++ trunk/srv/filesystem/FileMode.h     Mon Jul  6 11:14:22 2009
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2009 Niek Linnenbank
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __FILESYSTEM_FILEMODE_H
+#define __FILESYSTEM_FILEMODE_H
+
+/**
+ * File access permissions.
+ */
+typedef enum FileMode
+{
+    OwnerR   = 0400,
+    OwnerW   = 0200,
+    OwnerX   = 0100,
+    OwnerRW  = 0600,
+    OwnerRX  = 0500,
+    OwnerRWX = 0700,
+    GroupR   = 0040,
+    GroupW   = 0020,
+    GroupX   = 0010,
+    GroupRW  = 0060,
+    GroupRX  = 0050,
+    GroupRWX = 0070,
+    OtherR   = 0004,
+    OtherW   = 0002,
+    OtherX   = 0001,
+    OtherRW  = 0006,
+    OtherRX  = 0005,
+    OtherRWX = 0007,
+}
+FileMode;
+
+#endif /* __FILESYSTEM_FILEMODE_H */

Added: trunk/srv/filesystem/FileStat.h
==============================================================================
--- (empty file)
+++ trunk/srv/filesystem/FileStat.h     Mon Jul  6 11:14:22 2009
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2009 Niek Linnenbank
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __FILESYSTEM_FILESTAT_H
+#define __FILESYSTEM_FILESTAT_H
+
+#include <Types.h>
+#include "FileType.h"
+
+/**
+ * Contains file information.
+ */
+typedef struct FileStat
+{
+    /** File type. */
+    FileType type;
+
+    /** Size of the file in bytes. */
+    Size size;
+
+    /** User identity. */
+    UserID userID;
+
+    /** Group identity. */
+    GroupID groupID;
+
+    /** Device identity. */
+    DeviceID deviceID;
+}
+FileStat;
+
+#endif /* __FILESYSTEM_FILESTAT_H */

Modified: trunk/srv/filesystem/FileSystemMessage.h
==============================================================================
--- trunk/srv/filesystem/FileSystemMessage.h    (original)
+++ trunk/srv/filesystem/FileSystemMessage.h    Mon Jul  6 11:14:22 2009
@@ -22,6 +22,9 @@
 #include <IPCServer.h>
 #include <Types.h>
 #include <Error.h>
+#include "FileType.h"
+#include "FileMode.h"
+#include "FileStat.h"

 /**
  * Actions which may be performed on the filesystem.
@@ -45,47 +48,6 @@
 }
 FileSystemAction;

-/**
- * All possible filetypes.
- */
-typedef enum FileType
-{
-    RegularFile         = 0,
-    DirectoryFile       = 1,
-    BlockDeviceFile     = 2,
-    CharacterDeviceFile = 3,
-    SymlinkFile         = 4,
-    FIFOFile            = 5,
-    SocketFile         = 6,
-    UnknownFile                = 7,
-}
-FileType;
-
-/**
- * Contains file information.
- */
-typedef struct FileStat
-{
-    /** File type. */
-    FileType type;
-
-    /** Size of the file in bytes. */
-    Size size;
-
-    /** User identity. */
-    UserID userID;
-
-    /** Group identity. */
-    GroupID groupID;
-
-    /** Device identity. */
-    DeviceID deviceID;
-}
-FileStat;
-
-/** File access permissions. */
-typedef uint FileMode;
-
 /**
  * FileSystem IPC message.
  */
@@ -150,7 +112,7 @@
      * @param pid Process to send the request to.
      */
     void createFile(char *path, FileType type = RegularFile,
-                   FileMode mode = 0600, u16 major = ZERO,
+                   FileMode mode = OwnerRW, u16 major = ZERO,
                    u16 minor = ZERO, ProcessID pid = VFSSRV_PID)
     {
        this->action   = CreateFile;

Added: trunk/srv/filesystem/FileType.h
==============================================================================
--- (empty file)
+++ trunk/srv/filesystem/FileType.h     Mon Jul  6 11:14:22 2009
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2009 Niek Linnenbank
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __FILESYSTEM_FILETYPE_H
+#define __FILESYSTEM_FILETYPE_H
+
+/**
+ * All possible filetypes.
+ */
+typedef enum FileType
+{
+    RegularFile         = 0,
+    DirectoryFile       = 1,
+    BlockDeviceFile     = 2,
+    CharacterDeviceFile = 3,
+    SymlinkFile         = 4,
+    FIFOFile            = 5,
+    SocketFile         = 6,
+    UnknownFile                = 7,
+}
+FileType;
+
+#endif /* __FILESYSTEM_FILETYPE_H */

Modified: trunk/srv/serial/SerialServer.cpp
==============================================================================
--- trunk/srv/serial/SerialServer.cpp   (original)
+++ trunk/srv/serial/SerialServer.cpp   Mon Jul  6 11:14:22 2009
@@ -18,6 +18,7 @@
 #include <API/IPCMessage.h>
 #include <API/ProcessCtl.h>
 #include <FileSystemMessage.h>
+#include <FileMode.h>
 #include <ProcessMessage.h>
 #include <LogMessage.h>
 #include <Config.h>
@@ -71,7 +72,7 @@
            snprintf(path, sizeof(path), "/dev/serial%u", i);

            /* Create the file. */
-           fs.createFile(path, CharacterDeviceFile, 0600,
+           fs.createFile(path, CharacterDeviceFile, OwnerRW,
                          proc.pid(), i);
                        
            /* Register IRQ handler. */

Modified: trunk/srv/terminal/TerminalServer.cpp
==============================================================================
--- trunk/srv/terminal/TerminalServer.cpp       (original)
+++ trunk/srv/terminal/TerminalServer.cpp       Mon Jul  6 11:14:22 2009
@@ -24,6 +24,7 @@
 #include <IPCServer.h>
 #include <FileSystem.h>
 #include <FileSystemMessage.h>
+#include <FileMode.h>
 #include <ProcessMessage.h>
 #include "TerminalServer.h"
 #include "Terminal.h"
@@ -58,7 +59,7 @@
        snprintf(path, sizeof(path), "/dev/tty%d", i);
        
        /* Create device file. */
-       fs.createFile(path, CharacterDeviceFile, 0600, proc.pid(), i);
+       fs.createFile(path, CharacterDeviceFile, OwnerRW, proc.pid(), i);
        
        /* Allocate a Terminal. */
        term = new Terminal;
@@ -70,7 +71,7 @@
     }
     /* Points to the currently active console. */
     snprintf(path, sizeof(path), "/dev/console");
-    fs.createFile(path, CharacterDeviceFile, 0200, proc.pid(), CONSOLE);
+    fs.createFile(path, CharacterDeviceFile, OwnerW, proc.pid(), CONSOLE);

     /* Activate current console. */
     current = terminals[0];

Other related posts:

  • » [freenos] [freenos commit] r201 - Moved FileType, FileMode, FileStat into separate header files. - codesite-noreply