There is a folder /data , in it there are many links to folders mounted via NFS, for example.

 /data/2C -> /mnt/nfs/data/2C 

Three-level sub-folder system, PHP gets the name of the folder, for example. /data/2C/3D/FF and creates it if( !file_exists($folderName)) , via mkdir( $folderName, 0775, true) - the third parameter means that, if necessary, you need to create intermediate subfolders.

I noticed a strange glitch - there are loops of links in cases where the names of the first two levels coincide. For example, when the folder /2C/2C/XX needed instead of the subfolder /2C/2C inside /data/2C/ there appears not a subfolder, but a new link to /mnt/nfs/data/2C - thus, a circular reference is formed.

Is this a nfs bug, PHP mkdir() or my code?

The code is about this, nothing special:

 public static function getFolder( $id) { $folder = sprintf( '%s/%s', Config::get( 'mycoolapp.DATA_PATH'), self::hexPath( $id) ); // verify / create the folder if( !file_exists( $folder) && !mkdir( $folder, 0775, TRUE)) { Log::error("Folder creation failed", array( 'folder' => $folder)); } 

The hexPath() method just somehow makes a hexadecimal string XX/YY/ZZZZ from integer id

Everything works great on hundreds of thousands of folders. The exception is these single glitches when the names of subfolders of neighboring levels match.

  • Most likely the code, and you can show the key points in the question? - Naumov
  • added a code snippet, but this is unlikely to help. The code works in hundreds of thousands of folders, and there are literally several glitches — everywhere, the names of the folders in the adjacent levels match. - Sergiks
  • And just came to create an ass from the console? Can fs really consider a directory a duplicate and link it to a link - Naumov
  • ls -ld on problem directories in both directories. Rights to / mnt / nfs / data / * what? Also make sure that you use an absolute path, for example, print the contents of $folder before creating it. - 0andriy

0