Main Page | Data Structures | File List | Data Fields | Globals

securestorage_api.c File Reference

Secure Storage API source file. More...

#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
#include <dirent.h>
#include <fcntl.h>
#include <time.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <gfal_api.h>
#include "lcg_util.h"
#include "ss-util.h"
#include "keystore_client.h"
#include "securestorage.h"
#include "securestorage_api.h"

Go to the source code of this file.

Functions

int securestorage_open_extended (char *lfn, int flags, mode_t mode, char *vo, char *guid, char *se)
 open remote file on Storage Element ( EXTENDED )

int securestorage_open_se (char *lfn, int flags, mode_t mode, char *se)
 open remote file on specified Storage Element

int securestorage_open (char *lfn, int flags, mode_t mode)
 open remote file on default Storage Element

int securestorage_close (int fd)
 close remote file

int securestorage_write (int fd, void *buffer, size_t size)
 encrypt and write

int securestorage_read (int fd, void *buffer, size_t size)
 read and decrypt

off_t securestorage_lseek (int fd, off_t offset, int whence)
 positions/repositions to offset

int securestorage_del_extended (char *lfn, int aflag, char *se, char *vo, char *conf_file, int insecure, int verbose, int timeout)
 delete remote file ( EXTENDED )

int securestorage_del (char *lfn, int aflag, char *se)
 delete remote file

ss_DIRsecurestorage_opendir (const char *name)
 open remote directory

dirent * securestorage_readdir (ss_DIR *dp)
 read remote directory

int securestorage_closedir (ss_DIR *dp)
 close remote directory

int securestorage_mkdir (const char *path, mode_t mode)
 Make remote directory.

int securestorage_rmdir (const char *path)
 Remove remote directory.

int securestorage_statg (const char *path, const char *guid, struct ss_filestatg *statbuf)
 Get information about a LFC file or directory.


Variables

int serrno
int errno


Detailed Description

Secure Storage API source file.

Author:
Giordano Scuderi and Nicola Dominante
Date:
2007

Definition in file securestorage_api.c.


Function Documentation

int securestorage_close int  fd  ) 
 

close remote file

opened with securestorage_open or securestorage_open_extended.

Author:
Giordano Scuderi
Parameters:
fd Remote file descriptor.
Returns:
0 if success or < 0 if fail in this case errno is set appropriately.

Definition at line 440 of file securestorage_api.c.

References errno.

Referenced by main().

int securestorage_closedir ss_DIR dp  ) 
 

close remote directory

in LCG File Catalog.

Author:
Giordano Scuderi
Parameters:
dp ss_DIR pointer returned from securestorage_opendir function.
Returns:
0 if success or < 0 if fail in this case errno is set appropriately.

Definition at line 976 of file securestorage_api.c.

References errno, lfc_closedir(), serrno, and SS_EINVAL.

Referenced by main().

int securestorage_del char *  lfn,
int  aflag,
char *  se
 

delete remote file

from selected SE, or all SE if -a flag is set to 1; it delete the associated Key if -a flag was specified, or if last replica was deleted.

Author:
Giordano Scuderi
Parameters:
lfn Logical File name of file that will be deleted.
aflag If specified all replica's and KEY will be deleted.
se Specify Storage Element that contain a replica to delete; (if -a doesn't specified). if NULL it use VO_<vo>_DEFAULT_SE environment variable.
Returns:
0 if success or < 0 if fail in this case errno is set appropriately.

Definition at line 847 of file securestorage_api.c.

References errno, insecure, securestorage_del_extended(), SS_EINVALSE, SS_EINVALVO, verbose, and VO.

Referenced by main().

int securestorage_del_extended char *  lfn,
int  aflag,
char *  se,
char *  vo,
char *  conf_file,
int  insecure,
int  verbose,
int  timeout
 

delete remote file ( EXTENDED )

from selected SE, or all SE if -a flag is set to 1; it delete the associated Key if -a flag was specified, or if last replica was deleted; extended ( user could specify vo, conf_file, insecure,verbose and timeout ).

Author:
Giordano Scuderi
Parameters:
lfn Logical File name of file that will be deleted.
aflag If specified all replica's and KEY will be deleted.
se Specify Storage Element that contain a replica to delete; (if -a doesn't specified). if NULL it use VO_<vo>_DEFAULT_SE environment variable.
vo Virtual Organization; if NULL it use LCG_GFAL_VO environment varianble.
conf_file Actually ignored.
insecure Actually ignored.
verbose if 1 output is more verbose.
timeout 
Returns:
0 if success or < 0 if fail in this case errno is set appropriately.

Definition at line 690 of file securestorage_api.c.

References accept_host, accept_lfn, accept_vo, errno, insecure, LCG_MAXPATHLEN, ss_check_lfn(), ss_delete_key(), SS_EINVALLFN, SS_EINVALSE, SS_EINVALVO, SS_ENAMETOOLONG, SS_ENOENT, SS_ENOREPLICA, ss_get_lfchome(), verbose, and VO.

Referenced by securestorage_del().

off_t securestorage_lseek int  fd,
off_t  offset,
int  whence
 

positions/repositions to offset

the file associated with the descriptor fd generated by a previous securestorage_open.

whence:
Indicates how to interpret the offset value:
SEEK_SET the offset is set from beginning of file.
SEEK_CUR the offset is added to current position.
SEEK_END the offset is added to current file size.
Author:
Giordano Scuderi, Nicola Dominante
Parameters:
fd Destination file descriptor.
offset The offset.
whence Indicates how to interpret the offset value.
Returns:
0 if success or < 0 if fail in this case errno is set appropriately.

Definition at line 546 of file securestorage_api.c.

References AES_BLOCK_SIZE, AES_encrypt(), errno, HEX_IVSIZE, ivec_dec(), ivec_inc(), securestorage_write(), SS_EOFFSET, SS_ESPIPE, and SS_EWHENCE.

Referenced by main().

int securestorage_mkdir const char *  path,
mode_t  mode
 

Make remote directory.

in LCG File Catalog.

Author:
Giordano Scuderi
Parameters:
path Remote directory path.
mode Octal permission used for directory creation (for example: 0644).
Returns:
0 if success or < 0 if fail in this case errno is set appropriately.

Definition at line 999 of file securestorage_api.c.

References accept_lfn, errno, lfc_mkdir(), serrno, SS_EINVAL, SS_EINVALLFN, and ss_get_lfchome().

Referenced by main().

int securestorage_open char *  lfn,
int  flags,
mode_t  mode
 

open remote file on default Storage Element

existing file will be opened for reading, new file will be opened for reading and writing.

flags:
Value is built by put in OR the bits defined in <fcntl.h> but one and only one of the first three flags below must be used:
O_RDONLY open for reading only
O_WRONLY open for writing only
O_RDWR open for reading and writing
O_CREAT create a new file
O_LARGEFILE allows files whose sizes cannot be represented in 31 bits to be opened.
mode:
Is used only if the file is created.
Author:
Giordano Scuderi
Parameters:
lfn New LFN to create, or existing LFN to read.
flags For example O_CREAT|O_WRONLY to create new file.
mode Octal permission used on file creation (for example: 0644).
Returns:
file descriptor if success or < 0 if fail in this case errno is set appropriately.

Definition at line 392 of file securestorage_api.c.

References errno, securestorage_open_extended(), SS_EINVALLFN, SS_EINVALSE, SS_EINVALVO, and VO.

Referenced by main().

int securestorage_open_extended char *  lfn,
int  flags,
mode_t  mode,
char *  vo,
char *  guid,
char *  se
 

open remote file on Storage Element ( EXTENDED )

existing file will be opened for reading, new file will be opened for reading and writing.
Extended version ( user could specify VO, GUID and destination SE ).

Author:
Giordano Scuderi
Parameters:
lfn Input LFN.
flags 
mode 
vo Virtual Organization; if NULL it use LCG_GFAL_VO environment varianble.
guid On file creation, if null this GUID will be used for the remote file; when file is opened for reading will be ignored.
se On file creation, it specify destination Storage Element; if NULL it use VO_<vo>_DEFAULT_SE environment variable.
Returns:
file descriptor if success or < 0 if fail in this case errno is set appropriately.

Definition at line 167 of file securestorage_api.c.

References accept_host, accept_lfn, accept_vo, AES_BLOCK_SIZE, AES_set_encrypt_key(), errno, HEX_IVSIZE, HEX_KEYSIZE, insecure, ss_check_lfn(), SS_EENCINIT, SS_EEXIST, SS_EINVALGUID, SS_EINVALLFN, SS_EINVALSE, SS_EINVALVO, ss_generate_surl(), ss_get_key(), ss_get_lfchome(), ss_get_surl(), ss_rand(), ss_send_key(), and verbose.

Referenced by securestorage_open(), and securestorage_open_se().

int securestorage_open_se char *  lfn,
int  flags,
mode_t  mode,
char *  se
 

open remote file on specified Storage Element

existing file will be opened for reading, new file will be opened for reading and writing.

flags:
Value is built by put in OR the bits defined in <fcntl.h> but one and only one of the first three flags below must be used:
O_RDONLY open for reading only
O_WRONLY open for writing only
O_RDWR open for reading and writing
O_CREAT create a new file
O_LARGEFILE allows files whose sizes cannot be represented in 31 bits to be opened.
mode:
Is used only if the file is created.
Author:
Giordano Scuderi, Nicola Dominante
Parameters:
lfn New LFN to create, or existing LFN to read.
flags For example O_CREAT|O_WRONLY to create new file.
mode Octal permission used on file creation (for example: 0644).
se On file creation, it specify destination Storage Element;
Returns:
file descriptor if success or < 0 if fail in this case errno is set appropriately.

Definition at line 355 of file securestorage_api.c.

References errno, securestorage_open_extended(), SS_EINVALLFN, SS_EINVALSE, SS_EINVALVO, and VO.

ss_DIR* securestorage_opendir const char *  name  ) 
 

open remote directory

from LCG File Catalog.

Author:
Giordano Scuderi
Parameters:
name Remote directory path.
Returns:
ss_DIR pointer if success or NULL if fail in this case errno is set appropriately.

Definition at line 893 of file securestorage_api.c.

References accept_host, accept_lfn, errno, lfc_opendirxg(), serrno, SS_EINVAL, SS_EINVALLFN, and ss_get_lfchome().

Referenced by main().

int securestorage_read int  fd,
void *  buffer,
size_t  size
 

read and decrypt

a file from remote Storage Element ( SE ).

Author:
Giordano Scuderi
Parameters:
fd File descriptor.
buffer Buffer that contains decrypted plain data.
size Size of data to read from remote file.
Returns:
0 if success or < 0 if fail in this case errno is set appropriately.

Definition at line 506 of file securestorage_api.c.

References errno, and securestorage_AES_ctr().

Referenced by main().

struct dirent* securestorage_readdir ss_DIR dp  ) 
 

read remote directory

from LCG File Catalog.

Author:
Giordano Scuderi
Parameters:
dp ss_DIR pointer returned from securestorage_opendir function.
Returns:
dirent struct pointer if success or NULL if fail in this case errno is set appropriately.

Definition at line 952 of file securestorage_api.c.

References errno, lfc_readdir(), serrno, and SS_EINVAL.

Referenced by main().

int securestorage_rmdir const char *  path  ) 
 

Remove remote directory.

from LCG File Catalog.

Author:
Giordano Scuderi
Parameters:
path Remote directory path.
Returns:
0 if success or < 0 if fail in this case errno is set appropriately.

Definition at line 1046 of file securestorage_api.c.

References accept_lfn, errno, lfc_rmdir(), serrno, SS_EINVALLFN, and ss_get_lfchome().

Referenced by main().

int securestorage_statg const char *  path,
const char *  guid,
struct ss_filestatg statbuf
 

Get information about a LFC file or directory.

from LCG File Catalog.

Author:
Giordano Scuderi
Parameters:
path Remote directory path.
guid File GUID (Global Unique Identifier).
statbuf LFC filestat structure that contains returned information.
Returns:
0 if success or < 0 if fail in this case errno is set appropriately.

Definition at line 1091 of file securestorage_api.c.

References accept_lfn, errno, lfc_statg(), serrno, SS_EINVALLFN, and ss_get_lfchome().

Referenced by main().

int securestorage_write int  fd,
void *  buffer,
size_t  size
 

encrypt and write

a file on remote Storage Element ( SE ).

Author:
Giordano Scuderi
Parameters:
fd File descriptor.
buffer Buffer that contains plain data to encrypt and write into remote SE.
size Size of data in buffer to write on remote file.
Returns:
0 if success or < 0 if fail in this case errno is set appropriately.

Definition at line 466 of file securestorage_api.c.

References errno, and securestorage_AES_ctr().

Referenced by main(), and securestorage_lseek().


Variable Documentation

int errno
 

Definition at line 113 of file securestorage_api.c.

int serrno
 

Definition at line 112 of file securestorage_api.c.


Generated on Wed May 30 09:56:31 2007 for Secure Storage Service by doxygen 1.3.5