2011-06-16 22:28:14 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2002-2009, Haiku Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2005-10-29 20:27:43 +04:00
|
|
|
#ifndef _FS_ATTR_H
|
|
|
|
#define _FS_ATTR_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <OS.h>
|
|
|
|
#include <dirent.h>
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct attr_info {
|
|
|
|
uint32 type;
|
|
|
|
off_t size;
|
|
|
|
} attr_info;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
libroot_build: *Actually* fix attribute usage on Haiku.
To quote jscipione (from 95e8362c52af35a4012ca4d0facd62fb9856b619),
"Let me tell you a story about a bug" -- though this tale spans a much
lesser time than that one did.
In 5e19679ea35a79a26477c6215c7abba9bb7c4d00, I enabled libroot_build for
Haiku, instead of using the system libroot as we had before. There were
a number of bugs introduced along with this that I hadn't fixed (and there
may be more after this), but most of the obvious ones (crashes on x86_64...)
were fixed shortly enough.
Attribute usage, though, was a different story. Unlike most of the POSIX
calls in libroot, which were aliasing system functions no matter what the
platform, the attribute calls were not, as they are specific to Haiku.
Initially I had completely forgot about them, and it wasn't until a few days
later when I noticed that I had an "attributes" directory in my generated
that I realized that the "generic" attribute layer was being used on Haiku.
I attempted a fix for this in 5e19679ea35a79a26477c6215c7abba9bb7c4d00,
thinking that would clear the problem up, but I didn't actually run a test
beyond seeing that my BuildConfig had been updated properly. In fact,
BuildSetup was hard-wired to not even pass that definition through on
Haiku, and so that commit had in effect caused nothing.
My initial "fix" of just changing BuildSetup then caused a build failure,
as while libroot_build itself compiled, it ran into errors whenever attributes
were used, because in letting the real libroot's attribute calls shine
through, I had bypassed libroot_build's FD emulation/shim layer.
Then I tried and failed at three separate attempts to solve this with code:
- a version of the "fs_attr_...h" interface for Haiku. This proved possible
in theory, but in practice I would need to reimplement a lot of attribute
handling code in it, because all I had access to from there was syscalls.
- a version of "fs_attr_untyped" that bypassed its reimplementations of
the "fs*attr" functions for the libroot ones, only using the FD shim layer.
This proved possibly not even theoretically possible because it would have
caused preprocessor hell in some of the build headers, and also assumptions
about how attributes are read were totally different.
- a completely new "fs_attr_haiku" that was a completely new interface to
the fs*attr functions. This proved practically impossible because of the
need to include structures from the system libroot to call out to readdir,
etc. that attempts to solve would also have caused preprocessor hell.
Then I realized that the Linux xattr emulation library, which I'd used
as a reference when attempting the first solution, was shipped by default
as a system library in all builds of Haiku ... and so I could just tell
fs_attr_untyped to use the Linux xattr handler, and then link against libgnu.
So that is how I arrived at this strange and decidedly unorthodox solution
to a problem of my own creation.
2017-12-30 05:26:00 +03:00
|
|
|
|
2011-06-16 22:28:14 +04:00
|
|
|
extern ssize_t fs_read_attr(int fd, const char *attribute, uint32 type,
|
|
|
|
off_t pos, void *buffer, size_t readBytes);
|
|
|
|
extern ssize_t fs_write_attr(int fd, const char *attribute, uint32 type,
|
|
|
|
off_t pos, const void *buffer, size_t readBytes);
|
2005-10-29 20:27:43 +04:00
|
|
|
extern int fs_remove_attr(int fd, const char *attribute);
|
2011-06-16 22:28:14 +04:00
|
|
|
extern int fs_stat_attr(int fd, const char *attribute,
|
|
|
|
struct attr_info *attrInfo);
|
2005-10-29 20:27:43 +04:00
|
|
|
|
2011-06-16 22:28:14 +04:00
|
|
|
extern int fs_open_attr(const char *path, const char *attribute,
|
|
|
|
uint32 type, int openMode);
|
|
|
|
extern int fs_fopen_attr(int fd, const char *attribute, uint32 type,
|
|
|
|
int openMode);
|
2005-10-29 20:27:43 +04:00
|
|
|
extern int fs_close_attr(int fd);
|
|
|
|
|
|
|
|
extern DIR *fs_open_attr_dir(const char *path);
|
2018-04-15 06:59:18 +03:00
|
|
|
extern DIR *fs_lopen_attr_dir(const char *path);
|
2005-10-29 20:27:43 +04:00
|
|
|
extern DIR *fs_fopen_attr_dir(int fd);
|
|
|
|
extern int fs_close_attr_dir(DIR *dir);
|
|
|
|
extern struct dirent *fs_read_attr_dir(DIR *dir);
|
|
|
|
extern void fs_rewind_attr_dir(DIR *dir);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _FS_ATTR_H */
|