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.
This commit is contained in:
Rémi Denis-Courmont 2015-11-05 21:23:45 +02:00
parent 8b83104e21
commit d2ed3fb624
3 changed files with 29 additions and 6 deletions

2
NEWS
View File

@ -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

View File

@ -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;

View 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 ()