2020-09-13 07:49:25 +00:00
|
|
|
/*
|
|
|
|
* s3fs - FUSE-based file system backed by Amazon S3
|
|
|
|
*
|
|
|
|
* Copyright(C) 2007 Randy Rizun <rrizun@gmail.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef S3FS_FDCACHE_AUTO_H_
|
|
|
|
#define S3FS_FDCACHE_AUTO_H_
|
|
|
|
|
2021-06-27 06:15:48 +00:00
|
|
|
#include "autolock.h"
|
2020-09-13 07:49:25 +00:00
|
|
|
#include "fdcache_entity.h"
|
|
|
|
|
|
|
|
//------------------------------------------------
|
|
|
|
// class AutoFdEntity
|
|
|
|
//------------------------------------------------
|
2021-06-27 02:22:33 +00:00
|
|
|
// A class that opens fdentry and closes it automatically.
|
2020-09-13 07:49:25 +00:00
|
|
|
// This class object is used to prevent inconsistencies in
|
2021-06-27 02:22:33 +00:00
|
|
|
// the number of references in fdentry.
|
2020-09-13 07:49:25 +00:00
|
|
|
// The methods are wrappers to the method of the FdManager class.
|
|
|
|
//
|
|
|
|
class AutoFdEntity
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
FdEntity* pFdEntity;
|
2021-05-23 16:28:50 +00:00
|
|
|
int pseudo_fd;
|
2020-09-13 07:49:25 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
AutoFdEntity(AutoFdEntity& other);
|
|
|
|
bool operator=(AutoFdEntity& other);
|
|
|
|
|
|
|
|
public:
|
|
|
|
AutoFdEntity();
|
|
|
|
~AutoFdEntity();
|
|
|
|
|
2020-09-20 22:02:06 +00:00
|
|
|
bool Close();
|
2021-05-23 16:28:50 +00:00
|
|
|
int Detach();
|
|
|
|
bool Attach(const char* path, int existfd);
|
|
|
|
int GetPseudoFd() const { return pseudo_fd; }
|
|
|
|
|
2021-06-27 06:15:48 +00:00
|
|
|
FdEntity* Open(const char* path, headers_t* pmeta, off_t size, time_t time, int flags, bool force_tmpfile, bool is_create, AutoLock::Type type);
|
2021-05-23 16:55:25 +00:00
|
|
|
FdEntity* GetExistFdEntity(const char* path, int existfd = -1);
|
2021-06-27 02:22:33 +00:00
|
|
|
FdEntity* OpenExistFdEntity(const char* path, int flags = O_RDONLY);
|
2020-09-13 07:49:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // S3FS_FDCACHE_AUTO_H_
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* tab-width: 4
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* End:
|
|
|
|
* vim600: expandtab sw=4 ts=4 fdm=marker
|
|
|
|
* vim<600: expandtab sw=4 ts=4
|
|
|
|
*/
|