Alex Rivera | Logout

How to create named pipe (mkfifo) in Android?

Asked 2010-04-29T19:46:11.587
15

I am having trouble in creating named pipe in Android and the example below illustrates my dilemma:

res = mkfifo("/sdcard/fifo9000", S_IRWXO);
if (res != 0)
{
    LOG("Error while creating a pipe (return:%d, errno:%d)", res, errno);
}

The code always prints:

Error while creating a pipe (return:-1, errno:1)

I can't figure out exactly why this fails. The application has android.permission.WRITE_EXTERNAL_STORAGE permissions. I can create normal files with exactly the same name in the same location, but pipe creation fails. The pipe in question should be accessible from multiple applications.

  1. I suspect that noone can create pipes in /sdcard. Where would it be the best location to do so?
  2. What mode mast should I set (2nd parameter)?
  3. Does application need any extra permissions?
Edit
Report

1 Answer

8

The default filesystem of /sdcard is FAT32, which doesn't support named pipes.

On a non-rooted device the only possible place you could try to create those pipes would be the application data directory /data/data/com.example/ . Note: You shouldn't hardcode that value, use the Context.getApplicationInfo().dataDir .

But be aware that whenever the user is using Apps2SD or whenever Google implements that support officially you need to make sure to let the user know that the app can't be stored on vfat files system.

answered 2010-05-03T12:42:03.873

Your Answer