[mythtv-users] Two new physical drives appear as subdirectories of the same drive: why?
Scott Theisen
scott.the.elm at gmail.com
Mon Mar 7 20:10:45 UTC 2022
Since I have been looking at that part of the MythTV code, I'll add my
two cents:
MythTV gets its filesystem data by (from my WIP PR
https://github.com/MythTV/mythtv/pull/485 ):
```
bool FileSystemInfo::refresh()
{
struct statfs statbuf {};
// there are cases where statfs will return 0 (good), but f_blocks and
// others are invalid and set to 0 (such as when an automounted
directory
// is not mounted but still visible because --ghost was used),
// so check to make sure we can have a total size > 0
if ((statfs(getPath().toLocal8Bit().constData(), &statbuf) == 0) &&
(statbuf.f_blocks > 0) && (statbuf.f_bsize > 0)
)
{
m_total = statbuf.f_blocks * statbuf.f_bsize;
//free = statbuf.f_bavail * statbuf.f_bsize;
m_used = m_total - statbuf.f_bavail * statbuf.f_bsize;
m_blksize = statbuf.f_bsize;
// TODO keep as B not KiB
m_total >>= 10;
m_used >>= 10;
#ifdef Q_OS_DARWIN
char *fstypename = statbuf.f_fstypename;
m_local = !(
(strcmp(fstypename, "nfs") == 0) || // NFS|FTP
(strcmp(fstypename, "afpfs") == 0) || // AppleShare
(strcmp(fstypename, "smbfs") == 0) // SMB
);
#elif defined(__linux__)
long fstype = statbuf.f_type;
m_local = !(
(fstype == 0x6969) || // NFS
(fstype == 0x517B) || // SMB
(fstype == 0xFF534D42L) // CIFS
);
#else
m_local = true; // for equivalent behavior
#endif
return true;
}
return false;
}
```
This path can include network mounted filesystems, which would be
available to more than one backend. Consolidate() uses a default fuzz
value of ~14 MiB.
On 3/6/22 21:27, Stephen Worthington wrote:
> On Sun, 6 Mar 2022 23:03:07 +0000, you wrote:
>
>> On 06/03/2022 22:03, UB40D via mythtv-users wrote:
>>> On Sun, 6 Mar 2022 at 00:33, Gary Buhrmaster <gary.buhrmaster at gmail.com>
>>> wrote:
>>>
>>>> On Sat, Mar 5, 2022 at 11:56 PM UB40D via mythtv-users
>>>> <mythtv-users at mythtv.org> wrote:
>>>>
>>>>> Thanks for this explanation but I find it mindboggling... Why does Myth
>>>> need "heuristics" when perfectly reliable first-hand information is
>>>> available from the computer and OS about which drive is which?
>>>>
>>>> Because some people choose to use different
>>>> directories on the same drive, and therefore
>>>> the amount of space available on the drive is
>>>> not always a simple thing to calculate. Only
>>>> when the available space is different does
>>>> MythTV "guess" that they must be different
>>>> drives (and calculates space as if they are
>>>> different).
>>>>
>>> I am not sure I understand the problem the programmers experienced when
>>> they wrote the code that way. It seems to me that there is no need for
>>> heuristics (= guesswork) when unequivocal information is readily available.
>>>
>>> for every directory d listed in mythtv setup as containing recordings:
>>> df -h $d will return something like
>>> Filesystem Size Used Avail Use% Mounted on
>>> /dev/sdd1 17T 16T 294G 99% /mnt/wd18000a1
>>>
>>> so it is trivial to figure out both
>>> a) how much free space is left on the drive that hosts that directory
>>> b) whether that directory is on the same filesystem or drive of any other
>>> directory (to avoid double-counting)
>>>
>>> I may be missing something crucial but I still fail to see why any
>>> guesswork might be needed.
>>>
>>> BTW I did copy some files from the "recording" drive to one of those new
>>> "read-only" drives and indeed they now appear as separate drives, and the
>>> reported total amount of free space is now what I expected, so thanks to
>>> David and you for that suggestion.
>>>
In order to use the partitions, you must identify which partition a
folder is on. How to do this will be different depending on the OS
(especially Windows vs. UNIX-like). Using the UUID of the partition may
be a better solution, but that is not the purpose of my PR and I will
not investigate it.
>> Your arrangement implies that one partition = one storage directory. In the past this was not always
>> the case. Users may have created more than one storage directory on a single partition, perhaps to
>> keep different recordings separate or for other reasons. When that is true it is not possible to
>> discover the free space in each storage directory. Indeed, there may have been other non-myth
>> directories on those devices as well, adding to the fun.
>>
>> In these days, when storage is stupid cheap, such configurations are not usually necessary.
> But they do still exist. I have two directories in different storage
> groups on each of my recording drives. One is for my recordings, and
> the other is for recordings I did for my mother from my pay satellite
> service. Her MythTV box has access to the directories containing her
> recordings, and I can transfer the database entries for them to her
> box so that they show up there are normal recordings. All of that is
> now redundant as her MythTV box now has access to SAT>IP tuners for my
> satellite service and she records the satellite programmes that way.
> But there are still quite a few old recordings left in her
> directories.
Not only do they still exist, but it is (was?) the default for Ubuntu to
have different folders for recordings and live TV.
More information about the mythtv-users
mailing list