diff --git a/libc/include/fsmarshall-msg.h b/libc/include/fsmarshall-msg.h index bbad39af..427c237a 100644 --- a/libc/include/fsmarshall-msg.h +++ b/libc/include/fsmarshall-msg.h @@ -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" */ diff --git a/sortix/fs/user.cpp b/sortix/fs/user.cpp index bec77d4c..77347e94 100644 --- a/sortix/fs/user.cpp +++ b/sortix/fs/user.cpp @@ -585,10 +585,27 @@ Unode::Unode(Ref 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,