* We now ignore associated files. This makes the double entries of bug #3861

disappear.
* When parsing rock ridge attributes, we no longer stop when we encounter an
  unknown one. Instead, we just parse through until the end. The ISO image as
  part of #3861 also made this visible.
* Minor cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30655 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-05-07 08:00:10 +00:00
parent 843ce67e3d
commit 47a214def6
3 changed files with 61 additions and 41 deletions
@@ -303,6 +303,8 @@ parse_rock_ridge(iso9660_inode* node, char* buffer, char* end)
length = *(uint8*)(buffer + 2); length = *(uint8*)(buffer + 2);
if (buffer + length > end) if (buffer + length > end)
break; break;
if (length == 0)
break;
switch (((int)buffer[0] << 8) + buffer[1]) { switch (((int)buffer[0] << 8) + buffer[1]) {
// Stat structure stuff // Stat structure stuff
@@ -496,7 +498,7 @@ parse_rock_ridge(iso9660_inode* node, char* buffer, char* end)
// Deep directory record masquerading as a file. // Deep directory record masquerading as a file.
case 'CL': case 'CL':
TRACE(("RR: found CL, length %u\n", length)); TRACE(("RR: found CL, length %u\n", length));
node->flags |= ISO_ISDIR; node->flags |= ISO_IS_DIR;
node->startLBN[LSB_DATA] = *(uint32*)(buffer+4); node->startLBN[LSB_DATA] = *(uint32*)(buffer+4);
node->startLBN[MSB_DATA] = *(uint32*)(buffer+8); node->startLBN[MSB_DATA] = *(uint32*)(buffer+8);
break; break;
@@ -508,7 +510,8 @@ parse_rock_ridge(iso9660_inode* node, char* buffer, char* end)
case 'RE': case 'RE':
// Relocated directory, we should skip. // Relocated directory, we should skip.
TRACE(("RR: found RE, length %u\n", length)); TRACE(("RR: found RE, length %u\n", length));
return B_BAD_VALUE; // TODO: support relocated directories
return B_NOT_SUPPORTED;
case 'TF': case 'TF':
TRACE(("RR: found TF, length %u\n", length)); TRACE(("RR: found TF, length %u\n", length));
@@ -518,10 +521,17 @@ parse_rock_ridge(iso9660_inode* node, char* buffer, char* end)
TRACE(("RR: found RR, length %u\n", length)); TRACE(("RR: found RR, length %u\n", length));
break; break;
case 'SF':
TRACE(("RR: found SF, sparse files not supported!\n"));
// TODO: support sparse files
return B_NOT_SUPPORTED;
default: default:
TRACE(("RR: %x, %x, end of extensions.\n", if (buffer[0] == '\0') {
buffer[0], buffer[1])); TRACE(("RR: end of extensions\n"));
done = true; done = true;
} else
TRACE(("RR: Unknown tag %c%c\n", buffer[0], buffer[1]));
break; break;
} }
} }
@@ -712,10 +722,15 @@ ISOReadDirEnt(iso9660_volume *volume, dircookie *cookie, struct dirent *dirent,
cacheBlock = cookie->block; cacheBlock = cookie->block;
if (blockData != NULL && totalRead < cookie->totalSize) { if (blockData != NULL && totalRead < cookie->totalSize) {
bool done = false;
while (!done) {
iso9660_inode node; iso9660_inode node;
result = InitNode(&node, blockData + cookie->pos, &bytesRead, result = InitNode(&node, blockData + cookie->pos, &bytesRead,
volume->joliet_level); volume->joliet_level);
if (result == B_OK) { if (result != B_OK)
break;
if ((node.flags & ISO_IS_ASSOCIATED_FILE) == 0) {
size_t nameBufferSize = bufferSize - sizeof(struct dirent); size_t nameBufferSize = bufferSize - sizeof(struct dirent);
dirent->d_dev = volume->id; dirent->d_dev = volume->id;
@@ -736,13 +751,17 @@ ISOReadDirEnt(iso9660_volume *volume, dircookie *cookie, struct dirent *dirent,
"of size %lu\n", node.name, nameBufferSize)); "of size %lu\n", node.name, nameBufferSize));
result = B_BAD_VALUE; result = B_BAD_VALUE;
} }
cookie->pos += bytesRead;
done = true;
} }
cookie->pos += bytesRead;
if (cookie->pos == volume->logicalBlkSize[FS_DATA_FORMAT]) { if (cookie->pos == volume->logicalBlkSize[FS_DATA_FORMAT]) {
cookie->pos = 0; cookie->pos = 0;
cookie->block++; cookie->block++;
} }
}
} else { } else {
if (totalRead >= cookie->totalSize) if (totalRead >= cookie->totalSize)
result = B_ENTRY_NOT_FOUND; result = B_ENTRY_NOT_FOUND;
@@ -782,6 +801,7 @@ InitNode(iso9660_inode* node, char* buffer, size_t* _bytesRead,
memset(node->attr.stat, 0, sizeof(node->attr.stat)); memset(node->attr.stat, 0, sizeof(node->attr.stat));
node->extAttrRecLen = *(uint8*)buffer++; node->extAttrRecLen = *(uint8*)buffer++;
TRACE(("InitNode - ext attr length is %ld\n", node->extAttrRecLen));
node->startLBN[LSB_DATA] = *(uint32*)buffer; node->startLBN[LSB_DATA] = *(uint32*)buffer;
buffer += 4; buffer += 4;
@@ -819,7 +839,7 @@ InitNode(iso9660_inode* node, char* buffer, size_t* _bytesRead,
TRACE(("InitNode - file id length is %lu\n", node->name_length)); TRACE(("InitNode - file id length is %lu\n", node->name_length));
// Set defaults, in case there is no RockRidge stuff. // Set defaults, in case there is no RockRidge stuff.
node->attr.stat[FS_DATA_FORMAT].st_mode |= (node->flags & ISO_ISDIR) != 0 node->attr.stat[FS_DATA_FORMAT].st_mode |= (node->flags & ISO_IS_DIR) != 0
? S_IFDIR | S_IXUSR | S_IRUSR | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH ? S_IFDIR | S_IXUSR | S_IRUSR | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH
: S_IFREG | S_IRUSR | S_IRGRP | S_IROTH; : S_IFREG | S_IRUSR | S_IRGRP | S_IROTH;
@@ -116,12 +116,12 @@ struct iso9660_inode {
// These go with the flags member of the iso9660_volume struct. // These go with the flags member of the iso9660_volume struct.
enum { enum {
ISO_ISHIDDEN = 0, ISO_IS_HIDDEN = 0x01,
ISO_ISDIR = 2, ISO_IS_DIR = 0x02,
ISO_ISASSOCFILE = 4, ISO_IS_ASSOCIATED_FILE = 0x04,
ISO_EXTATTR = 8, ISO_EXTENDED_ATTRIBUTE = 0x08,
ISO_EXTPERM = 16, ISO_EXTENDED_PERMISSIONS = 0x10,
ISO_MOREDIRS = 128 ISO_MORE_DIRS = 0x80
}; };
@@ -355,7 +355,7 @@ fs_read_vnode(fs_volume *_vol, ino_t vnodeID, fs_vnode *_node,
*_type = newNode->attr.stat[FS_DATA_FORMAT].st_mode & ~(S_IWUSR | S_IWGRP | S_IWOTH); *_type = newNode->attr.stat[FS_DATA_FORMAT].st_mode & ~(S_IWUSR | S_IWGRP | S_IWOTH);
*_flags = 0; *_flags = 0;
if ((newNode->flags & ISO_ISDIR) == 0) { if ((newNode->flags & ISO_IS_DIR) == 0) {
newNode->cache = file_cache_create(ns->id, vnodeID, newNode->cache = file_cache_create(ns->id, vnodeID,
newNode->dataLen[FS_DATA_FORMAT]); newNode->dataLen[FS_DATA_FORMAT]);
} }
@@ -471,7 +471,7 @@ fs_read(fs_volume *_vol, fs_vnode *_node, void *cookie, off_t pos, void *buffer,
{ {
iso9660_inode *node = (iso9660_inode *)_node->private_node; iso9660_inode *node = (iso9660_inode *)_node->private_node;
if (node->flags & ISO_ISDIR) if ((node->flags & ISO_IS_DIR) != 0)
return EISDIR; return EISDIR;
uint32 fileSize = node->dataLen[FS_DATA_FORMAT]; uint32 fileSize = node->dataLen[FS_DATA_FORMAT];
@@ -548,7 +548,7 @@ fs_open_dir(fs_volume* /*_volume*/, fs_vnode* _node, void** _cookie)
TRACE(("fs_open_dir - node is %p\n", node)); TRACE(("fs_open_dir - node is %p\n", node));
if (!(node->flags & ISO_ISDIR)) if ((node->flags & ISO_IS_DIR) == 0)
return B_NOT_A_DIRECTORY; return B_NOT_A_DIRECTORY;
dircookie* dirCookie = (dircookie*)malloc(sizeof(dircookie)); dircookie* dirCookie = (dircookie*)malloc(sizeof(dircookie));