how to SYNC to inhibit all partitions
Posted: Thu May 30, 2013 10:46 pm
Can someone point me (enlight) where to look (website, code, sdk docs,...) to add to poweroff SYNC feature (like in reboot cmd.)?
TIA
TIA
Support Forum
https://forum.hyperion-entertainment.com/
https://forum.hyperion-entertainment.com/viewtopic.php?t=1778
Code: Select all
static void Sync(void) {
const uint32 flags = LDF_READ|LDF_DEVICES;
struct DeviceNode *dn;
dn = IDOS->LockDosList(flags);
while ((dn = (struct DeviceNode *)IDOS->NextDosEntry((struct DosList *)dn, flags))) {
if (dn->dn_Port != NULL) {
/* Skip RAM Disk */
if (!strcmp((char *)BADDR(dn->dn_Name)+1, "RAM"))
continue;
/* Cause filesystem to flush all pending writes. */
/* Inhibit should do this as well but might be useful for old
filesystems that don't support inhibit? */
IDOS->FlushVolumePort(dn->dn_Port); /* Requires dos.library V53.90 */
/* Inhibit filesystem. */
IDOS->InhibitPort(dn->dn_Port, TRUE); /* Requires dos.library V53.88 */
}
}
IDOS->UnLockDosList(flags);
}
He wants to poweroff, not rebootZeroG wrote:Or he could just use C:Reboot SYNC...
Thx it works fine your codesalass00 wrote:Essentially all you need to do is go through all the devices in the doslist and inhibit them.
..
The DeviceNode struct is a specialised version of the DosList structure which applies only when the type field of the DosList is DLT_DEVICE. There are also others like VolumeNode for DLT_VOLUME and AssignNode for DLT_ASSIGN. The DosList structure just combines all of these into one structure using a union for the type specific fields.javierdlr wrote: Thx it works fine your codejust a question:
Why are you using 'struct DeviceNode *dn;' instead of 'struct DosList *dl;' looking in autodocs 'IDOS->LockDosList()' result "should" be a DosList structure. Or am I mixing things (or too complicated for a non programmer guy :-O )
Code: Select all
static void Sync(void) {
int32 result;
struct Node *nd = NULL;
struct InfoData id;
struct DevProc *dp = NULL;
struct List *list = IDOS->AllocDosObjectTags(DOS_VOLUMELIST,
ADO_Type, LDF_VOLUMES,
ADO_AddColon, TRUE,
TAG_END);
if(list)
{
for( nd = IExec->GetHead(list); nd; nd = IExec->GetSucc(nd) )
{
dp = IDOS->GetDeviceProc(nd->ln_Name, NULL);
if( !ILocale->StrnCmp(NULL, nd->ln_Name, "RAM Disk:", -1, SC_ASCII) ) continue; // Skip RAM Disk
result = IDOS->GetDiskInfoTags(GDI_StringNameInput, nd->ln_Name,
GDI_InfoData, &id,
TAG_END);
if(result)
{
if(id.id_DiskState == ID_DISKSTATE_WRITE_PROTECTED) continue;
// Cause filesystem to flush all pending writes.
// Inhibit should do this as well but might be useful for old
// filesystems that don't support Inhibit to use Flush
IDOS->FlushVolumePort(dp->dvp_Port); // Requires dos.library V53.90
IDOS->InhibitPort(dp->dvp_Port, TRUE); // Requires dos.library V53.88
}
}
IDOS->FreeDeviceProc(dp);
IDOS->FreeDosObject(DOS_VOLUMELIST,list);
}
}
Drop the ram disk test entirely, it's pointless, RAM will inhibit like all the others, so there's absolutely no point in doing that.javierdlr wrote:Hi, now using this code to SYNC, suing AllocDosObjectTags now:
Tried a couple of times and seems to work fine, any "difference"/"better" to use AllocDosObject() instead of previous one.
Could I get a problem, 'cos now I strncmp 'RAM Disk:' instead of 'RAM:', maybe someone renamed 'RAM Disk:' to 'RAMDisk:' or alike.
TIA