Hello community,

here is the log from the commit of package btfs for openSUSE:Factory checked in 
at 2017-08-24 18:56:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/btfs (Old)
 and      /work/SRC/openSUSE:Factory/.btfs.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "btfs"

Thu Aug 24 18:56:03 2017 rev:2 rq:518425 version:2.16

Changes:
--------
--- /work/SRC/openSUSE:Factory/btfs/btfs.changes        2017-08-18 
15:02:50.111407307 +0200
+++ /work/SRC/openSUSE:Factory/.btfs.new/btfs.changes   2017-08-24 
18:56:31.886507354 +0200
@@ -1,0 +2,8 @@
+Wed Aug 23 17:09:41 UTC 2017 - [email protected]
+
+- 2.16
+  * Implement listxattr and getxattr
+  * Return IS_BTFS xattr on all files and directories
+  * Add btfsstat program
+
+-------------------------------------------------------------------

Old:
----
  v2.15.tar.gz

New:
----
  v2.16.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ btfs.spec ++++++
--- /var/tmp/diff_new_pack.oAP4NL/_old  2017-08-24 18:56:32.586408802 +0200
+++ /var/tmp/diff_new_pack.oAP4NL/_new  2017-08-24 18:56:32.586408802 +0200
@@ -17,7 +17,7 @@
 
 
 Name:           btfs
-Version:        2.15
+Version:        2.16
 Release:        0
 Summary:        A BitTorrent file system based on FUSE
 License:        GPL-3.0
@@ -27,11 +27,11 @@
 BuildRequires:  autoconf
 BuildRequires:  automake
 BuildRequires:  gcc
+BuildRequires:  libboost_system-devel
 BuildRequires:  pkgconfig
 BuildRequires:  pkgconfig(fuse)
 BuildRequires:  pkgconfig(libcurl)
 BuildRequires:  pkgconfig(libtorrent-rasterbar) > 0.16
-BuildRequires:  libboost_system-devel
 
 %description
 With BTFS, you can mount any .torrent file or magnet link and then use it as
@@ -56,5 +56,6 @@
 %{_mandir}/man1/%{name}.1%{ext_man}
 %{_bindir}/btfs
 %{_bindir}/btplay
+%{_bindir}/btfsstat
 
 %changelog

++++++ v2.15.tar.gz -> v2.16.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/btfs-2.15/.gitignore new/btfs-2.16/.gitignore
--- old/btfs-2.15/.gitignore    2017-08-04 09:12:07.000000000 +0200
+++ new/btfs-2.16/.gitignore    2017-08-23 18:12:29.000000000 +0200
@@ -1,5 +1,6 @@
 *.o
 btfs
+btfsstat
 
 # generated files
 Makefile
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/btfs-2.15/.travis.yml new/btfs-2.16/.travis.yml
--- old/btfs-2.15/.travis.yml   2017-08-04 09:12:07.000000000 +0200
+++ new/btfs-2.16/.travis.yml   2017-08-23 18:12:29.000000000 +0200
@@ -2,22 +2,22 @@
 matrix:
   include:
     - os: linux
-      env: LIBTORRENT_BRANCH=master BUILDENV="CXX=g++-7 CC=gcc-7 CPP=cpp-7 
CXXFLAGS=-fpermissive"
+      env: LIBTORRENT_BRANCH=master TOOLCHAIN="CXX=g++-7 CC=gcc-7 CPP=cpp-7"
     - os: linux
-      env: LIBTORRENT_BRANCH=RC_1_1 BUILDENV="CXX=g++-7 CC=gcc-7 CPP=cpp-7 
CXXFLAGS=-fpermissive"
+      env: LIBTORRENT_BRANCH=RC_1_1 TOOLCHAIN="CXX=g++-7 CC=gcc-7 CPP=cpp-7"
     - os: linux
-      env: LIBTORRENT_BRANCH=RC_1_0 BUILDENV="CXX=g++-7 CC=gcc-7 CPP=cpp-7 
CXXFLAGS=-fpermissive"
+      env: LIBTORRENT_BRANCH=RC_1_0 TOOLCHAIN="CXX=g++-7 CC=gcc-7 CPP=cpp-7"
     - os: osx
-      env: LIBTORRENT_BRANCH=master BUILDENV="CXXFLAGS=-std=c++11"
+      env: LIBTORRENT_BRANCH=master
     - os: osx
-      env: LIBTORRENT_BRANCH=RC_1_1 BUILDENV="CXXFLAGS=-std=c++11"
+      env: LIBTORRENT_BRANCH=RC_1_1
     - os: osx
-      env: LIBTORRENT_BRANCH=RC_1_0 BUILDENV="CXXFLAGS=-std=c++11"
+      env: LIBTORRENT_BRANCH=RC_1_0
   allow_failures:
     - os: linux
-      env: LIBTORRENT_BRANCH=master BUILDENV="CXX=g++-7 CC=gcc-7 CPP=cpp-7 
CXXFLAGS=-fpermissive"
+      env: LIBTORRENT_BRANCH=master TOOLCHAIN="CXX=g++-7 CC=gcc-7 CPP=cpp-7"
     - os: osx
-      env: LIBTORRENT_BRANCH=master BUILDENV="CXXFLAGS=-std=c++11"
+      env: LIBTORRENT_BRANCH=master
 env:
   global:
     - MAKEFLAGS=-j2
@@ -41,8 +41,8 @@
       brew install curl;
     fi
 install:
-  - env $BUILDENV ./scripts/build-libtorrent $LIBTORRENT_BRANCH /tmp
+  - env $TOOLCHAIN CXXFLAGS="-fpermissive -w -std=c++11" 
./scripts/build-libtorrent $LIBTORRENT_BRANCH /tmp
 before_script:
   - autoreconf -i
 script:
-  - env $BUILDENV ./configure && make && make test
+  - env $TOOLCHAIN ./configure && make && make test
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/btfs-2.15/configure.ac new/btfs-2.16/configure.ac
--- old/btfs-2.15/configure.ac  2017-08-04 09:12:07.000000000 +0200
+++ new/btfs-2.16/configure.ac  2017-08-23 18:12:29.000000000 +0200
@@ -1,5 +1,5 @@
 AC_PREREQ([2.69])
-AC_INIT(btfs, 2.15, [email protected], btfs, 
https://github.com/johang/btfs)
+AC_INIT(btfs, 2.16, [email protected], btfs, 
https://github.com/johang/btfs)
 AC_CONFIG_SRCDIR([src/btfs.cc])
 
 AM_INIT_AUTOMAKE
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/btfs-2.15/src/Makefile.am 
new/btfs-2.16/src/Makefile.am
--- old/btfs-2.15/src/Makefile.am       2017-08-04 09:12:07.000000000 +0200
+++ new/btfs-2.16/src/Makefile.am       2017-08-23 18:12:29.000000000 +0200
@@ -1,5 +1,14 @@
-bin_PROGRAMS = btfs
+EXTRACXXFLAGS = -std=c++11 \
+                -Wall \
+                -Wextra \
+                -Wconversion \
+                -Wsign-compare \
+                -Wsign-conversion \
+                -Wno-unused-parameter
+bin_PROGRAMS = btfs btfsstat
 btfs_SOURCES = btfs.cc btfs.h
-btfs_CPPFLAGS = -Wall -Wextra -Wconversion -Wsign-compare -Wsign-conversion 
-Wno-unused-parameter $(FUSE_CFLAGS) $(LIBTORRENT_CFLAGS) $(LIBCURL_CFLAGS)
-btfs_CXXFLAGS = -std=c++11
+btfs_CXXFLAGS = $(EXTRACXXFLAGS) $(FUSE_CFLAGS) $(LIBTORRENT_CFLAGS) 
$(LIBCURL_CFLAGS)
 btfs_LDADD = $(FUSE_LIBS) $(LIBTORRENT_LIBS) $(LIBCURL_LIBS)
+btfsstat_SOURCES = btfsstat.cc btfsstat.h
+btfsstat_CXXFLAGS = $(EXTRACXXFLAGS)
+btfsstat_LDADD =
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/btfs-2.15/src/btfs.cc new/btfs-2.16/src/btfs.cc
--- old/btfs-2.15/src/btfs.cc   2017-08-04 09:12:07.000000000 +0200
+++ new/btfs-2.16/src/btfs.cc   2017-08-23 18:12:29.000000000 +0200
@@ -34,6 +34,7 @@
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wsign-conversion"
 #pragma GCC diagnostic ignored "-Wconversion"
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 #include <libtorrent/torrent_info.hpp>
 #include <libtorrent/session.hpp>
 #include <libtorrent/alert.hpp>
@@ -391,6 +392,11 @@
 }
 
 static bool
+is_root(const char *path) {
+       return strcmp(path, "/") == 0;
+}
+
+static bool
 is_dir(const char *path) {
        return dirs.find(path) != dirs.end();
 }
@@ -402,7 +408,7 @@
 
 static int
 btfs_getattr(const char *path, struct stat *stbuf) {
-       if (!is_dir(path) && !is_file(path) && strcmp(path, "/") != 0)
+       if (!is_dir(path) && !is_file(path) && !is_root(path))
                return -ENOENT;
 
        pthread_mutex_lock(&lock);
@@ -413,7 +419,7 @@
        stbuf->st_gid = getgid();
        stbuf->st_mtime = time_of_mount;
 
-       if (strcmp(path, "/") == 0 || is_dir(path)) {
+       if (is_root(path) || is_dir(path)) {
                stbuf->st_mode = S_IFDIR | 0755;
        } else {
                auto ti = handle.torrent_file();
@@ -447,7 +453,7 @@
 static int
 btfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
                off_t offset, struct fuse_file_info *fi) {
-       if (!is_dir(path) && !is_file(path) && strcmp(path, "/") != 0)
+       if (!is_dir(path) && !is_file(path) && !is_root(path))
                return -ENOENT;
 
        if (is_file(path))
@@ -659,6 +665,75 @@
        pthread_mutex_unlock(&lock);
 }
 
+static int
+btfs_listxattr(const char *path, char *data, size_t len) {
+       const char *xattrs = NULL;
+       int xattrslen = 0;
+
+       if (is_root(path)) {
+               xattrs = XATTR_IS_BTFS "\0" XATTR_IS_BTFS_ROOT;
+               xattrslen = sizeof (XATTR_IS_BTFS "\0" XATTR_IS_BTFS_ROOT);
+       } else if (is_dir(path)) {
+               xattrs = XATTR_IS_BTFS;
+               xattrslen = sizeof (XATTR_IS_BTFS);
+       } else if (is_file(path)) {
+               xattrs = XATTR_IS_BTFS "\0" XATTR_FILE_INDEX;
+               xattrslen = sizeof (XATTR_IS_BTFS "\0" XATTR_FILE_INDEX);
+       } else {
+               return -ENOENT;
+       }
+
+       // The minimum required length
+       if (len == 0)
+               return xattrslen;
+
+       if (len < (size_t) xattrslen)
+               return -ERANGE;
+
+       memcpy(data, xattrs, (size_t) xattrslen);
+
+       return xattrslen;
+}
+
+#ifdef __APPLE__
+static int
+btfs_getxattr(const char *path, const char *key, char *value, size_t len,
+               uint32_t position) {
+#else
+static int
+btfs_getxattr(const char *path, const char *key, char *value, size_t len) {
+       uint32_t position = 0;
+#endif
+       char xattr[16];
+       int xattrlen = 0;
+
+       std::string k(key);
+
+       if (is_file(path) && k == XATTR_FILE_INDEX) {
+               xattrlen = snprintf(xattr, sizeof (xattr), "%d", files[path]);
+       } else if (is_root(path) && k == XATTR_IS_BTFS_ROOT) {
+               xattrlen = 0;
+       } else if (k == XATTR_IS_BTFS) {
+               xattrlen = 0;
+       } else {
+               return -ENODATA;
+       }
+
+       // The minimum required length
+       if (len == 0)
+               return xattrlen;
+
+       if (position >= (uint32_t) xattrlen)
+               return 0;
+
+       if (len < (size_t) xattrlen - position)
+               return -ERANGE;
+
+       memcpy(value, xattr + position, (size_t) xattrlen - position);
+
+       return xattrlen - (int) position;
+}
+
 static bool
 populate_target(std::string& target, char *arg) {
        std::string templ;
@@ -860,6 +935,8 @@
        btfs_ops.open = btfs_open;
        btfs_ops.read = btfs_read;
        btfs_ops.statfs = btfs_statfs;
+       btfs_ops.listxattr = btfs_listxattr;
+       btfs_ops.getxattr = btfs_getxattr;
        btfs_ops.init = btfs_init;
        btfs_ops.destroy = btfs_destroy;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/btfs-2.15/src/btfs.h new/btfs-2.16/src/btfs.h
--- old/btfs-2.15/src/btfs.h    2017-08-04 09:12:07.000000000 +0200
+++ new/btfs-2.16/src/btfs.h    2017-08-23 18:12:29.000000000 +0200
@@ -20,8 +20,15 @@
 #ifndef BTFS_H
 #define BTFS_H
 
+#include <vector>
+#include <list>
+#include <fstream>
+
+#include "libtorrent/config.hpp"
 #include <libtorrent/peer_request.hpp>
 
+#include "btfsstat.h"
+
 namespace btfs
 {
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/btfs-2.15/src/btfsstat.cc 
new/btfs-2.16/src/btfsstat.cc
--- old/btfs-2.15/src/btfsstat.cc       1970-01-01 01:00:00.000000000 +0100
+++ new/btfs-2.16/src/btfsstat.cc       2017-08-23 18:12:29.000000000 +0200
@@ -0,0 +1,118 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <limits.h>
+#include <dirent.h>
+#include <math.h>
+#include <libgen.h>
+
+#include <sys/types.h>
+#include <sys/xattr.h>
+#include <sys/stat.h>
+
+#include <list>
+#include <string>
+#include <iostream>
+
+#include "btfsstat.h"
+
+#ifndef ENOATTR
+#define ENOATTR ENODATA
+#endif
+
+using namespace btfs;
+
+static bool
+string_compare(const std::string& a, const std::string& b) {
+       return a.compare(b) == 0;
+}
+
+static std::list<std::string>
+list(std::string path) {
+       std::list<std::string> files;
+
+       DIR *dp = opendir(path.c_str());
+
+       if (!dp)
+               return files;
+
+       for (struct dirent *ep = readdir(dp); ep; ep = readdir(dp)) {
+               std::string f(ep->d_name);
+
+               if (f != "." && f != "..")
+                       files.push_back(f);
+       }
+
+       closedir(dp);
+
+       files.sort(string_compare);
+
+       return files;
+}
+
+static void
+scan(std::string indent, std::string d, std::string f) {
+       struct stat s;
+       memset(&s, 0, sizeof (s));
+
+       std::string p = d + "/" + f;
+
+       if (lstat(p.c_str(), &s) < 0)
+               return;
+
+       if (S_ISDIR(s.st_mode)) {
+               printf("%s%s/\n", indent.c_str(), f.c_str());
+
+               std::list<std::string> l = list(p);
+
+               for (auto i = l.begin(); i != l.end(); ++i) {
+                       scan(indent + "    ", p, *i);
+               }
+       } else if (S_ISREG(s.st_mode)) {
+               // Download progress for this file (in percent)
+               long progress = lround((100.0 * 512.0 * (double) s.st_blocks) /
+                       (double) s.st_size);
+
+               printf("%s%s (%3ld%%)\n", indent.c_str(), f.c_str(), progress);
+       }
+}
+
+int
+main(int argc, char *argv[]) {
+       if (argc < 2) {
+               printf("Usage: %s MOUNT_POINTS...\n", argv[0]);
+               return 1;
+       }
+
+       for (int i = 1; i < argc; i++) {
+#ifdef __APPLE__
+               if (getxattr(argv[i], XATTR_IS_BTFS, NULL, 0, 0, 0) < 0) {
+#else
+               if (getxattr(argv[i], XATTR_IS_BTFS, NULL, 0) < 0) {
+#endif
+                       printf("%s: %s is not a btfs mount: %s\n", argv[0], 
argv[i],
+                               strerror(errno));
+                       return 2;
+               }
+
+               char *root = realpath(argv[i], NULL);
+
+               if (!root) {
+                       perror("failed to canonicalize path");
+                       return 3;
+               }
+
+               char *dir = strdup(root);
+               char *base = strdup(root);
+
+               scan("", dirname(root), basename(root));
+
+               free(base);
+               free(dir);
+
+               free(root);
+       }
+
+       return 0;
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/btfs-2.15/src/btfsstat.h new/btfs-2.16/src/btfsstat.h
--- old/btfs-2.15/src/btfsstat.h        1970-01-01 01:00:00.000000000 +0100
+++ new/btfs-2.16/src/btfsstat.h        2017-08-23 18:12:29.000000000 +0200
@@ -0,0 +1,12 @@
+#ifndef __BTFSSTAT_H__
+#define __BTFSSTAT_H__
+
+#define XATTR_FILE_INDEX "user.btfs.file_index"
+#define XATTR_IS_BTFS_ROOT "user.btfs.is_btfs_root"
+#define XATTR_IS_BTFS "user.btfs.is_btfs"
+
+namespace btfs
+{
+}
+
+#endif


Reply via email to