[haiku-commits] r42045 - haiku/trunk/src/add-ons/kernel/file_systems/ramfs

  • From: kallisti5@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 8 Jun 2011 05:14:00 +0200 (CEST)

Author: kallisti5
Date: 2011-06-08 05:13:59 +0200 (Wed, 08 Jun 2011)
New Revision: 42045
Changeset: https://dev.haiku-os.org/changeset/42045

Modified:
   haiku/trunk/src/add-ons/kernel/file_systems/ramfs/Volume.cpp
   haiku/trunk/src/add-ons/kernel/file_systems/ramfs/Volume.h
   haiku/trunk/src/add-ons/kernel/file_systems/ramfs/kernel_interface.cpp
Log:
begin reorganizing ramfs callback parameters to match new filesystem driver 
standard; correct incorrect style fix as per Ingo; correct layout of fs 
operation mapping struct

Modified: haiku/trunk/src/add-ons/kernel/file_systems/ramfs/Volume.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/ramfs/Volume.cpp        
2011-06-08 02:56:54 UTC (rev 42044)
+++ haiku/trunk/src/add-ons/kernel/file_systems/ramfs/Volume.cpp        
2011-06-08 03:13:59 UTC (rev 42045)
@@ -166,7 +166,7 @@
 
 // Mount
 status_t
-Volume::Mount(dev_t id)
+Volume::Mount(uint32 flags)
 {
        Unmount();
 

Modified: haiku/trunk/src/add-ons/kernel/file_systems/ramfs/Volume.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/ramfs/Volume.h  2011-06-08 
02:56:54 UTC (rev 42044)
+++ haiku/trunk/src/add-ons/kernel/file_systems/ramfs/Volume.h  2011-06-08 
03:13:59 UTC (rev 42045)
@@ -96,7 +96,7 @@
                                                        Volume(fs_volume* 
volume);
                                                        ~Volume();
 
-       status_t Mount(dev_t nsid);
+       status_t Mount(uint32 flags);
        status_t Unmount();
 
        dev_t GetID() const { return fID; }

Modified: haiku/trunk/src/add-ons/kernel/file_systems/ramfs/kernel_interface.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/file_systems/ramfs/kernel_interface.cpp      
2011-06-08 02:56:54 UTC (rev 42044)
+++ haiku/trunk/src/add-ons/kernel/file_systems/ramfs/kernel_interface.cpp      
2011-06-08 03:13:59 UTC (rev 42045)
@@ -80,8 +80,8 @@
 
 // ramfs_mount
 static status_t
-ramfs_mount(dev_t nsid, const char* /*device*/, uint32 flags,
-       const char* /*args*/, fs_volume* _volume, ino_t* rootID)
+ramfs_mount(fs_volume* _volume, const char* /*device*/, uint32 flags,
+       const char* /*args*/, ino_t* _rootID)
 {
        FUNCTION_START();
        // parameters are ignored for now
@@ -96,14 +96,14 @@
        if (volume == NULL)
                return B_NO_MEMORY;
 
-       status_t status = volume->Mount(nsid);
+       status_t status = volume->Mount(flags);
 
        if (status != B_OK) {
                delete volume;
                RETURN_ERROR(status);
        }
 
-       *rootID = volume->GetRootDirectory()->GetID();
+       *_rootID = volume->GetRootDirectory()->GetID();
        _volume->private_volume = volume;
 
        RETURN_ERROR(B_OK);
@@ -169,7 +169,7 @@
 
 // ramfs_sync
 static status_t
-ramfs_sync(fs_volume /*fs*/)
+ramfs_sync(fs_volume* /*fs*/)
 {
        FUNCTION_START();
        return B_OK;
@@ -181,8 +181,8 @@
 
 // ramfs_lookup
 static status_t
-ramfs_lookup(fs_volume* _volume, fs_vnode* _dir, const char *entryName,
-       ino_t *vnid, int *type)
+ramfs_lookup(fs_volume* _volume, fs_vnode* _dir, const char* entryName,
+       ino_t* _vnodeID)
 {
 //     FUNCTION_START();
        Volume* volume = (Volume*)_volume->private_volume;
@@ -201,13 +201,13 @@
 
                // special entries: "." and ".."
                if (!strcmp(entryName, ".")) {
-                       *vnid = dir->GetID();
-                       if (volume->GetVNode(*vnid, &node) != B_OK)
+                       *_vnodeID = dir->GetID();
+                       if (volume->GetVNode(*_vnodeID, &node) != B_OK)
                                error = B_BAD_VALUE;
                } else if (!strcmp(entryName, "..")) {
                        Directory *parent = dir->GetParent();
                        if (parent && volume->GetVNode(parent->GetID(), &node) 
== B_OK)
-                               *vnid = node->GetID();
+                               *_vnodeID = node->GetID();
                        else
                                error = B_BAD_VALUE;
 
@@ -217,12 +217,9 @@
                        error = dir->FindAndGetNode(entryName, &node);
 SET_ERROR(error, error);
                        if (error == B_OK)
-                               *vnid = node->GetID();
+                               *_vnodeID = node->GetID();
                }
 
-               // get the node's type
-               if (error == B_OK)
-                       *type = node->GetMode() & S_IFMT;
        } else
                SET_ERROR(error, B_ERROR);
        RETURN_ERROR(error);
@@ -250,7 +247,7 @@
 
 // ramfs_write_vnode
 static status_t
-ramfs_write_vnode(fs_volume /*fs*/, fs_vnode DARG(_node), bool /*reenter*/)
+ramfs_write_vnode(fs_volume* /*fs*/, fs_vnode* DARG(_node), bool /*reenter*/)
 {
 // DANGER: If dbg_printf() is used, this thread will enter another FS and
 // even perform a write operation. The is dangerous here, since this hook
@@ -287,7 +284,7 @@
 
 // ramfs_ioctl
 static status_t
-ramfs_ioctl(fs_volume* _volume, fs_vnode /*node*/, void** /*cookie*/,
+ramfs_ioctl(fs_volume* _volume, fs_vnode* /*node*/, void** /*cookie*/,
        uint32 cmd, void *buffer, size_t /*length*/)
 {
        FUNCTION_START();
@@ -337,7 +334,7 @@
 
 // ramfs_set_flags
 static status_t
-ramfs_set_flags(fs_volume /*fs*/, fs_vnode /*node*/, void** /*cookie*/,
+ramfs_set_flags(fs_volume* /*fs*/, fs_vnode* /*node*/, void** /*cookie*/,
        int /*flags*/)
 {
        FUNCTION_START();
@@ -348,7 +345,7 @@
 
 // ramfs_fsync
 static status_t
-ramfs_fsync(fs_volume /*fs*/, fs_vnode /*node*/)
+ramfs_fsync(fs_volume* /*fs*/, fs_vnode* /*node*/)
 {
        FUNCTION_START();
        return B_OK;
@@ -751,29 +748,26 @@
 // FileCookie
 class FileCookie {
 public:
-                                                       FileCookie(int 
openMode) : fOpenMode(openMode),
-                                                               
fLastNotificationTime(0) {}
+       FileCookie(int openMode) : fOpenMode(openMode), 
fLastNotificationTime(0) {}
 
-                       inline int              GetOpenMode() { return 
fOpenMode; }
+       inline int GetOpenMode() { return fOpenMode; }
+       inline bigtime_t GetLastNotificationTime() { return 
fLastNotificationTime; }
 
-                       inline bigtime_t GetLastNotificationTime()
-                                                               { return 
fLastNotificationTime; }
+       inline bool     NotificationIntervalElapsed(bool set = false)
+       {
+               bigtime_t currentTime = system_time();
+               bool result = (currentTime
+                       - fLastNotificationTime > kNotificationInterval);
 
-                       inline bool             
NotificationIntervalElapsed(bool set = false)
-                                                               {
-                                                                       
bigtime_t currentTime = system_time();
-                                                                       bool 
result = (currentTime
-                                                                               
- fLastNotificationTime
-                                                                               
        > kNotificationInterval);
-                                                                       if (set 
&& result)
-                                                                               
fLastNotificationTime = currentTime;
+               if (set && result)
+                       fLastNotificationTime = currentTime;
 
-                                                                       return 
result;
-                                                               }
+               return result;
+       }
 
 private:
-                       int                             fOpenMode;
-                       bigtime_t               fLastNotificationTime;
+       int fOpenMode;
+       bigtime_t fLastNotificationTime;
 };
 
 
@@ -927,7 +921,7 @@
 
 // ramfs_free_cookie
 static status_t
-ramfs_free_cookie(fs_volume /*fs*/, fs_vnode /*_node*/, void** _cookie)
+ramfs_free_cookie(fs_volume* /*fs*/, fs_vnode* /*_node*/, void** _cookie)
 {
        FUNCTION_START();
        FileCookie *cookie = (FileCookie*)_cookie;
@@ -1209,7 +1203,7 @@
 
 // ramfs_open_dir
 static status_t
-ramfs_open_dir(fs_volume /*fs*/, fs_vnode* _node, void** _cookie)
+ramfs_open_dir(fs_volume* /*fs*/, fs_vnode* _node, void** _cookie)
 {
 //     FUNCTION_START();
 //     Volume *volume = (Volume*)fs;
@@ -1246,7 +1240,7 @@
 
 // ramfs_close_dir
 static status_t
-ramfs_close_dir(fs_volume /*fs*/, fs_vnode DARG(_node), void** _cookie)
+ramfs_close_dir(fs_volume* /*fs*/, fs_vnode* DARG(_node), void** _cookie)
 {
        FUNCTION_START();
        FUNCTION(("dir: (%Lu)\n", ((Node*)_node)->GetID()));
@@ -1260,7 +1254,7 @@
 
 // ramfs_free_dir_cookie
 static status_t
-ramfs_free_dir_cookie(fs_volume /*fs*/, fs_vnode /*_node*/, void** _cookie)
+ramfs_free_dir_cookie(fs_volume* /*fs*/, fs_vnode* /*_node*/, void** _cookie)
 {
        FUNCTION_START();
        DirectoryCookie *cookie = (DirectoryCookie*)_cookie;
@@ -1271,7 +1265,7 @@
 
 // ramfs_read_dir
 static status_t
-ramfs_read_dir(fs_volume* _volume, fs_vnode DARG(_node), void** _cookie,
+ramfs_read_dir(fs_volume* _volume, fs_vnode* DARG(_node), void** _cookie,
        struct dirent *buffer, size_t bufferSize, uint32 *count)
 {
        FUNCTION_START();
@@ -1317,7 +1311,7 @@
 
 // ramfs_rewind_dir
 static status_t
-ramfs_rewind_dir(fs_volume /*fs*/, fs_vnode /*_node*/, void** _cookie)
+ramfs_rewind_dir(fs_volume* /*fs*/, fs_vnode* /*_node*/, void** _cookie)
 {
        FUNCTION_START();
        // No locking needed, since the Directory is guaranteed to live at this
@@ -1366,7 +1360,7 @@
 
 // ramfs_close_attr_dir
 static status_t
-ramfs_close_attr_dir(fs_volume /*fs*/, fs_vnode /*_node*/, void** _cookie)
+ramfs_close_attr_dir(fs_volume* /*fs*/, fs_vnode* /*_node*/, void** _cookie)
 {
        FUNCTION_START();
        // No locking needed, since the Node is guaranteed to live at this time
@@ -1379,7 +1373,7 @@
 
 // ramfs_free_attr_dir_cookie
 static status_t
-ramfs_free_attr_dir_cookie(fs_volume /*fs*/, fs_vnode /*_node*/,
+ramfs_free_attr_dir_cookie(fs_volume* /*fs*/, fs_vnode* /*_node*/,
        void** _cookie)
 {
        FUNCTION_START();
@@ -1393,7 +1387,7 @@
 
 // ramfs_read_attr_dir
 static status_t
-ramfs_read_attr_dir(fs_volume* _volume, fs_vnode _node, void** _cookie,
+ramfs_read_attr_dir(fs_volume* _volume, fs_vnode* _node, void** _cookie,
        struct dirent *buffer, size_t bufferSize, uint32 *count)
 {
        FUNCTION_START();
@@ -1436,7 +1430,7 @@
 
 // ramfs_rewind_attr_dir
 static status_t
-ramfs_rewind_attr_dir(fs_volume /*fs*/, fs_vnode /*_node*/, void** _cookie)
+ramfs_rewind_attr_dir(fs_volume* /*fs*/, fs_vnode* /*_node*/, void** _cookie)
 {
        FUNCTION_START();
        // No locking needed, since the Node is guaranteed to live at this time
@@ -1643,7 +1637,7 @@
 
 // ramfs_free_attr_cookie
 static status_t
-ramfs_free_attr_cookie(fs_volume /*fs*/, fs_vnode /*_node*/, void** _cookie)
+ramfs_free_attr_cookie(fs_volume* /*fs*/, fs_vnode* /*_node*/, void** _cookie)
 {
        FUNCTION_START();
        AttributeCookie *cookie = (AttributeCookie*)_cookie;
@@ -1768,8 +1762,8 @@
 
 // ramfs_rename_attr
 static status_t
-ramfs_rename_attr(fs_volume /*fs*/, fs_vnode /*_fromNode*/,
-       const char */*fromName*/, fs_vnode /*_toNode*/, const char */*toName*/)
+ramfs_rename_attr(fs_volume* /*fs*/, fs_vnode* /*_fromNode*/,
+       const char */*fromName*/, fs_vnode* /*_toNode*/, const char */*toName*/)
 {
        // TODO : ramfs_rename_attr
        return B_BAD_VALUE;
@@ -1849,7 +1843,7 @@
 
 // ramfs_close_index_dir
 static status_t
-ramfs_close_index_dir(fs_volume /*fs*/, void** /*_cookie*/)
+ramfs_close_index_dir(fs_volume* /*fs*/, void** /*_cookie*/)
 {
        FUNCTION_START();
        return B_OK;
@@ -1858,7 +1852,7 @@
 
 // ramfs_free_index_dir_cookie
 static status_t
-ramfs_free_index_dir_cookie(fs_volume /*fs*/, void** _cookie)
+ramfs_free_index_dir_cookie(fs_volume* /*fs*/, void** _cookie)
 {
        FUNCTION_START();
        IndexDirCookie *cookie = (IndexDirCookie*)_cookie;
@@ -1908,7 +1902,7 @@
 
 // ramfs_rewind_index_dir
 static status_t
-ramfs_rewind_index_dir(fs_volume /*fs*/, void** _cookie)
+ramfs_rewind_index_dir(fs_volume* /*fs*/, void** _cookie)
 {
        FUNCTION_START();
        IndexDirCookie *cookie = (IndexDirCookie*)_cookie;
@@ -2063,7 +2057,7 @@
 
 // ramfs_close_query
 static status_t
-ramfs_close_query(fs_volume /*fs*/, void** /*cookie*/)
+ramfs_close_query(fs_volume* /*fs*/, void** /*cookie*/)
 {
        FUNCTION_START();
        return B_OK;
@@ -2151,7 +2145,7 @@
        &ramfs_read_fs_info,
        &ramfs_write_fs_info,
        &ramfs_sync,
-       &ramfs_get_vnode,
+       &ramfs_read_vnode,
 
        /* index directory & index operations */
        &ramfs_open_index_dir,
@@ -2177,7 +2171,6 @@
        /* vnode operations */
        &ramfs_lookup,                  // lookup
        NULL,                                   // get name
-       &ramfs_read_vnode,              // read
        &ramfs_write_vnode,             // write
        &ramfs_remove_vnode,    // remove
 
@@ -2245,6 +2238,8 @@
        NULL,   // &ramfs_write_attr_stat,
        &ramfs_rename_attr,
        &ramfs_remove_attr,
+
+       /* special nodes */
        NULL    // create_special_node
 };
 


Other related posts:

  • » [haiku-commits] r42045 - haiku/trunk/src/add-ons/kernel/file_systems/ramfs - kallisti5