No longer takes an attribute for a file, or a device for an attribute.
Implemented attribute support. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6709 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
#include <NodeMonitor.h>
|
#include <NodeMonitor.h>
|
||||||
#include <Drivers.h>
|
#include <Drivers.h>
|
||||||
|
#include <fs_attr.h>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -203,9 +204,22 @@ DataEditor::SetTo(BEntry &entry, const char *attribute)
|
|||||||
fFile.GetStat(&stat);
|
fFile.GetStat(&stat);
|
||||||
fIsDevice = (stat.st_mode & (S_IFBLK | S_IFCHR)) != 0;
|
fIsDevice = (stat.st_mode & (S_IFBLK | S_IFCHR)) != 0;
|
||||||
|
|
||||||
|
if (attribute != NULL)
|
||||||
|
fAttribute = strdup(attribute);
|
||||||
|
else
|
||||||
|
fAttribute = NULL;
|
||||||
|
|
||||||
fBlockSize = 512;
|
fBlockSize = 512;
|
||||||
|
|
||||||
if (fIsDevice) {
|
if (IsAttribute()) {
|
||||||
|
attr_info info;
|
||||||
|
status = fFile.GetAttrInfo(fAttribute, &info);
|
||||||
|
if (status != B_OK)
|
||||||
|
return status;
|
||||||
|
|
||||||
|
fSize = info.size;
|
||||||
|
fType = info.type;
|
||||||
|
} else if (fIsDevice) {
|
||||||
// ToDo: is there any other possibility to issue a ioctl() from a BFile?
|
// ToDo: is there any other possibility to issue a ioctl() from a BFile?
|
||||||
device_geometry geometry;
|
device_geometry geometry;
|
||||||
int device = fFile.Dup();
|
int device = fFile.Dup();
|
||||||
@@ -220,9 +234,6 @@ DataEditor::SetTo(BEntry &entry, const char *attribute)
|
|||||||
fSize = 1LL * geometry.head_count * geometry.cylinder_count
|
fSize = 1LL * geometry.head_count * geometry.cylinder_count
|
||||||
* geometry.sectors_per_track * geometry.bytes_per_sector;
|
* geometry.sectors_per_track * geometry.bytes_per_sector;
|
||||||
fBlockSize = geometry.bytes_per_sector;
|
fBlockSize = geometry.bytes_per_sector;
|
||||||
} else if (IsAttribute()) {
|
|
||||||
// ToDo: add support for attributes!
|
|
||||||
fSize = 0;
|
|
||||||
} else {
|
} else {
|
||||||
status = fFile.GetSize(&fSize);
|
status = fFile.GetSize(&fSize);
|
||||||
if (status < B_OK) {
|
if (status < B_OK) {
|
||||||
@@ -231,11 +242,6 @@ DataEditor::SetTo(BEntry &entry, const char *attribute)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attribute != NULL)
|
|
||||||
fAttribute = strdup(attribute);
|
|
||||||
else
|
|
||||||
fAttribute = NULL;
|
|
||||||
|
|
||||||
fView = NULL;
|
fView = NULL;
|
||||||
fRealViewOffset = 0;
|
fRealViewOffset = 0;
|
||||||
fViewOffset = 0;
|
fViewOffset = 0;
|
||||||
@@ -476,7 +482,12 @@ DataEditor::SetBlockSize(size_t size)
|
|||||||
status_t
|
status_t
|
||||||
DataEditor::Update()
|
DataEditor::Update()
|
||||||
{
|
{
|
||||||
ssize_t bytesRead = fFile.ReadAt(fRealViewOffset, fView, fRealViewSize);
|
ssize_t bytesRead;
|
||||||
|
if (IsAttribute())
|
||||||
|
bytesRead = fFile.ReadAttr(fAttribute, fType, fRealViewOffset, fView, fRealViewSize);
|
||||||
|
else
|
||||||
|
bytesRead = fFile.ReadAt(fRealViewOffset, fView, fRealViewSize);
|
||||||
|
|
||||||
if (bytesRead < B_OK)
|
if (bytesRead < B_OK)
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
|
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ class DataEditor : public BLocker {
|
|||||||
entry_ref fRef;
|
entry_ref fRef;
|
||||||
BFile fFile;
|
BFile fFile;
|
||||||
const char *fAttribute;
|
const char *fAttribute;
|
||||||
|
type_code fType;
|
||||||
bool fIsDevice, fIsReadOnly;
|
bool fIsDevice, fIsReadOnly;
|
||||||
off_t fRealSize, fSize;
|
off_t fRealSize, fSize;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user