open.c (2053B)
1 /* 2 This file is part of gnunet-fuse. 3 Copyright (C) 2012 GNUnet e.V. 4 5 gnunet-fuse is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published 7 by the Free Software Foundation; either version 3, or (at your 8 option) any later version. 9 10 gnunet-fuse is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 19 */ 20 /* 21 * open.c - FUSE open function 22 * 23 * Created on: Mar 14, 2012 24 * Author: mg 25 * 26 * File open operation 27 * 28 * No creation (O_CREAT, O_EXCL) and by default also no 29 * truncation (O_TRUNC) flags will be passed to open(). If an 30 * application specifies O_TRUNC, fuse first calls truncate() 31 * and then open(). Only if 'atomic_o_trunc' has been 32 * specified and kernel version is 2.6.24 or later, O_TRUNC is 33 * passed on to open. 34 * 35 * Unless the 'default_permissions' mount option is given, 36 * open should check if the operation is permitted for the 37 * given flags. Optionally open may also return an arbitrary 38 * filehandle in the fuse_file_info structure, which will be 39 * passed to all file operations. 40 * 41 * Changed in version 2.2 42 */ 43 44 /** 45 * @file fuse/open.c 46 * @brief opening files 47 * @author Christian Grothoff 48 */ 49 #include "gnunet-fuse.h" 50 #include "gfs_download.h" 51 52 53 int 54 gn_open (const char *path, struct fuse_file_info *fi) 55 { 56 struct GNUNET_FUSE_PathInfo *pi; 57 int eno; 58 59 pi = GNUNET_FUSE_path_info_get (path, &eno); 60 if (NULL == pi) 61 return - eno; 62 /* NOTE: once we allow writes, we need to keep the RC 63 incremented until close... */ 64 GNUNET_FUSE_path_info_done (pi); 65 if (O_RDONLY != (fi->flags & 3)) 66 return - EACCES; 67 return 0; 68 } 69 70 /* end of open.c */