Whamcloud - gitweb
debian: drop libattr1-dev from the build dependencies list
[tools/e2fsprogs.git] / misc / create_inode.c
index 1d9a596..e8d1df6 100644 (file)
@@ -124,7 +124,7 @@ static errcode_t set_inode_extra(ext2_filsys fs, ext2_ino_t ino,
        ext2fs_set_i_uid_high(inode, st->st_uid >> 16);
        inode.i_gid = st->st_gid;
        ext2fs_set_i_gid_high(inode, st->st_gid >> 16);
-       inode.i_mode |= st->st_mode;
+       inode.i_mode = (LINUX_S_IFMT & inode.i_mode) | (~S_IFMT & st->st_mode);
        inode.i_atime = st->st_atime;
        inode.i_mtime = st->st_mtime;
        inode.i_ctime = st->st_ctime;
@@ -662,7 +662,7 @@ errcode_t do_write_internal(ext2_filsys fs, ext2_ino_t cwd, const char *src,
                com_err(__func__, 0, "Warning: inode already set");
        ext2fs_inode_alloc_stats2(fs, newfile, +1, 0);
        memset(&inode, 0, sizeof(inode));
-       inode.i_mode = (statbuf.st_mode & ~LINUX_S_IFMT) | LINUX_S_IFREG;
+       inode.i_mode = (statbuf.st_mode & ~S_IFMT) | LINUX_S_IFREG;
        inode.i_atime = inode.i_ctime = inode.i_mtime =
                fs->now ? fs->now : time(0);
        inode.i_links_count = 1;