PHP 文件/目录统计相关函数在已安装的 CIFS 上不起作用

标签 php linux mount stat cifs

我在 32 位 Linux 上使用 PHP 遍历挂载的远程文件系统 (CIFS),我注意到 Unix 的统计相关函数不起作用(stat() filemtime()is_dir() 等)。

这是起点:

$ sudo mkdir /mnt/cifs-mount-point
$ sudo mount -t cifs -o user="user",password="password" //example.local/share /mnt/cifs-mount-point

这些是一些测试:

<?php

stat('/mnt/cifs-mount-point/directory');   // This will rise a Warning and return false
is_dir('/mnt/cifs-mount-point/directory'); // Will return false

我已经在 Bash 中检查过相同的内容,它按预期工作:

$ stat /mnt/cifs-mount-point
$ if [ -d /mnt/cifs-mount-point ] ; then echo "is dir"; fi

最佳答案

如果您在安装时未指定选项 noserverino,则

stat() 可能无法在 32 位系统中安装的 CIFS 上运行。例如:

mount -t cifs -o user="user",password="password",noserverino //example.local/share /mnt/cifs-mount-point

其他基于 stat() 数据的函数,例如文件时间函数和 is_dir() 也会受到同样的影响。

发生这种情况是因为如果您不指定选项 noserverino,则远程 inode 可能是基于 64 位的,因此本地系统无法处理它。

关于PHP 文件/目录统计相关函数在已安装的 CIFS 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26718203/

相关文章:

php - 我无法使用 Postgres 和 PHP 插入数据

linux - 通过 Yaourt Manjaro 错误安装 Gitkraken

c++ - 如何使用 clang/LLVM 库编译 C++ 代码?

linux - 安装实例存储损坏 ec2 实例

php - 轻松将 WordPress 数据库从本地迁移到生产环境

php - 如何获取创建当前对象的类?

linux - linux 中的 scull 设备驱动程序

macos - 如何在 Mac OS 上本地挂载 Docker 容器(就像我会使用 USB 驱动器一样)?

linux - 挂载点下隐藏文件夹的大小

php - 安全存储外部数据库密码