Add reference counting filesystem messages.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-06-15 00:37:57 +02:00
parent 2ea7607f4e
commit 740187674a
2 changed files with 30 additions and 1 deletions

View File

@ -312,7 +312,19 @@ struct fsm_req_rename
//char newname[newnamelen];
};
#define FSM_MSG_NUM 38
#define FSM_REQ_REFER 38
struct fsm_req_refer
{
ino_t ino;
};
#define FSM_REQ_UNREF 39
struct fsm_req_unref
{
ino_t ino;
};
#define FSM_MSG_NUM 40
#if defined(__cplusplus)
} /* extern "C" */

View File

@ -585,10 +585,27 @@ Unode::Unode(Ref<Server> server, ino_t ino, mode_t type)
this->ino = ino;
this->dev = (dev_t) server;
this->type = type;
// Let the remote know that the kernel is using this inode.
if ( Channel* channel = server->Connect() )
{
struct fsm_req_refer msg;
msg.ino = ino;
SendMessage(channel, FSM_REQ_REFER, &msg, sizeof(msg));
channel->KernelClose();
}
}
Unode::~Unode()
{
// Let the remote know that the kernel is no longer using this inode.
if ( Channel* channel = server->Connect() )
{
struct fsm_req_unref msg;
msg.ino = ino;
SendMessage(channel, FSM_REQ_UNREF, &msg, sizeof(msg));
channel->KernelClose();
}
}
bool Unode::SendMessage(Channel* channel, size_t type, void* ptr, size_t size,