Whamcloud - gitweb
Many files:
[tools/e2fsprogs.git] / lib / ext2fs / link.c
index 2bef3dc..293a085 100644 (file)
@@ -29,6 +29,7 @@ struct link_struct  {
        ino_t           inode;
        int             flags;
        int             done;
+       struct ext2fs_sb *sb;
 };     
 
 static int link_proc(struct ext2_dir_entry *dirent,
@@ -84,11 +85,17 @@ static int link_proc(struct ext2_dir_entry *dirent,
        dirent->inode = ls->inode;
        dirent->name_len = ls->namelen;
        strncpy(dirent->name, ls->name, ls->namelen);
+       if (ls->sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_FILETYPE)
+               dirent->name_len |= (ls->flags & 0x7) << 8;
 
        ls->done++;
        return DIRENT_ABORT|DIRENT_CHANGED;
 }
 
+/*
+ * Note: the low 3 bits of the flags field are used as the directory
+ * entry filetype.
+ */
 #ifdef __TURBOC__
 #pragma argsused
 #endif
@@ -106,8 +113,9 @@ errcode_t ext2fs_link(ext2_filsys fs, ino_t dir, const char *name, ino_t ino,
        ls.name = name;
        ls.namelen = name ? strlen(name) : 0;
        ls.inode = ino;
-       ls.flags = 0;
+       ls.flags = flags;
        ls.done = 0;
+       ls.sb = (struct ext2fs_sb *) fs->super;
 
        retval = ext2fs_dir_iterate(fs, dir, DIRENT_FLAG_INCLUDE_EMPTY,
                                    0, link_proc, &ls);