Index: uspace/lib/c/generic/elf/elf_mod.c
===================================================================
--- uspace/lib/c/generic/elf/elf_mod.c	(revision 48178b568c006324ebb7e11ca81008ed5e8ea96d)
+++ uspace/lib/c/generic/elf/elf_mod.c	(revision e796dc8e72167ff996dc83b98755ebf926622aed)
@@ -44,5 +44,7 @@
  */
 
+#include <errno.h>
 #include <stdio.h>
+#include <vfs/vfs.h>
 #include <sys/types.h>
 #include <align.h>
@@ -50,9 +52,9 @@
 #include <as.h>
 #include <elf/elf.h>
-#include <unistd.h>
-#include <fcntl.h>
 #include <smc.h>
 #include <loader/pcb.h>
 #include <entry_point.h>
+#include <str_error.h>
+#include <stdlib.h>
 
 #include <elf/elf_load.h>
@@ -82,5 +84,5 @@
  * pointed to by @a info.
  *
- * @param file_name Path to the ELF file.
+ * @param file      ELF file.
  * @param so_bias   Bias to use if the file is a shared object.
  * @param info      Pointer to a structure for storing information
@@ -90,19 +92,15 @@
  *
  */
-int elf_load_file(const char *file_name, size_t so_bias, eld_flags_t flags,
-    elf_finfo_t *info)
+static int elf_load_file2(int file, size_t so_bias, eld_flags_t flags, elf_finfo_t *info)
 {
 	elf_ld_t elf;
 
-	int fd;
-	int rc;
-
-	fd = open(file_name, O_RDONLY);
-	if (fd < 0) {
-		DPRINTF("failed opening file\n");
-		return -1;
-	}
-
-	elf.fd = fd;
+	int ofile = vfs_clone(file, true);
+	int rc = _vfs_open(ofile, MODE_READ);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	elf.fd = ofile;
 	elf.info = info;
 	elf.flags = flags;
@@ -110,6 +108,13 @@
 	rc = elf_load_module(&elf, so_bias);
 
-	close(fd);
-
+	close(ofile);
+	return rc;
+}
+
+int elf_load_file(const char *path, size_t so_bias, eld_flags_t flags, elf_finfo_t *info)
+{
+	int file = vfs_lookup(path);
+	int rc = elf_load_file2(file, so_bias, flags, info);
+	close(file);
 	return rc;
 }
