From owner-freebsd-hackers Mon Aug 27 4:16: 5 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from bazooka.unixfreak.org (bazooka.unixfreak.org [63.198.170.138]) by hub.freebsd.org (Postfix) with ESMTP id 2077837B408 for ; Mon, 27 Aug 2001 04:16:02 -0700 (PDT) (envelope-from dima@unixfreak.org) Received: by bazooka.unixfreak.org (Postfix, from userid 1000) id BA49D3E2F; Mon, 27 Aug 2001 04:16:01 -0700 (PDT) Received: from bazooka.unixfreak.org (localhost [127.0.0.1]) by bazooka.unixfreak.org (Postfix) with ESMTP id AF2783C12D; Mon, 27 Aug 2001 04:16:01 -0700 (PDT) To: "Eugene L. Vorokov" Cc: freebsd-hackers@freebsd.org Subject: Re: problem with unloading device driver In-Reply-To: <200108270943.f7R9hf901857@bugz.infotecs.ru>; from vel@bugz.infotecs.ru on "Mon, 27 Aug 2001 13:43:41 +0400 (MSD)" Date: Mon, 27 Aug 2001 04:15:56 -0700 From: Dima Dorfman Message-Id: <20010827111601.BA49D3E2F@bazooka.unixfreak.org> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG "Eugene L. Vorokov" wrote: > Hello, > > I have a module which adds new device. It does make_dev() and then simulates > mknod() syscall, so that /dev/name is always automatically created. > Also I have a daemon which reads from and writes to this device. The daemon > opens the device once and then holds it open. When my module unloads, > it simulates unlink() and then does detsroy_dev(). I just noticed that > when I unload my module, the first write() by daemon to the fd associated with > that device causes system to crash. Trace looks like this: You're unloading your module while something still has an fd associated with a device it provides? How do you expect that to work? The right thing to do would be to keep track of how many times your device has been opened, and fail to unload (return an error from the modevent handler) if something still has it open. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message