protocol_flare.c File Reference
#include "magma.h"Defines | |
| #define | MAX_READ_TRY 16 |
| #define | PATH_LENGTH 255 |
| #define | INCLUDE_FLARE_INTERNALS |
Functions | |
| int | transmit_getattr (int s, struct in_addr *sa, char *share) |
| int | transmit_readlink (int s, struct in_addr *sa, char *share) |
| int | transmit_readdir (int s, struct in_addr *sa, char *share) |
| int | transmit_mknod (int s, struct in_addr *sa, char *share) |
| int | transmit_mkdir (int s, struct in_addr *sa, char *share) |
| int | transmit_unlink (int s, struct in_addr *sa, char *share) |
| int | transmit_rmdir (int s, struct in_addr *sa, char *share) |
| int | transmit_symlink (int s, struct in_addr *sa, char *share) |
| int | transmit_rename (int s, struct in_addr *sa, char *share) |
| int | transmit_link (int s, struct in_addr *sa, char *share) |
| int | transmit_chmod (int s, struct in_addr *sa, char *share) |
| int | transmit_chown (int s, struct in_addr *sa, char *share) |
| int | transmit_truncate (int s, struct in_addr *sa, char *share) |
| int | transmit_utime (int s, struct in_addr *sa, char *share) |
| int | transmit_open (int s, struct in_addr *sa, char *share) |
| int | transmit_read (int s, struct in_addr *sa, char *share) |
| int | transmit_write (int s, struct in_addr *sa, char *share) |
| int | transmit_statfs (int s, struct in_addr *sa, char *share) |
| int | transmit_add_flare_to_parent (int s, struct in_addr *sa, char *share) |
| int | transmit_remove_flare_from_parent (int s, struct in_addr *sa, char *share) |
| int | transmit_f_opendir (int s, struct in_addr *sa, char *share) |
| int | transmit_f_readdir (int s, struct in_addr *sa, char *share) |
| void | manage_fuse (int s, struct sockaddr_in *peer, socklen_t *peer_len) |
Define Documentation
| #define INCLUDE_FLARE_INTERNALS |
| #define MAX_READ_TRY 16 |
| #define PATH_LENGTH 255 |
Function Documentation
| void manage_fuse | ( | int | s, | |
| struct sockaddr_in * | peer, | |||
| socklen_t * | peer_len | |||
| ) |
manages an incoming flare connection.
- Parameters:
-
s network socket peer remote peer IP address peer_len size of *peer structure
| int transmit_add_flare_to_parent | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
Adds a flare to its parent.
- Parameters:
-
s client socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_chmod | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
change permission on a flare.
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_chown | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
change ownership on a flare
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_f_opendir | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
Performs opendir().
- Parameters:
-
s client socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_f_readdir | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
Performs readdir().
- Parameters:
-
s client socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_getattr | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
Performs lstat().
- Parameters:
-
s client socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_link | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
hard link two flares. hard links are not yet implemented... so far, doing a link() just calls a symlink()
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_mkdir | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
create a directory flare
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_mknod | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
manages a mknod() operation
- Parameters:
-
s peer socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_open | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
perform a open() on a flare. note that open is just used by fuse to check if a file is accessible. real creation is done using mknod().
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_read | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
return a slice of a file
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_readdir | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
manage a readdir() operation. for further informations please read protocol_pkt.h (search for pktqs_readdir() and read following macros).
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_readlink | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
read target of a link
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_remove_flare_from_parent | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
Removes a flare form its parent.
- Parameters:
-
s client socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_rename | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
rename a flare. renaming is a perfect example of magma internal complexity (which is solved kindly by POSIX standard).
rename()ing a flare can involve from 1 to 4(!) nodes. the most complex case is when flare "/path1/original", hosted on node "n1", has to be moved to "/path2/newname", hosted on node "n2", while flare "/path1/" is on node n3 and "/path2/" is on node n4.
that is pure pain in the ass! magma should. 1. add entry in /path2/ on node n4 2. create flare "/path2/newname" on n2 and sync contents. 3. remove entry from /path1/ on node n3 4. delete flare from itself on node n1
everything should be managed with a chain of fallback tests which should recover previous state if a step fail!
BUT! POSIX standard states that when a rename() is performed on two paths on different filesystems, should return -1 and set errno = EXDEV (Invalid cross-device link).
take mv(1) behaviour as an example, while renaming /tmp/file to /home/user/file (assuming that /tmp and /home are on different filesystems):
[..cut..] rename("/home/tx0/xyz", "/tmp/xyz") = -1 EXDEV (Invalid cross-device link) unlink("/tmp/xyz") = -1 ENOENT (No such file or directory) open("/home/tx0/xyz", O_RDONLY|O_LARGEFILE) = 3 fstat64(3, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0 open("/tmp/xyz", O_WRONLY|O_CREAT|O_LARGEFILE, 0100644) = 4 [..cut..]
as you can see, rename failed with EXDEV errno. so mv assumes that a normal copy (read/write pair) plus unlink should be performed! and do it. but magma already has operations for opening, reading and writing a flare (which also add and remove flares from parent flares)
so, that's the plan: if source and destination is both locally we implement rename for speed reasons (it's simply a matter of create new destination flare, save it, copy contents, case by case -- is a directory? a symlink? what? -- and than erasing the original one). for all other cases, -1 EXDEV will be returned!
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_rmdir | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
remove a directory flare
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_statfs | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
do a statfs()
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_symlink | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
create a symlink to a destination
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_truncate | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
truncate a file
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_unlink | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
delete a flare (which is not a directory)
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_utime | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
perform utime() on a flare
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to
| int transmit_write | ( | int | s, | |
| struct in_addr * | sa, | |||
| char * | share | |||
| ) |
write a piece of file
- Parameters:
-
s network socket sa struct in_addr of connecting peer share path of the share this connection refers to