diff options
author | Eric Wong <normalperson@yhbt.net> | 2007-12-28 02:56:25 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2007-12-28 02:56:25 +0000 |
commit | b79f6b882a70526ec2e9fc231e0baeebdfef1e52 (patch) | |
tree | 719912135d059476070834c3c62ae940955e9e20 /src/ls.c | |
parent | 0d26248a0d8cb2e5cf6be5a438a18b16793bbb63 (diff) | |
download | mpd-b79f6b882a70526ec2e9fc231e0baeebdfef1e52.tar.gz mpd-b79f6b882a70526ec2e9fc231e0baeebdfef1e52.tar.xz mpd-b79f6b882a70526ec2e9fc231e0baeebdfef1e52.zip |
Merge branches/ew r7104
thread-safety work in preparation for rewrite to use pthreads
Expect no regressions against trunk (r7078), possibly minor
performance improvements in update (due to fewer heap
allocations), but increased stack usage.
Applied the following patches:
* maxpath_str for reentrancy (temporary fix, reverted)
* path: start working on thread-safe variants of these methods
* Re-entrancy work on path/character-set conversions
* directory.c: exploreDirectory() use reentrant functions here
* directory/update: more use of reentrant functions + cleanups
* string_toupper: a strdup-less version of strDupToUpper
* get_song_url: a static-variable-free version of getSongUrl()
* Use reentrant/thread-safe get_song_url everywhere
* replace rmp2amp with the reentrant version, rmp2amp_r
* Get rid of the non-reentrant/non-thread-safe rpp2app, too.
* buffer2array: assert strdup() returns a usable value in unit tests
* replace utf8ToFsCharset and fsCharsetToUtf8 with thread-safe variants
* fix storing playlists w/o absolute paths
* parent_path(), a reentrant version of parentPath()
* parentPath => parent_path for reentrancy and thread-safety
* allow "make test" to automatically run embedded unit tests
* remove convStrDup() and maxpath_str()
* use MPD_PATH_MAX everywhere instead of MAXPATHLEN
* path: get rid of appendSlash, pfx_path and just use pfx_dir
* get_song_url: fix the ability to play songs in the top-level music_directory
git-svn-id: https://svn.musicpd.org/mpd/trunk@7106 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/ls.c')
-rw-r--r-- | src/ls.c | 29 |
1 files changed, 17 insertions, 12 deletions
@@ -108,22 +108,24 @@ int lsPlaylists(int fd, char *utf8path) struct dirent *ent; char *dup; char *utf8; - char s[MAXPATHLEN + 1]; + char s[MPD_PATH_MAX]; + char path_max_tmp[MPD_PATH_MAX]; List *list = NULL; ListNode *node = NULL; - char *path = utf8ToFsCharset(utf8path); - char *actualPath = rpp2app(path); + char *actualPath = rpp2app_r(path_max_tmp, + utf8_to_fs_charset(path_max_tmp, + utf8path)); int actlen = strlen(actualPath) + 1; - int maxlen = MAXPATHLEN - actlen; + int maxlen = MPD_PATH_MAX - actlen; int suflen = strlen(PLAYLIST_FILE_SUFFIX) + 1; int suff; - if (actlen > MAXPATHLEN - 1 || (dir = opendir(actualPath)) == NULL) { + if (actlen > MPD_PATH_MAX - 1 || (dir = opendir(actualPath)) == NULL) { return 0; } - s[MAXPATHLEN] = '\0'; - /* this is safe, notice actlen > MAXPATHLEN-1 above */ + s[MPD_PATH_MAX - 1] = '\0'; + /* this is safe, notice actlen > MPD_PATH_MAX-1 above */ strcpy(s, actualPath); strcat(s, "/"); @@ -138,12 +140,14 @@ int lsPlaylists(int fd, char *utf8path) memcpy(s + actlen, ent->d_name, len); if (stat(s, &st) == 0) { if (S_ISREG(st.st_mode)) { + char path_max_tmp[MPD_PATH_MAX]; if (list == NULL) list = makeList(NULL, 1); dup[suff] = '\0'; - if ((utf8 = fsCharsetToUtf8(dup))) { + utf8 = fs_charset_to_utf8(path_max_tmp, + dup); + if (utf8) insertInList(list, utf8, NULL); - } } } } @@ -181,16 +185,17 @@ int lsPlaylists(int fd, char *utf8path) int myStat(char *utf8file, struct stat *st) { - char *file = utf8ToFsCharset(utf8file); + char path_max_tmp[MPD_PATH_MAX]; + char *file = utf8_to_fs_charset(path_max_tmp, utf8file); char *actualFile = file; if (actualFile[0] != '/') - actualFile = rmp2amp(file); + actualFile = rmp2amp_r(path_max_tmp, file); return stat(actualFile, st); } -static int isFile(char *utf8file, time_t * mtime) +int isFile(char *utf8file, time_t * mtime) { struct stat st; |