--- lphdisk-0.9.1.ds1.orig/Makefile +++ lphdisk-0.9.1.ds1/Makefile @@ -7,34 +7,18 @@ INSTALL_PREFIX = /usr/local CFLAGS = -g -Wall -LIBS = - -LRMIDIR = lrmi-0.6m +LDLIBS = -lx86 all: lphdisk -lphdisk: lphdisk.o lrmi.o - $(CC) $(CFLAGS) -o lphdisk lphdisk.o lrmi.o $(LIBS) - -lphdisk.o: lphdisk.c lrmi.h vbe.h - -lrmi.o: - cd $(LRMIDIR) && $(MAKE) $@ - cp $(LRMIDIR)/lrmi.o . - -%.h: $(LRMIDIR)/%.h - cp $^ $@ - install: all install -m 755 lphdisk $(INSTALL_PREFIX)/sbin install -m 644 lphdisk.8 $(INSTALL_PREFIX)/man/man8 clean: - cd $(LRMIDIR) && $(MAKE) $@ - rm -f *.o lrmi.h vbe.h + rm -f *.o distclean: clean - cd $(LRMIDIR) && $(MAKE) $@ rm -f lphdisk .PHONY: all install clean distclean --- lphdisk-0.9.1.ds1.orig/lphdisk.c +++ lphdisk-0.9.1.ds1/lphdisk.c @@ -19,8 +19,10 @@ Be careful! */ +#define _LARGEFILE64_SOURCE #include #include +#include #include #include #include @@ -29,7 +31,7 @@ #include #include #include -#include "lrmi.h" +#include #include "vbe.h" /* General Program Defines: */ @@ -100,58 +102,6 @@ /* General Purpose Utility Routines */ /*****************************************************************************/ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* The following is a hack to take advantage of the ext2 "_llseek" system */ -/* call to do seeks to "long long" offsets under linux (this is needed to */ -/* seek to sectors beyond 4194303 (2GB)). This isn't directly supported by */ -/* glibc, so we need to make our own interface function for it. We should */ -/* be able to get the _NR__llseek define from linux/unistd.h. From this we */ -/* can construct a wrapper to perform the right system call. */ - -#include /* for __NR__llseek */ - -typedef long long lloff_t; - -#ifdef __NR__llseek - -static _syscall5(int,_llseek, unsigned int,fd, unsigned long,offset_high, - unsigned long,offset_low, lloff_t *,result, - unsigned int,origin) - -lloff_t llseek (unsigned int fd, lloff_t offset, unsigned int origin) { - lloff_t result; - int retval; - - retval = _llseek (fd, ((unsigned long long) offset) >> 32, - ((unsigned long long) offset) & 0xffffffff, - &result, origin); - return (retval == -1 ? (lloff_t) retval : result); -} - -#else /* __NR__llseek */ - -/* Somehow, __NR__llseek wasn't in linux/unistd.h. This shouldn't ever */ -/* happen, but better safe than sorry.. The best we can do is emulate it */ -/* with lseek, and hope we don't get an offset that's too large (throw an */ -/* error if we do) */ - -lloff_t llseek (unsigned int fd, lloff_t offset, unsigned int origin) { - off_t offt_offset = (off_t) offset; - - if ((lloff_t)offt_offset != offset) { - /* converting to off_t and back yields different result, indicating an */ - /* overflow.. */ - errno = EINVAL; - return -1; - } else { - return lseek(fd, offt_offset, origin); - } -} - -#endif /* __NR__llseek */ - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - #define get16(p) get_int_le(p,2) #define get32(p) get_int_le(p,4) @@ -189,9 +139,9 @@ /* success, nonzero on error. */ int seek_sector (int fd, size_t secno) { - lloff_t offset = (lloff_t) secno * SECTOR_SIZE; + off64_t offset = (off64_t) secno * SECTOR_SIZE; - if (llseek(fd, offset, SEEK_SET) == (lloff_t) -1) + if (lseek64(fd, offset, SEEK_SET) == (off64_t) -1) return -1; return 0; @@ -556,25 +506,29 @@ int meminfo_physmem(void) { FILE *f; - unsigned int size; + unsigned int size = 0; int ramsize; + char s[128]; if (!(f = fopen(meminfo_filename, "r"))) { debug("Unable to open %s: %s\n", meminfo_filename, strerror(errno)); return 0; } - fscanf(f, "%*[^\n]\n"); /* Read the header line and discard it */ - if (fscanf(f, "Mem: %u", &size) != 1) { + while (fgets(s, sizeof(s), f)) { + if (sscanf(s, "MemTotal: %u", &size) == 1) { + break; + } + } + if (size == 0) { debug("Parse of %s failed.\n", meminfo_filename); return 0; } fclose(f); - /* convert to KB and then round up to the next power of 2 (since RAM */ + /* size is in KB and then round up to the next power of 2 (since RAM */ /* sizes don't come in anything else, so this should correct for the */ /* kernel size, etc) */ - size >>= 10; debug("%s reports memory size of %d KB", meminfo_filename, size); for (ramsize = 1; size; size >>= 1) ramsize <<= 1; @@ -718,22 +672,22 @@ {"force", 0, 0, 'f'}, {0,0,0,0}}; -const char usage_string[] = "\ -Usage: %1$s [options] [device] -Prepare a hibernation partition for APM suspend-to-disk. - -options: - -h, --help Display brief usage and option information (this screen) - -p, --probeonly Only calculate and display required size, do not format - -q, --quiet Turn off informational messages, useful for scripts - -d, --debug Turn on (verbose) debugging messages - -n, --nowrite Do not actually write to the disk - -f, --force **DANGEROUS** Format without regard to potential problems - -'device' should be a raw disk device (not a partition). The default device -is /dev/hda. - -(%2$s)\n\n"; +const char usage_string[] = "" +"Usage: %1$s [options] [device]\n" +"Prepare a hibernation partition for APM suspend-to-disk.\n" +"\n" +"options:\n" +" -h, --help Display brief usage and option information (this screen)\n" +" -p, --probeonly Only calculate and display required size, do not format\n" +" -q, --quiet Turn off informational messages, useful for scripts\n" +" -d, --debug Turn on (verbose) debugging messages\n" +" -n, --nowrite Do not actually write to the disk\n" +" -f, --force **DANGEROUS** Format without regard to potential problems\n" +"\n" +"'device' should be a raw disk device (not a partition). The default device\n" +"is /dev/hda.\n" +"\n" +"(%2$s)\n\n"; void print_usage (void) { char *progname = rindex(argv0, '/'); @@ -750,7 +704,7 @@ dev_t dev; int partition; int ramsize, vramsize, required_size; - size_t required_sectors; + size_t required_sectors = 0; argv0 = argv[0]; @@ -821,9 +775,9 @@ } if (!required_size) { - if (!quiet_flag) printf("Reccomended partition size is unknown.\n"); + if (!quiet_flag) printf("Recommended partition size is unknown.\n"); } else { - if (!quiet_flag) printf("Reccomended partition size is %d MB" + if (!quiet_flag) printf("Recommended partition size is %d MB" " (%d sectors)\n", ((required_size+1023) >> 10), required_sectors); } @@ -923,7 +877,7 @@ if ((pi[partition-1].size < required_sectors) && !quiet_flag) { fprintf(stderr, "Warning: hibernate partition size (%d) is smaller than" - " reccomended size (%d).\n", pi[partition-1].size, + " recommended size (%d).\n", pi[partition-1].size, required_sectors); } --- lphdisk-0.9.1.ds1.orig/vbe.h +++ lphdisk-0.9.1.ds1/vbe.h @@ -0,0 +1,95 @@ +/* +This file is in the public domain. +*/ + +#ifndef _VBE_H +#define _VBE_H + +/* structures for vbe 2.0 */ + +struct vbe_info_block { + char vbe_signature[4]; + short vbe_version; + unsigned short oem_string_off; + unsigned short oem_string_seg; + int capabilities; + unsigned short video_mode_list_off; + unsigned short video_mode_list_seg; + short total_memory; + short oem_software_rev; + unsigned short oem_vendor_name_off; + unsigned short oem_vendor_name_seg; + unsigned short oem_product_name_off; + unsigned short oem_product_name_seg; + unsigned short oem_product_rev_off; + unsigned short oem_product_rev_seg; + char reserved[222]; + char oem_data[256]; +} __attribute__ ((packed)); + +#define VBE_ATTR_MODE_SUPPORTED (1 << 0) +#define VBE_ATTR_TTY (1 << 2) +#define VBE_ATTR_COLOR (1 << 3) +#define VBE_ATTR_GRAPHICS (1 << 4) +#define VBE_ATTR_NOT_VGA (1 << 5) +#define VBE_ATTR_NOT_WINDOWED (1 << 6) +#define VBE_ATTR_LINEAR (1 << 7) + +#define VBE_WIN_RELOCATABLE (1 << 0) +#define VBE_WIN_READABLE (1 << 1) +#define VBE_WIN_WRITEABLE (1 << 2) + +#define VBE_MODEL_TEXT 0 +#define VBE_MODEL_CGA 1 +#define VBE_MODEL_HERCULES 2 +#define VBE_MODEL_PLANAR 3 +#define VBE_MODEL_PACKED 4 +#define VBE_MODEL_256 5 +#define VBE_MODEL_RGB 6 +#define VBE_MODEL_YUV 7 + +struct vbe_mode_info_block { + unsigned short mode_attributes; + unsigned char win_a_attributes; + unsigned char win_b_attributes; + unsigned short win_granularity; + unsigned short win_size; + unsigned short win_a_segment; + unsigned short win_b_segment; + unsigned short win_func_ptr_off; + unsigned short win_func_ptr_seg; + unsigned short bytes_per_scanline; + unsigned short x_resolution; + unsigned short y_resolution; + unsigned char x_char_size; + unsigned char y_char_size; + unsigned char number_of_planes; + unsigned char bits_per_pixel; + unsigned char number_of_banks; + unsigned char memory_model; + unsigned char bank_size; + unsigned char number_of_image_pages; + unsigned char res1; + unsigned char red_mask_size; + unsigned char red_field_position; + unsigned char green_mask_size; + unsigned char green_field_position; + unsigned char blue_mask_size; + unsigned char blue_field_position; + unsigned char rsvd_mask_size; + unsigned char rsvd_field_position; + unsigned char direct_color_mode_info; + unsigned int phys_base_ptr; + unsigned int offscreen_mem_offset; + unsigned short offscreen_mem_size; + unsigned char res2[206]; +} __attribute__ ((packed)); + +struct vbe_palette_entry { + unsigned char blue; + unsigned char green; + unsigned char red; + unsigned char align; +} __attribute__ ((packed)); + +#endif --- lphdisk-0.9.1.ds1.orig/debian/control +++ lphdisk-0.9.1.ds1/debian/control @@ -0,0 +1,17 @@ +Source: lphdisk +Section: admin +Priority: extra +Maintainer: Roberto Lumbreras +Build-Depends: cdbs, debhelper (>= 7), libx86-dev +Standards-Version: 3.8.0 + +Package: lphdisk +Architecture: i386 +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: prepares hibernation partition for Phoenix NoteBIOS + This utility prepares and formats the hibernation partition for + notebook computers that use Phoenix NoteBIOS. Once this partition + has been prepared, it can be used with the BIOS's APM Suspend-To-Disk + feature. Laptops that can make use of a hibernation partition include + several ARMNotes, the Dell Inspiron 5000, Sony VAIOs, and many + Tuxtops laptops. --- lphdisk-0.9.1.ds1.orig/debian/rules +++ lphdisk-0.9.1.ds1/debian/rules @@ -0,0 +1,8 @@ +#!/usr/bin/make -f + +include /usr/share/cdbs/1/class/makefile.mk +include /usr/share/cdbs/1/rules/debhelper.mk + +DEB_MAKE_CLEAN_TARGET := distclean +DEB_MAKE_INSTALL_TARGET := + --- lphdisk-0.9.1.ds1.orig/debian/watch +++ lphdisk-0.9.1.ds1/debian/watch @@ -0,0 +1,2 @@ +version=3 +opts=dversionmangle=s/\.ds\d+$// http://www.procyon.com/~pda/lphdisk/ (?:.*/)?lphdisk-?_?([\w+\d+\.]+|\d+)(?:\.tar|\.tgz)(?:\.gz|\.bz2|) --- lphdisk-0.9.1.ds1.orig/debian/changelog +++ lphdisk-0.9.1.ds1/debian/changelog @@ -0,0 +1,69 @@ +lphdisk (0.9.1.ds1-1) unstable; urgency=low + + * Fix FTBFS because of missing *_MASK defines: use -lx86 instead of + ancient lrmi copy; use vbe.h from lrmi 0.10. + * Delete old lrmi code from source and repackage lphdisk. + * Updated standards. + + -- Roberto Lumbreras Sun, 08 Mar 2009 19:42:07 +0100 + +lphdisk (0.9.1-3) unstable; urgency=high (fixes critical bug) + + * Remove unneeded linux-kernel-headers dependency. + * Use fseek64 to get rid of llseek issues. (closes: #400795) + + -- Roberto Lumbreras Wed, 29 Nov 2006 10:13:50 +0100 + +lphdisk (0.9.1-2) unstable; urgency=low + + * Fix FTBFS because old syscall usage. (closes: #394535) + Apply patch so lphdisk compiles with new kernel headers; + Build-depend on linux-kernel-headers >= 2.6.18. + + -- Roberto Lumbreras Mon, 23 Oct 2006 17:31:14 +0200 + +lphdisk (0.9.1-1) unstable; urgency=low + + * New maintainer. (Closes: #374110) + * New upstream version. (Closes: #358699, #183560, #105438) + * Fix spelling typos. (Closes: #358703) + * Fix /proc/meminfo parsing. (Closes: #358701, #223106, #223123) + * ACKing NMU. (Closes: #194985) + * Switch to cdbs. + * Updated standards. + + -- Roberto Lumbreras Tue, 25 Jul 2006 18:21:01 +0200 + +lphdisk (0.9-1.1) unstable; urgency=low + + * NMU, DebCamp BSP + * Patched to fix compiler errors with GCC 3.3 + Thanks to Thomas Poindessous for the patch (Closes: #194985) + + -- Alberto Gonzalez Iniesta Sun, 13 Jul 2003 20:45:07 +0200 + +lphdisk (0.9-1) unstable; urgency=low + + * New upstream release + * Add debian/watch + * Removed dh_testversion 2 + * Add $(MAKE) clean in clean target. + + -- Masato Taruishi Mon, 27 Aug 2001 18:13:48 +0900 + +lphdisk (0.4-2) unstable; urgency=low + + * New Maintainer. + * Added Build-Depends. + + -- Masato Taruishi Sun, 26 Nov 2000 05:36:54 +0900 + +lphdisk (0.4-1) unstable; urgency=low + + * First release. + + -- Joey Hess Fri, 10 Nov 2000 20:54:14 -0800 + +Local variables: +mode: debian-changelog +End: --- lphdisk-0.9.1.ds1.orig/debian/lphdisk.manpages +++ lphdisk-0.9.1.ds1/debian/lphdisk.manpages @@ -0,0 +1 @@ +lphdisk.8 --- lphdisk-0.9.1.ds1.orig/debian/lphdisk.install +++ lphdisk-0.9.1.ds1/debian/lphdisk.install @@ -0,0 +1 @@ +lphdisk usr/sbin/ --- lphdisk-0.9.1.ds1.orig/debian/compat +++ lphdisk-0.9.1.ds1/debian/compat @@ -0,0 +1 @@ +7 --- lphdisk-0.9.1.ds1.orig/debian/copyright +++ lphdisk-0.9.1.ds1/debian/copyright @@ -0,0 +1,23 @@ +This is a Debian prepackaged version of the lphdisk utility. + +This package was put together by Joey Hess , using +sources from http://www.procyon.com/~pda/lphdisk/ + + * Copyright 2000-2001 Patrick D. Ashmore and + * Alex Stewart + * This software is released under the Artistic License + +On Debian systems, the full text of the Artistic license is in the file +/usr/share/common-licenses/Artistic + +----------------------------------------------------------------------- + +Linux Real Mode Interface - A library of DPMI-like functions for Linux: + +Copyright (C) 1998 by Josh Vanderhoof + +You are free to distribute and modify this file, as long as you +do not remove this copyright notice and clearly label modified +versions as being modified. + +This software has NO WARRANTY. Use it at your own risk. --- lphdisk-0.9.1.ds1.orig/debian/lphdisk.dirs +++ lphdisk-0.9.1.ds1/debian/lphdisk.dirs @@ -0,0 +1 @@ +usr/sbin --- lphdisk-0.9.1.ds1.orig/debian/lphdisk.docs +++ lphdisk-0.9.1.ds1/debian/lphdisk.docs @@ -0,0 +1,5 @@ +CREDITS +NEWS +README +TODO +debian/README.Debian-source --- lphdisk-0.9.1.ds1.orig/debian/README.Debian-source +++ lphdisk-0.9.1.ds1/debian/README.Debian-source @@ -0,0 +1,8 @@ +lphdisk for Debian +------------------ + +The upstream source has been repackaged because it shipped an ancient lrmi +version in the lrmi-0.6m directory. Now lphdisk links against libx86 instead +of the old lrmi, and includes vbe.h from lrmi-0.10. + + -- Roberto Lumbreras Mon, 09 Mar 2009 02:43:53 +0100