Commit d2ed3fb6 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

directory: ignore non-regular non-directory files by default

Playing FIFOs and devices (especially character devices) typically
only makes sense if explicitly requested. Playing FIFOs will usually
lock up. Playing devices could have any effects.

Add an option to restore the old behaviour in case someone wants it.
parent 8b83104e
......@@ -27,6 +27,8 @@ Access:
* SMB/FTP/SFTP accesses can list directories
* Support for SAT>IP server dialect for RTSP (satip://)
* New "concat" access module for concatenating byte streams
* Named pipes and device nodes are no longer included in directory listings
by default. Use --list-special-files to include them back.
Decoder:
* OMX GPU-zerocopy support for decoding and display on Android using OpenMax IL
......
......@@ -45,6 +45,7 @@ struct access_sys_t
{
char *base_uri;
DIR *dir;
bool special_files;
};
/*****************************************************************************
......@@ -68,6 +69,7 @@ int DirInit (access_t *access, DIR *dir)
goto error;
sys->dir = dir;
sys->special_files = var_InheritBool(access, "list-special-files");
access->p_sys = sys;
access->pf_readdir = DirRead;
......@@ -126,14 +128,31 @@ input_item_t *DirRead(access_t *access)
switch (st.st_mode & S_IFMT)
{
case S_IFBLK: type = ITEM_TYPE_DISC; break;
case S_IFCHR: type = ITEM_TYPE_CARD; break;
case S_IFIFO: type = ITEM_TYPE_STREAM; break;
case S_IFREG: type = ITEM_TYPE_FILE; break;
case S_IFDIR: type = ITEM_TYPE_DIRECTORY; break;
case S_IFBLK:
if (!sys->special_files)
continue;
type = ITEM_TYPE_DISC;
break;
case S_IFCHR:
if (!sys->special_files)
continue;
type = ITEM_TYPE_CARD;
break;
case S_IFIFO:
if (!sys->special_files)
continue;
type = ITEM_TYPE_STREAM;
break;
case S_IFREG:
type = ITEM_TYPE_FILE;
break;
case S_IFDIR:
type = ITEM_TYPE_DIRECTORY;
break;
/* S_IFLNK cannot occur while following symbolic links */
/* S_IFSOCK cannot be opened with open()/openat() */
default: continue; /* ignore */
default:
continue; /* ignore */
}
#else
type = ITEM_TYPE_FILE;
......
......@@ -50,4 +50,6 @@ vlc_module_begin ()
#endif
set_callbacks( DirOpen, DirClose )
add_bool("list-special-files", false, N_("List special files"),
N_("Include devices and pipes when listing directories"), true)
vlc_module_end ()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment