sj-i /
php-fuse
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * This file is part of the sj-i/php-fuse package. |
||
| 5 | * |
||
| 6 | * (c) sji <[email protected]> |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | declare(strict_types=1); |
||
| 13 | |||
| 14 | namespace Fuse; |
||
| 15 | |||
| 16 | use Fuse\Libc\Fcntl\Flock; |
||
| 17 | use Fuse\Libc\Fuse\FuseBufVec; |
||
| 18 | use Fuse\Libc\Fuse\FuseConnInfo; |
||
| 19 | use Fuse\Libc\Fuse\FuseDirFill; |
||
| 20 | use Fuse\Libc\Fuse\FuseDirHandle; |
||
| 21 | use Fuse\Libc\Fuse\FuseFileInfo; |
||
| 22 | use Fuse\Libc\Fuse\FuseFillDir; |
||
| 23 | use Fuse\Libc\Fuse\FuseIoctlArgPointer; |
||
| 24 | use Fuse\Libc\Fuse\FuseIoctlDataPointer; |
||
| 25 | use Fuse\Libc\Fuse\FusePollHandle; |
||
| 26 | use Fuse\Libc\Fuse\FusePrivateData; |
||
| 27 | use Fuse\Libc\Fuse\FuseReadDirBuffer; |
||
| 28 | use Fuse\Libc\String\CBytesBuffer; |
||
| 29 | use Fuse\Libc\String\CStringBuffer; |
||
| 30 | use Fuse\Libc\Sys\Stat\Stat; |
||
| 31 | use Fuse\Libc\Sys\StatVfs\StatVfs; |
||
| 32 | use Fuse\Libc\Time\TimeSpec; |
||
| 33 | use Fuse\Libc\Utime\UtimBuf; |
||
| 34 | use TypedCData\TypedCDataArray; |
||
| 35 | |||
| 36 | trait MountableFilesystemTrait |
||
| 37 | { |
||
| 38 | public function getOperations(): FuseOperations |
||
| 39 | { |
||
| 40 | $fuse_operations = new FuseOperations(); |
||
| 41 | |||
| 42 | $fuse_operations->getattr = [$this, 'getattr']; |
||
| 43 | $fuse_operations->readlink = [$this, 'readlink']; |
||
| 44 | /** @psalm-suppress DeprecatedProperty */ |
||
| 45 | $fuse_operations->getdir = [$this, 'getdir']; |
||
|
0 ignored issues
–
show
Deprecated Code
introduced
by
Loading history...
|
|||
| 46 | $fuse_operations->mknod = [$this, 'mknod']; |
||
| 47 | $fuse_operations->mkdir = [$this, 'mkdir']; |
||
| 48 | $fuse_operations->unlink = [$this, 'unlink']; |
||
| 49 | $fuse_operations->rmdir = [$this, 'rmdir']; |
||
| 50 | $fuse_operations->symlink = [$this, 'symlink']; |
||
| 51 | $fuse_operations->rename = [$this, 'rename']; |
||
| 52 | $fuse_operations->link = [$this, 'link']; |
||
| 53 | $fuse_operations->chmod = [$this, 'chmod']; |
||
| 54 | $fuse_operations->chown = [$this, 'chown']; |
||
| 55 | $fuse_operations->truncate = [$this, 'truncate']; |
||
| 56 | $fuse_operations->utime = [$this, 'utime']; |
||
| 57 | $fuse_operations->open = [$this, 'open']; |
||
| 58 | $fuse_operations->read = [$this, 'read']; |
||
| 59 | $fuse_operations->write = [$this, 'write']; |
||
| 60 | $fuse_operations->statfs = [$this, 'statfs']; |
||
| 61 | $fuse_operations->flush = [$this, 'flush']; |
||
| 62 | $fuse_operations->release = [$this, 'release']; |
||
| 63 | $fuse_operations->fsync = [$this, 'fsync']; |
||
| 64 | $fuse_operations->setxattr = [$this, 'setxattr']; |
||
| 65 | $fuse_operations->getxattr = [$this, 'getxattr']; |
||
| 66 | $fuse_operations->listxattr = [$this, 'listxattr']; |
||
| 67 | $fuse_operations->removexattr = [$this, 'removexattr']; |
||
| 68 | $fuse_operations->opendir = [$this, 'opendir']; |
||
| 69 | $fuse_operations->readdir = [$this, 'readdir']; |
||
| 70 | $fuse_operations->releasedir = [$this, 'releasedir']; |
||
| 71 | $fuse_operations->fsyncdir = [$this, 'fsyncdir']; |
||
| 72 | $fuse_operations->init = [$this, 'init']; |
||
| 73 | $fuse_operations->destroy = [$this, 'destroy']; |
||
| 74 | $fuse_operations->access = [$this, 'access']; |
||
| 75 | $fuse_operations->create = [$this, 'create']; |
||
| 76 | $fuse_operations->ftruncate = [$this, 'ftruncate']; |
||
| 77 | $fuse_operations->fgetattr = [$this, 'fgetattr']; |
||
| 78 | $fuse_operations->lock = [$this, 'lock']; |
||
| 79 | $fuse_operations->utimens = [$this, 'utimens']; |
||
| 80 | $fuse_operations->bmap = [$this, 'bmap']; |
||
| 81 | $fuse_operations->ioctl = [$this, 'ioctl']; |
||
| 82 | $fuse_operations->poll = [$this, 'poll']; |
||
| 83 | $fuse_operations->write_buf = [$this, 'writeBuf']; |
||
| 84 | $fuse_operations->read_buf = [$this, 'readBuf']; |
||
| 85 | $fuse_operations->flock = [$this, 'flock']; |
||
| 86 | $fuse_operations->fallocate = [$this, 'fallocate']; |
||
| 87 | $fuse_operations->flag_nullpath_ok = $this->getFlagNullpathOk(); |
||
| 88 | $fuse_operations->flag_nopath = $this->getFlagNopath(); |
||
| 89 | $fuse_operations->flag_utime_omit_ok = $this->getFlagUtimeOmitOk(); |
||
| 90 | |||
| 91 | return $fuse_operations; |
||
| 92 | } |
||
| 93 | |||
| 94 | /** |
||
| 95 | * int (*getattr) (const char *, struct stat *); |
||
| 96 | */ |
||
| 97 | abstract public function getattr(string $path, Stat $stat): int; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * int (*readlink) (const char *, char *, size_t); |
||
| 101 | */ |
||
| 102 | abstract public function readlink(string $path, CStringBuffer $buffer, int $size): int; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * int (*getdir) (const char *, fuse_dirh_t, fuse_dirfil_t); |
||
| 106 | * |
||
| 107 | * @deprecated |
||
| 108 | */ |
||
| 109 | abstract public function getdir(string $path, FuseDirHandle $dirhandle, FuseDirFill $dirfill): int; |
||
| 110 | |||
| 111 | /** |
||
| 112 | * int (*mknod) (const char *, mode_t, dev_t); |
||
| 113 | */ |
||
| 114 | abstract public function mknod(string $path, int $mode, int $dev): int; |
||
| 115 | |||
| 116 | /** |
||
| 117 | * int (*mkdir) (const char *, mode_t); |
||
| 118 | */ |
||
| 119 | abstract public function mkdir(string $path, int $mode): int; |
||
| 120 | |||
| 121 | /** |
||
| 122 | * int (*unlink) (const char *); |
||
| 123 | */ |
||
| 124 | abstract public function unlink(string $path): int; |
||
| 125 | |||
| 126 | /** |
||
| 127 | * int (*rmdir) (const char *); |
||
| 128 | */ |
||
| 129 | abstract public function rmdir(string $path): int; |
||
| 130 | |||
| 131 | /** |
||
| 132 | * int (*symlink) (const char *, const char *); |
||
| 133 | */ |
||
| 134 | abstract public function symlink(string $path, string $link): int; |
||
| 135 | |||
| 136 | /** |
||
| 137 | * int (*rename) (const char *, const char *); |
||
| 138 | */ |
||
| 139 | abstract public function rename(string $from, string $to): int; |
||
| 140 | |||
| 141 | /** |
||
| 142 | * int (*link) (const char *, const char *); |
||
| 143 | */ |
||
| 144 | abstract public function link(string $path, string $link): int; |
||
| 145 | |||
| 146 | /** |
||
| 147 | * int (*chmod) (const char *, mode_t); |
||
| 148 | */ |
||
| 149 | abstract public function chmod(string $path, int $mode): int; |
||
| 150 | |||
| 151 | /** |
||
| 152 | * int (*chown) (const char *, uid_t, gid_t); |
||
| 153 | */ |
||
| 154 | abstract public function chown(string $path, int $uid, int $gid): int; |
||
| 155 | |||
| 156 | /** |
||
| 157 | * int (*truncate) (const char *, off_t); |
||
| 158 | */ |
||
| 159 | abstract public function truncate(string $path, int $offset): int; |
||
| 160 | |||
| 161 | /** |
||
| 162 | * int (*utime) (const char *, struct utimbuf *); |
||
| 163 | */ |
||
| 164 | abstract public function utime(string $path, UtimBuf $utime_buf): int; |
||
| 165 | |||
| 166 | /** |
||
| 167 | * int (*open) (const char *, struct fuse_file_info *); |
||
| 168 | */ |
||
| 169 | abstract public function open(string $path, FuseFileInfo $fuse_file_info): int; |
||
| 170 | |||
| 171 | /** |
||
| 172 | * int (*read) (const char *, char *, size_t, off_t, struct fuse_file_info *); |
||
| 173 | */ |
||
| 174 | abstract public function read( |
||
| 175 | string $path, |
||
| 176 | CBytesBuffer $buffer, |
||
| 177 | int $size, |
||
| 178 | int $offset, |
||
| 179 | FuseFileInfo $fuse_file_info |
||
| 180 | ): int; |
||
| 181 | |||
| 182 | /** |
||
| 183 | * int (*write) (const char *, const char *, size_t, off_t, struct fuse_file_info *); |
||
| 184 | */ |
||
| 185 | abstract public function write( |
||
| 186 | string $path, |
||
| 187 | string $buffer, |
||
| 188 | int $size, |
||
| 189 | int $offset, |
||
| 190 | FuseFileInfo $fuse_file_info |
||
| 191 | ): int; |
||
| 192 | |||
| 193 | /** |
||
| 194 | * int (*statfs) (const char *, struct statvfs *); |
||
| 195 | */ |
||
| 196 | abstract public function statfs(string $path, StatVfs $statvfs): int; |
||
| 197 | |||
| 198 | /** |
||
| 199 | * int (*flush) (const char *, struct fuse_file_info *); |
||
| 200 | */ |
||
| 201 | abstract public function flush(string $path, FuseFileInfo $fuse_file_info): int; |
||
| 202 | |||
| 203 | /** |
||
| 204 | * int (*release) (const char *, struct fuse_file_info *); |
||
| 205 | */ |
||
| 206 | abstract public function release(string $path, FuseFileInfo $fuse_file_info): int; |
||
| 207 | |||
| 208 | /** |
||
| 209 | * int (*fsync) (const char *, int, struct fuse_file_info *); |
||
| 210 | */ |
||
| 211 | abstract public function fsync(string $path, int $flags, FuseFileInfo $fuse_file_info): int; |
||
| 212 | |||
| 213 | /** |
||
| 214 | * int (*setxattr) (const char *, const char *, const char *, size_t, int); |
||
| 215 | */ |
||
| 216 | abstract public function setxattr(string $path, string $name, string $value, int $size): int; |
||
| 217 | |||
| 218 | /** |
||
| 219 | * int (*getxattr) (const char *, const char *, char *, size_t); |
||
| 220 | */ |
||
| 221 | abstract public function getxattr(string $path, string $name, ?string &$value, int $size): int; |
||
| 222 | |||
| 223 | /** |
||
| 224 | * int (*listxattr) (const char *, char *, size_t);* |
||
| 225 | */ |
||
| 226 | abstract public function listxattr(string $path, ?string &$value, int $size): int; |
||
| 227 | |||
| 228 | /** |
||
| 229 | * int (*removexattr) (const char *, const char *); |
||
| 230 | */ |
||
| 231 | abstract public function removexattr(string $path, string $name): int; |
||
| 232 | |||
| 233 | /** |
||
| 234 | * int (*opendir) (const char *, struct fuse_file_info *); |
||
| 235 | */ |
||
| 236 | abstract public function opendir(string $path, FuseFileInfo $fuse_file_info): int; |
||
| 237 | |||
| 238 | /** |
||
| 239 | * int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *); |
||
| 240 | */ |
||
| 241 | abstract public function readdir( |
||
| 242 | string $path, |
||
| 243 | FuseReadDirBuffer $buf, |
||
| 244 | FuseFillDir $filler, |
||
| 245 | int $offset, |
||
| 246 | FuseFileInfo $fuse_file_info |
||
| 247 | ): int; |
||
| 248 | |||
| 249 | /** |
||
| 250 | * int (*releasedir) (const char *, struct fuse_file_info *); |
||
| 251 | */ |
||
| 252 | abstract public function releasedir(string $path, FuseFileInfo $fuse_file_info): int; |
||
| 253 | |||
| 254 | /** |
||
| 255 | * int (*fsyncdir) (const char *, int, struct fuse_file_info *); |
||
| 256 | */ |
||
| 257 | abstract public function fsyncdir(string $path, FuseFileInfo $fuse_file_info): int; |
||
| 258 | |||
| 259 | /** |
||
| 260 | * void *(*init) (struct fuse_conn_info *conn); |
||
| 261 | */ |
||
| 262 | abstract public function init(FuseConnInfo $conn): ?FusePrivateData; |
||
| 263 | |||
| 264 | /** |
||
| 265 | * void (*destroy) (void *); |
||
| 266 | */ |
||
| 267 | abstract public function destroy(?FusePrivateData $private_data): void; |
||
| 268 | |||
| 269 | /** |
||
| 270 | * int (*access) (const char *, int); |
||
| 271 | */ |
||
| 272 | abstract public function access(string $path, int $mode): int; |
||
| 273 | |||
| 274 | /** |
||
| 275 | * int (*create) (const char *, mode_t, struct fuse_file_info *); |
||
| 276 | */ |
||
| 277 | abstract public function create(string $path, int $mode, FuseFileInfo $fuse_file_info): int; |
||
| 278 | |||
| 279 | /** |
||
| 280 | * int (*ftruncate) (const char *, off_t, struct fuse_file_info *); |
||
| 281 | */ |
||
| 282 | abstract public function ftruncate(string $path, int $offset, FuseFileInfo $fuse_file_info): int; |
||
| 283 | |||
| 284 | /** |
||
| 285 | * int (*fgetattr) (const char *, struct stat *, struct fuse_file_info *); |
||
| 286 | */ |
||
| 287 | abstract public function fgetattr(string $path, Stat $stat, FuseFileInfo $fuse_file_info): int; |
||
| 288 | |||
| 289 | /** |
||
| 290 | * int (*lock) (const char *, struct fuse_file_info *, int cmd, struct flock *); |
||
| 291 | */ |
||
| 292 | abstract public function lock(string $path, FuseFileInfo $fuse_file_info, int $cmd, Flock $flock): int; |
||
| 293 | |||
| 294 | /** |
||
| 295 | * int (*utimens) (const char *, const struct timespec tv[2]); |
||
| 296 | * |
||
| 297 | * @param TypedCDataArray<TimeSpec> $tv |
||
| 298 | */ |
||
| 299 | abstract public function utimens(string $path, TypedCDataArray $tv): int; |
||
| 300 | |||
| 301 | /** |
||
| 302 | * int (*bmap) (const char *, size_t blocksize, uint64_t *idx); |
||
| 303 | */ |
||
| 304 | abstract public function bmap(string $path, int $blocksize, int &$idx): int; |
||
| 305 | |||
| 306 | /** |
||
| 307 | * unsigned int flag_nullpath_ok:1; |
||
| 308 | * unsigned int flag_nopath:1; |
||
| 309 | * unsigned int flag_utime_omit_ok:1; |
||
| 310 | * unsigned int flag_reserved:29; |
||
| 311 | */ |
||
| 312 | abstract public function setFlagNullpathOk(bool $flag): void; |
||
| 313 | abstract public function getFlagNullpathOk(): bool; |
||
| 314 | abstract public function setFlagNopath(bool $flag): void; |
||
| 315 | abstract public function getFlagNopath(): bool; |
||
| 316 | abstract public function setFlagUtimeOmitOk(bool $flag): void; |
||
| 317 | abstract public function getFlagUtimeOmitOk(): bool; |
||
| 318 | |||
| 319 | /** |
||
| 320 | * int (*ioctl) (const char *, int cmd, void *arg, struct fuse_file_info *, unsigned int flags, void *data); |
||
| 321 | */ |
||
| 322 | abstract public function ioctl( |
||
| 323 | string $path, |
||
| 324 | int $cmd, |
||
| 325 | FuseIoctlArgPointer $arg, |
||
| 326 | FuseFileInfo $fuse_file_info, |
||
| 327 | int $flags, |
||
| 328 | FuseIoctlDataPointer $data |
||
| 329 | ): int; |
||
| 330 | |||
| 331 | /** |
||
| 332 | * int (*poll) (const char *, struct fuse_file_info *, struct fuse_pollhandle *ph, unsigned *reventsp); |
||
| 333 | */ |
||
| 334 | abstract public function poll( |
||
| 335 | string $path, |
||
| 336 | FuseFileInfo $fuse_file_info, |
||
| 337 | FusePollHandle $fuse_pollhandle, |
||
| 338 | int &$reventsp |
||
| 339 | ): int; |
||
| 340 | |||
| 341 | /** |
||
| 342 | * int (*write_buf) (const char *, struct fuse_bufvec *buf, off_t off, struct fuse_file_info *); |
||
| 343 | */ |
||
| 344 | abstract public function writeBuf(string $path, FuseBufVec $buf, int $offset, FuseFileInfo $fuse_file_info): int; |
||
| 345 | |||
| 346 | /** |
||
| 347 | * int (*read_buf) (const char *, struct fuse_bufvec **bufp, size_t size, off_t off, struct fuse_file_info *); |
||
| 348 | * |
||
| 349 | * @param TypedCDataArray<FuseBufVec> $bufp |
||
| 350 | */ |
||
| 351 | abstract public function readBuf( |
||
| 352 | string $path, |
||
| 353 | TypedCDataArray $bufp, |
||
| 354 | int $size, |
||
| 355 | int $offset, |
||
| 356 | FuseFileInfo $fuse_file_info |
||
| 357 | ): int; |
||
| 358 | |||
| 359 | /** |
||
| 360 | * int (*flock) (const char *, struct fuse_file_info *, int op); |
||
| 361 | */ |
||
| 362 | abstract public function flock(string $path, FuseFileInfo $fuse_file_info, int $op): int; |
||
| 363 | |||
| 364 | /** |
||
| 365 | * int (*fallocate) (const char *, int, off_t, off_t, struct fuse_file_info *); |
||
| 366 | */ |
||
| 367 | abstract public function fallocate(string $path, int $mode, int $offset, FuseFileInfo $fuse_file_info): int; |
||
| 368 | } |
||
| 369 |