From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 10 15:30:18 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 83F0016A421 for ; Wed, 10 Aug 2005 15:30:18 +0000 (GMT) (envelope-from myself@rojer.pp.ru) Received: from hermes.hw.ru (hermes.hw.ru [80.68.240.91]) by mx1.FreeBSD.org (Postfix) with ESMTP id EFAD943D45 for ; Wed, 10 Aug 2005 15:30:17 +0000 (GMT) (envelope-from myself@rojer.pp.ru) Received: from [80.68.243.98] (account rojer@rbc.ru HELO [80.68.243.98]) by hermes.hw.ru (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 89073769 for freebsd-hackers@freebsd.org; Wed, 10 Aug 2005 19:30:15 +0400 Message-ID: <42FA1D86.9000506@rojer.pp.ru> Date: Wed, 10 Aug 2005 19:30:14 +0400 From: Deomid Ryabkov User-Agent: Thunderbird 1.0+ (X11/20050731) MIME-Version: 1.0 To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: filesystem implementation questions X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2005 15:30:18 -0000 Hello, hackers :) I am implementing a custom filesystem, based on nullfs, its purpose is tracking changes made to the fs, and the idea is to do that by changing the semantics of (largely unused anyway) atime attribute of the underlying UFS (which is mounted -o noatime for that reason. and I don't really care about filesystems with no atime attribute. extreme portability is not a requirement). Specifically, I want atime updated on directories from where the change has taken place all the way up to the mount point of my filesystem. This way, a tree of changed directories can be built at any given time and synchronised to mirrors. Now, I have a couple of questions about taking proper actions while doing my job inside the kernel. 1) I understand that it is generally impossible to find a parent directory for VREG or VLNK vnode (I don't care about pipes or sockets), as it may have many links. To overcome this, I store a pointer to a parent vnode as a member of my struct mirrfs_node upon successful lookup or creation of VREG vnode and create an additional refernce to the parent vnode. The refernce to parent is released when VREG vnode becomes inactive. The question is, what might be the implications of this? Could it be that I am doing something terribly wrong? 2) Each time I need to propagate a change, I walk my way up the directories starting at the directory where the change has occured by repeatedly calling VOP_LOOKUP with a hand-crafted struct componentname, where cnp.cn_nameptr is ".." Same question: is it the right thing to do? could this get me in trouble? 3) When updating directories while walking up, I might need root privileges which my curthread might not have. It is undesirable and might be impossible to have permissions needed for setattr to succeed for every curthread. So, I know what I am doing and I need root for that. The question is, what is the right way to get the needed struct ucred? I thought about crcopy'ing curthread->td_ucred and then change_[er]uid on it. Is that ok? Are there any implications? Thanks in advance... -- Deomid Ryabkov aka Rojer myself@rojer.pp.ru rojer@sysadmins.ru ICQ: 8025844