http___fmi.wikidot.com_spu2_1.xml
http___www.enterprisestorageforum.com_storage-management_object-vs.-posix-storage-2.html_1.xml
1.1 1.2 2.1 3.1 4.1 5.1 6.1 7.1 8.1
Примитиви за работа с файлове. (Мария и Деян) Примитивите - int creat( const char *filename, mode_t mode ) - създава се файл с име filename по указания начин в mode; - int open( const char* filename, int oflag ) - отваря файл с име filename за четене, писане или четене и писане според oflag - int close( int fd ) - освобождава файловия дескриптор fd - size_t read( int fd, void* buffer, size_t nbytes ) - чете в buffer от файла сочен от fd не повече от nbytes - size_t write( int fd, void* buffer, size_t nbytes ) - същото като read, но записване, а не четене - off_t lseek( int fd, off_t offset, int flag ) - текущата позиция на файла сочен от fd се премества на offset позиции спрямо flag
1.1 2.1 3.1 3.2 3.3 3.4 3.5 4.1 5.1 6.1 7.1 8.1 9.1 10.1 10.2 10.3 10.4 10.5 10.6 11.1 12.1 12.2 14.1 15.1 16.1 17.1 17.2 18.1 18.2 19.1 19.2 19.3 19.4 20.1 20.2 21.1 21.2 22.1 22.2 23.1 24.1 25.1 25.2 26.1 27.1 28.1
Object vs. POSIX Storage - Page 2 Object-POSIX? What really is needed is a hybrid file system that contains some of the aspects of object storage and some of the aspects of a POSIX file system. An obvious starting point is to either add the object storage functions (GET/PUT/DELETE) to POSIX, or to add some POSIX functions to object storage. In either case, the interesting part is trying to find the balance between object-oriented storage and POSIX. Adding too many functions to object storage makes the result look much more like POSIX. Conversely, if not enough functions are added to the object storage, then it won't be as easy to port applications. For either approach the overall general goals, at least in my mind, should be the following. - Simple to use - Only a few additional IO functions - Allow easy porting of POSIX IO applications - Add byte-level access in some fashion to object storage or object storage functions to POSIX storage. The controversial addition is the last one — adding byte-level access to object storage or adding object functions to POSIX. In my opinion, and I'm sure there will be people who won't agree with it, it is better to start with the simple object storage and add the needed functions to it. The biggest reason for this choice is simplicity. Object storage is very simple in concept with a very few IO functions. In addition, while people have been sold on the idea of object storage, they have found that writing applications to use it directly is really not easy. Therefore, I think it's better to start with object storage and add a few useful byte-level functions so that it's infinitely easier to port applications to use object storage. Here is my list of initial functions to add to object storage. There are some specific reasons I chose just these five functions and not more (or less). If byte-level access is going to be added to object storage an "open" function will be needed that returns a file descriptor that can be used throughput the application. To get an idea of what this function entails, an excerpt of the POSIX "open" manpage from Linux is listed below: int open(const char *pathname, int flags); int open(const char *pathname, int flags, mode_t mode); int creat(const char *pathname, mode_t mode); Given a pathname for a file, open() returns a file descriptor, a small, nonnegative integer for use in subsequent system calls (read(2), write(2), lseek(2), fcntl(2), etc.). The file descriptor returned by a successful call will be the lowest-numbered file descriptor not currently open for the process. By default, the new file descriptor is set to remain open across an execve(2) (i.e., the FD_CLOEXEC file descriptor flag described in fcntl(2) is initially disabled; the O_CLOEXEC flag, described below, can be used to change this default). The file offset is set to the beginning of the file (see lseek(2)). A call to open() creates a new open file description, an entry in the system-wide table of open files. This entry records the file offset and the file status flags (modifiable via the fcntl(2) F_SETFL operation). A file descriptor is a reference to one of these entries; this reference is unaffected if pathname is subsequently removed or modified to refer to a different file. The new open file description is initially not shared with any other process, but sharing may arise via fork(2). The argument flags must include one of the following access modes: O_RDONLY, O_WRONLY, or O_RDWR. These request opening the file read-only, write-only, or read/write, respectively. The "open" function creates the file descriptor which can then be used by subsequent IO functions such as read, write and lseek. The descriptor will around as long as the application is running. In addition to "open" we'll need the equivalent "close" function. Below is an excerpt of the POSIX close manpage from Linux: close(): int close(int fd); close() closes a file descriptor, so that it no longer refers to any file and may be reused. Any record locks (see fcntl(2)) held on the file it was associated with, and owned by the process, are removed (regardless of the file descriptor that was used to obtain the lock). If fd is the last file descriptor referring to the underlying open file description (see open(2)), the resources associated with the open file description are freed; if the descriptor was the last reference to a file which has been removed using unlink(2) the file is deleted. These two functions, open and close, give us the ability to create access to the data for the application at a byte level. Previous Page Next Page