Fix readdir I/O error on file names larger than 255 bytes in Solaris.

If a readdir operation returned a file name larger than 255 bytes,
Solaris/Illumos would return I/O error from the readdir operation.
Fixed by truncating the file name returned in the readdir operation.
edge.strict_endians
Erik Larsson 2014-04-18 11:54:54 +02:00
parent a0914beb98
commit 9e7184e2a6
2 changed files with 44 additions and 4 deletions

View File

@ -79,7 +79,9 @@
#if defined(__APPLE__) || defined(__DARWIN__)
#include <sys/dirent.h>
#endif /* defined(__APPLE__) || defined(__DARWIN__) */
#elif defined(__sun) && defined (__SVR4)
#include <param.h>
#endif /* defined(__APPLE__) || defined(__DARWIN__), ... */
#include "compat.h"
#include "attrib.h"
@ -1020,7 +1022,25 @@ static int ntfs_fuse_filler(ntfs_fuse_fill_context_t *fill_ctx,
memset(filename + MAXNAMLEN, 0, filenamelen - MAXNAMLEN);
ntfs_log_debug(" after: '%s'\n", filename);
}
#endif /* defined(__APPLE__) || defined(__DARWIN__) */
#elif defined(__sun) && defined (__SVR4)
/*
* Returning file names larger than MAXNAMELEN (256) bytes
* causes Solaris/Illumos to return an I/O error from the system
* call.
* However we also need space for a terminating NULL, or user
* space tools will bug out since they expect a NULL terminator.
* Effectively the maximum length of a file name is MAXNAMELEN -
* 1 (255).
*/
if (filenamelen > (MAXNAMELEN - 1)) {
ntfs_log_debug("Truncating %d byte filename to %d "
"bytes.\n", filenamelen, MAXNAMELEN - 1);
ntfs_log_debug(" before: '%s'\n", filename);
memset(&filename[MAXNAMELEN - 1], 0,
filenamelen - (MAXNAMELEN - 1));
ntfs_log_debug(" after: '%s'\n", filename);
}
#endif /* defined(__APPLE__) || defined(__DARWIN__), ... */
current = fill_ctx->last;
sz = fuse_add_direntry(fill_ctx->req,

View File

@ -78,7 +78,9 @@
#if defined(__APPLE__) || defined(__DARWIN__)
#include <sys/dirent.h>
#endif /* defined(__APPLE__) || defined(__DARWIN__) */
#elif defined(__sun) && defined (__SVR4)
#include <param.h>
#endif /* defined(__APPLE__) || defined(__DARWIN__), ... */
#include "compat.h"
#include "attrib.h"
@ -1057,7 +1059,25 @@ static int ntfs_fuse_filler(ntfs_fuse_fill_context_t *fill_ctx,
memset(filename + MAXNAMLEN, 0, filenamelen - MAXNAMLEN);
ntfs_log_debug(" after: '%s'\n", filename);
}
#endif /* defined(__APPLE__) || defined(__DARWIN__) */
#elif defined(__sun) && defined (__SVR4)
/*
* Returning file names larger than MAXNAMELEN (256) bytes
* causes Solaris/Illumos to return an I/O error from the system
* call.
* However we also need space for a terminating NULL, or user
* space tools will bug out since they expect a NULL terminator.
* Effectively the maximum length of a file name is MAXNAMELEN -
* 1 (255).
*/
if (filenamelen > (MAXNAMELEN - 1)) {
ntfs_log_debug("Truncating %d byte filename to %d "
"bytes.\n", filenamelen, MAXNAMELEN - 1);
ntfs_log_debug(" before: '%s'\n", filename);
memset(&filename[MAXNAMELEN - 1], 0,
filenamelen - (MAXNAMELEN - 1));
ntfs_log_debug(" after: '%s'\n", filename);
}
#endif /* defined(__APPLE__) || defined(__DARWIN__), ... */
ret = fill_ctx->filler(fill_ctx->buf, filename, &st, 0);
}