Page 1 of 1

Devices which are Expunged but don't leave...

PostPosted: Sat Mar 18, 2017 2:45 pm
by Spirantho
Hi everybody,

In my device I have a little Expunge function which just sets md->cw_device.dd_Library.lib_Flags |= LIBF_DELEXP and returns 0.

In the past I could get rid of the device using an avail flush or whatever, but now nothing I seem to do (since I updated to FE?) gets rid of the old device code so I have to keep rebooting to try my new builds.
Is there an example of what should be in my Expunge() routine to make it leave cleanly?

Thanks!

Re: Devices which are Expunged but don't leave...

PostPosted: Sat Mar 18, 2017 11:18 pm
by trixie
@Spirantho

I've never coded a device but I'd say that the expunge procedure will be similar to (if not the same as) that of a library.

Normally, in the expunge function you should check the library instance counter (lib_OpenCnt), and if it is > 0, set lib_Flags |= LIBF_DELEXP and return 0 (LIBF_DELEXP stands for delayed expunge: something else is still using the library, so we can't expunge right now). If the counter == 0, you do your library cleanup, then IExec->Remove() from the system library list, and IExec->DeleteLibrary().

Re: Devices which are Expunged but don't leave...

PostPosted: Sun Mar 19, 2017 8:49 pm
by tboeckel
The latest SDK should include the "Expunge" tool to specifically expunge single libraries/devices (i.e. "Expunge my.device") or multiple libraries/devices matching a pattern (i.e. "Expunge my_#?.device" to expunge "my_first.device" and "my_second.device") from memory.

Apart from that you should obey what Trixie already said. The LIBF_DELEXP flag should only be set if your library/device cannot be expunged when your Expunge vector is called, because it is still opened. But if there are no living instances then you should of course do the actual expunging. When else would you do it otherwise if no in the Expunge vector?

Re: Devices which are Expunged but don't leave...

PostPosted: Mon Mar 20, 2017 8:43 pm
by ssolie
Spirantho wrote:In the past I could get rid of the device using an avail flush or whatever, but now nothing I seem to do (since I updated to FE?) gets rid of the old device code so I have to keep rebooting to try my new builds...

There must be an error in your Expunge() vector implementation because it does work. There is some info on the wiki here:
http://wiki.amigaos.net/wiki/Exec_Devic ... g_a_Device

Normally, all you should have to do is replace the file and the OS will auto-magically expunge it for you.

In cases where replacing the file is not possible there is an Expunge command in your SDK to trigger an expunge manually.