00001 00008 /* ==================================================================== 00009 * File: securestorage.h 00010 * 00011 * Function: Secure Storage header file 00012 * 00013 * Author(s): Giordano Scuderi and Nicola Dominante 00014 * 00015 * Copyright: Copyright (c) 2007 <Giordano Scuderi - gscuderi@unicosrl.it> 00016 * All Rights Reserved. 00017 * 00018 * Notes: Redistributions of any form whatsoever must retain the following 00019 * acknowledgment: 00020 * "This product includes software developed by Giordano Scuderi 00021 * for Unico SRL" 00022 * 00023 * ==================================================================== 00024 * Copyright (c) Giordano Scuderi, Unico SRL. All rights reserved. 00025 * 00026 * Redistribution and use in source and binary forms, with or without 00027 * modification, are permitted provided that the following conditions 00028 * are met: 00029 * 00030 * 1. Redistributions of source code must retain the above copyright 00031 * notice, this list of conditions and the following disclaimer. 00032 * 00033 * 2. Redistributions in binary form must reproduce the above copyright 00034 * notice, this list of conditions and the following disclaimer in 00035 * the documentation and/or other materials provided with the 00036 * distribution. 00037 * 00038 * 3. All advertising materials mentioning features or use of this 00039 * software must display the following acknowledgment: 00040 * "This product includes software developed by Giordano Scuderi 00041 * for Unico SRL" 00042 * 00043 * 4. The names "Secure Storage" must not be used to 00044 * endorse or promote products derived from this software without 00045 * prior written permission. For written permission, please contact 00046 * gscuderi@unicosrl.it. 00047 * 00048 * 5. Products derived from this software may not be called "Secure Storage" 00049 * nor may "Secure Storage" appear in their names without prior written 00050 * permission of Giordano Scuderi (Unico SRL). 00051 * 00052 * 6. Redistributions of any form whatsoever must retain the following 00053 * acknowledgment: 00054 * "This product includes software developed by Giordano Scuderi 00055 * for Unico SRL" 00056 * 00057 * THIS SOFTWARE IS PROVIDED BY UNICO SRL ``AS IS'' AND ANY 00058 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00059 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00060 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL UNICO SRL OR 00061 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00062 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00063 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00064 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00065 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00066 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00067 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 00068 * OF THE POSSIBILITY OF SUCH DAMAGE. 00069 * ==================================================================== 00070 * 00071 * "This product includes software developed by the OpenSSL Project 00072 * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 00073 * 00074 */ 00075 00076 // \def Max lenght of LFN Path. 00077 #define LCG_MAXPATHLEN 1023 00078 // \def Max lenght of local Path. 00079 #define MAXPATHLENGTH 255 00080 // \def Default Virtual Organization Environment Variable. 00081 #define VO "LCG_GFAL_VO" 00082 00083 typedef unsigned long long u_signed64; 00084 // \def Maximum length for a pool name. 00085 #define SS_MAXPOOLNAMELEN 15 00086 // \def Maximum length for a hostname. 00087 #define SS_MAXHOSTNAMELEN 63 00088 // \def Maximum length for a replica. 00089 #define SS_MAXSFNLEN 1103 00090 // \def Maximum length for a GUID. 00091 #define SS_MAXGUIDLEN 36 00092 00093 // \struct LFC Directory structure. 00094 typedef struct { 00095 int dd_fd; /* socket for communication with server */ 00096 u_signed64 fileid; 00097 int bod; /* beginning of directory */ 00098 int eod; /* end of directory */ 00099 int dd_loc; /* offset in buffer */ 00100 int dd_size; /* amount of data in buffer */ 00101 char *dd_buf; /* directory buffer */ 00102 int nbreplicas; 00103 char *replicas; 00104 } ss_DIR; 00105 00106 // \struct LFC filestat structure. 00107 struct ss_filestatg { 00108 u_signed64 fileid; 00109 char guid[SS_MAXGUIDLEN+1]; 00110 mode_t filemode; 00111 int nlink; /* number of files in a directory */ 00112 uid_t uid; 00113 gid_t gid; 00114 u_signed64 filesize; 00115 time_t atime; /* last access to file */ 00116 time_t mtime; /* last file modification */ 00117 time_t ctime; /* last metadata modification */ 00118 short fileclass; /* 1 --> experiment, 2 --> user */ 00119 char status; /* ' ' --> online, 'm' --> migrated */ 00120 char csumtype[3]; 00121 char csumvalue[33]; 00122 }; 00123 00124 struct lfc_filereplica { 00125 u_signed64 fileid; 00126 u_signed64 nbaccesses; 00127 time_t atime; /* last access to replica */ 00128 time_t ptime; /* replica pin time */ 00129 char status; 00130 char f_type; 00131 char poolname[SS_MAXPOOLNAMELEN+1]; 00132 char host[SS_MAXHOSTNAMELEN+1]; 00133 char fs[80]; 00134 char sfn[SS_MAXSFNLEN+1]; 00135 }; 00136 00137 #ifdef __cplusplus 00138 extern "C" { 00139 #endif 00140 00158 int lcg_scr(char *src_file,char *dest_file,char *guid,char *lfn,char *vo, 00159 char *conf_file,int insecure,int verbose,char *actual_gid); 00160 00175 int lcg_scp(char *src_file,char *dest_file,char *vo,char *conf_file, 00176 int insecure,int verbose); 00177 00194 int lcg_sdel(char *src_file,int aflag,char *se,char *vo,char *conf_file, 00195 int insecure,int verbose,int timeout); 00196 00197 00198 /****************************************************************************** 00199 * 00200 * SecureStorage API - encrypt/decrypt block of data 00201 * 00202 * 00203 * 00204 ******************************************************************************/ 00205 00222 int securestorage_open_extended(char *lfn, int flags, mode_t mode, 00223 char *vo, char *guid, char *se); 00224 00247 int securestorage_open_se (char *lfn, int flags, mode_t mode, char *se) ; 00248 00249 00271 int securestorage_open( char *lfn, int flags, mode_t mode ); 00272 00273 00282 int securestorage_close (int fd); 00283 00284 00295 int securestorage_write (int fd, void *buffer, size_t size ); 00296 00297 00308 int securestorage_read ( int fd, void *buffer, size_t size ); 00309 00310 00327 off_t securestorage_lseek (int fd, off_t offset, int whence); 00328 00329 00348 int securestorage_del_extended (char *lfn,int aflag,char *se,char *vo, 00349 char *conf_file,int insecure,int verbose,int timeout); 00350 00351 00364 int securestorage_del ( char *lfn, int aflag, char *se ); 00365 00366 00375 ss_DIR *securestorage_opendir (const char *name); 00376 00377 00386 struct dirent *securestorage_readdir (ss_DIR *dp); 00387 00388 00397 int securestorage_closedir (ss_DIR *dp); 00398 00399 00409 int securestorage_mkdir (const char *path, mode_t mode); 00410 00411 00420 int securestorage_rmdir (const char *path); 00421 00422 00433 int securestorage_statg (const char *path, const char *guid, 00434 struct ss_filestatg *statbuf); 00435 00436 00446 const char *securestorage_error(int errnum); 00447 00448 00449 #ifdef __cplusplus 00450 } /* closing brace for extern "C" */ 00451 #endif 00452