ifuse_open doesn't handle file modes correctly
Reported by Matt Colyer | March 24th, 2009 @ 03:22 AM | in 1.0 Release
ifuse_open() needs call something along the lines of:
int afc_mode_from_posix_mode(long long *afc_mode, const mode_t mode);
{
int i, result = -1;
const mode_t allowed_modes[7] = {
O_RDONLY,
O_RDONLY,
O_RDWR | O_CREAT,
O_WRONLY | O_CREAT | O_TRUNC,
O_RDWR | O_CREAT | O_TRUNC,
O_WRONLY | O_APPEND | O_CREAT,
O_RDWR | O_APPEND | O_CREAT
};
for(i = 0; i < 7; i++)
if(mode == allowed_modes[i]) {
*afc_mode = (long long)i;
result = 0;
break;
}
return result;
}
ifuse_open(...)
{
...
if (afc_mode_from_posix_mode(&mode, fi->flags & 0xSOMETHING)
return EPERM;
else
iphone_afc_open_file(afc, path, mode, &file);
...
}
instead of the present three-case if..else.
nb. (untested, undebugged, puesudo code); if nobody else makes it into something working, I'll do that tonight/tomorrow.
-Paul
Comments and changes to this ticket
-
Paul Sladen April 18th, 2009 @ 01:04 AM
Credit to Nikias for having the brains to think about this one!
And as to why... the six permissions are exactly those used by:
fopen(..., "r" "r+" "w" "w+" "a" "a+");
-
Nikias Bassen April 19th, 2009 @ 02:55 PM
- Tag set to afc, ifuse, patch
Hi, here's a patch for ifuse where ifuse_open does handle the filemodes correctly and ifuse_create just calls ifuse_open (as the open mode flags are given in fi->flags anyway).
-
Nikias Bassen April 19th, 2009 @ 02:57 PM
- Tag changed from afc, ifuse, patch to afc, ifuse, libiphone, patch
- Assigned user set to Matt Colyer
And here's the corresponding patch for libiphone, iphoneclient and afccheck are updated accordingly.
-
Nikias Bassen April 21st, 2009 @ 04:01 PM
here's the patch for ifuse created using git format-patch.
-
Matt Colyer May 8th, 2009 @ 03:45 PM
- State changed from new to resolved
(from [d0809fa25c43d179de621839a7aee2cdc05e3d65]) Handle file modes correctly
[#4 state:resolved]
Signed-off-by: Matt Colyer matt@colyer.name http://github.com/MattColyer/ifu...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
A project around supporting the iPhone in Linux.
See http://libimobiledevice.org