rfc:streammetadata

This is an old revision of the document!


Request for Comments: How to write RFCs

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_OWNER_NAME	4
    #define PHP_STREAM_META_GROUP		5
    #define PHP_STREAM_META_ACCESS		6

implementing various aspects of touch(), chmod(), etc. Values are defined by option and currently are:

* For PHP_STREAM_META_TOUCH - struct utime * * For PHP_STREAM_META_OWNER_NAME, PHP_STREAM_META_OWNER_NAME - char * * For all the rest - long *

Userspace part

Userspace stream handler implements this wrapper by using userspace method:

  public function stream_metadata($path, $option, $value)

See example below as for suggested implementation for virtualized filesystem. The option values match options above, and have constants defined without the PHP prefix (i.e., STREAM_META_TOUCH, etc.). The value is:

* For STREAM_META_TOUCH - array specifying modification and access time (both optional, can be empty array) * For STREAM_META_OWNER_NAME, STREAM_META_OWNER_NAME - string specifying the name * For all the rest - integer

Examples

rfc/streammetadata.1300074596.txt.gz · Last modified: 2017/09/22 13:28 (external edit)