From: Bartlomiej Grzelewski Date: Wed, 12 Feb 2014 14:19:50 +0000 (+0100) Subject: Fix implementation and rename FstreamHelper to FstreamAccessros. X-Git-Tag: submit/tizen/20140618.161300~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=57ebb3317874fe5a290ede0337acb79c1e23c80c;p=platform%2Fcore%2Fsecurity%2Fsecurity-manager.git Fix implementation and rename FstreamHelper to FstreamAccessros. [Issue#] N/A [Bug] FstreamHelper always inherited from fstream::__filebuf but it gets as param ofstream and should inherits from ofstream::__filebuf. [Cause] Name FstreamHelper was miningless. [Solution] N/A [Verfication] Build, run tests. Change-Id: I2a884860032d84f7cac05084dab4d3e3a2a5bbe9 --- diff --git a/src/server/dpl/core/include/dpl/fstream-helper.h b/src/server/dpl/core/include/dpl/fstream-helper.h deleted file mode 100644 index 9de82376..00000000 --- a/src/server/dpl/core/include/dpl/fstream-helper.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved - * - * Contact: Bumjin Im - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License - * - * @file fstream-helper.h - * @author Marek Smolinski (m.smolinski@samsung.com) - * @version 1.0 - * @brief This file is the implementation file of fstream-helper - * - */ - -#ifndef __FSTREAM_HELPER__ -#define __FSTREAM_HELPER__ - -#include - -namespace DPL { - -/* - * Bypass lack of public member function to get file - * descriptor from fstream objects in std - * This feature is needed for flushing data from kernel space buffer to - * physical device [fsync(int fd) - syscall] on opened fstream object -*/ - -struct FstreamHelper : std::fstream::__filebuf_type { - template - static int getFd(T &strm) { - return static_cast(strm.rdbuf())->_M_file.fd(); - } -}; - -} // namespace DPL - -#endif // __FSTREAM_HELPER__ diff --git a/src/server/dpl/core/include/dpl/fstream_accessors.h b/src/server/dpl/core/include/dpl/fstream_accessors.h new file mode 100644 index 00000000..1c595b63 --- /dev/null +++ b/src/server/dpl/core/include/dpl/fstream_accessors.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: Bumjin Im + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + * + * @file fstream-helper.h + * @author Marek Smolinski (m.smolinski@samsung.com) + * @version 1.0 + * @brief This file is the implementation file of fstream-helper + * + */ + +#ifndef SECURITY_SERVER_FSTREAM_ACCESSORS_H +#define SECURITY_SERVER_FSTREAM_ACCESSORS_H + +namespace DPL { + +/* + * Bypass lack of public member function to get file + * descriptor from fstream objects in std + * This feature is needed for flushing data from kernel space buffer to + * physical device [fsync(int fd) - syscall] on opened fstream object +*/ + +template +class FstreamAccessors : T::__filebuf_type { + typedef FstreamAccessors MyType; +public: + static int GetFd(T &strm) { + return static_cast(strm.rdbuf())->_M_file.fd(); + } +}; + +} // namespace DPL + +#endif // SECURITY_SERVER_FSTREAM_ACCESSORS_H diff --git a/src/server/dpl/log/src/audit-smack-log.cpp b/src/server/dpl/log/src/audit-smack-log.cpp index dbd328e8..d3a704c7 100644 --- a/src/server/dpl/log/src/audit-smack-log.cpp +++ b/src/server/dpl/log/src/audit-smack-log.cpp @@ -39,7 +39,7 @@ #include #include -#include +#include #define UNUSED __attribute__((unused)) @@ -136,7 +136,7 @@ void AuditSmackLog::HandleWrite(const char *message, std::string("] ") << function << std::string("(): ") << message << std::endl; - fsync(DPL::FstreamHelper::getFd(m_outputStream)); // flush kernel space buffer + fsync(DPL::FstreamAccessors::GetFd(m_outputStream)); // flush kernel space buffer } int AuditSmackLog::CreateLogFile() diff --git a/src/server/service/password-file-buffer.cpp b/src/server/service/password-file-buffer.cpp index 41720717..8ce8adea 100644 --- a/src/server/service/password-file-buffer.cpp +++ b/src/server/service/password-file-buffer.cpp @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include @@ -85,7 +85,7 @@ namespace SecurityServer } file.flush(); - fsync(DPL::FstreamHelper::getFd(file)); // flush kernel space buffer + fsync(DPL::FstreamAccessors::GetFd(file)); // flush kernel space buffer file.close(); } diff --git a/src/server/service/password-file.cpp b/src/server/service/password-file.cpp index 960c5234..79cc5496 100644 --- a/src/server/service/password-file.cpp +++ b/src/server/service/password-file.cpp @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include @@ -362,7 +362,7 @@ namespace SecurityServer } attemptFile.flush(); - fsync(DPL::FstreamHelper::getFd(attemptFile)); // flush kernel space buffer + fsync(DPL::FstreamAccessors::GetFd(attemptFile)); // flush kernel space buffer attemptFile.close(); }