tags:

views:

126

answers:

2

Hi, i'm hacking some samba internals, and I want to log, what's written in read_file and write_file, exactly I want to get file name, directory, and how much bytes are written.

in struct files_struct, there is defined file name (char* fsp_name), and I can count number of written bytes, but in files_struct there is no field with directory.

Is there any way, how to determine opened file's directory in samba guts?

A: 

Assuming that the char* fsp_name contains the full file (and not the relative name), could you use strpbrk () (man 3 strpbrk)? Loop searching for "/", until it returns NULL. Then your directory is from fsp_name to the pointer it returned the last time.

MighMoS
fsp_name doesn't contain full path, only file name :(
Yossarian
A: 

OK, so - solution: files_struct contains 'conn' field, which has 'char * origpath' - which contains current file's directory.

Yossarian