Whamcloud - gitweb
Merge branch 'maint' into next
authorTheodore Ts'o <tytso@mit.edu>
Wed, 13 Dec 2017 04:45:02 +0000 (23:45 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 13 Dec 2017 04:45:02 +0000 (23:45 -0500)
1  2 
configure
configure.ac
lib/config.h.in
misc/Makefile.in
misc/create_inode.c

diff --combined configure
+++ b/configure
@@@ -7236,6 -7236,8 +7236,8 @@@ main (
      if (*(data + i) != *(data3 + i))
        return 14;
    close (fd);
+   free (data);
+   free (data3);
    return 0;
  }
  _ACEOF
  done
  
  fi
- for ac_header in      dirent.h        errno.h         execinfo.h      getopt.h        malloc.h        mntent.h        paths.h         semaphore.h     setjmp.h        signal.h        stdarg.h        stdint.h        stdlib.h        termios.h       termio.h        unistd.h        utime.h         attr/xattr.h    linux/falloc.h  linux/fd.h      linux/fsmap.h   linux/major.h   linux/loop.h    linux/types.h   net/if_dl.h     netinet/in.h    sys/acl.h       sys/disklabel.h         sys/disk.h      sys/file.h      sys/ioctl.h     sys/key.h       sys/mkdev.h     sys/mman.h      sys/mount.h     sys/prctl.h     sys/resource.h  sys/select.h    sys/socket.h    sys/sockio.h    sys/stat.h      sys/syscall.h   sys/sysctl.h    sys/sysmacros.h         sys/time.h      sys/types.h     sys/un.h        sys/wait.h
 -for ac_header in      dirent.h        errno.h         execinfo.h      getopt.h        malloc.h        mntent.h        paths.h         semaphore.h     setjmp.h        signal.h        stdarg.h        stdint.h        stdlib.h        termios.h       termio.h        unistd.h        utime.h         attr/xattr.h    linux/falloc.h  linux/fd.h      linux/major.h   linux/loop.h    net/if_dl.h     netinet/in.h    sys/acl.h       sys/disklabel.h         sys/disk.h      sys/file.h      sys/ioctl.h     sys/key.h       sys/mkdev.h     sys/mman.h      sys/mount.h     sys/prctl.h     sys/resource.h  sys/select.h    sys/socket.h    sys/sockio.h    sys/stat.h      sys/syscall.h   sys/sysctl.h    sys/sysmacros.h         sys/time.h      sys/types.h     sys/un.h        sys/wait.h      sys/xattr.h
++for ac_header in      dirent.h        errno.h         execinfo.h      getopt.h        malloc.h        mntent.h        paths.h         semaphore.h     setjmp.h        signal.h        stdarg.h        stdint.h        stdlib.h        termios.h       termio.h        unistd.h        utime.h         attr/xattr.h    linux/falloc.h  linux/fd.h      linux/fsmap.h   linux/major.h   linux/loop.h    linux/types.h   net/if_dl.h     netinet/in.h    sys/acl.h       sys/disklabel.h         sys/disk.h      sys/file.h      sys/ioctl.h     sys/key.h       sys/mkdev.h     sys/mman.h      sys/mount.h     sys/prctl.h     sys/resource.h  sys/select.h    sys/socket.h    sys/sockio.h    sys/stat.h      sys/syscall.h   sys/sysctl.h    sys/sysmacros.h         sys/time.h      sys/types.h     sys/un.h        sys/wait.h      sys/xattr.h
  do :
    as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
  ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
  if test -n "$DLOPEN_LIB" ; then
     ac_cv_func_dlopen=yes
  fi
 -for ac_func in        __secure_getenv         add_key         backtrace       blkid_probe_get_topology        blkid_probe_enable_partitions   chflags         dlopen  fadvise64       fallocate       fallocate64     fchown  fdatasync       fstat64         ftruncate64     futimes         getcwd  getdtablesize   getmntinfo      getpwuid_r      getrlimit       getrusage       jrand48         keyctl  llistxattr      llseek  lseek64         mallinfo        mbstowcs        memalign        mempcpy         mmap    msync   nanosleep       open64  pathconf        posix_fadvise   posix_fadvise64         posix_memalign  prctl   pread   pwrite  pread64         pwrite64        secure_getenv   setmntent       setresgid       setresuid       snprintf        srandom         stpcpy  strcasecmp      strdup  strnlen         strptime        strtoull        sync_file_range         sysconf         usleep  utime   utimes  valloc
 +for ac_func in        __secure_getenv         add_key         backtrace       blkid_probe_get_topology        blkid_probe_enable_partitions   chflags         dlopen  fadvise64       fallocate       fallocate64     fchown  fcntl   fdatasync       fstat64         fsync   ftruncate64     futimes         getcwd  getdtablesize   getmntinfo      getpwuid_r      getrlimit       getrusage       jrand48         keyctl  llistxattr      llseek  lseek64         mallinfo        mbstowcs        memalign        mempcpy         mmap    msync   nanosleep       open64  pathconf        posix_fadvise   posix_fadvise64         posix_memalign  prctl   pread   pwrite  pread64         pwrite64        secure_getenv   setmntent       setresgid       setresuid       snprintf        srandom         stpcpy  strcasecmp      strdup  strnlen         strptime        strtoull        sync_file_range         sysconf         usleep  utime   utimes  valloc
  do :
    as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
  ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --combined configure.ac
@@@ -918,10 -918,8 +918,10 @@@ AC_CHECK_HEADERS(m4_flatten(
        attr/xattr.h
        linux/falloc.h
        linux/fd.h
 +      linux/fsmap.h
        linux/major.h
        linux/loop.h
 +      linux/types.h
        net/if_dl.h
        netinet/in.h
        sys/acl.h
        sys/types.h
        sys/un.h
        sys/wait.h
+       sys/xattr.h
  ]))
  dnl Check where to find a dd(1) that supports iflag=fullblock
  dnl and oflag=append
@@@ -1115,10 -1114,8 +1116,10 @@@ AC_CHECK_FUNCS(m4_flatten(
        fallocate
        fallocate64
        fchown
 +      fcntl
        fdatasync
        fstat64
 +      fsync
        ftruncate64
        futimes
        getcwd
diff --combined lib/config.h.in
  /* Define to 1 if you have the <linux/fd.h> header file. */
  #undef HAVE_LINUX_FD_H
  
 +/* Define to 1 if you have the <linux/fsmap.h> header file. */
 +#undef HAVE_LINUX_FSMAP_H
 +
  /* Define to 1 if you have the <linux/loop.h> header file. */
  #undef HAVE_LINUX_LOOP_H
  
  /* Define to 1 if you have the `sync_file_range' function. */
  #undef HAVE_SYNC_FILE_RANGE
  
 +/* Define to 1 if you have the 'fsync' function. */
 +#undef HAVE_FSYNC
 +
  /* Define to 1 if you have the `sysconf' function. */
  #undef HAVE_SYSCONF
  
  /* Define to 1 if you have the <sys/wait.h> header file. */
  #undef HAVE_SYS_WAIT_H
  
+ /* Define to 1 if you have the <sys/xattr.h> header file. */
+ #undef HAVE_SYS_XATTR_H
  /* Define to 1 if you have the <termios.h> header file. */
  #undef HAVE_TERMIOS_H
  
diff --combined misc/Makefile.in
@@@ -252,7 -252,7 +252,7 @@@ base_device: base_device.
        $(Q) $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(srcdir)/base_device.c \
                -DDEBUG -o base_device $(SYSLIBS)
  
 -check:: base_device
 +fullcheck check:: base_device
        ./base_device < $(srcdir)/base_device.tst > base_device.out
        cmp $(srcdir)/base_device.tst base_device.out
  
@@@ -392,19 -392,19 +392,19 @@@ fuse2fs: $(FUSE2FS_OBJS) $(DEPLIBS) $(D
                $(CLOCK_GETTIME_LIB) $(SYSLIBS)
  
  journal.o: $(srcdir)/../debugfs/journal.c
-       $(E) "  CC $@"
+       $(E) "  CC $<"
        $(Q) $(CC) -c $(JOURNAL_CFLAGS) -I$(srcdir) \
                $(srcdir)/../debugfs/journal.c -o $@
  @PROFILE_CMT@ $(Q) $(CC) $(JOURNAL_CFLAGS) -g -pg -o profiled/$*.o -c $<
  
  recovery.o: $(srcdir)/../e2fsck/recovery.c
-       $(E) "  CC $@"
+       $(E) "  CC $<"
        $(Q) $(CC) -c $(JOURNAL_CFLAGS) -I$(srcdir) \
                $(srcdir)/../e2fsck/recovery.c -o $@
  @PROFILE_CMT@ $(Q) $(CC) $(JOURNAL_CFLAGS) -g -pg -o profiled/$*.o -c $<
  
  revoke.o: $(srcdir)/../e2fsck/revoke.c
-       $(E) "  CC $@"
+       $(E) "  CC $<"
        $(Q) $(CC) -c $(JOURNAL_CFLAGS) -I$(srcdir) \
                $(srcdir)/../e2fsck/revoke.c -o $@
  @PROFILE_CMT@ $(Q) $(CC) $(JOURNAL_CFLAGS) -g -pg -o profiled/$*.o -c $<
diff --combined misc/create_inode.c
@@@ -18,7 -18,9 +18,9 @@@
  #include <sys/types.h>
  #include <unistd.h>
  #include <limits.h> /* for PATH_MAX */
- #ifdef HAVE_ATTR_XATTR_H
+ #if defined HAVE_SYS_XATTR_H
+ #include <sys/xattr.h>
+ #elif defined HAVE_ATTR_XATTR_H
  #include <attr/xattr.h>
  #endif
  #include <sys/ioctl.h>
@@@ -683,31 -685,10 +685,31 @@@ out
        return retval;
  }
  
 +struct file_info {
 +      char *path;
 +      size_t path_len;
 +      size_t path_max_len;
 +};
 +
 +static errcode_t path_append(struct file_info *target, const char *file)
 +{
 +      if (strlen(file) + target->path_len + 1 > target->path_max_len) {
 +              target->path_max_len *= 2;
 +              target->path = realloc(target->path, target->path_max_len);
 +              if (!target->path)
 +                      return EXT2_ET_NO_MEMORY;
 +      }
 +      target->path_len += sprintf(target->path + target->path_len, "/%s",
 +                                  file);
 +      return 0;
 +}
 +
  /* Copy files from source_dir to fs */
  static errcode_t __populate_fs(ext2_filsys fs, ext2_ino_t parent_ino,
                               const char *source_dir, ext2_ino_t root,
 -                             struct hdlinks_s *hdlinks)
 +                             struct hdlinks_s *hdlinks,
 +                             struct file_info *target,
 +                             struct fs_ops_callbacks *fs_callbacks)
  {
        const char      *name;
        DIR             *dh;
        errcode_t       retval = 0;
        int             read_cnt;
        int             hdlink;
 +      size_t          cur_dir_path_len;
  
        if (chdir(source_dir) < 0) {
                retval = errno;
                                save_inode = 1;
                }
  
 +              cur_dir_path_len = target->path_len;
 +              retval = path_append(target, name);
 +              if (retval)
 +                      return retval;
 +
 +              if (fs_callbacks && fs_callbacks->create_new_inode) {
 +                      retval = fs_callbacks->create_new_inode(fs,
 +                              target->path, name, parent_ino, root,
 +                              st.st_mode & S_IFMT);
 +                      if (retval)
 +                              goto out;
 +              }
 +
                switch(st.st_mode & S_IFMT) {
                case S_IFCHR:
                case S_IFBLK:
@@@ -857,8 -824,7 +859,8 @@@ find_lnf
                                        goto out;
                        }
                        /* Populate the dir recursively*/
 -                      retval = __populate_fs(fs, ino, name, root, hdlinks);
 +                      retval = __populate_fs(fs, ino, name, root, hdlinks,
 +                                             target, fs_callbacks);
                        if (retval)
                                goto out;
                        if (chdir("..")) {
                        goto out;
                }
  
 +              if (fs_callbacks && fs_callbacks->end_create_new_inode) {
 +                      retval = fs_callbacks->end_create_new_inode(fs,
 +                              target->path, name, parent_ino, root,
 +                              st.st_mode & S_IFMT);
 +                      if (retval)
 +                              goto out;
 +              }
 +
                /* Save the hardlink ino */
                if (save_inode) {
                        /*
                        hdlinks->hdl[hdlinks->count].dst_ino = ino;
                        hdlinks->count++;
                }
 +              target->path_len = cur_dir_path_len;
 +              target->path[target->path_len] = 0;
        }
  
  out:
        return retval;
  }
  
 -errcode_t populate_fs(ext2_filsys fs, ext2_ino_t parent_ino,
 -                    const char *source_dir, ext2_ino_t root)
 +errcode_t populate_fs2(ext2_filsys fs, ext2_ino_t parent_ino,
 +                     const char *source_dir, ext2_ino_t root,
 +                     struct fs_ops_callbacks *fs_callbacks)
  {
 +      struct file_info file_info;
        struct hdlinks_s hdlinks;
        errcode_t retval;
  
                return retval;
        }
  
 -      retval = __populate_fs(fs, parent_ino, source_dir, root, &hdlinks);
 +      file_info.path_len = 0;
 +      file_info.path_max_len = 255;
 +      file_info.path = calloc(file_info.path_max_len, 1);
  
 +      retval = __populate_fs(fs, parent_ino, source_dir, root, &hdlinks,
 +                             &file_info, fs_callbacks);
 +
 +      free(file_info.path);
        free(hdlinks.hdl);
        return retval;
  }
 +
 +errcode_t populate_fs(ext2_filsys fs, ext2_ino_t parent_ino,
 +                    const char *source_dir, ext2_ino_t root)
 +{
 +      return populate_fs2(fs, parent_ino, source_dir, root, NULL);
 +}