[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 
years.
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 
4kbytes,
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.

Albert

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>

main()
{
char *filename,*name;
int fd;
char *barcode[10];
size_t size;


filename="test.dat";
fd=open(filename, O_RDONLY);

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

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

close(fd);

}




More information about the stgt mailing list