|
Lines 5-16
Link Here
|
| 5 |
#include <fcntl.h> |
5 |
#include <fcntl.h> |
| 6 |
#include <dirent.h> |
6 |
#include <dirent.h> |
| 7 |
#include <cstdio> |
7 |
#include <cstdio> |
| 8 |
#include <fstab.h> |
|
|
| 9 |
#include <iostream> |
8 |
#include <iostream> |
| 10 |
#include <sys/types.h> |
9 |
#include <sys/types.h> |
| 11 |
#include <sys/stat.h> |
10 |
#include <sys/stat.h> |
| 12 |
#include <unistd.h> |
11 |
#include <unistd.h> |
| 13 |
|
12 |
|
|
|
13 |
#ifdef __UCLIBC__ |
| 14 |
#include <mntent.h> |
| 15 |
#ifndef _PATH_FSTAB |
| 16 |
#define _PATH_FSTAB "/etc/fstab" |
| 17 |
#endif |
| 18 |
#else |
| 19 |
#include <fstab.h> |
| 20 |
#endif |
| 21 |
|
| 14 |
#include "config.h" |
22 |
#include "config.h" |
| 15 |
#include "mythcontext.h" |
23 |
#include "mythcontext.h" |
| 16 |
|
24 |
|
|
Lines 40-45
Link Here
|
| 40 |
#endif |
48 |
#endif |
| 41 |
#define SUPER_OPT_DEV "dev=" |
49 |
#define SUPER_OPT_DEV "dev=" |
| 42 |
|
50 |
|
|
|
51 |
#ifdef __UCLIBC__ |
| 52 |
#define SETMEP FILE *fstab; struct mntent * mep = NULL; |
| 53 |
#define SET (fstab = setmntent (_PATH_FSTAB, "r")) < 0 |
| 54 |
#define ERRORTYPE "setmntend" |
| 55 |
#define GETNEXT getmntent(fstab) |
| 56 |
#define END endmntent(fstab); |
| 57 |
#define FSNAMESPEC mnt_fsname |
| 58 |
#define MNTOPTS mnt_opts |
| 59 |
#define TYPE mnt_type |
| 60 |
#define SPECFSNAME mnt_fsname |
| 61 |
#define FILEDIR mnt_dir |
| 62 |
#else |
| 63 |
#define SETMEP struct fstab * mep = NULL |
| 64 |
#define SET !setfsent() |
| 65 |
#define ERRORTYPE "setfsent" |
| 66 |
#define GETNEXT getfsent() |
| 67 |
#define END endfsent() |
| 68 |
#define FSNAMESPEC fs_spec |
| 69 |
#define MNTOPTS fs_mntops |
| 70 |
#define TYPE vfstype |
| 71 |
#define SPECFSNAME fs_spec |
| 72 |
#define FILEDIR fs_file |
| 73 |
#endif |
| 74 |
|
| 43 |
using namespace std; |
75 |
using namespace std; |
| 44 |
|
76 |
|
| 45 |
MediaMonitor *theMonitor = NULL; |
77 |
MediaMonitor *theMonitor = NULL; |
|
Lines 93-104
Link Here
|
| 93 |
// Loop through the file system table and add any supported devices. |
125 |
// Loop through the file system table and add any supported devices. |
| 94 |
bool MediaMonitor::addFSTab() |
126 |
bool MediaMonitor::addFSTab() |
| 95 |
{ |
127 |
{ |
| 96 |
struct fstab * mep = NULL; |
128 |
SETMEP; |
| 97 |
|
129 |
|
| 98 |
// Attempt to open the file system descriptor entry. |
130 |
// Attempt to open the file system descriptor entry. |
| 99 |
if (!setfsent()) |
131 |
if (SET) |
| 100 |
{ |
132 |
{ |
| 101 |
perror("setfsent"); |
133 |
perror(ERRORTYPE); |
| 102 |
cerr << "MediaMonitor::addFSTab - Failed to open " |
134 |
cerr << "MediaMonitor::addFSTab - Failed to open " |
| 103 |
_PATH_FSTAB |
135 |
_PATH_FSTAB |
| 104 |
" for reading." << endl; |
136 |
" for reading." << endl; |
|
Lines 107-116
Link Here
|
| 107 |
else |
139 |
else |
| 108 |
{ |
140 |
{ |
| 109 |
// Add all the entries |
141 |
// Add all the entries |
| 110 |
while ((mep = getfsent()) != NULL) |
142 |
while ((mep = GETNEXT) != NULL) |
| 111 |
(void) addDevice(mep); |
143 |
(void) addDevice(mep); |
| 112 |
|
144 |
|
| 113 |
endfsent(); |
145 |
END; |
| 114 |
} |
146 |
} |
| 115 |
|
147 |
|
| 116 |
if (m_Devices.isEmpty()) |
148 |
if (m_Devices.isEmpty()) |
|
Lines 128-136
Link Here
|
| 128 |
} |
160 |
} |
| 129 |
|
161 |
|
| 130 |
// Given a fstab entry to a media device determine what type of device it is |
162 |
// Given a fstab entry to a media device determine what type of device it is |
|
|
163 |
#ifdef __UCLIBC__ |
| 164 |
bool MediaMonitor::addDevice(struct mntent * mep) |
| 165 |
#else |
| 131 |
bool MediaMonitor::addDevice(struct fstab * mep) |
166 |
bool MediaMonitor::addDevice(struct fstab * mep) |
|
|
167 |
#endif |
| 132 |
{ |
168 |
{ |
| 133 |
QString devicePath( mep->fs_spec ); |
169 |
#ifdef __UCLIBC__ |
|
|
170 |
if (mep == NULL) |
| 171 |
return false; |
| 172 |
#endif |
| 173 |
QString devicePath( mep->FSNAMESPEC ); |
| 134 |
//cout << "addDevice - " << devicePath << endl; |
174 |
//cout << "addDevice - " << devicePath << endl; |
| 135 |
|
175 |
|
| 136 |
MythMediaDevice* pDevice = NULL; |
176 |
MythMediaDevice* pDevice = NULL; |
|
Lines 142-159
Link Here
|
| 142 |
if (mep == NULL) |
182 |
if (mep == NULL) |
| 143 |
return false; |
183 |
return false; |
| 144 |
|
184 |
|
| 145 |
if (stat(mep->fs_spec, &sbuf) < 0) |
185 |
if (stat(mep->FSNAMESPEC, &sbuf) < 0) |
| 146 |
return false; |
186 |
return false; |
| 147 |
|
187 |
|
| 148 |
// Can it be mounted? |
188 |
// Can it be mounted? |
| 149 |
if ( ! ( ((strstr(mep->fs_mntops, "owner") && |
189 |
if ( ! ( ((strstr(mep->MNTOPTS, "owner") && |
| 150 |
(sbuf.st_mode & S_IRUSR)) || strstr(mep->fs_mntops, "user")) && |
190 |
(sbuf.st_mode & S_IRUSR)) || strstr(mep->MNTOPTS, "user")) && |
| 151 |
(strstr(mep->fs_vfstype, MNTTYPE_ISO9660) || |
191 |
(strstr(mep->TYPE, MNTTYPE_ISO9660) || |
| 152 |
strstr(mep->fs_vfstype, MNTTYPE_UDF) || |
192 |
strstr(mep->TYPE, MNTTYPE_UDF) || |
| 153 |
strstr(mep->fs_vfstype, MNTTYPE_AUTO)) ) ) |
193 |
strstr(mep->TYPE, MNTTYPE_AUTO)) ) ) |
| 154 |
{ |
194 |
{ |
| 155 |
if ( strstr(mep->fs_mntops, MNTTYPE_ISO9660) && |
195 |
if ( strstr(mep->MNTOPTS, MNTTYPE_ISO9660) && |
| 156 |
strstr(mep->fs_vfstype, MNTTYPE_SUPERMOUNT) ) |
196 |
strstr(mep->TYPE, MNTTYPE_SUPERMOUNT) ) |
| 157 |
{ |
197 |
{ |
| 158 |
is_supermount = true; |
198 |
is_supermount = true; |
| 159 |
} |
199 |
} |
|
Lines 163-172
Link Here
|
| 163 |
} |
203 |
} |
| 164 |
} |
204 |
} |
| 165 |
|
205 |
|
| 166 |
if (strstr(mep->fs_mntops, MNTTYPE_ISO9660) || |
206 |
if (strstr(mep->MNTOPTS, MNTTYPE_ISO9660) || |
| 167 |
strstr(mep->fs_vfstype, MNTTYPE_ISO9660) || |
207 |
strstr(mep->TYPE, MNTTYPE_ISO9660) || |
| 168 |
strstr(mep->fs_vfstype, MNTTYPE_UDF) || |
208 |
strstr(mep->TYPE, MNTTYPE_UDF) || |
| 169 |
strstr(mep->fs_vfstype, MNTTYPE_AUTO)) |
209 |
strstr(mep->TYPE, MNTTYPE_AUTO)) |
| 170 |
{ |
210 |
{ |
| 171 |
is_cdrom = true; |
211 |
is_cdrom = true; |
| 172 |
//cout << "Device is a CDROM" << endl; |
212 |
//cout << "Device is a CDROM" << endl; |
|
Lines 175-188
Link Here
|
| 175 |
if (!is_supermount) |
215 |
if (!is_supermount) |
| 176 |
{ |
216 |
{ |
| 177 |
if (is_cdrom) |
217 |
if (is_cdrom) |
| 178 |
pDevice = MythCDROM::get(this, QString(mep->fs_spec), |
218 |
pDevice = MythCDROM::get(this, QString(mep->SPECFSNAME), |
| 179 |
is_supermount, m_AllowEject); |
219 |
is_supermount, m_AllowEject); |
| 180 |
} |
220 |
} |
| 181 |
else |
221 |
else |
| 182 |
{ |
222 |
{ |
| 183 |
char *dev; |
223 |
char *dev; |
| 184 |
int len = 0; |
224 |
int len = 0; |
| 185 |
dev = strstr(mep->fs_mntops, SUPER_OPT_DEV); |
225 |
dev = strstr(mep->MNTOPTS, SUPER_OPT_DEV); |
| 186 |
dev += sizeof(SUPER_OPT_DEV)-1; |
226 |
dev += sizeof(SUPER_OPT_DEV)-1; |
| 187 |
while (dev[len] != ',' && dev[len] != ' ' && dev[len] != 0) |
227 |
while (dev[len] != ',' && dev[len] != ' ' && dev[len] != 0) |
| 188 |
len++; |
228 |
len++; |
|
Lines 202-208
Link Here
|
| 202 |
|
242 |
|
| 203 |
if (pDevice) |
243 |
if (pDevice) |
| 204 |
{ |
244 |
{ |
| 205 |
pDevice->setMountPath(mep->fs_file); |
245 |
pDevice->setMountPath(mep->FILEDIR); |
| 206 |
VERBOSE(VB_ALL, QString("Mediamonitor: Adding %1") |
246 |
VERBOSE(VB_ALL, QString("Mediamonitor: Adding %1") |
| 207 |
.arg(pDevice->getDevicePath())); |
247 |
.arg(pDevice->getDevicePath())); |
| 208 |
if (pDevice->testMedia() == MEDIAERR_OK) |
248 |
if (pDevice->testMedia() == MEDIAERR_OK) |
|
Lines 224-230
Link Here
|
| 224 |
QString devicePath( devPath ); |
264 |
QString devicePath( devPath ); |
| 225 |
//cout << "addDevice - " << devicePath << endl; |
265 |
//cout << "addDevice - " << devicePath << endl; |
| 226 |
|
266 |
|
| 227 |
struct fstab * mep = NULL; |
267 |
SETMEP; |
| 228 |
char lpath[PATH_MAX]; |
268 |
char lpath[PATH_MAX]; |
| 229 |
|
269 |
|
| 230 |
// Resolve the simlink for the device. |
270 |
// Resolve the simlink for the device. |
|
Lines 233-241
Link Here
|
| 233 |
lpath[len] = 0; |
273 |
lpath[len] = 0; |
| 234 |
|
274 |
|
| 235 |
// Attempt to open the file system descriptor entry. |
275 |
// Attempt to open the file system descriptor entry. |
| 236 |
if (!setfsent()) |
276 |
if (SET) |
| 237 |
{ |
277 |
{ |
| 238 |
perror("setfsent"); |
278 |
perror(ERRORTYPE); |
| 239 |
cerr << "MediaMonitor::addDevice - Failed to open " |
279 |
cerr << "MediaMonitor::addDevice - Failed to open " |
| 240 |
_PATH_FSTAB |
280 |
_PATH_FSTAB |
| 241 |
" for reading." << endl; |
281 |
" for reading." << endl; |
|
Lines 244-268
Link Here
|
| 244 |
else |
284 |
else |
| 245 |
{ |
285 |
{ |
| 246 |
// Loop over the file system descriptor entry. |
286 |
// Loop over the file system descriptor entry. |
| 247 |
while ((mep = getfsent()) != NULL) |
287 |
while ((mep = GETNEXT) != NULL) |
| 248 |
{ |
288 |
{ |
| 249 |
// cout << "***************************************************" << endl; |
289 |
// cout << "***************************************************" << endl; |
| 250 |
// cout << "devicePath == " << devicePath << endl; |
290 |
// cout << "devicePath == " << devicePath << endl; |
| 251 |
// cout << "mep->fs_spec == " << mep->fs_spec << endl; |
291 |
// cout << "mep->FSNAMESPEC == " << mep->FSNAMESPEC << endl; |
| 252 |
// cout << "lpath == " << lpath << endl; |
292 |
// cout << "lpath == " << lpath << endl; |
| 253 |
// cout << "strcmp(devicePath, mep->fs_spec) == " << strcmp(devicePath, mep->fs_spec) << endl; |
293 |
// cout << "strcmp(devicePath, mep->FSNAMESPEC) == " << strcmp(devicePath, mep->FSNAMESPEC) << endl; |
| 254 |
// cout << "len ==" << len << endl; |
294 |
// cout << "len ==" << len << endl; |
| 255 |
// cout << "strcmp(lpath, mep->fs_spec)==" << strcmp(lpath, mep->fs_spec) << endl; |
295 |
// cout << "strcmp(lpath, mep->FSNAMESPEC)==" << strcmp(lpath, mep->FSNAMESPEC) << endl; |
| 256 |
// cout <<endl << endl; |
296 |
// cout <<endl << endl; |
| 257 |
|
297 |
|
| 258 |
// Check to see if this is the same as our passed in device. |
298 |
// Check to see if this is the same as our passed in device. |
| 259 |
if ((strcmp(devicePath, mep->fs_spec) != 0) && |
299 |
if ((strcmp(devicePath, mep->FSNAMESPEC) != 0) && |
| 260 |
(len && (strcmp(lpath, mep->fs_spec) != 0))) |
300 |
(len && (strcmp(lpath, mep->FSNAMESPEC) != 0))) |
| 261 |
continue; |
301 |
continue; |
| 262 |
|
302 |
|
| 263 |
} |
303 |
} |
| 264 |
|
304 |
|
| 265 |
endfsent(); |
305 |
END; |
| 266 |
} |
306 |
} |
| 267 |
|
307 |
|
| 268 |
if (mep) |
308 |
if (mep) |