From owner-freebsd-hackers Mon Aug 27 4:32:34 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from bugz.infotecs.ru (bugz.infotecs.ru [195.210.139.22]) by hub.freebsd.org (Postfix) with ESMTP id 3903E37B409 for ; Mon, 27 Aug 2001 04:32:31 -0700 (PDT) (envelope-from vel@bugz.infotecs.ru) Received: (from root@localhost) by bugz.infotecs.ru (8.11.6/8.11.4) id f7RBVs902785; Mon, 27 Aug 2001 15:31:55 +0400 (MSD) (envelope-from vel) From: "Eugene L. Vorokov" Message-Id: <200108271131.f7RBVs902785@bugz.infotecs.ru> Subject: Re: problem with unloading device driver To: dima@unixfreak.org (Dima Dorfman) Date: Mon, 27 Aug 2001 15:31:54 +0400 (MSD) Cc: freebsd-hackers@freebsd.org In-Reply-To: <20010827111601.BA49D3E2F@bazooka.unixfreak.org> from "Dima Dorfman" at Aug 27, 2001 04:15:56 AM X-Mailer: ELM [version 2.5 PL5] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 > > 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. Oh yes ... but I thought kernel should know that I unloaded the driver and close associated fd's, returning some error code when a program still tries to operate on them. Anyway, I now return EBUSY, and it works fine. Thanks ! Regards, Eugene To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message