

/* usage: split1_xattr [ --crtime ] fname 
 * 
 * writes xattr container for fname to stdout
 *
 * the --crtime flag causes the creation time of the file
 * to be stored in the xattr container
 * 
 * Returns -1 if errors detected, and 0 otherwise.
 *
 */

#include "util.h"
#include "xattr_util.h"

void usage()
{
   fprintf(stderr, "usage: split1_xattr [ --crtime ] fname cname\n");
}

int main(int argc, char **argv)
{
   char *fname;
   struct stat sbuf;
   int crtime;
   int i;

   crtime = 0;

   i = 1;
   while (i < argc) {
      if (strcmp(argv[i], "--crtime") == 0) {
         i++;
         crtime = 1;
      }
      else
         break;
   }

   if (i != argc-1) {
      usage();
      return -1;
   }

   fname = argv[argc-1];

   if (lstat(fname, &sbuf))
      return -1;

   return split_xattr(fname, &sbuf, "", crtime);
}

