Installer: Unblock CD tray, and eject it, shutdown on quit.
* This was done in the Bootscript.cd before, but now the Installer does it directly, but only in case the Deskbar is not running.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
* Copyright 2015, Axel Dörfler <[email protected]>
|
||||||
* Copyright 2009, Stephan Aßmus <[email protected]>
|
* Copyright 2009, Stephan Aßmus <[email protected]>
|
||||||
* Copyright 2005, Jérôme DUVAL.
|
* Copyright 2005, Jérôme DUVAL.
|
||||||
* All rights reserved. Distributed under the terms of the MIT License.
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
@@ -6,10 +7,16 @@
|
|||||||
|
|
||||||
#include "InstallerApp.h"
|
#include "InstallerApp.h"
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
|
#include <Roster.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
|
|
||||||
|
#include <syscalls.h>
|
||||||
|
|
||||||
#include "tracker_private.h"
|
#include "tracker_private.h"
|
||||||
|
#include "Utility.h"
|
||||||
|
|
||||||
|
|
||||||
static const uint32 kMsgAgree = 'agre';
|
static const uint32 kMsgAgree = 'agre';
|
||||||
@@ -108,3 +115,25 @@ InstallerApp::ReadyToRun()
|
|||||||
new InstallerWindow();
|
new InstallerWindow();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InstallerApp::Quit()
|
||||||
|
{
|
||||||
|
BApplication::Quit();
|
||||||
|
|
||||||
|
if (!be_roster->IsRunning(kDeskbarSignature)) {
|
||||||
|
// Synchronize disks, and reboot the system
|
||||||
|
sync();
|
||||||
|
|
||||||
|
if (Utility::IsReadOnlyVolume("/boot")) {
|
||||||
|
// Unblock CD tray, and eject the CD
|
||||||
|
Utility::BlockMedia("/boot", false);
|
||||||
|
Utility::EjectMedia("/boot");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quickly shutdown without possibly touching anything on disk
|
||||||
|
// (which we might just have ejected)
|
||||||
|
_kern_shutdown(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ public:
|
|||||||
InstallerApp();
|
InstallerApp();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
virtual void AboutRequested();
|
virtual void AboutRequested();
|
||||||
virtual void ReadyToRun();
|
virtual void ReadyToRun();
|
||||||
|
virtual void Quit();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EULAWindow* fEULAWindow;
|
EULAWindow* fEULAWindow;
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
SubDir HAIKU_TOP src apps installer ;
|
SubDir HAIKU_TOP src apps installer ;
|
||||||
|
|
||||||
UsePrivateHeaders shared storage tracker ;
|
UsePrivateHeaders shared storage tracker ;
|
||||||
|
UsePrivateSystemHeaders ;
|
||||||
|
|
||||||
SubDirHdrs [ FDirName $(HAIKU_TOP) src kits tracker ] ;
|
SubDirHdrs [ FDirName $(HAIKU_TOP) src kits tracker ] ;
|
||||||
|
SubDirHdrs [ FDirName $(HAIKU_TOP) src servers launch ] ;
|
||||||
|
|
||||||
Application Installer :
|
Application Installer :
|
||||||
CopyEngine.cpp
|
CopyEngine.cpp
|
||||||
@@ -14,11 +17,18 @@ Application Installer :
|
|||||||
ProgressReporter.cpp
|
ProgressReporter.cpp
|
||||||
UnzipEngine.cpp
|
UnzipEngine.cpp
|
||||||
WorkerThread.cpp
|
WorkerThread.cpp
|
||||||
: be tracker translation libshared.a [ TargetLibstdc++ ]
|
|
||||||
|
# From launch_daemon
|
||||||
|
Utility.cpp
|
||||||
|
|
||||||
|
: be tracker translation libshared.a [ TargetLibstdc++ ]
|
||||||
localestub
|
localestub
|
||||||
: Installer.rdef
|
: Installer.rdef
|
||||||
;
|
;
|
||||||
|
|
||||||
|
SEARCH on <src!apps!installer>Utility.cpp = [
|
||||||
|
FDirName $(HAIKU_TOP) src servers launch ] ;
|
||||||
|
|
||||||
DoCatalogs Installer :
|
DoCatalogs Installer :
|
||||||
x-vnd.Haiku-Installer
|
x-vnd.Haiku-Installer
|
||||||
:
|
:
|
||||||
|
|||||||
@@ -17,6 +17,38 @@
|
|||||||
#include <Volume.h>
|
#include <Volume.h>
|
||||||
|
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
IssueDeviceCommand(const char* path, int opcode, void* buffer,
|
||||||
|
size_t bufferSize)
|
||||||
|
{
|
||||||
|
fs_info info;
|
||||||
|
if (fs_stat_dev(dev_for_path(path), &info) == B_OK) {
|
||||||
|
if (strcmp(info.fsh_name, "devfs") != 0)
|
||||||
|
path = info.device_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
int device = open(path, O_RDONLY);
|
||||||
|
if (device < 0)
|
||||||
|
return device;
|
||||||
|
|
||||||
|
status_t status = B_OK;
|
||||||
|
|
||||||
|
if (ioctl(device, opcode, buffer, bufferSize) != 0) {
|
||||||
|
fprintf(stderr, "Failed to process %d on %s: %s\n", opcode, path,
|
||||||
|
strerror(errno));
|
||||||
|
status = errno;
|
||||||
|
}
|
||||||
|
close(device);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // private namespace
|
||||||
|
|
||||||
|
|
||||||
namespace Utility {
|
namespace Utility {
|
||||||
|
|
||||||
|
|
||||||
@@ -55,25 +87,15 @@ IsReadOnlyVolume(const char* path)
|
|||||||
status_t
|
status_t
|
||||||
BlockMedia(const char* path, bool block)
|
BlockMedia(const char* path, bool block)
|
||||||
{
|
{
|
||||||
fs_info info;
|
return IssueDeviceCommand(path, B_SCSI_PREVENT_ALLOW, &block,
|
||||||
if (fs_stat_dev(dev_for_path(path), &info) == B_OK) {
|
sizeof(block));
|
||||||
if (strcmp(info.fsh_name, "devfs") != 0)
|
}
|
||||||
path = info.device_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
int device = open(path, O_RDONLY);
|
|
||||||
if (device < 0)
|
|
||||||
return device;
|
|
||||||
|
|
||||||
status_t status = B_OK;
|
status_t
|
||||||
|
EjectMedia(const char* path)
|
||||||
if (ioctl(device, B_SCSI_PREVENT_ALLOW, &block, sizeof(block)) != 0) {
|
{
|
||||||
fprintf(stderr, "Failed to block media on %s: %s\n", path,
|
return IssueDeviceCommand(path, B_EJECT_DEVICE, NULL, 0);
|
||||||
strerror(errno));
|
|
||||||
status = errno;
|
|
||||||
}
|
|
||||||
close(device);
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace Utility {
|
|||||||
bool IsReadOnlyVolume(const char* path);
|
bool IsReadOnlyVolume(const char* path);
|
||||||
|
|
||||||
status_t BlockMedia(const char* path, bool block);
|
status_t BlockMedia(const char* path, bool block);
|
||||||
|
status_t EjectMedia(const char* path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user