Don't crash when trying to chmod/chown the root directory

This commit is contained in:
Sebastian Meßmer 2015-04-23 09:24:52 +02:00
parent 6821684654
commit 89a9f1e3d2

View File

@ -73,19 +73,29 @@ unique_ptr<Blob> CryNode::LoadBlob() const {
void CryNode::stat(struct ::stat *result) const { void CryNode::stat(struct ::stat *result) const {
if(_parent.get() == nullptr) { if(_parent.get() == nullptr) {
//We arethe root directory. //We are the root directory.
//TODO What should we do? //TODO What should we do?
result->st_mode = S_IFDIR; result->st_mode = S_IFDIR;
} else { } else {
_parent->statChild(_key, result); _parent->statChild(_key, result);
} }
} }
void CryNode::chmod(mode_t mode) { void CryNode::chmod(mode_t mode) {
if (_parent.get() == nullptr) {
//We are the root direcory.
//TODO What should we do?
throw FuseErrnoException(EIO);
}
_parent->chmodChild(_key, mode); _parent->chmodChild(_key, mode);
} }
void CryNode::chown(uid_t uid, gid_t gid) { void CryNode::chown(uid_t uid, gid_t gid) {
if (_parent.get() == nullptr) {
//We are the root direcory.
//TODO What should we do?
throw FuseErrnoException(EIO);
}
_parent->chownChild(_key, uid, gid); _parent->chownChild(_key, uid, gid);
} }