Coder Social home page Coder Social logo

hdapsd's People

Contributors

evgeni avatar t-8ch avatar unbrice avatar zdzichu avatar ztombol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hdapsd's Issues

Documentation installed twice

The documentation is installed both as README and README.md under @prefix@/doc/hdapsd. They are two distinct copies, README is not a symlink.

Support config files

Let's have a config file, I think the following options should be implemented:

  • device -- if set, either a single device, or a coma separated list. the parser should not choke on spaces here.
  • sensitivity -- an integer
  • adaptive -- bool
  • pidfile -- obviously, a string.
  • syslog -- bool

Making sense of configuration and service handling

This issue may seem a bit loaded, touching on systemd, udev and configuration, but the problems are related and can only be solved together. I intend this issue to be a starting point for discussion on these observations.

Overview

I installed hdapsd and found that:

  1. its behaviour is probably not what most users would expect or want, and
  2. configuration is difficult

In the followings I describe the issues involved and the proposed solutions.
#1. Behaviour

Issue

The installed udev rule causes all disks to be automatically protected by launching a daemon for each disk using [email protected]. This happens for external disks too. Every time one is connected a new process is launched only to fail, as these disk do not support head unload on command (only via APM, as far as I know). There is no easy way of excluding disks.

I think this automatic behaviour has little value as most users have only one or two disks to protect, and manually adjusting settings (e.g. fine tuning --sensitivity) is always desired.

Solution

Removing the udev rule turns off the automatic behaviour, however configuration still remains difficult. See the next section.

Required modifications:

  • removing hdapsd.rules
    #2. Configuration

Issue

There is a built-in configuration system implemented with libconfig, but it does not seem to be used (the configuration file is not installed either).

The only way to change settings is by overwriting parts or the whole service file in /etc/systemd/system/. Users unfamiliar with systemd will find this difficult.

Solutions

Using libconfig

The built-in libconfig based configuration provides a simple way to modify setting in /etc/hdapsd.conf. Since configuration specified this way applies to all protected disks, it is sufficient to run a single daemon process using hdapsd.service, instead of one for each disk with [email protected].

Note that pidfile, syslog and background should be removed from the configuration file as these have to be set in the service file for systemd to work properly. See systemd.service(5) for more.

Required modifications:

  • slight modification to hdapsd.service
  • removing [email protected]
  • installing hdapsd.conf to /etc
  • removing some options from the config file

Using EnvironmentFile

Using the EnvironmentFile option in the service file to read command line arguments to hdapsd from a file and append them to ExecStart. This is what smartd does. See systemd.exec(5) for more.

/etc/conf.d/hdpasd

HDAPSD_ARGS='--sensitivity 40 --device=/dev/disk/by-id/ata-HTS541040G9AT00'

hdapsd.service (excerpt)

[Service]
EnvironmentFile=/etc/conf.d/hdpasd
ExecStart=/usr/sbin/hdapsd --pidfile --background --syslog $HDAPSD_ARGS

Required modifications:

  • slight modification of hdapsd.service
  • removing [email protected]
  • installing an environment file to /etc/conf.d

Using systemd local configuration

It is possible to overwrite a service file in part or entirely by adding a local configuration in /etc/systemd/system.

/usr/lib/systemd/system/hdapsd.service (excerpt)

ExecStart=/usr/sbin/hdapsd --pidfile --background --syslog --adaptive

/etc/systemd/system/hdapsd.service (excerpt)

# The empty assignment resets the option, see systemd.exec(5)
ExecStart=
ExecStart=/usr/sbin/hdapsd --pidfile --background --syslog --sensitivity 40 --device /dev/sda

This technique can be used with [email protected] as well to provide per disk configuration (if that is desired).

Summary

The configuration side of the issue really depends on the level of control you want to have (global and/or per disk configuration) and the preferred way of configuration (libconfig or environment file, and/or systemd).

On the behaviour side of the issue. If I'm wrong and there is a legitimate reason for keeping udev in the loop, some other solution have to be found for easing configuration and excluding disks.

I tried to be as concise as possible while still being clear about the approach of each proposed solution. Of course I would be happy to contribute code if you find that some of these modifications are necessary.

If you are still reading, thank you and give yourself a pat on the back!

Thank you for maintaining hdapsd!

systemd support

Arch ships a service file, that starts the service as a real service, with dependencies etc [1].
Our version, which came from Fedora (and is used in the AUR version of the package [2]), relies on activation by udev. This is IMHO cool (esp as it enables hotplug for new disks), but is confusing for users, as they cannot control hdapsd via systemctl.

[1] https://projects.archlinux.org/svntogit/community.git/tree/trunk/hdapsd.systemd?h=packages/hdapsd
[2] https://aur.archlinux.org/packages/hdapsd-git

Verify documentation

Manpage vs help() vs readme? Are all uptodate in regards to the code

--force-rotational is missing from the manpage

Could not find a suitable interface

Hello, I'm getting this message every time I start the daemon:

Could not find a suitable interface

What's wrong? I'm using Ubuntu 14.04 on a HP Envy 17 Laptop (with HP 3D DriveGuard support).

EPERM (Operation not permitted) while trying to open Acer BMA150 accelerometer

I'm running hdapsd on ubuntu 17.04, version 1:20141203-1.

sudo strace hdapsd
shows this error:

open("/dev/input/event8", O_RDONLY) = -1 EPERM (Operation not permitted)

cat /proc/bus/input/devices

I: Bus=0019 Vendor=0000 Product=0000 Version=0000
N: Name="Acer BMA150 accelerometer"
P: Phys=wmi/input1
S: Sysfs=/devices/virtual/input/input11
U: Uniq=
H: Handlers=event8 js0
B: PROP=0
B: EV=9
B: ABS=7

Tried sudo rmmod joydev but nothing changed except no "js0" in Handlers list
Any idea?

toshiba_haps is now in /sys/devices/platform/TOS620A:00

im not sure if i am doing something wrong but i dont have no one of this files

#define TOSHIBA_MOVEMENT_FILE   "/sys/devices/platform/toshiba_haps/movement"
#define TOSHIBA_LEVEL_FILE  "/sys/devices/platform/toshiba_haps/protection_level"
#define TOSHIBA_POSITION_FILE   "/sys/devices/platform/toshiba_acpi/position"

but i have this other ones:

mercuriete@localhost /sys/devices/platform/TOS620A:00/firmware_node $ ls -l
total 0
lrwxrwxrwx 1 root root    0 sep 20 11:27 driver -> ../../../../bus/acpi/drivers/Toshiba HAPS
-r--r--r-- 1 root root 4096 sep 20 12:00 hid
-r--r--r-- 1 root root 4096 sep 20 12:00 modalias
-r--r--r-- 1 root root 4096 sep 20 12:00 path
lrwxrwxrwx 1 root root    0 sep 20 12:00 physical_node -> ../../../platform/TOS620A:00
drwxr-xr-x 2 root root    0 sep 20 12:00 power
-rw-r--r-- 1 root root 4096 sep 20 12:00 protection_level
--w------- 1 root root 4096 sep 20 12:00 reset_protection
-r--r--r-- 1 root root 4096 sep 20 12:00 status
lrwxrwxrwx 1 root root    0 sep 20 11:27 subsystem -> ../../../../bus/acpi
-rw-r--r-- 1 root root 4096 sep 20 12:00 uevent

i need some help because the driver is working because it writes to dmesg an event every time that i move the computer. and hdapsd starts automatically with systemd but then exits with code 255 after tries to load a lot of modules.

by the way, i compile toshiba_haps inside the kernel not as a module. i dont know if this could be the problem.

thanks for your work

edit: version of linux:
uname -a
Linux localhost 4.0.5-gentoo #17 SMP PREEMPT Tue Sep 8 21:37:19 WEST 2015 x86_64 Intel(R) Core(TM) i7-4720HQ CPU @ 2.60GHz GenuineIntel GNU/Linux

Subsequent parks missing from logs

I set up hdapsd and wanted to verify it is working.
For this I started it with --verbose, kept something writing to the disk and let the device fall repeatedly (of course gently breaking it instead of letting it hit the floor).
Each time could hear the disk head move, then park as it entered free fall, then quickly start to move again, but this is the output I got:

Sat Mar 30 18:45:31 2019: Starting hdapsd
Sat Mar 30 18:45:31 2019: WARNING: You did not supply any devices to protect, trying autodetection.
Sat Mar 30 18:45:31 2019: Adding autodetected device: sdb
Sat Mar 30 18:45:31 2019: Trying INTERFACE_HDAPS
Sat Mar 30 18:45:31 2019: Trying INTERFACE_AMS
Sat Mar 30 18:45:31 2019: Trying INTERFACE_FREEFALL
Sat Mar 30 18:45:31 2019: Selected interface: FREEFALL
Sat Mar 30 18:45:31 2019: Uses hardware logic from /dev/freefall
disk: sdb
threshold: 15
read_method: hardware-logic
sampling_rate: 50
HW=1
Sat Mar 30 18:46:18 2019: parking
HW=1
HW=1
HW=1
HW=1
HW=1
HW=1

Running hdapsd without --verbose and with --syslog, as one would with a daemon, means I get no indication that the disk was parked after the first time, which hardly seems intentional.

Can't be sure if it's working fine.

Hi there! I'm using Linux Mint KDE 18.3 and I installed hdapsd on my HP Envy laptop from the repositories, however I'm really not sure if something is wrong. I'm sorry to bother you but I really don't know if this is working correctly.
Reading this wiki article
https://wiki.archlinux.org/index.php/Hard_Drive_Active_Protection_System
I have seen there is a hdaps-gl function (the article points to this github) but I can't seem to get it working. Issuing it as a terminal command gives a "no such command" response.
There doesn't seem to be a way to know if my HDD is being protected. All I can do is figure that it is working since there is a hdapsd daemon running.
However when I wanted to use a joystick I noticed I have trouble (Always detected as second joystick) because the laptop's built-in accelerometer always gets detected as the first joystick (js0), and I don't know what would happen to the HDD protection if I do some changes
(like this https://ubuntuforums.org/showthread.php?t=1595666
I want the accelerometer to always be something like js9)
maybe it will stop working?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.