Index: uspace/app/bithenge/file.c
===================================================================
--- uspace/app/bithenge/file.c	(revision 5c5c346a81e0aea0674218b0f43267bcdceee60a)
+++ uspace/app/bithenge/file.c	(revision 50985c34afbbfea83fb8a03ed868a052d884e50c)
@@ -40,4 +40,5 @@
 #include <fcntl.h>
 #include <macros.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <sys/stat.h>
@@ -49,4 +50,5 @@
 	int fd;
 	aoff64_t size; // needed by file_read()
+	bool needs_close;
 } file_blob_t;
 
@@ -95,4 +97,39 @@
 };
 
+static int new_file_blob(bithenge_blob_t **out, int fd, bool needs_close)
+{
+	assert(out);
+
+	struct stat stat;
+	int rc = fstat(fd, &stat);
+	if (rc != EOK) {
+		if (needs_close)
+			close(fd);
+		return rc;
+	}
+
+	// Create blob
+	file_blob_t *blob = malloc(sizeof(*blob));
+	if (!blob) {
+		if (needs_close)
+			close(fd);
+		return ENOMEM;
+	}
+	rc = bithenge_new_random_access_blob(blob_from_file(blob),
+	    &file_ops);
+	if (rc != EOK) {
+		free(blob);
+		if (needs_close)
+			close(fd);
+		return rc;
+	}
+	blob->fd = fd;
+	blob->size = stat.size;
+	blob->needs_close = needs_close;
+	*out = blob_from_file(blob);
+
+	return EOK;
+}
+
 /** Create a blob for a file. The blob must be freed with @a
  * bithenge_blob_t::bithenge_blob_destroy after it is used.
@@ -102,37 +139,34 @@
 int bithenge_new_file_blob(bithenge_blob_t **out, const char *filename)
 {
-	assert(out);
 	assert(filename);
 
-	int fd;
-	fd = open(filename, O_RDONLY);
+	int fd = open(filename, O_RDONLY);
 	if (fd < 0)
 		return fd;
 
-	struct stat stat;
-	int rc = fstat(fd, &stat);
-	if (rc != EOK) {
-		close(fd);
-		return rc;
-	}
+	return new_file_blob(out, fd, true);
+}
 
-	// Create blob
-	file_blob_t *blob = malloc(sizeof(*blob));
-	if (!blob) {
-		close(fd);
-		return ENOMEM;
-	}
-	rc = bithenge_new_random_access_blob(blob_from_file(blob),
-	    &file_ops);
-	if (rc != EOK) {
-		free(blob);
-		close(fd);
-		return rc;
-	}
-	blob->fd = fd;
-	blob->size = stat.size;
-	*out = blob_from_file(blob);
+/** Create a blob for a file descriptor. The blob must be freed with @a
+ * bithenge_blob_t::bithenge_blob_destroy after it is used.
+ * @param[out] out Stores the created blob.
+ * @param fd The file descriptor.
+ * @return EOK on success or an error code from errno.h. */
+int bithenge_new_file_blob_from_fd(bithenge_blob_t **out, int fd)
+{
+	return new_file_blob(out, fd, false);
+}
 
-	return EOK;
+/** Create a blob for a file pointer. The blob must be freed with @a
+ * bithenge_blob_t::bithenge_blob_destroy after it is used.
+ * @param[out] out Stores the created blob.
+ * @param file The file pointer.
+ * @return EOK on success or an error code from errno.h. */
+int bithenge_new_file_blob_from_file(bithenge_blob_t **out, FILE *file)
+{
+	int fd = fileno(file);
+	if (fd < 0)
+		return errno;
+	return new_file_blob(out, fd, false);
 }
 
Index: uspace/app/bithenge/file.h
===================================================================
--- uspace/app/bithenge/file.h	(revision 5c5c346a81e0aea0674218b0f43267bcdceee60a)
+++ uspace/app/bithenge/file.h	(revision 50985c34afbbfea83fb8a03ed868a052d884e50c)
@@ -38,7 +38,10 @@
 #define BITHENGE_FILE_H_
 
+#include <stdio.h>
 #include "blob.h"
 
-int bithenge_new_file_blob(bithenge_blob_t **, const char *filename);
+int bithenge_new_file_blob(bithenge_blob_t **, const char *);
+int bithenge_new_file_blob_from_fd(bithenge_blob_t **, int);
+int bithenge_new_file_blob_from_file(bithenge_blob_t **, FILE *);
 
 #endif
Index: uspace/app/bithenge/test.c
===================================================================
--- uspace/app/bithenge/test.c	(revision 5c5c346a81e0aea0674218b0f43267bcdceee60a)
+++ uspace/app/bithenge/test.c	(revision 50985c34afbbfea83fb8a03ed868a052d884e50c)
@@ -89,4 +89,9 @@
 	bithenge_blob_destroy(blob);
 
+	bithenge_new_file_blob_from_fd(&blob, 0);
+	printf("Data from fd:0: ");
+	print_blob(blob);
+	bithenge_blob_destroy(blob);
+
 	return 0;
 }
