[Stgt-devel] Barcode in extended attributes

Albert Pauw albert.pauw
Mon Jul 28 18:22:48 CEST 2008

FYI my programming skills are very limited, as I haven't programmed for 
But here is a little snippet of code that retrieves the barcode nicely 
through extended attributes,
which is the way to go I think.

The value of the attribute can be a zero terminated string of maximum 
but also a binary blob of 4kbytes which should be big enough to carry 
the filemarks as well.

For the barcode this could maybe incorporated into the smc code? 
Apologies for not doing it
myself, as I don't have the skills to do so.


P.S. Barcode can be set by "setfattr -n user.Barcode -v LTO2001LA test.dat"

Anyway here is the code:

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <attr/xattr.h>
#include <stdlib.h>

char *filename,*name;
int fd;
char *barcode[10];
size_t size;

fd=open(filename, O_RDONLY);

fgetxattr(fd, "user.Barcode", barcode, sizeof(barcode));

printf("The barcode of %s is %s\n", filename, barcode);



More information about the stgt mailing list