core: Support named pipes

This is mainly useful for sysvinit's "/dev/initctl".
This commit is contained in:
Colin Walters 2011-11-09 09:08:58 -05:00
parent 1d23e4b8e8
commit a103218fd1
3 changed files with 22 additions and 2 deletions

View File

@ -259,11 +259,15 @@ ostree_stat_and_checksum_file (int dir_fd, const char *path,
device_id = g_strdup_printf ("%u", (guint)stbuf.st_rdev);
g_checksum_update (content_sha256, (guint8*)device_id, strlen (device_id));
}
else if (S_ISFIFO(stbuf.st_mode))
{
g_assert (objtype == OSTREE_OBJECT_TYPE_FILE);
}
else
{
g_set_error (error, G_IO_ERROR,
G_IO_ERROR_FAILED,
"Unsupported file '%s' (must be regular, symbolic link, or device)",
"Unsupported file '%s' (must be regular, symbolic link, fifo, or character/block device)",
path);
goto out;
}
@ -477,6 +481,10 @@ ostree_pack_object (GOutputStream *output,
device = g_file_info_get_attribute_uint32 (finfo, G_FILE_ATTRIBUTE_UNIX_DEVICE);
object_size = 4;
}
else if (S_ISFIFO (mode))
{
object_size = 0;
}
else
g_assert_not_reached ();
@ -525,6 +533,9 @@ ostree_pack_object (GOutputStream *output,
goto out;
g_assert (bytes_written == 4);
}
else if (S_ISFIFO (mode))
{
}
else
g_assert_not_reached ();
}
@ -774,6 +785,14 @@ unpack_file (const char *path,
goto out;
}
}
else if (S_ISFIFO (mode))
{
if (mkfifo (dest_path, mode) < 0)
{
ot_util_set_error_from_errno (error, errno);
goto out;
}
}
else
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,

View File

@ -827,7 +827,7 @@ query_child_info_file_archive (OstreeRepo *repo,
file_type = G_FILE_TYPE_SYMBOLIC_LINK;
else if (S_ISREG (mode))
file_type = G_FILE_TYPE_REGULAR;
else if (S_ISBLK (mode) || S_ISCHR(mode))
else if (S_ISBLK (mode) || S_ISCHR(mode) || S_ISFIFO(mode))
file_type = G_FILE_TYPE_SPECIAL;
else
{

View File

@ -90,6 +90,7 @@ setup_test_repository () {
$OSTREE commit -b test2 -s "Test Commit 1" -m "Commit body first"
mkdir baz
mkfifo baz/afifo # named pipe
echo moo > baz/cow
echo alien > baz/saucer
mkdir baz/deeper