Index: uspace/lib/ext4/libext4_filesystem.c
===================================================================
--- uspace/lib/ext4/libext4_filesystem.c	(revision e5f8762f9e1ae7002a61bcf86c0a75283fd2ab38)
+++ uspace/lib/ext4/libext4_filesystem.c	(revision ebcaff4f6e2f0a2e0a7525123e8627ef2fdcbb03)
@@ -783,4 +783,74 @@
 }
 
+int ext4_filesystem_add_orphan(ext4_filesystem_t *fs,
+		ext4_inode_ref_t *inode_ref)
+{
+	uint32_t next_orphan = ext4_superblock_get_last_orphan(fs->superblock);
+	ext4_inode_set_deletion_time(inode_ref->inode, next_orphan);
+	ext4_superblock_set_last_orphan(fs->superblock, inode_ref->index);
+	inode_ref->dirty = true;
+
+	return EOK;
+}
+
+int ext4_filesystem_delete_orphan(ext4_filesystem_t *fs,
+		ext4_inode_ref_t *inode_ref)
+{
+	int rc;
+
+	uint32_t last_orphan = ext4_superblock_get_last_orphan(fs->superblock);
+	assert(last_orphan > 0);
+
+	uint32_t next_orphan = ext4_inode_get_deletion_time(inode_ref->inode);
+
+	if (last_orphan == inode_ref->index) {
+		ext4_superblock_set_last_orphan(fs->superblock, next_orphan);
+		ext4_inode_set_deletion_time(inode_ref->inode, 0);
+		inode_ref->dirty = true;
+		return EOK;
+	}
+
+	ext4_inode_ref_t *current;
+	rc = ext4_filesystem_get_inode_ref(fs, last_orphan, &current);
+	if (rc != EOK) {
+		return rc;
+	}
+	next_orphan = ext4_inode_get_deletion_time(current->inode);
+
+	bool found;
+
+	while (next_orphan != 0) {
+		if (next_orphan == inode_ref->index) {
+			next_orphan = ext4_inode_get_deletion_time(inode_ref->inode);
+			ext4_inode_set_deletion_time(current->inode, next_orphan);
+			current->dirty = true;
+			found = true;
+			break;
+		}
+
+		ext4_filesystem_put_inode_ref(current);
+
+		rc = ext4_filesystem_get_inode_ref(fs, next_orphan, &current);
+		if (rc != EOK) {
+			return rc;
+		}
+		next_orphan = ext4_inode_get_deletion_time(current->inode);
+
+	}
+
+	ext4_inode_set_deletion_time(inode_ref->inode, 0);
+
+	rc = ext4_filesystem_put_inode_ref(current);
+	if (rc != EOK) {
+		return rc;
+	}
+
+	if (!found) {
+		return ENOENT;
+	}
+
+	return EOK;
+}
+
 /**
  * @}
Index: uspace/lib/ext4/libext4_filesystem.h
===================================================================
--- uspace/lib/ext4/libext4_filesystem.h	(revision e5f8762f9e1ae7002a61bcf86c0a75283fd2ab38)
+++ uspace/lib/ext4/libext4_filesystem.h	(revision ebcaff4f6e2f0a2e0a7525123e8627ef2fdcbb03)
@@ -70,4 +70,8 @@
 extern int ext4_filesystem_release_inode_block(ext4_filesystem_t *,
 		ext4_inode_ref_t *, uint32_t);
+extern int ext4_filesystem_add_orphan(ext4_filesystem_t *,
+		ext4_inode_ref_t *);
+extern int ext4_filesystem_delete_orphan(ext4_filesystem_t *,
+		ext4_inode_ref_t *);
 #endif
 
Index: uspace/lib/ext4/libext4_superblock.c
===================================================================
--- uspace/lib/ext4/libext4_superblock.c	(revision e5f8762f9e1ae7002a61bcf86c0a75283fd2ab38)
+++ uspace/lib/ext4/libext4_superblock.c	(revision ebcaff4f6e2f0a2e0a7525123e8627ef2fdcbb03)
@@ -354,4 +354,14 @@
 }
 
+uint32_t ext4_superblock_get_last_orphan(ext4_superblock_t *sb)
+{
+	return uint32_t_le2host(sb->last_orphan);
+}
+
+void ext4_superblock_set_last_orphan(ext4_superblock_t *sb, uint32_t last_orphan)
+{
+	sb->last_orphan = host2uint32_t_le(last_orphan);
+}
+
 uint32_t* ext4_superblock_get_hash_seed(ext4_superblock_t *sb)
 {
Index: uspace/lib/ext4/libext4_superblock.h
===================================================================
--- uspace/lib/ext4/libext4_superblock.h	(revision e5f8762f9e1ae7002a61bcf86c0a75283fd2ab38)
+++ uspace/lib/ext4/libext4_superblock.h	(revision ebcaff4f6e2f0a2e0a7525123e8627ef2fdcbb03)
@@ -272,6 +272,7 @@
 uint32_t s_journal_inum; // Inode number of journal file
 uint32_t s_journal_dev; // Device number of journal file
-uint32_t s_last_orphan; // Head of list of inodes to delete
 */
+extern uint32_t ext4_superblock_get_last_orphan(ext4_superblock_t *);
+extern void ext4_superblock_set_last_orphan(ext4_superblock_t *, uint32_t);
 extern uint32_t* ext4_superblock_get_hash_seed(ext4_superblock_t *);
 /*
