Date: Sun, 26 Apr 2020 09:32:51 +0000 (UTC) From: Alexey Dokuchaev <danfe@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r533001 - in head/sysutils: . parkverbot parkverbot/files Message-ID: <202004260932.03Q9Wp5C038710@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: danfe Date: Sun Apr 26 09:32:50 2020 New Revision: 533001 URL: https://svnweb.freebsd.org/changeset/ports/533001 Log: Daemon to prevent hard disk head parking in rotational media. WWW: http://parkverbot.sourceforge.net/ Added: head/sysutils/parkverbot/ head/sysutils/parkverbot/Makefile (contents, props changed) head/sysutils/parkverbot/distinfo (contents, props changed) head/sysutils/parkverbot/files/ head/sysutils/parkverbot/files/patch-src_parkverbot.c (contents, props changed) head/sysutils/parkverbot/pkg-descr (contents, props changed) Modified: head/sysutils/Makefile Modified: head/sysutils/Makefile ============================================================================== --- head/sysutils/Makefile Sun Apr 26 09:32:31 2020 (r533000) +++ head/sysutils/Makefile Sun Apr 26 09:32:50 2020 (r533001) @@ -861,6 +861,7 @@ SUBDIR += panicmail SUBDIR += parafly SUBDIR += parallel + SUBDIR += parkverbot SUBDIR += pass-otp SUBDIR += pass-update SUBDIR += password-store Added: head/sysutils/parkverbot/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/parkverbot/Makefile Sun Apr 26 09:32:50 2020 (r533001) @@ -0,0 +1,24 @@ +# Created by: Alexey Dokuchaev <danfe@FreeBSD.org> +# $FreeBSD$ + +PORTNAME= parkverbot +PORTVERSION= 1.2 +CATEGORIES= sysutils +MASTER_SITES= SF/${PORTNAME}/${PORTVERSION} + +MAINTAINER= danfe@FreeBSD.org +COMMENT= Hard disk head parking inhibitor + +LICENSE= GPLv2+ + +LIB_DEPENDS= libHX.so:lang/libhx + +USES= pkgconfig tar:xz +GNU_CONFIGURE= yes + +PLIST_FILES= man/man8/parkverbot.8.gz sbin/parkverbot + +post-install: + ${RM} -r ${STAGEDIR}/lib/systemd + +.include <bsd.port.mk> Added: head/sysutils/parkverbot/distinfo ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/parkverbot/distinfo Sun Apr 26 09:32:50 2020 (r533001) @@ -0,0 +1,3 @@ +TIMESTAMP = 1418026245 +SHA256 (parkverbot-1.2.tar.xz) = 982ee8d75d951300b9c9ba65e8b34adca9a14a8090e1225fb33a35937e26e334 +SIZE (parkverbot-1.2.tar.xz) = 73960 Added: head/sysutils/parkverbot/files/patch-src_parkverbot.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/parkverbot/files/patch-src_parkverbot.c Sun Apr 26 09:32:50 2020 (r533001) @@ -0,0 +1,89 @@ +--- src/parkverbot.c.orig 2013-01-28 15:01:56 UTC ++++ src/parkverbot.c +@@ -18,6 +18,7 @@ + #include <string.h> + #include <time.h> + #include <unistd.h> ++#include <sys/disk.h> + #include <sys/mount.h> + #include <libHX/init.h> + #include <libHX/list.h> +@@ -34,7 +35,8 @@ + struct pv_bdev_entry { + struct HXlist_head anchor; + const char *path; +- loff_t size, prev_pos; ++ off_t size, prev_pos; ++ unsigned sector_size; + int fd; + }; + +@@ -43,7 +45,7 @@ static struct timespec pv_req_interval = {4, 0}; + static unsigned long long pv_disk_window = 16384; + static unsigned long long pv_buffer_size = 64; + +-static const char *pv_readable_size(char *buf, size_t bufsize, loff_t size) ++static const char *pv_readable_size(char *buf, size_t bufsize, off_t size) + { + static const char unit_names[][2] = + {"", "K", "M", "G", "T", "P", "E", "Y", "Z"}; +@@ -73,7 +75,7 @@ static bool pv_in_window(size_t prev_pos, size_t new_p + static int pv_mainloop(void) + { + struct pv_bdev_entry *e; +- loff_t new_pos; ++ off_t new_pos; + ssize_t read_ret; + char *buffer; + +@@ -86,6 +88,12 @@ static int pv_mainloop(void) + while (true) { + HXlist_for_each_entry(e, &pv_bdev_list, anchor) { + new_pos = HX_drand(0, e->size); ++ /* ++ * read(2) and write(2) require the offset to be ++ * a multiple of the sector size, otherwise they ++ * will return EINVAL; see FreeBSD PR 91149. ++ */ ++ new_pos -= new_pos % e->sector_size; + if (pv_in_window(e->prev_pos, new_pos, e)) { + printf("%s: %llu (in guard window)\n", e->path, + static_cast(unsigned long long, new_pos)); +@@ -118,6 +126,7 @@ static bool pv_open_device(const char *path) + struct pv_bdev_entry *e; + char buf[32]; + uint64_t size; ++ unsigned sector_size; + int fd; + + fd = open(path, O_RDONLY | O_BINARY); +@@ -125,10 +134,14 @@ static bool pv_open_device(const char *path) + fprintf(stderr, "%s: %s\n", path, strerror(errno)); + return false; + } +- if (ioctl(fd, BLKGETSIZE64, &size) < 0) { +- fprintf(stderr, "%s: BLKGETSIZE64: %s\n", path, strerror(errno)); ++ if (ioctl(fd, DIOCGSECTORSIZE, §or_size) < 0) { ++ fprintf(stderr, "%s: DIOCGSECTORSIZE: %s\n", path, strerror(errno)); + return false; + } ++ if (ioctl(fd, DIOCGMEDIASIZE, &size) < 0) { ++ fprintf(stderr, "%s: DIOCGMEDIASIZE: %s\n", path, strerror(errno)); ++ return false; ++ } + e = malloc(sizeof(*e)); + if (e == NULL) { + fprintf(stderr, "%s: %s\n", __func__, strerror(errno)); +@@ -138,9 +151,10 @@ static bool pv_open_device(const char *path) + HXlist_init(&e->anchor); + e->path = path; + e->size = size; ++ e->sector_size = sector_size; + e->fd = fd; +- printf("Added %s (size %s)\n", e->path, +- pv_readable_size(buf, sizeof(buf), e->size)); ++ printf("Added %s (size %s, sector size %d bytes)\n", e->path, ++ pv_readable_size(buf, sizeof(buf), e->size), sector_size); + HXlist_add_tail(&pv_bdev_list, &e->anchor); + return true; + } Added: head/sysutils/parkverbot/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/parkverbot/pkg-descr Sun Apr 26 09:32:50 2020 (r533001) @@ -0,0 +1,3 @@ +Daemon to prevent hard disk head parking in rotational media. + +WWW: http://parkverbot.sourceforge.net/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004260932.03Q9Wp5C038710>