Colin Günther <coling@xxxxxx> wrote: > Axel Dörfler schrieb: > > The _user_*() functions are syscalls, they are not supposed to be > > called > > within the kernel. > > You probably want to use vm_map_file() instead. > Mmh, where is the vm_map_file() counterpart? > - I looked into munmap()'s callchain, which uses unmap_address_range > in > the end. Unfortunately unmap_address_range is declared static and > thus > not accessible by firmware_put(). You get an area, and you can delete those with delete_area() as usual. It's even part of the public kernel interface as documented in the BeBook. A mapped file is just like any other area. > - I looked into delete_area, quickly finding a comment in > _user_delete_area about deleting areas is for userland created areas > only. Mmh. As I said, _user_*() functions are not supposed to be called from within the kernel. > - I looked in the code for close() in the hope that closing the file > might trigger some unmapping. It doesn't look like there is taking > place > any unmapping along the call chain down to file_close() in vfs.cpp. > (The > curiousity let me look in the bfs_close(), too, pretty empty in there > :) The file descriptor is not used besides getting the file's cache - IOW (as in mmap()) it's still your responsibility to close the file descriptor, and that will not harm the area. > Now I'm asking myself whether file mapping for firmware loading is > the > right approach at all. I mean instead of using the previous approach > of > reading the whole file in by using read(). Because then I could just > use > free() when firmware_put() is called. Depending on the locking flags, mapping has the advantage that the data is mapped in when needed, and unmapped if not (and that you save copying the data to a buffer). Otherwise it doesn't really matter much. In any case, you can still just call delete_area() when firmware_put() is called. Still confused? :-) Bye, Axel.