* Filter out write permissions.
* We now report more correct stat data. The information are retrieved from the Package* objects. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34098 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -65,6 +65,24 @@ Directory::GroupID() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
timespec
|
||||||
|
Directory::ModifiedTime() const
|
||||||
|
{
|
||||||
|
if (PackageDirectory* packageDirectory = fPackageDirectories.Head())
|
||||||
|
return packageDirectory->ModifiedTime();
|
||||||
|
|
||||||
|
timespec time = { 0, 0 };
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
off_t
|
||||||
|
Directory::FileSize() const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Directory::AddPackageNode(PackageNode* packageNode)
|
Directory::AddPackageNode(PackageNode* packageNode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ public:
|
|||||||
virtual mode_t Mode() const;
|
virtual mode_t Mode() const;
|
||||||
virtual uid_t UserID() const;
|
virtual uid_t UserID() const;
|
||||||
virtual gid_t GroupID() const;
|
virtual gid_t GroupID() const;
|
||||||
|
virtual timespec ModifiedTime() const;
|
||||||
|
virtual off_t FileSize() const;
|
||||||
|
|
||||||
virtual status_t AddPackageNode(PackageNode* packageNode);
|
virtual status_t AddPackageNode(PackageNode* packageNode);
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,26 @@ LeafNode::GroupID() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
timespec
|
||||||
|
LeafNode::ModifiedTime() const
|
||||||
|
{
|
||||||
|
if (PackageLeafNode* packageNode = fPackageNodes.Head())
|
||||||
|
return packageNode->ModifiedTime();
|
||||||
|
|
||||||
|
timespec time = { 0, 0 };
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
off_t
|
||||||
|
LeafNode::FileSize() const
|
||||||
|
{
|
||||||
|
if (PackageLeafNode* packageNode = fPackageNodes.Head())
|
||||||
|
return packageNode->FileSize();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LeafNode::AddPackageNode(PackageNode* packageNode)
|
LeafNode::AddPackageNode(PackageNode* packageNode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ public:
|
|||||||
virtual mode_t Mode() const;
|
virtual mode_t Mode() const;
|
||||||
virtual uid_t UserID() const;
|
virtual uid_t UserID() const;
|
||||||
virtual gid_t GroupID() const;
|
virtual gid_t GroupID() const;
|
||||||
|
virtual timespec ModifiedTime() const;
|
||||||
|
virtual off_t FileSize() const;
|
||||||
|
|
||||||
virtual status_t AddPackageNode(PackageNode* packageNode);
|
virtual status_t AddPackageNode(PackageNode* packageNode);
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ public:
|
|||||||
virtual mode_t Mode() const = 0;
|
virtual mode_t Mode() const = 0;
|
||||||
virtual uid_t UserID() const = 0;
|
virtual uid_t UserID() const = 0;
|
||||||
virtual gid_t GroupID() const = 0;
|
virtual gid_t GroupID() const = 0;
|
||||||
|
virtual timespec ModifiedTime() const = 0;
|
||||||
|
virtual off_t FileSize() const = 0;
|
||||||
|
|
||||||
virtual status_t AddPackageNode(PackageNode* packageNode) = 0;
|
virtual status_t AddPackageNode(PackageNode* packageNode) = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -18,3 +18,10 @@ PackageFile::PackageFile(mode_t mode, const PackageData& data)
|
|||||||
PackageFile::~PackageFile()
|
PackageFile::~PackageFile()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
off_t
|
||||||
|
PackageFile::FileSize() const
|
||||||
|
{
|
||||||
|
return fData.UncompressedSize();
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ public:
|
|||||||
const PackageData& data);
|
const PackageData& data);
|
||||||
virtual ~PackageFile();
|
virtual ~PackageFile();
|
||||||
|
|
||||||
|
virtual off_t FileSize() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PackageData fData;
|
PackageData fData;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -39,3 +39,10 @@ PackageNode::Init(PackageDirectory* parent, const char* name)
|
|||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
off_t
|
||||||
|
PackageNode::FileSize() const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#define PACKAGE_NODE_H
|
#define PACKAGE_NODE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
#include <util/SinglyLinkedList.h>
|
#include <util/SinglyLinkedList.h>
|
||||||
@@ -33,12 +35,20 @@ public:
|
|||||||
gid_t GroupID() const { return fGroupID; }
|
gid_t GroupID() const { return fGroupID; }
|
||||||
void SetGroupID(gid_t id) { fGroupID = id; }
|
void SetGroupID(gid_t id) { fGroupID = id; }
|
||||||
|
|
||||||
|
void SetModifiedTime(const timespec& time)
|
||||||
|
{ fModifiedTime = time; }
|
||||||
|
const timespec& ModifiedTime() const
|
||||||
|
{ return fModifiedTime; }
|
||||||
|
|
||||||
|
virtual off_t FileSize() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PackageDirectory* fParent;
|
PackageDirectory* fParent;
|
||||||
char* fName;
|
char* fName;
|
||||||
mode_t fMode;
|
mode_t fMode;
|
||||||
uid_t fUserID;
|
uid_t fUserID;
|
||||||
gid_t fGroupID;
|
gid_t fGroupID;
|
||||||
|
timespec fModifiedTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -134,15 +134,17 @@ struct Volume::PackageLoaderContentHandler : PackageContentHandler {
|
|||||||
|
|
||||||
status_t error;
|
status_t error;
|
||||||
|
|
||||||
|
// get the file mode -- filter out write permissions
|
||||||
|
mode_t mode = entry->Mode() & ~(mode_t)(S_IWUSR | S_IWGRP | S_IWOTH);
|
||||||
|
|
||||||
// create the package node
|
// create the package node
|
||||||
PackageNode* node;
|
PackageNode* node;
|
||||||
if (S_ISREG(entry->Mode())) {
|
if (S_ISREG(mode)) {
|
||||||
// file
|
// file
|
||||||
node = new(std::nothrow) PackageFile(entry->Mode(), entry->Data());
|
node = new(std::nothrow) PackageFile(mode, entry->Data());
|
||||||
} else if (S_ISLNK(entry->Mode())) {
|
} else if (S_ISLNK(mode)) {
|
||||||
// symlink
|
// symlink
|
||||||
PackageSymlink* symlink = new(std::nothrow) PackageSymlink(
|
PackageSymlink* symlink = new(std::nothrow) PackageSymlink(mode);
|
||||||
entry->Mode());
|
|
||||||
if (symlink == NULL)
|
if (symlink == NULL)
|
||||||
RETURN_ERROR(B_NO_MEMORY);
|
RETURN_ERROR(B_NO_MEMORY);
|
||||||
|
|
||||||
@@ -153,9 +155,9 @@ struct Volume::PackageLoaderContentHandler : PackageContentHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
node = symlink;
|
node = symlink;
|
||||||
} else if (S_ISDIR(entry->Mode())) {
|
} else if (S_ISDIR(mode)) {
|
||||||
// directory
|
// directory
|
||||||
node = new(std::nothrow) PackageDirectory(entry->Mode());
|
node = new(std::nothrow) PackageDirectory(mode);
|
||||||
} else
|
} else
|
||||||
RETURN_ERROR(B_BAD_DATA);
|
RETURN_ERROR(B_BAD_DATA);
|
||||||
|
|
||||||
@@ -167,6 +169,8 @@ struct Volume::PackageLoaderContentHandler : PackageContentHandler {
|
|||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
|
|
||||||
|
node->SetModifiedTime(entry->ModifiedTime());
|
||||||
|
|
||||||
// add it to the parent directory
|
// add it to the parent directory
|
||||||
if (parentDir != NULL)
|
if (parentDir != NULL)
|
||||||
parentDir->AddChild(node);
|
parentDir->AddChild(node);
|
||||||
|
|||||||
@@ -285,17 +285,17 @@ packagefs_read_stat(fs_volume* fsVolume, fs_vnode* fsNode, struct stat* st)
|
|||||||
|
|
||||||
NodeReadLocker nodeLocker(node);
|
NodeReadLocker nodeLocker(node);
|
||||||
|
|
||||||
// TODO: Fill in correctly!
|
|
||||||
st->st_mode = node->Mode();
|
st->st_mode = node->Mode();
|
||||||
st->st_nlink = 1;
|
st->st_nlink = 1;
|
||||||
st->st_uid = 0;
|
st->st_uid = node->UserID();
|
||||||
st->st_gid = 0;
|
st->st_gid = node->GroupID();
|
||||||
st->st_size = 0;
|
st->st_size = node->FileSize();
|
||||||
st->st_blksize = kOptimalIOSize;
|
st->st_blksize = kOptimalIOSize;
|
||||||
st->st_atime = 0;
|
st->st_mtim = node->ModifiedTime();
|
||||||
st->st_mtime = 0;
|
st->st_atim = st->st_mtim;
|
||||||
st->st_ctime = 0;
|
st->st_ctim = st->st_mtim;
|
||||||
st->st_crtime = 0;
|
// TODO: Perhaps manage a changed time (particularly for directories)?
|
||||||
|
st->st_crtim = st->st_mtim;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user