Re: [PATCH] Fits: tool to parse stream

2012-10-22 Thread Arne Jansen
On 15.10.2012 16:32, Chris Mason wrote:
 On Sat, Oct 13, 2012 at 09:41:28AM -0600, David Sterba wrote:
 On Sat, Oct 13, 2012 at 09:08:57AM +0100, Rory Campbell-Lange wrote:
 Perhaps BTRFS Incremental Stream or Backup Incremental Stream should
 be considered, with the file extension .bis.

 From the brainstorming we had about the name, the intention behind the
 stream is to be filesystem independent.

 So this might be named FIS with .fis extension, that is not far from the
 proposed name. However, this hasn't been approved by the Slang committee
 yet :)
 
 urbandictionary has some entries for fis, although I'm not really sure
 that matters.  .fs is still my favorite, or .fss if you want to have the
 word stream in there.

We finally settled on 'far', Filesystem Agnostic Replication.

-Arne

 
 The stream parser is really cool though, thanks Arne.
 
 -chris
 
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Fits: tool to parse stream

2012-10-22 Thread Chris Mason
On Mon, Oct 22, 2012 at 12:41:49AM -0600, Arne Jansen wrote:
 On 15.10.2012 16:32, Chris Mason wrote:
  On Sat, Oct 13, 2012 at 09:41:28AM -0600, David Sterba wrote:
  On Sat, Oct 13, 2012 at 09:08:57AM +0100, Rory Campbell-Lange wrote:
  Perhaps BTRFS Incremental Stream or Backup Incremental Stream should
  be considered, with the file extension .bis.
 
  From the brainstorming we had about the name, the intention behind the
  stream is to be filesystem independent.
 
  So this might be named FIS with .fis extension, that is not far from the
  proposed name. However, this hasn't been approved by the Slang committee
  yet :)
  
  urbandictionary has some entries for fis, although I'm not really sure
  that matters.  .fs is still my favorite, or .fss if you want to have the
  word stream in there.
 
 We finally settled on 'far', Filesystem Agnostic Replication.

I like that one a lot.

-chris
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Fits: tool to parse stream

2012-10-15 Thread Chris Mason
On Sat, Oct 13, 2012 at 09:41:28AM -0600, David Sterba wrote:
 On Sat, Oct 13, 2012 at 09:08:57AM +0100, Rory Campbell-Lange wrote:
  Perhaps BTRFS Incremental Stream or Backup Incremental Stream should
  be considered, with the file extension .bis.
 
 From the brainstorming we had about the name, the intention behind the
 stream is to be filesystem independent.
 
 So this might be named FIS with .fis extension, that is not far from the
 proposed name. However, this hasn't been approved by the Slang committee
 yet :)

urbandictionary has some entries for fis, although I'm not really sure
that matters.  .fs is still my favorite, or .fss if you want to have the
word stream in there.

The stream parser is really cool though, thanks Arne.

-chris

--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Fits: tool to parse stream

2012-10-15 Thread Alex Lyakas
Thanks, Arne,
it will definitely help to debug issues.

Alex.


On Mon, Oct 15, 2012 at 4:32 PM, Chris Mason chris.ma...@fusionio.com wrote:
 On Sat, Oct 13, 2012 at 09:41:28AM -0600, David Sterba wrote:
 On Sat, Oct 13, 2012 at 09:08:57AM +0100, Rory Campbell-Lange wrote:
  Perhaps BTRFS Incremental Stream or Backup Incremental Stream should
  be considered, with the file extension .bis.

 From the brainstorming we had about the name, the intention behind the
 stream is to be filesystem independent.

 So this might be named FIS with .fis extension, that is not far from the
 proposed name. However, this hasn't been approved by the Slang committee
 yet :)

 urbandictionary has some entries for fis, although I'm not really sure
 that matters.  .fs is still my favorite, or .fss if you want to have the
 word stream in there.

 The stream parser is really cool though, thanks Arne.

 -chris

 --
 To unsubscribe from this list: send the line unsubscribe linux-btrfs in
 the body of a message to majord...@vger.kernel.org
 More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Fits: tool to parse stream

2012-10-13 Thread Arne Jansen
On 10/12/12 15:32, Arne Jansen wrote:

 The idea of the btrfs send stream format was to generate it in a way that
 it is easy to receive on different platforms. Thus the proposed name FITS, for
 Filesystem Incremental Backup Stream. We should also build the tools to
 receive the stream on different platforms.

I meant to write 'Filesystem Incremental Transport Stream', but, as
Andrey Kuzmin pointed out, the name FITS is already taken. As the
'Backup' slipped in somehow, FIBS might be an alternative. Any
thoughts?

-Arne
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Fits: tool to parse stream

2012-10-13 Thread Hugo Mills
On Sat, Oct 13, 2012 at 09:02:27AM +0200, Arne Jansen wrote:
 On 10/12/12 15:32, Arne Jansen wrote:
 
  The idea of the btrfs send stream format was to generate it in a way that
  it is easy to receive on different platforms. Thus the proposed name FITS, 
  for
  Filesystem Incremental Backup Stream. We should also build the tools to
  receive the stream on different platforms.
 
 I meant to write 'Filesystem Incremental Transport Stream', but, as
 Andrey Kuzmin pointed out, the name FITS is already taken. As the
 'Backup' slipped in somehow, FIBS might be an alternative. Any
 thoughts?

   Fibs is a slang term for lies. Probably not ideal.

   Hugo.

-- 
=== Hugo Mills: hugo@... carfax.org.uk | darksatanic.net | lug.org.uk ===
  PGP key: 515C238D from wwwkeys.eu.pgp.net or http://www.carfax.org.uk
   --- Strive for apathy! ---


signature.asc
Description: Digital signature


Re: [PATCH] Fits: tool to parse stream

2012-10-13 Thread Rory Campbell-Lange
On 13/10/12, Arne Jansen (sensi...@gmx.net) wrote:
 On 10/12/12 15:32, Arne Jansen wrote:
 
  The idea of the btrfs send stream format was to generate it in a way that
  it is easy to receive on different platforms. Thus the proposed name FITS, 
  for
  Filesystem Incremental Backup Stream. We should also build the tools to
  receive the stream on different platforms.
 
 I meant to write 'Filesystem Incremental Transport Stream', but, as
 Andrey Kuzmin pointed out, the name FITS is already taken. As the
 'Backup' slipped in somehow, FIBS might be an alternative. Any
 thoughts?

Perhaps BTRFS Incremental Stream or Backup Incremental Stream should
be considered, with the file extension .bis.

The word bis is also, according to Wikipedia, ...a prefix of suffix
designating the second instance of a thing..., which seems largely
appropriate.
http://en.m.wikipedia.org/wiki/BIS

Rory

-- 
Rory Campbell-Lange
r...@campbell-lange.net
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Fits: tool to parse stream

2012-10-13 Thread David Sterba
On Sat, Oct 13, 2012 at 09:08:57AM +0100, Rory Campbell-Lange wrote:
 Perhaps BTRFS Incremental Stream or Backup Incremental Stream should
 be considered, with the file extension .bis.

From the brainstorming we had about the name, the intention behind the
stream is to be filesystem independent.

So this might be named FIS with .fis extension, that is not far from the
proposed name. However, this hasn't been approved by the Slang committee
yet :)

david
--
To unsubscribe from this list: send the line unsubscribe linux-btrfs in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Fits: tool to parse stream

2012-10-12 Thread Arne Jansen
Simple tool to parse a fits-stream from stdout.

Signed-off-by: Arne Jansen sensi...@gmx.net
---

The idea of the btrfs send stream format was to generate it in a way that
it is easy to receive on different platforms. Thus the proposed name FITS, for
Filesystem Incremental Backup Stream. We should also build the tools to
receive the stream on different platforms.
As a place to collect those I created at git at 

git://git.kernel.org/pub/scm/linux/kernel/git/arne/fits-progs.git
---

 Makefile|4 +
 fitsparse.c |  402 +++
 2 files changed, 406 insertions(+), 0 deletions(-)
 create mode 100644 Makefile
 create mode 100644 fitsparse.c

diff --git a/Makefile b/Makefile
new file mode 100644
index 000..1c56476
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+all: fitsparse
+
+fitsparse: fitsparse.c
+   gcc -Wall fitsparse.c -o fitsparse
diff --git a/fitsparse.c b/fitsparse.c
new file mode 100644
index 000..3a52250
--- /dev/null
+++ b/fitsparse.c
@@ -0,0 +1,402 @@
+/*
+ * Copyright (C) 2012 STRATO.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License v2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ */
+
+#include stdio.h
+#include stdlib.h
+#include stdint.h
+#include string.h
+#include errno.h
+#include time.h
+
+int print_binary = 0;
+
+/*
+ * stream definitions taken from send.h, (C) Alexander Block
+ */
+#define BTRFS_SEND_STREAM_MAGIC btrfs-stream
+#define BTRFS_SEND_STREAM_VERSION 1
+#define BTRFS_SEND_BUF_SIZE (1024 * 64)
+
+struct btrfs_stream_header {
+   char magic[sizeof(BTRFS_SEND_STREAM_MAGIC)];
+   uint32_t version;
+} __attribute__ ((__packed__));
+
+struct btrfs_cmd_header {
+   /* len excluding the header */
+   uint32_t len;
+   uint16_t cmd;
+   /* crc including the header with zero crc field */
+   uint32_t crc;
+} __attribute__ ((__packed__));
+
+struct btrfs_tlv_header {
+   uint16_t tlv_type;
+   /* len excluding the header */
+   uint16_t tlv_len;
+} __attribute__ ((__packed__));
+
+char *cmd_names[] = {
+   UNSPEC,
+   SUBVOL,
+   SNAPSHOT,
+   MKFILE,
+   MKDIR,
+   MKNOD,
+   MKFIFO,
+   MKSOCK,
+   SYMLINK,
+   RENAME,
+   LINK,
+   UNLINK,
+   RMDIR,
+   SET_XATTR,
+   REMOVE_XATTR,
+   WRITE,
+   CLONE,
+   TRUNCATE,
+   CHMOD,
+   CHOWN,
+   UTIMES,
+   END
+};
+#define MAX_CMDS (sizeof(cmd_names) / sizeof(char *))
+
+#define TYPE_UNDEF 0
+#define TYPE_INT   1
+#define TYPE_STRING2
+#define TYPE_BINARY3
+#define TYPE_TIME  4
+#define TYPE_HEX   5
+#define TYPE_OCTAL 6
+#define TYPE_LEN_ONLY  7
+
+struct attr_types {
+   const char  *name;
+   int type;
+} attrs[] = {
+   { UNSPEC, TYPE_UNDEF },
+   { UUID, TYPE_BINARY },
+   { CTRANSID, TYPE_INT },
+   { INO, TYPE_INT },
+   { SIZE, TYPE_INT },
+   { MODE, TYPE_OCTAL },
+   { UID, TYPE_INT },
+   { GID, TYPE_INT },
+   { RDEV, TYPE_HEX },
+   { CTIME, TYPE_TIME },
+   { MTIME, TYPE_TIME },
+   { ATIME, TYPE_TIME },
+   { OTIME, TYPE_TIME },
+   { XATTR_NAME, TYPE_STRING },
+   { XATTR_DATA, TYPE_BINARY },
+   { PATH, TYPE_STRING },
+   { PATH_TO, TYPE_STRING },
+   { PATH_LINK, TYPE_STRING },
+   { FILE_OFFSET, TYPE_INT },
+   { DATA, TYPE_LEN_ONLY },
+   { CLONE_UUID, TYPE_BINARY },
+   { CLONE_CTRANSID, TYPE_INT },
+   { CLONE_PATH, TYPE_STRING },
+   { CLONE_OFFSET, TYPE_INT },
+   { CLONE_LEN, TYPE_INT }
+};
+#define MAX_ATTRS (sizeof(attrs) / sizeof(struct attr_types))
+
+uint16_t
+read16(const void *d)
+{
+   const uint8_t *data = d;
+
+   return data[0] + (1  8) * (uint16_t)data[1];
+}
+
+uint32_t
+read32(const void *d)
+{
+   const uint8_t *data = d;
+
+   return read16(data) + (1  16) * (uint32_t)read16(data + 2);
+}
+
+uint64_t
+read64(const void *d)
+{
+   const uint8_t *data = d;
+
+   return read32(data) + (1ull  32) * (uint64_t)read32(data + 2);
+}
+
+/* 
+ * Extracted from the linux kernel source code, lib/libcrc32c.c.
+ * 
+ */
+static const uint32_t crc32c_table[256] = {
+   0xL, 0xF26B8303L, 0xE13B70F7L, 0x1350F3F4L,
+   0xC79A971FL, 0x35F1141CL, 0x26A1E7E8L, 0xD4CA64EBL,
+   0x8AD958CFL, 0x78B2DBCCL, 0x6BE22838L, 0x9989AB3BL,
+   0x4D43CFD0L, 

Re: [PATCH] Fits: tool to parse stream

2012-10-12 Thread Arne Jansen
On 12.10.2012 17:19, Andrey Kuzmin wrote:
 Besides already occupied name discussed in a separate thread, I'd suggest to
 check if libcrc32 may be linked directly instead of copying. Formats for 
 various
 types may be also declared static instead of conditionals in the code.
 

The code is completely self contained. The idea was that it just builds on every
platform.

-Arne

 Regards,
 Andrey
 
 12.10.2012 17:33 пользователь Arne Jansen sensi...@gmx.net
 mailto:sensi...@gmx.net написал:
 
 Simple tool to parse a fits-stream from stdout.
 
 Signed-off-by: Arne Jansen sensi...@gmx.net mailto:sensi...@gmx.net
 ---
 
 The idea of the btrfs send stream format was to generate it in a way that
 it is easy to receive on different platforms. Thus the proposed name 
 FITS, for
 Filesystem Incremental Backup Stream. We should also build the tools to
 receive the stream on different platforms.
 As a place to collect those I created at git at
 
 git://git.kernel.org/pub/scm/linux/kernel/git/arne/fits-progs.git
 http://git.kernel.org/pub/scm/linux/kernel/git/arne/fits-progs.git
 ---
 
  Makefile|4 +
  fitsparse.c |  402 
 +++
  2 files changed, 406 insertions(+), 0 deletions(-)
  create mode 100644 Makefile
  create mode 100644 fitsparse.c
 
 diff --git a/Makefile b/Makefile
 new file mode 100644
 index 000..1c56476
 --- /dev/null
 +++ b/Makefile
 @@ -0,0 +1,4 @@
 +all: fitsparse
 +
 +fitsparse: fitsparse.c
 +   gcc -Wall fitsparse.c -o fitsparse
 diff --git a/fitsparse.c b/fitsparse.c
 new file mode 100644
 index 000..3a52250
 --- /dev/null
 +++ b/fitsparse.c
 @@ -0,0 +1,402 @@
 +/*
 + * Copyright (C) 2012 STRATO.  All rights reserved.
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public
 + * License v2 as published by the Free Software Foundation.
 + *
 + * This program is distributed in the hope that it will be useful,
 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 + * General Public License for more details.
 + *
 + * You should have received a copy of the GNU General Public
 + * License along with this program; if not, write to the
 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 + * Boston, MA 021110-1307, USA.
 + */
 +
 +#include stdio.h
 +#include stdlib.h
 +#include stdint.h
 +#include string.h
 +#include errno.h
 +#include time.h
 +
 +int print_binary = 0;
 +
 +/*
 + * stream definitions taken from send.h, (C) Alexander Block
 + */
 +#define BTRFS_SEND_STREAM_MAGIC btrfs-stream
 +#define BTRFS_SEND_STREAM_VERSION 1
 +#define BTRFS_SEND_BUF_SIZE (1024 * 64)
 +
 +struct btrfs_stream_header {
 +   char magic[sizeof(BTRFS_SEND_STREAM_MAGIC)];
 +   uint32_t version;
 +} __attribute__ ((__packed__));
 +
 +struct btrfs_cmd_header {
 +   /* len excluding the header */
 +   uint32_t len;
 +   uint16_t cmd;
 +   /* crc including the header with zero crc field */
 +   uint32_t crc;
 +} __attribute__ ((__packed__));
 +
 +struct btrfs_tlv_header {
 +   uint16_t tlv_type;
 +   /* len excluding the header */
 +   uint16_t tlv_len;
 +} __attribute__ ((__packed__));
 +
 +char *cmd_names[] = {
 +   UNSPEC,
 +   SUBVOL,
 +   SNAPSHOT,
 +   MKFILE,
 +   MKDIR,
 +   MKNOD,
 +   MKFIFO,
 +   MKSOCK,
 +   SYMLINK,
 +   RENAME,
 +   LINK,
 +   UNLINK,
 +   RMDIR,
 +   SET_XATTR,
 +   REMOVE_XATTR,
 +   WRITE,
 +   CLONE,
 +   TRUNCATE,
 +   CHMOD,
 +   CHOWN,
 +   UTIMES,
 +   END
 +};
 +#define MAX_CMDS (sizeof(cmd_names) / sizeof(char *))
 +
 +#define TYPE_UNDEF 0
 +#define TYPE_INT   1
 +#define TYPE_STRING2
 +#define TYPE_BINARY3
 +#define TYPE_TIME  4
 +#define TYPE_HEX   5
 +#define TYPE_OCTAL 6
 +#define TYPE_LEN_ONLY  7
 +
 +struct attr_types {
 +   const char  *name;
 +   int type;
 +} attrs[] = {
 +   { UNSPEC, TYPE_UNDEF },
 +   { UUID, TYPE_BINARY },
 +   { CTRANSID, TYPE_INT },
 +   { INO, TYPE_INT },
 +   { SIZE, TYPE_INT },
 +   { MODE, TYPE_OCTAL },
 +   { UID, TYPE_INT },
 +   { GID, TYPE_INT },
 +   { RDEV, TYPE_HEX },
 +   { CTIME, TYPE_TIME },
 +   { MTIME, TYPE_TIME },
 +   { ATIME, TYPE_TIME },