> BTW, occasionally there are also different ways to do the same thing
> in the library [something I don't like all the time as well] and what
> you're trying to do is different how ntfsresize achives this and if
> you continue on your way I would expect finding bugs in the library.
The code that I showed you does work. I am getting the correct location on
the disk of the file that I am looking for.
As far as finding bugs goes. I think I have found two minor bugs. One that
I reported a few days ago. Which was a simple typo.
And the second one that I just found was trying to free a pointer to the
"I30" constant.
This can happen in the "free(na->name)" call.
| void ntfs_attr_close(ntfs_attr *na)
| {
| if (NAttrNonResident(na) && na->rl)
| free(na->rl);
| if (na->name != AT_UNNAMED)
| free(na->name); /*Will sometimes try to free .bss memory*/
| free(na);
| return;
| }
I get this problem when I do following function call:
ntfs_inode_lookup_by_name(ni_root, ufilename, ulen);
Which in turn makes the following function call:
ia_na = ntfs_attr_open(dir_ni, AT_INDEX_ALLOCATION, I30, 4);
Which in turn calls:
__ntfs_attr_init(na, ni, type, name, name_len);
Which in turn takes a pointer to I30 and puts it in the na->name.
| static __inline__ void __ntfs_attr_init(ntfs_attr *na, ntfs_inode *ni,
| const ATTR_TYPES type, uchar_t *name, const u32 name_len)
| {
| na->rl = NULL;
| na->ni = ni;
| na->type = type;
| if (name) {
| na->name = name;
| na->name_len = name_len;
| } else {
| na->name = AT_UNNAMED;
| na->name_len = 0;
| }
| }
To bypass the problem I changed ntfs_attr_close to be:
| if (na->name != AT_UNNAMED && na->name != I30)
| free(na->name);
But I don't think that is a very good general solution.
-------------------
Russ Christensen
Computer Science, Undergraduate
www.cs.utah.edu/~rchriste/
"Give a man a computer program and you give him a headache; teach him
to program computers, and you give him the power to create headaches
for others for the rest of his life."
--R.B. Forest
|