Remove unused mmap io interface 22/318622/3 accepted/tizen_unified_x_asan accepted/tizen/unified/20250122.130617 accepted/tizen/unified/x/20250122.173321 accepted/tizen/unified/x/asan/20250211.003152
authorJiyong <jiyong.min@samsung.com>
Tue, 21 Jan 2025 07:30:01 +0000 (16:30 +0900)
committerJiyong <jiyong.min@samsung.com>
Wed, 22 Jan 2025 01:44:37 +0000 (10:44 +0900)
Change-Id: I38f896128a3088a12caf1f9f92ec4bd99ae80b38

config.h.in
configure.ac
formats/ffmpeg/Makefile.am
formats/ffmpeg/mm_file_formats.c
packaging/libmm-fileinfo.spec
utils/Makefile.am
utils/include/mm_file_utils.h
utils/mm_file_util_io.c
utils/mm_file_util_io_mmap.c [deleted file]

index 93d4de0da2cf258ab7feb526dfdd64752d9dad0f..cc98688f06e3bd45d0163343a3c6abc329fca2f8 100644 (file)
@@ -42,9 +42,6 @@
 /* Define to 1 if you have the `memset' function. */
 #undef HAVE_MEMSET
 
-/* Define to 1 if you have a working `mmap' system call. */
-#undef HAVE_MMAP
-
 /* Define to 1 if you have the `munmap' function. */
 #undef HAVE_MUNMAP
 
index 7d205dd912266a46f6a2c25c041440292bedac6a..5c76f74670fae1dd12464707c9f189622074ae94 100644 (file)
@@ -44,7 +44,6 @@ AC_FUNC_LSTAT
 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
 AC_FUNC_MALLOC
 AC_FUNC_MEMCMP
-AC_FUNC_MMAP
 AC_FUNC_REALLOC
 AC_CHECK_FUNCS([gettimeofday memset munmap strcasecmp strdup])
 
@@ -125,19 +124,7 @@ AC_ARG_ENABLE(dyn, AC_HELP_STRING([--enable-dyn], [using dyn]),
 ],[USE_DYN=yes])
 AM_CONDITIONAL(USE_DYN, test "x$USE_DYN" = "xyes")
 AC_MSG_RESULT(checking for USE_DYN ... $USE_DYN)
-
-dnl use iommap --------------------------------------------------------------------------
-AC_ARG_ENABLE(iommap, AC_HELP_STRING([--enable-iommap], [using iommap]),
-[
-   case "${enableval}" in
-       yes) USE_IOMMAP=yes ;;
-        no) USE_IOMMAP=no ;;
-         *) AC_MSG_ERROR(bad value ${enableval} for --enable-iommap) ;;
-   esac
-],[USE_IOMMAP=no])
-AM_CONDITIONAL(USE_IOMMAP, test "x$USE_IOMMAP" = "xyes")
-AC_MSG_RESULT(checking for USE_IOMMAP ... $USE_IOMMAP)
-        
 dnl use testmode  --------------------------------------------------------------------------
 AC_ARG_ENABLE(testmode, AC_HELP_STRING([--enable-testmode], [using testmode]),
 [
index eb5befc1435490e5c3c8d08c521a720ffe8be497..16234e74b52e148b77dbab1a91ed808c54c35515 100755 (executable)
@@ -43,10 +43,6 @@ if USE_DUMP
 libmmfile_formats_la_CFLAGS += -DMMFILE_FORMAT_DEBUG_DUMP
 endif
 
-if USE_IOMMAP
-libmmfile_formats_la_CFLAGS += -D__MMFILE_MMAP_MODE__
-endif
-
 
 libmmfile_formats_la_LIBADD = $(MMCOMMON_LIBS) \
                                $(AVUTIL_LIBS) \
index 5399e71622f4c986ca91534fdda6c32b36e937da..5f7a6411b181af6693b8983e07c6abe0caa393c7 100755 (executable)
@@ -297,17 +297,13 @@ _PreprocessFile(MMFileSourceType *fileSrc, char **urifilename, int *formatEnum)
 
        if (fileSrc->type == MM_FILE_SRC_TYPE_FILE) {
                unsigned long long fileExt = 0;
-#ifdef __MMFILE_MMAP_MODE__
-               const char *uriStr = MMFILE_MMAP_URI;
-#else
-               const char *uriStr = MMFILE_FILE_URI;
-#endif
+
                fileName = (const char *)(fileSrc->file.path);
                filename_len = strlen(fileName);
 
                int pos = filename_len;
 
-               *urifilename = g_strconcat(uriStr, fileName, NULL);
+               *urifilename = g_strconcat(MMFILE_FILE_URI, fileName, NULL);
 
                /**
                 * Get file extension from file's name
index aff6a6af07aeb085f7232a605d27964ae7ce3067..fa2edb9e6b6cd250f40b6df0e42ca5980e1bb6c4 100644 (file)
@@ -1,6 +1,6 @@
 Name:      libmm-fileinfo
 Summary:    Media Fileinfo
-Version:    1.1.0
+Version:    1.1.1
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
@@ -58,7 +58,7 @@ export CFLAGS+=" -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast -fgnu89-inlin
 
 %reconfigure \
 CFLAGS="${CFLAGS} -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\" " LDFLAGS="${LDFLAGS}" \
-./configure --disable-testmode --disable-dump --enable-dyn --disable-iommap --prefix=/usr \
+./configure --disable-testmode --disable-dump --enable-dyn --prefix=/usr \
 %if 0%{?gtests:1}
        --enable-tests \
 %endif
index 4d7ba104c9d1aab4ed6962b53e350b6e7115a35c..aee476a84c58316f50569ba84692f9d9678aefeb 100755 (executable)
@@ -5,7 +5,6 @@ noinst_HEADERS =  include/mm_file_utils.h
 libmmfile_utils_la_SOURCES = mm_file_util_io.c \
                           mm_file_util_io_file.c \
                           mm_file_util_io_mem.c \
-                          mm_file_util_io_mmap.c \
                           mm_file_util_print.c \
                           mm_file_util_mime.c \
                           mm_file_util_string.c \
index 904ec2e4b6bbd14f54060e64471000b31202352a..1bd7fba1c8db4c36889455cf4b7fee873eff20d5 100755 (executable)
@@ -113,8 +113,6 @@ int MMFileFormatIsValidAPE(MMFileIOHandle *pFileIO, const char *mmfileuri, int d
 #define MMFILE_FILE_URI_LEN    7
 #define MMFILE_MEM_URI         "mem://"
 #define MMFILE_MEM_URI_LEN     6
-#define MMFILE_MMAP_URI        "mmap://"
-#define MMFILE_MMAP_URI_LEN    7
 #define MMFILE_AVIO_BUFFER_LEN         32768
 
 #define MMFILE_RDONLY          O_RDONLY
index 03698dc9c3639e9078a21717887b01a9694d10b0..3e22c7a87c05feea2467084dcb1f583ee8cd0d64 100644 (file)
@@ -319,11 +319,9 @@ int mmfile_register_io_all()
 
        extern MMFileIOFunc mmfile_file_io_handler;
        extern MMFileIOFunc mmfile_mem_io_handler;
-       extern MMFileIOFunc mmfile_mmap_io_handler;
 
        mmfile_register_io_func(&mmfile_file_io_handler);
        mmfile_register_io_func(&mmfile_mem_io_handler);
-       mmfile_register_io_func(&mmfile_mmap_io_handler);
 
        return MMFILE_UTIL_SUCCESS;
 }
diff --git a/utils/mm_file_util_io_mmap.c b/utils/mm_file_util_io_mmap.c
deleted file mode 100755 (executable)
index 143862c..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * libmm-fileinfo
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Haejeong Kim <backto.kim@samsung.com>
- *
- * 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.
- *
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include "mm_file_debug.h"
-#include "mm_file_utils.h"
-
-
-typedef struct {
-       int fd;
-       unsigned char *ptr;
-       long long size;
-       long long offset;
-       int     state;
-} MMFMMapIOHandle;
-
-static int mmf_mmap_open(MMFileIOHandle *handle, const char *filename, int flags)
-{
-       MMFMMapIOHandle *mmapHandle = NULL;
-       struct stat finfo = {0, };
-       int access = O_RDONLY;
-
-       if (!handle || !filename || !handle->iofunc || !handle->iofunc->handleName) {
-               debug_error(DEBUG, "invalid param\n");
-               return MMFILE_UTIL_FAIL;
-       }
-
-       filename += strlen(handle->iofunc->handleName) + 3; /* :// */
-
-       mmapHandle = g_new0(MMFMMapIOHandle, 1);
-
-#ifdef O_BINARY
-       access |= O_BINARY;
-#endif
-
-       mmapHandle->fd = open(filename, access);
-       if (mmapHandle->fd < 0) {
-               debug_error(DEBUG, "error: open error: %s\n", filename);
-               goto exception;
-       }
-
-       if (fstat(mmapHandle->fd, &finfo) == -1) {
-               debug_error(DEBUG, "error: fstat\n");
-               goto exception;
-       }
-
-       if (!S_ISREG(finfo.st_mode)) {
-               debug_error(DEBUG, "error: it is not regular file\n");
-               goto exception;
-       }
-
-       mmapHandle->size = finfo.st_size;
-       mmapHandle->offset = 0;
-       mmapHandle->state = 0;
-
-       /*mmapHandle->ptr = mmap64(0, mmapHandle->size, PROT_READ, MAP_SHARED, mmapHandle->fd, 0); */
-       mmapHandle->ptr = mmap(0, mmapHandle->size, PROT_READ, MAP_SHARED, mmapHandle->fd, 0);
-
-       if (mmapHandle->ptr == (void *)-1) {
-               debug_error(DEBUG, "error: mmap\n");
-               mmapHandle->ptr = NULL;
-               goto exception;
-       }
-
-       handle->privateData = (void *) mmapHandle;
-
-       return MMFILE_UTIL_SUCCESS;
-
-exception:
-       if (mmapHandle->ptr) {
-               munmap(mmapHandle->ptr, mmapHandle->size);
-       }
-
-       if (mmapHandle->fd > 2) {
-               close(mmapHandle->fd);
-       }
-
-       mmfile_free(mmapHandle);
-       handle->privateData = NULL;
-
-       return MMFILE_UTIL_FAIL;
-}
-
-static int mmf_mmap_read(MMFileIOHandle *h, unsigned char *buf, int size)
-{
-       MMFMMapIOHandle *mmapHandle = NULL;
-       const unsigned char *c = NULL;
-       int len = 0;
-
-       if (!h || !h->privateData || !buf || size <= 0) {
-               debug_error(DEBUG, "invalid para\n");
-               return MMFILE_UTIL_FAIL;
-       }
-
-       mmapHandle = h->privateData;
-
-       c = mmapHandle->ptr + mmapHandle->offset;
-
-       if (mmapHandle->state != EOF) {
-               len = size;
-               if (len + mmapHandle->offset > mmapHandle->size) {
-                       len = mmapHandle->size - mmapHandle->offset;
-               }
-       } else {
-               return 0;
-       }
-
-       memcpy(buf, c, len);
-
-       mmapHandle->offset += len;
-
-       if (mmapHandle->offset == mmapHandle->size) {
-               mmapHandle->state = EOF;
-       }
-
-       return len;
-}
-
-static int mmf_mmap_write(MMFileIOHandle *h, unsigned char *buf, int size)
-{
-       MMFMMapIOHandle *mmapHandle = NULL;
-       unsigned char *c = NULL;
-       int len = 0;
-
-       if (!h || !h->privateData || !buf) {
-               debug_error(DEBUG, "invalid para\n");
-               return MMFILE_UTIL_FAIL;
-       }
-
-       mmapHandle = h->privateData;
-
-       c = mmapHandle->ptr + mmapHandle->offset;
-
-       if (mmapHandle->state != EOF) {
-               len = size;
-               if (len + mmapHandle->offset > mmapHandle->size) {
-                       len = mmapHandle->size - mmapHandle->offset;
-               }
-       } else {
-               return 0;
-       }
-
-       memcpy(c, buf, len);
-
-       mmapHandle->offset += len;
-
-       if (mmapHandle->offset == mmapHandle->size) {
-               mmapHandle->state = EOF;
-       }
-
-       return len;
-}
-
-
-static int64_t mmf_mmap_seek(MMFileIOHandle *h, int64_t pos, int whence)
-{
-       MMFMMapIOHandle *mmapHandle = NULL;
-       long tmp_offset = 0;
-
-       if (!h || !h->privateData) {
-               debug_error(DEBUG, "invalid para\n");
-               return MMFILE_UTIL_FAIL;
-       }
-
-       mmapHandle = h->privateData;
-
-       switch (whence) {
-       case SEEK_SET:
-               tmp_offset = 0 + pos;
-               break;
-       case SEEK_CUR:
-               tmp_offset = mmapHandle->offset + pos;
-               break;
-       case SEEK_END:
-               tmp_offset = mmapHandle->size + pos;
-               break;
-       default:
-               return MMFILE_UTIL_FAIL;
-       }
-
-       /*check validation*/
-       if (tmp_offset < 0) {
-               debug_error(DEBUG, "invalid file offset\n");
-               return MMFILE_UTIL_FAIL;
-       }
-
-       /*set */
-       mmapHandle->state = (tmp_offset >= mmapHandle->size) ? EOF : !EOF;
-       mmapHandle->offset = tmp_offset;
-
-       return mmapHandle->offset;
-}
-
-
-static long long mmf_mmap_tell(MMFileIOHandle *h)
-{
-       MMFMMapIOHandle *mmapHandle = NULL;
-
-       if (!h || !h->privateData) {
-               debug_error(DEBUG, "invalid para\n");
-               return MMFILE_UTIL_FAIL;
-       }
-
-       mmapHandle = h->privateData;
-
-       return mmapHandle->offset;
-}
-
-static int mmf_mmap_close(MMFileIOHandle *h)
-{
-       MMFMMapIOHandle *mmapHandle = NULL;
-
-       if (!h || !h->privateData) {
-               debug_error(DEBUG, "invalid para\n");
-               return MMFILE_UTIL_FAIL;
-       }
-
-       mmapHandle = h->privateData;
-
-       if (mmapHandle) {
-               if (mmapHandle->ptr) {
-                       munmap(mmapHandle->ptr, mmapHandle->size);
-               }
-
-               if (mmapHandle->fd > 2) {
-                       close(mmapHandle->fd);
-               }
-
-               mmfile_free(mmapHandle);
-       }
-
-       h->privateData = NULL;
-
-       return MMFILE_UTIL_SUCCESS;
-}
-
-
-MMFileIOFunc mmfile_mmap_io_handler = {
-       "mmap",
-       mmf_mmap_open,
-       mmf_mmap_read,
-       mmf_mmap_write,
-       mmf_mmap_seek,
-       mmf_mmap_tell,
-       mmf_mmap_close,
-       NULL
-};