This is an old revision of the document!
Request for Comments: How to write RFCs
- Version: 1.0
- Date: 2011-03-13
- Author: Stas Malyshev stas@php.net
- Status: Draft
- First Published at: http://wiki.php.net/rfc/streammetadata
Purpose
PHP file streams provide very powerful and useful abstraction layer over the I/O-related functions. However, there's a group of functions which are excluded from this support - namely, touch(), chmod(), chown() and chgrp() - i.e., functions dealing with file metadata. This lead to libraries implementing FS virtualization developing various hacks, such as here: https://code.google.com/p/bovigo/wiki/vfsStreamDocsFilemode
The purpose of this RFC is to plug this hole by creating stream metadata API allowing to override these functions.
Engine part
The stream wrapper gets an additional optional handler, like this:
int (*stream_metadata)(php_stream_wrapper *wrapper, char *url, int options, void *value, php_stream_context *context TSRMLS_DC);
The options supported currently are:
#define PHP_STREAM_META_TOUCH 1 #define PHP_STREAM_META_OWNER_NAME 2 #define PHP_STREAM_META_OWNER 3 #define PHP_STREAM_META_GROUP_NAME 4 #define PHP_STREAM_META_GROUP 5 #define PHP_STREAM_META_ACCESS 6
implementing various aspects of touch(), chmod(), etc.
Userspace part
Userspace stream handler implements this wrapper by using userspace method:
public function stream_metadata($path, $option, $var)
See example below as for suggested implementation for virtualized filesystem.