Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

ifuse_open doesn't handle file modes correctly

#4

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

Reported by Matt Colyer · March 24th, 2009 @ 03:22 AM

State: resolved
Milestone: 1.0 Release
Assigned to: Matt Colyer Matt Colyer

Activity

  1. Paul Sladen
    Paul Sladen

    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+");

    April 18th, 2009 @ 01:04 AM

  2. Nikias Bassen
    Nikias Bassen
    • 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).

    April 19th, 2009 @ 02:55 PM

  3. Nikias Bassen
    Nikias Bassen
    • 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.

    April 19th, 2009 @ 02:57 PM

  4. Nikias Bassen
    Nikias Bassen

    here's the patch for ifuse created using git format-patch.

    April 21st, 2009 @ 04:01 PM

  5. Nikias Bassen
    Nikias Bassen

    and the patch for libiphone updating the file open modes.

    April 21st, 2009 @ 04:02 PM

  6. Matt Colyer
    Matt Colyer
    • State changed from new to resolved

    (from [d0809fa25c43d179de621839a7aee2cdc05e3d65]) Handle file modes correctly

    [#4 ifuse_open doesn't handle file modes correctly state:resolved]

    Signed-off-by: Matt Colyer matt@colyer.name http://github.com/MattColyer/ifu...

    May 8th, 2009 @ 03:45 PM

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.