nfs-ganesha 1.4

fsal_symlinks.c

Go to the documentation of this file.
00001 /*
00002  * vim:expandtab:shiftwidth=8:tabstop=8:
00003  */
00004 
00013 #ifdef HAVE_CONFIG_H
00014 #include "config.h"
00015 #endif
00016 
00017 #include "fsal.h"
00018 #include "fsal_internal.h"
00019 #include "fsal_convert.h"
00020 #include "fsal_common.h"
00021 #include <string.h>
00022 
00051 fsal_status_t FSAL_readlink(fsal_handle_t * linkhandle, /* IN */
00052                             fsal_op_context_t * p_context,      /* IN */
00053                             fsal_path_t * p_link_content,       /* OUT */
00054                             fsal_attrib_list_t * link_attributes        /* [ IN/OUT ] */
00055     )
00056 {
00057 
00058   int rc;
00059   fsal_status_t st;
00060   char link_content_out[FSAL_MAX_PATH_LEN];
00061 
00062   /* sanity checks.
00063    * note : link_attributes is optional.
00064    */
00065   if(!linkhandle || !p_context || !p_link_content)
00066     Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_readlink);
00067 
00068   TakeTokenFSCall();
00069 
00070   /* >> call your filesystem readlink function << */
00071 
00072   ReleaseTokenFSCall();
00073 
00074   /* >> convert error code and return on error << */
00075 
00076   /* >> convert fs output to fsal_path_t
00077    * for example, if this is a char * (link_content_out) :
00078    */
00079 
00080   st = FSAL_str2path(link_content_out, FSAL_MAX_PATH_LEN, p_link_content);
00081 
00082   if(FSAL_IS_ERROR(st))
00083     Return(st.major, st.minor, INDEX_FSAL_readlink);
00084 
00085   /* retrieves object attributes, if asked */
00086 
00087   if(link_attributes)
00088     {
00089 
00090       fsal_status_t status;
00091 
00092       status = FSAL_getattrs(linkhandle, p_context, link_attributes);
00093 
00094       /* On error, we set a flag in the returned attributes */
00095 
00096       if(FSAL_IS_ERROR(status))
00097         {
00098           FSAL_CLEAR_MASK(link_attributes->asked_attributes);
00099           FSAL_SET_MASK(link_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR);
00100         }
00101 
00102     }
00103 
00104   Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_readlink);
00105 
00106 }
00107 
00142 fsal_status_t FSAL_symlink(fsal_handle_t * parent_directory_handle,     /* IN */
00143                            fsal_name_t * p_linkname,    /* IN */
00144                            fsal_path_t * p_linkcontent, /* IN */
00145                            fsal_op_context_t * p_context,       /* IN */
00146                            fsal_accessmode_t accessmode,        /* IN (ignored) */
00147                            fsal_handle_t * link_handle, /* OUT */
00148                            fsal_attrib_list_t * link_attributes /* [ IN/OUT ] */
00149     )
00150 {
00151 
00152   int rc;
00153 
00154   /* sanity checks.
00155    * note : link_attributes is optional.
00156    */
00157   if(!parent_directory_handle ||
00158      !p_context || !link_handle || !p_linkname || !p_linkcontent)
00159     Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_symlink);
00160 
00161   /* Tests if symlinking is allowed by configuration. */
00162 
00163   if(!global_fs_info.symlink_support)
00164     Return(ERR_FSAL_NOTSUPP, 0, INDEX_FSAL_symlink);
00165 
00166   TakeTokenFSCall();
00167 
00168   /* >> call your fs symlink call << */
00169 
00170   ReleaseTokenFSCall();
00171 
00172   /* >> convert status and return on error <<  */
00173 
00174   /* >> set output handle << */
00175 
00176   if(link_attributes)
00177     {
00178 
00179       /* >> fill output attributes if they are asked << */
00180 
00181     }
00182 
00183   /* OK */
00184   Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_symlink);
00185 }