Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在破解一些 samba 内部结构,并且我想记录 read_file 和 write_file 中写入的内容,确切地说我想获取文件名、目录以及写入的字节数。
在 struct files_struct 中,定义了文件名 (char* fsp_name),我可以计算写入字节数,但在 files_struct 中没有带目录的字段。
有什么办法,如何确定在 samba 胆量中打开文件的目录?
假设char* fsp_name包含完整文件(而不是相对名称),您可以使用strpbrk ()(man 3 strpbrk)吗?循环搜索“/”,直到它返回NULL。然后你的目录是从 fsp_name 到它最后一次返回的指针。
char* fsp_name
strpbrk ()
NULL
好的,所以 - 解决方案:files_struct 包含 'conn' 字段,其中有 'char * origpath' - 包含当前文件的目录。