Main Page | Report this Page
 
   
Linux Forum Index  »  Linux Development - System  »  file signature...
Page 1 of 1    
Author Message
Bill Cunningham...
Posted: Wed Sep 24, 2008 6:09 pm
Guest
I can't use stdc to write a file signature for a file format can I?
Wouldn't I have to get into the sys calls and maybe even kernel internals to
do this with lynx. I am going to write a parser soon. But I want to parser
to have a unique signature in it's header somewhere. 0x7f is I believe the
signature for linux. I will write a 128 unique number generator in C with
linux to get the number so it will not conflict with other file types like
adobe's .pdf and so on. Can anyone suggest any source code to create a file
signature and what else I might need to do?

Bill
Bill Cunningham...
Posted: Wed Sep 24, 2008 6:59 pm
Guest
"Bill Cunningham" <nospam at (no spam) nspam.invalid> wrote in message
news:48dac89f$0$5476$bbae4d71 at (no spam) news.suddenlink.net...
Quote:
I can't use stdc to write a file signature for a file format can I?
Wouldn't I have to get into the sys calls and maybe even kernel internals
to do this with lynx. I am going to write a parser soon. But I want to
parser to have a unique signature in it's header somewhere. 0x7f is I
believe the signature for linux. I will write a 128 unique number
generator in C with linux to get the number so it will not conflict with
other file types like adobe's .pdf and so on. Can anyone suggest any
source code to create a file signature and what else I might need to do?

Bill

I have a feeling elf.h is going to be needed here.

B
Richar...
Posted: Wed Sep 24, 2008 7:56 pm
Guest
"Bill Cunningham" <nospam at (no spam) nspam.invalid> writes:

Quote:
I can't use stdc to write a file signature for a file format can I?
Wouldn't I have to get into the sys calls and maybe even kernel internals to
do this with lynx. I am going to write a parser soon. But I want to parser
to have a unique signature in it's header somewhere. 0x7f is I believe the
signature for linux. I will write a 128 unique number generator in C with
linux to get the number so it will not conflict with other file types like
adobe's .pdf and so on. Can anyone suggest any source code to create a file
signature and what else I might need to do?

Bill

By stdc do you mean "standard c" Bill?

I think you should ask in c.l.c : they are always willing to help people
with their parsers and 128 unique number generators there!

Enjoy!

9/10

Crosspost & Followup-To: comp.lang.c

(ps not bad - almost as good as the one where you were telling the lads
in linux development how you were about to write a device driver!)
Joe Pfeiffer...
Posted: Wed Sep 24, 2008 8:38 pm
Guest
"Bill Cunningham" <nospam at (no spam) nspam.invalid> writes:

Quote:
I can't use stdc to write a file signature for a file format can I?
Wouldn't I have to get into the sys calls and maybe even kernel internals to
do this with lynx. I am going to write a parser soon. But I want to parser
to have a unique signature in it's header somewhere. 0x7f is I believe the
signature for linux. I will write a 128 unique number generator in C with
linux to get the number so it will not conflict with other file types like
adobe's .pdf and so on. Can anyone suggest any source code to create a file
signature and what else I might need to do?

I'm sorry -- what are you talking about? You can write anything you
want to any file you want. If you want to start your file with the
string "Bill Cunningham's File Format" you're more than welcome to do
that. I've got no idea what this has to do with lynx, and less what
you mean you say 7f is the signature for linux.
Bill Cunningham...
Posted: Thu Sep 25, 2008 6:04 pm
Guest
"Joe Pfeiffer" <pfeiffer at (no spam) cs.nmsu.edu> wrote in message
news:1bprmtt36z.fsf at (no spam) snowball.wb.pfeifferfamily.net...

Quote:
I'm sorry -- what are you talking about? You can write anything you
want to any file you want. If you want to start your file with the
string "Bill Cunningham's File Format" you're more than welcome to do
that. I've got no idea what this has to do with lynx, and less what
you mean you say 7f is the signature for linux.

Yes yes sorry. I said lynx and not linux. Lynx is a web browser. I mean
in the OS's internals. STDC is higher level than what I want and this is
what this group is supposed to be about.

Bill
Joe Pfeiffer...
Posted: Thu Sep 25, 2008 9:04 pm
Guest
"Bill Cunningham" <nospam at (no spam) nspam.invalid> writes:

Quote:
"Joe Pfeiffer" <pfeiffer at (no spam) cs.nmsu.edu> wrote in message
news:1bprmtt36z.fsf at (no spam) snowball.wb.pfeifferfamily.net...

I'm sorry -- what are you talking about? You can write anything you
want to any file you want. If you want to start your file with the
string "Bill Cunningham's File Format" you're more than welcome to do
that. I've got no idea what this has to do with lynx, and less what
you mean you say 7f is the signature for linux.

Yes yes sorry. I said lynx and not linux. Lynx is a web browser. I mean
in the OS's internals. STDC is higher level than what I want and this is
what this group is supposed to be about.

I'm still confused -- when you say "stdc", do you mean the standard C
library, aka libc? It doesn't get much lower level than the write()
system call. And I still don't know what "7C is the signature for
linux" would mean.
Josef Moellers...
Posted: Fri Sep 26, 2008 1:57 am
Guest
Bill Cunningham wrote:
Quote:
"Joe Pfeiffer" <pfeiffer at (no spam) cs.nmsu.edu> wrote in message
news:1bprmtt36z.fsf at (no spam) snowball.wb.pfeifferfamily.net...

I'm sorry -- what are you talking about? You can write anything you
want to any file you want. If you want to start your file with the
string "Bill Cunningham's File Format" you're more than welcome to do
that. I've got no idea what this has to do with lynx, and less what
you mean you say 7f is the signature for linux.

Yes yes sorry. I said lynx and not linux. Lynx is a web browser. I mean
in the OS's internals. STDC is higher level than what I want and this is
what this group is supposed to be about.

IIUC you want your file to have a specific signature that lets you
identify *your* files?
I don't know anything about the details, but ELF has .note sections that
you might be able to use for your purpose. Then there is also the
..comment section that looks promising, too.

Oh, and BTW the magic for ELF is four bytes: { 0x7f, 'E', 'L', 'F' }!

--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
Bill Cunningham...
Posted: Fri Sep 26, 2008 5:10 pm
Guest
"Josef Moellers" <josef.moellers at (no spam) fujitsu-siemens.com> wrote in message
news:gbi141$ble$1 at (no spam) nntp.fujitsu-siemens.com...

Quote:
IIUC you want your file to have a specific signature that lets you
identify *your* files?
I don't know anything about the details, but ELF has .note sections that
you might be able to use for your purpose. Then there is also the .comment
section that looks promising, too.

Oh, and BTW the magic for ELF is four bytes: { 0x7f, 'E', 'L', 'F' }!

Where can I put meta-data for my own format? Would that come after the

elf header?

Bill
Josef Moellers...
Posted: Mon Sep 29, 2008 2:25 am
Guest
Bill Cunningham wrote:
Quote:
"Josef Moellers" <josef.moellers at (no spam) fujitsu-siemens.com> wrote in message
news:gbi141$ble$1 at (no spam) nntp.fujitsu-siemens.com...

IIUC you want your file to have a specific signature that lets you
identify *your* files?
I don't know anything about the details, but ELF has .note sections that
you might be able to use for your purpose. Then there is also the .comment
section that looks promising, too.

Oh, and BTW the magic for ELF is four bytes: { 0x7f, 'E', 'L', 'F' }!

Where can I put meta-data for my own format? Would that come after the
elf header?

You need to consult the ELF spec. The ELF header contains file offsets
to various tables (e.g. section header table):

typedef struct {
unsigned char e_ident[EI_NIDENT];
uint16_t e_type;
uint16_t e_machine;
uint32_t e_version;
ElfN_Addr e_entry;
ElfN_Off e_phoff;
ElfN_Off e_shoff; <<< section header offset
uint32_t e_flags;
uint16_t e_ehsize;
uint16_t e_phentsize;
uint16_t e_phnum;
uint16_t e_shentsize;
uint16_t e_shnum;
uint16_t e_shstrndx;
} ElfN_Ehdr;

e_shoff This member holds the section header table’s file offset in
bytes. If the file has no section header table this
member
holds zero.
(from "man elf")

You would need to read an ELF file without a .note section and write one
with a .note section.

There are at least two libraries that will assist you in doing this:
libelf and libbfd.

There are also two programs that help you understand the file format:
readelf and objdump.

Josef
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
Bill Cunningham...
Posted: Mon Sep 29, 2008 4:31 pm
Guest
"Josef Moellers" <josef.moellers at (no spam) fujitsu-siemens.com> wrote in message
news:gbpvtp$253$1 at (no spam) nntp.fujitsu-siemens.com...
Quote:
You need to consult the ELF spec. The ELF header contains file offsets to
various tables (e.g. section header table):

typedef struct {
unsigned char e_ident[EI_NIDENT];
uint16_t e_type;
uint16_t e_machine;
uint32_t e_version;
ElfN_Addr e_entry;
ElfN_Off e_phoff;
ElfN_Off e_shoff; <<< section header offset
uint32_t e_flags;
uint16_t e_ehsize;
uint16_t e_phentsize;
uint16_t e_phnum;
uint16_t e_shentsize;
uint16_t e_shnum;
uint16_t e_shstrndx;
} ElfN_Ehdr;

e_shoff This member holds the section header table’s file offset in
bytes. If the file has no section header table this
member
holds zero.
(from "man elf")

You would need to read an ELF file without a .note section and write one
with a .note section.

There are at least two libraries that will assist you in doing this:
libelf and libbfd.

There are also two programs that help you understand the file format:
readelf and objdump.

Josef

Thanks much Josef.
 
Page 1 of 1       All times are GMT - 5 Hours
The time now is Fri Nov 21, 2008 5:35 pm