[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

rpms/util-linux/FC-4 util-linux-2.12p-audit-hwclock.patch, NONE, 1.1 util-linux-2.12p-execl.patch, NONE, 1.1 util-linux-2.12p-fdisk-gpt.patch, NONE, 1.1 util-linux-2.12p-mount-ocfs2.patch, NONE, 1.1 util-linux.spec, 1.77, 1.78



Author: kzak

Update of /cvs/dist/rpms/util-linux/FC-4
In directory cvs.devel.redhat.com:/tmp/cvs-serv4820

Modified Files:
	util-linux.spec 
Added Files:
	util-linux-2.12p-audit-hwclock.patch 
	util-linux-2.12p-execl.patch util-linux-2.12p-fdisk-gpt.patch 
	util-linux-2.12p-mount-ocfs2.patch 
Log Message:
- testing packages

util-linux-2.12p-audit-hwclock.patch:
 Makefile  |    4 +--
 audit.c   |   70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 audit.h   |   34 ++++++++++++++++++++++++++++++
 clock.h   |    7 +++++-
 hwclock.c |   37 +++++++++++++++++++++++---------
 kd.c      |    5 ++--
 rtc.c     |    7 +++---
 7 files changed, 146 insertions(+), 18 deletions(-)

--- NEW FILE util-linux-2.12p-audit-hwclock.patch ---
--- util-linux-2.12p/hwclock/Makefile.audit-hwclock	2004-12-15 20:11:59.000000000 +0100
+++ util-linux-2.12p/hwclock/Makefile	2005-07-12 15:18:04.000000000 +0200
@@ -18,8 +18,8 @@
 
 hwclock.o: hwclock.c
 hwclock.o cmos.o kd.o: ../defines.h
-hwclock.o cmos.o rtc.o kd.o: clock.h
-hwclock: hwclock.o cmos.o rtc.o kd.o
+hwclock.o cmos.o rtc.o kd.o: clock.h audit.h
+hwclock: hwclock.o cmos.o rtc.o kd.o audit.o -laudit
 
 CWFLAGS := $(subst -Wmissing-prototypes,,$(CFLAGS))
 
--- util-linux-2.12p/hwclock/kd.c.audit-hwclock	2004-12-15 21:21:17.000000000 +0100
+++ util-linux-2.12p/hwclock/kd.c	2005-07-12 15:15:29.000000000 +0200
@@ -19,6 +19,7 @@
 #include "../defines.h"		/* for HAVE_nanosleep */
 #include "clock.h"
 #include "nls.h"
+#include "audit.h"
 
 static int con_fd = -1;		/* opened by probe_for_kd_clock() */
 				/* never closed */
@@ -103,7 +104,7 @@
 
   if (ioctl(con_fd, KDGHWCLK, &t) == -1) {
     outsyserr(_("ioctl() failed to read time from %s"), con_fd_filename);
-    exit(EX_IOERR);
+    audit_exit(EX_IOERR);
   }
 
   tm->tm_sec  = t.sec;
@@ -139,7 +140,7 @@
 
   if (ioctl(con_fd, KDSHWCLK, &t ) == -1) {
     outsyserr(_("ioctl KDSHWCLK failed"));
-    exit(1);
+    audit_exit(1);
   }
   return 0;
 }
--- util-linux-2.12p/hwclock/rtc.c.audit-hwclock	2004-12-15 21:21:48.000000000 +0100
+++ util-linux-2.12p/hwclock/rtc.c	2005-07-12 15:15:29.000000000 +0200
@@ -8,6 +8,7 @@
 
 #include "clock.h"
 #include "nls.h"
+#include "audit.h"
 
 /*
  * Get defines for rtc stuff.
@@ -114,7 +115,7 @@
 
 	if (rtc_fd < 0) {
 		outsyserr(_("open() of %s failed"), rtc_dev_name);
-		exit(EX_OSFILE);
+		audit_exit(EX_OSFILE);
 	}
 	return rtc_fd;
 }
@@ -149,7 +150,7 @@
 		perror(ioctlname);
 		fprintf(stderr, _("ioctl() to %s to read the time failed.\n"),
 			rtc_dev_name);
-		exit(EX_IOERR);
+		audit_exit(EX_IOERR);
 	}
 
 	tm->tm_isdst = -1;          /* don't know whether it's dst */
@@ -329,7 +330,7 @@
 		perror(ioctlname);
 		fprintf(stderr, _("ioctl() to %s to set the time failed.\n"),
 			rtc_dev_name);
-		exit(EX_IOERR);
+		audit_exit(EX_IOERR);
 	}
 
 	if (debug)
--- util-linux-2.12p/hwclock/hwclock.c.audit-hwclock	2004-12-15 20:13:48.000000000 +0100
+++ util-linux-2.12p/hwclock/hwclock.c	2005-07-12 15:19:08.000000000 +0200
@@ -81,10 +81,12 @@
 #include <stdarg.h>
 #include <getopt.h>
 #include <sysexits.h>
+#include <libaudit.h>
 
 #include "../defines.h"		/* for HAVE_tm_gmtoff */
 #include "clock.h"
 #include "nls.h"
+#include "audit.h"
 
 #define MYNAME "hwclock"
 
@@ -1235,7 +1237,7 @@
     va_end(ap);
   }
  
-  exit(fmt ? EX_USAGE : 0);
+  audit_exit(fmt ? EX_USAGE : 0);
 }
 
 static const struct option longopts[] = {
@@ -1299,6 +1301,12 @@
 	/* Remember what time we were invoked */
 	gettimeofday(&startup_time, NULL);
 
+	audit_fd = audit_open();
+	if (audit_fd < 0) {
+		fprintf(stderr, "Error - unable to connect to audit system\n");
+		return EX_NOPERM;
+	}
+
 	setlocale(LC_ALL, "");
 #ifdef LC_NUMERIC
 	/* We need LC_CTYPE and LC_TIME and LC_MESSAGES, but must avoid
@@ -1394,6 +1402,13 @@
 	argc -= optind;
 	argv += optind;
 
+	if (testing != TRUE) {
+		if (adjust == TRUE || hctosys == TRUE || systohc == TRUE ||
+			set == TRUE || setepoch == TRUE) {
+			auditable_event(1);
+		}
+	}
+
 	if (argc > 0) {
 		usage(_("%s takes no non-option arguments.  "
 			"You supplied %d.\n"),
@@ -1404,27 +1419,27 @@
 		fprintf(stderr, _("You have specified multiple functions.\n"
 				  "You can only perform one function "
 				  "at a time.\n"));
-		exit(EX_USAGE);
+		audit_exit(EX_USAGE);
 	}
 
 	if (utc && local_opt) {
 		fprintf(stderr, _("%s: The --utc and --localtime options "
 				  "are mutually exclusive.  You specified "
 				  "both.\n"), MYNAME);
-		exit(EX_USAGE);
+		audit_exit(EX_USAGE);
 	}
 
 	if (adjust && noadjfile) {
 		fprintf(stderr, _("%s: The --adjust and --noadjfile options "
 				  "are mutually exclusive.  You specified "
 				  "both.\n"), MYNAME);
-		exit(EX_USAGE);
+		audit_exit(EX_USAGE);
 	}
 
 	if (noadjfile && !(utc || local_opt)) {
 		fprintf(stderr, _("%s: With --noadjfile, you must specify "
 				  "either --utc or --localtime\n"), MYNAME);
-		exit(EX_USAGE);
+		audit_exit(EX_USAGE);
 	}
 
 #ifdef __alpha__
@@ -1438,7 +1453,7 @@
 		if (rc != 0) {
 			fprintf(stderr, _("No usable set-to time.  "
 					  "Cannot set clock.\n"));
-			exit(EX_USAGE);
+			audit_exit(EX_USAGE);
 		}
 	}
 
@@ -1470,11 +1485,11 @@
 	}
 
 	if (!permitted)
-		exit(EX_NOPERM);
+		audit_exit(EX_NOPERM);
 
 	if (getepoch || setepoch) {
 		manipulate_epoch(getepoch, setepoch, epoch_option, testing);
-		return 0;
+		audit_exit(0);
 	}
 
 	if (debug)
@@ -1488,12 +1503,14 @@
 			fprintf(stderr,
 				_("Use the --debug option to see the details "
 				  "of our search for an access method.\n"));
-		exit(1);
+		audit_exit(1);
 	}
 
-	return manipulate_clock(show, adjust, noadjfile, set, set_time,
+	rc = manipulate_clock(show, adjust, noadjfile, set, set_time,
 				hctosys, systohc, startup_time, utc,
 				local_opt, testing);
+	audit_exit(rc);
+	return rc;	/* Not reached */
 }
 
 /* A single routine for greater uniformity */
--- /dev/null	2005-07-04 12:38:58.745411448 +0200
+++ util-linux-2.12p/hwclock/audit.h	2005-07-12 15:15:29.000000000 +0200
@@ -0,0 +1,34 @@
+/* audit.h -- This file contains the function prototypes for audit calls
+ * Copyright 2005 Red Hat Inc., Durham, North Carolina.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author:
+ *   Steve Grubb <sgrubb redhat com>
+ *
+ */
+
+#ifndef HW_AUDIT_H
+#define HW_AUDIT_H
+
+/* This is the file descriptor used by the audit system */
+extern int audit_fd;
+
+/* This is the logging functions */
+void auditable_event(int i);
+void audit_exit(int status);
+
+#endif
--- util-linux-2.12p/hwclock/clock.h.audit-hwclock	2000-12-07 17:39:53.000000000 +0100
+++ util-linux-2.12p/hwclock/clock.h	2005-07-12 15:15:29.000000000 +0200
@@ -24,7 +24,12 @@
 extern char *progname;
 extern int debug;
 extern int epoch_option;
-extern void outsyserr(char *msg, ...);
+extern void outsyserr(char *msg, ...)
+#ifdef __GNUC__
+        __attribute__ ((format (printf, 1, 2)));
+#else
+        ;
+#endif
 
 /* cmos.c */
 extern void set_cmos_epoch(int ARCconsole, int SRM);
--- /dev/null	2005-07-04 12:38:58.745411448 +0200
+++ util-linux-2.12p/hwclock/audit.c	2005-07-12 15:15:29.000000000 +0200
@@ -0,0 +1,70 @@
+/* audit.c -- This file contains the audit system extensions
+ *
+ * Copyright 2005 Red Hat Inc., Durham, North Carolina.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Authors:
+ *     Steve Grubb <sgrubb redhat com>
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <libaudit.h>
+#include "audit.h"
+
+int audit_fd = -1;
+
+/*
+ * This function will log a message to the audit system using a predefined
+ * message format. Parameter usage is as follows:
+ *
+ * op  -  operation. "adding user", "changing finger info", "deleting group"
+ * result - 0 = "success"  or  1 = "failed"
+ */
+static void audit_logger(const char *op, int result) 
+{
+	char msg_buf[256]; /* Common buffer for messaging */
+	const char *success;
+	extern char *progname;
+
+	if (!result)
+		success = "success";
+	else
+		success = "failed";
+
+	/* Add some audit info & log it.  */
+	snprintf(msg_buf, sizeof(msg_buf),
+		"%s: op=%s id=%u res=%s", progname, op, getuid(), success);
+	audit_send_user_message(audit_fd, AUDIT_USYS_CONFIG, msg_buf);
+	close(audit_fd);
+}
+
+static int audit_this = 0;
+void auditable_event(int i)
+{
+	audit_this = i;
+}
+
+void audit_exit(int status)
+{
+	if (audit_this)
+		audit_logger("changing system time", status);
+	exit(status);
+}
+

util-linux-2.12p-execl.patch:
 login-utils/agetty.c |    2 +-
 misc-utils/script.c  |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

--- NEW FILE util-linux-2.12p-execl.patch ---
--- util-linux-2.12p/login-utils/agetty.c.execl	2005-07-12 15:53:25.000000000 +0200
+++ util-linux-2.12p/login-utils/agetty.c	2005-07-12 15:53:49.000000000 +0200
@@ -382,7 +382,7 @@
 
     /* Let the login program take care of password validation. */
 
-    (void) execl(options.login, options.login, "--", logname, (char *) 0);
+    (void) execl(options.login, options.login, "--", logname, NULL);
     error(_("%s: can't exec %s: %m"), options.tty, options.login);
     exit(0);  /* quiet GCC */
 }
--- util-linux-2.12p/misc-utils/script.c.execl	2005-07-12 15:54:17.000000000 +0200
+++ util-linux-2.12p/misc-utils/script.c	2005-07-12 15:54:28.000000000 +0200
@@ -325,9 +325,9 @@
 		shname = shell;
 
 	if (cflg)
-		execl(shell, shname, "-c", cflg, 0);
+		execl(shell, shname, "-c", cflg, NULL);
 	else
-		execl(shell, shname, "-i", 0);
+		execl(shell, shname, "-i", NULL);
 
 	perror(shell);
 	fail();

util-linux-2.12p-fdisk-gpt.patch:
 Makefile |    4 
 fdisk.8  |    5 +
 fdisk.c  |   15 +++
 gpt.c    |  285 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gpt.h    |    9 +
 sfdisk.8 |    5 +
 sfdisk.c |   28 ++++++
 7 files changed, 349 insertions(+), 2 deletions(-)

--- NEW FILE util-linux-2.12p-fdisk-gpt.patch ---
--- util-linux-2.12p/fdisk/Makefile.gpt	2004-09-06 22:28:58.000000000 +0200
+++ util-linux-2.12p/fdisk/Makefile	2005-06-03 00:14:31.404242536 +0200
@@ -56,14 +56,14 @@
 	ln -s sfdisk activate
 
 fdisk: fdisk.o llseek.o disksize.o fdiskbsdlabel.o fdisksgilabel.o \
-	fdisksunlabel.o fdiskaixlabel.o i386_sys_types.o partname.o
+	fdisksunlabel.o fdiskaixlabel.o i386_sys_types.o partname.o gpt.o
 fdisk.o: fdisk.c fdisk.h
 fdiskbsdlabel.o: fdiskbsdlabel.c fdisk.h fdiskbsdlabel.h
 fdisksunlabel.o: fdisksunlabel.c fdisksunlabel.h fdisk.h
 fdiskaixlabel.o: fdiskaixlabel.c fdiskaixlabel.h fdisk.h
 fdisk.o cfdisk.o sfdisk.o fdiskbsdlabel.o fdisksunlabel.o \
 	fdisksgilabel.o fdiskaixlabel.o i386_sys_types.o partname.o: common.h
-sfdisk: sfdisk.o disksize.o i386_sys_types.o partname.o
+sfdisk: sfdisk.o disksize.o i386_sys_types.o partname.o gpt.o
 
 install: all
 	$(INSTALLDIR) $(SBINDIR)
--- util-linux-2.12p/fdisk/fdisk.c.gpt	2005-06-03 00:12:56.880612312 +0200
+++ util-linux-2.12p/fdisk/fdisk.c	2005-06-03 00:12:57.076582520 +0200
@@ -32,6 +32,8 @@
 #include <linux/blkpg.h>
 #endif
 
+#include "gpt.h"
+
 static void delete_partition(int i);
 
 #define hex_val(c)	({ \
@@ -2398,6 +2400,14 @@
 }
 
 static void
+gpt_warning(char *dev)
+{
+	if (gpt_probe_signature_devname(dev))
+		fprintf(stderr, _("\nWARNING: GPT (GUID Partition Table) detected on '%s'! "
+			"The util fdisk doesn't support GPT. Use GNU Parted.\n\n"), dev);
+}
+
+static void
 try(char *device, int user_specified) {
 	int gb;
 
@@ -2407,6 +2417,7 @@
 	if (!user_specified)
 		if (is_ide_cdrom_or_tape(device))
 			return;
+	gpt_warning(device);
 	if ((fd = open(disk_device, type_open)) >= 0) {
 		gb = get_boot(try_only);
 		if (gb > 0) { /* I/O error */
@@ -2468,6 +2479,8 @@
 	printf(_("%c: unknown command\n"), c);
 }
 
+
+
 int
 main(int argc, char **argv) {
 	int j, c;
@@ -2572,6 +2585,7 @@
 
 		for (j = optind; j < argc; j++) {
 			disk_device = argv[j];
+			gpt_warning(disk_device);
 			if ((fd = open(disk_device, type_open)) < 0)
 				fatal(unable_to_open);
 			if (disksize(fd, &size))
@@ -2592,6 +2606,7 @@
 	else
 		fatal(usage2);
 
+	gpt_warning(disk_device);
 	get_boot(fdisk);
 
 	if (osf_label) {
--- /dev/null	2005-05-29 23:08:17.791240320 +0200
+++ util-linux-2.12p/fdisk/gpt.h	2005-06-03 00:12:57.076582520 +0200
@@ -0,0 +1,9 @@
+
+#ifndef __GPT_H__
+#define __GPT_H__
+
+extern int gpt_probe_signature_fd(int fd);
+extern int gpt_probe_signature_devname(char *devname);
+
+#endif /* __GPT_H__ */
+
--- util-linux-2.12p/fdisk/fdisk.8.gpt	2005-06-03 00:12:56.895610032 +0200
+++ util-linux-2.12p/fdisk/fdisk.8	2005-06-03 00:12:57.076582520 +0200
@@ -42,6 +42,11 @@
 partition tables.
 It understands DOS type partition tables and BSD or SUN type disklabels.
 
+.B fdisk 
+doesn't understand GUID Partition Table (GPT) and 
+it is not designed for large partitions. In particular case use more advanced GNU 
+.B parted(8).
+
 The
 .I device
 is usually one of the following:
--- util-linux-2.12p/fdisk/sfdisk.8.gpt	2004-12-15 23:39:27.000000000 +0100
+++ util-linux-2.12p/fdisk/sfdisk.8	2005-06-03 00:12:57.077582368 +0200
@@ -18,6 +18,11 @@
 on a device, check the partitions on a device, and - very dangerous -
 repartition a device.
 
+.B sfdisk 
+doesn't understand GUID Partition Table (GPT) and 
+it is not designed for large partitions. In particular case use more advanced GNU 
+.B parted(8).
+
 .SS "List Sizes"
 .BI "sfdisk \-s " partition
 gives the size of
--- /dev/null	2005-05-29 23:08:17.791240320 +0200
+++ util-linux-2.12p/fdisk/gpt.c	2005-06-03 00:22:58.086215168 +0200
@@ -0,0 +1,285 @@
+/*
+    GPT (GUID Partition Table) signature detection. Based on libparted and 
+    util-linux/partx.
+  
+    Warning: this code doesn't do all GPT checks (CRC32, Protective MBR, ..). It's
+             really GPT signature detection only.
+    
+    -- Karel Zak <kzak redhat com> (Jun-2-2005)
+
+*/
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/utsname.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <linux/fs.h>
+
+#include "gpt.h"
+
+#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#define SECTOR_SIZE	512	/* default */
+
+#define _PED_SWAP64(x)		( (_GET_BYTE(x, 0) << 56)	\
+				+ (_GET_BYTE(x, 1) << 48)	\
+				+ (_GET_BYTE(x, 2) << 40)	\
+				+ (_GET_BYTE(x, 3) << 32)	\
+				+ (_GET_BYTE(x, 4) << 24)	\
+				+ (_GET_BYTE(x, 5) << 16)	\
+				+ (_GET_BYTE(x, 6) << 8)	\
+				+ (_GET_BYTE(x, 7) << 0) )
+
+#define PED_SWAP64(x)           ((uint64_t) _PED_SWAP64( (uint64_t) (x) ))
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+# define CPU_TO_LE64(x)	(x)
+#else
+# define CPU_TO_LE64(x)	PED_SWAP64(x)
+#endif
+
+#define BLKSSZGET  _IO(0x12,104) /* get block device sector size */
+#define BLKGETLASTSECT  _IO(0x12,108)   /* get last sector of block device */
+#define BLKGETSIZE _IO(0x12,96)	/* return device size */
+#define BLKGETSIZE64 _IOR(0x12,114,size_t)	/* return device size in bytes (u64 *arg) */
+
+#define GPT_HEADER_SIGNATURE 0x5452415020494645LL
+#define GPT_PRIMARY_PARTITION_TABLE_LBA 1
+
+typedef struct {
+        uint32_t time_low;
+        uint16_t time_mid;
+        uint16_t time_hi_and_version;
+        uint8_t  clock_seq_hi_and_reserved;
+        uint8_t  clock_seq_low;
+        uint8_t  node[6];
+} /* __attribute__ ((packed)) */ efi_guid_t;
+/* commented out "__attribute__ ((packed))" to work around gcc bug (fixed
+ * in gcc3.1): __attribute__ ((packed)) breaks addressing on initialized
+ * data.  It turns out we don't need it in this case, so it doesn't break
+ * anything :)
+ */
+
+typedef struct _GuidPartitionTableHeader_t {
+	uint64_t Signature;
+	uint32_t Revision;
+	uint32_t HeaderSize;
+	uint32_t HeaderCRC32;
+	uint32_t Reserved1;
+	uint64_t MyLBA;
+	uint64_t AlternateLBA;
+	uint64_t FirstUsableLBA;
+	uint64_t LastUsableLBA;
+	efi_guid_t DiskGUID;
+	uint64_t PartitionEntryLBA;
+	uint32_t NumberOfPartitionEntries;
+	uint32_t SizeOfPartitionEntry;
+	uint32_t PartitionEntryArrayCRC32;
+	uint8_t Reserved2[512 - 92];
+} __attribute__ ((packed)) GuidPartitionTableHeader_t;
+
+struct blkdev_ioctl_param {
+        unsigned int block;
+        size_t content_length;
+        char * block_contents;
+};
+
+static int
+_get_linux_version ()
+{
+	static int kver = -1;
+	struct utsname uts;
+	int major;
+	int minor;
+	int teeny;
+
+	if (kver != -1)
+		return kver;
+	if (uname (&uts))
+		return kver = 0;
+	if (sscanf (uts.release, "%u.%u.%u", &major, &minor, &teeny) != 3)
+		return kver = 0;
+	return kver = KERNEL_VERSION (major, minor, teeny);
+}
+
+static unsigned int
+_get_sector_size (int fd)
+{
+	unsigned int sector_size;
+
+	if (_get_linux_version() < KERNEL_VERSION (2,3,0))
+		return SECTOR_SIZE;
+	if (ioctl (fd, BLKSSZGET, &sector_size))
+		return SECTOR_SIZE;
+	return sector_size;
+}
+
+static uint64_t
+_get_num_sectors(int fd)
+{
+	int version = _get_linux_version();
+	unsigned long	size;
+	uint64_t bytes=0;
+
+	if (version >= KERNEL_VERSION(2,5,4) || 
+		(version <  KERNEL_VERSION(2,5,0) && 
+		 version >= KERNEL_VERSION (2,4,18)))
+	{
+                if (ioctl(fd, BLKGETSIZE64, &bytes) == 0) 
+                        return bytes / _get_sector_size(fd);
+	}
+	if (ioctl (fd, BLKGETSIZE, &size))
+		return 0;
+	return size;
+}
+
+static uint64_t
+last_lba(int fd)
+{
+	int rc;
+	uint64_t sectors = 0;
+	struct stat s;
+
+	memset(&s, 0, sizeof (s));
+	rc = fstat(fd, &s);
+	if (rc == -1) 
+	{
+		fprintf(stderr, "last_lba() could not stat: %s\n",
+			strerror(errno));
+		return 0;
+	}
+	if (S_ISBLK(s.st_mode))
+		sectors = _get_num_sectors(fd);
+	else 
+	{
+		fprintf(stderr,
+			"last_lba(): I don't know how to handle files with mode %x\n",
+			s.st_mode);
+		sectors = 1;
+	}
+	return sectors - 1;
+}
+
+static ssize_t
+read_lastoddsector(int fd, uint64_t lba, void *buffer, size_t count)
+{
+        int rc;
+        struct blkdev_ioctl_param ioctl_param;
+
+        if (!buffer) return 0; 
+
+        ioctl_param.block = 0; /* read the last sector */
+        ioctl_param.content_length = count;
+        ioctl_param.block_contents = buffer;
+
+        rc = ioctl(fd, BLKGETLASTSECT, &ioctl_param);
+        if (rc == -1) perror("read failed");
+
+        return !rc;
+}
+
+static ssize_t
+read_lba(int fd, uint64_t lba, void *buffer, size_t bytes)
+{
+	int sector_size = _get_sector_size(fd);
+	off_t offset = lba * sector_size;
+        ssize_t bytesread;
+
+	lseek(fd, offset, SEEK_SET);
+	bytesread = read(fd, buffer, bytes);
+
+        /* Kludge.  This is necessary to read/write the last
+           block of an odd-sized disk, until Linux 2.5.x kernel fixes.
+           This is only used by gpt.c, and only to read
+           one sector, so we don't have to be fancy.
+        */
+        if (!bytesread && !(last_lba(fd) & 1) && lba == last_lba(fd))
+                bytesread = read_lastoddsector(fd, lba, buffer, bytes);
+        return bytesread;
+}
+
+static GuidPartitionTableHeader_t *
+alloc_read_gpt_header(int fd, uint64_t lba)
+{
+	GuidPartitionTableHeader_t *gpt = 
+		(GuidPartitionTableHeader_t *) malloc(sizeof (GuidPartitionTableHeader_t));
+	if (!gpt)
+		return NULL;
+	memset(gpt, 0, sizeof (*gpt));
+	if (!read_lba(fd, lba, gpt, sizeof (GuidPartitionTableHeader_t))) 
+	{
+		free(gpt);
+		return NULL;
+	}
+	return gpt;
+}
+
+static int
+gpt_check_signature(int fd, uint64_t lba)
+{
+	GuidPartitionTableHeader_t *gpt;
+	int res=0;
+
+	if ((gpt = alloc_read_gpt_header(fd, lba)))
+	{
+		if (gpt->Signature == CPU_TO_LE64(GPT_HEADER_SIGNATURE))
+			res = 1;
+		free(gpt);
+	}
+	return res;
+}
+
+/* returns:
+ *	0 not found GPT
+ * 	1 for valid primary GPT header
+ *	2 for valid alternative GPT header
+ */
+int
+gpt_probe_signature_fd(int fd)
+{
+	int res = 0;
+
+	/* check primary GPT header */	
+	if (gpt_check_signature(fd, GPT_PRIMARY_PARTITION_TABLE_LBA))
+		res = 1;
+	else
+	{
+		/* check alternative GPT header */
+		uint64_t lastlba = last_lba(fd);
+        	if (gpt_check_signature(fd, lastlba))
+			res = 2;
+	}
+	return res;
+}
+
+int
+gpt_probe_signature_devname(char *devname)
+{
+	int res, fd;
+	if ((fd = open(devname, O_RDONLY)) < 0)
+		return 0;
+	res = gpt_probe_signature_fd(fd);
+	close(fd);
+	return res;
+}
+
+#ifdef GPT_TEST_MAIN
+int
+main(int argc, char **argv)
+{
+	if (argc!=2)
+	{
+		fprintf(stderr, "usage: %s <dev>\n", argv[0]);
+		exit(EXIT_FAILURE);
+	}
+	if (gpt_probe_signature_devname(argv[1]))
+		printf("GPT (GUID Partition Table) detected on %s\n", argv[1]);
+	exit(EXIT_SUCCESS);
+}
+#endif
--- util-linux-2.12p/fdisk/sfdisk.c.gpt	2004-12-15 19:18:30.000000000 +0100
+++ util-linux-2.12p/fdisk/sfdisk.c	2005-06-03 00:28:14.194159456 +0200
@@ -52,6 +52,8 @@
 #include "nls.h"
 #include "common.h"
 
+#include "gpt.h"
+
 #define SIZE(a)	(sizeof(a)/sizeof(a[0]))
 
 /*
@@ -2477,6 +2479,23 @@
 	return NULL;
 }	
 
+static void
+gpt_warning(char *dev, int warn_only)
+{
+	if (force)
+		warn_only = 1;
+	
+	if (gpt_probe_signature_devname(dev)) {
+		fflush(stdout);
+		fprintf(stderr, _("\nWARNING: GPT (GUID Partition Table) detected on '%s'! "
+			"The util sfdisk doesn't support GPT. Use GNU Parted.\n\n"), dev);
+		if (!warn_only) {
+			fprintf(stderr, _("Use the --force flag to overrule this check.\n"));
+			exit(1);
+		}
+	}
+}
+
 static void do_list(char *dev, int silent);
 static void do_size(char *dev, int silent);
 static void do_geom(char *dev, int silent);
@@ -2617,6 +2636,7 @@
 	while ((dev = nextproc()) != NULL) {
 	    if (is_ide_cdrom_or_tape(dev))
 		continue;
+	    gpt_warning(dev, 1);
 	    if (opt_out_geom)
 		do_geom(dev, 1);
 	    if (opt_size)
@@ -2642,6 +2662,7 @@
 
     if (opt_list || opt_out_geom || opt_size || verify) {
 	while (optind < argc) {
+	    gpt_warning(argv[optind], 1);
 	    if (opt_out_geom)
 	      do_geom(argv[optind], 0);
 	    if (opt_size)
@@ -2668,6 +2689,7 @@
 	  fatal(_("usage: sfdisk --change-id device partition-number Id\n"));
 	else if (optind != argc-3 && optind != argc-2)
 	  fatal(_("usage: sfdisk --id device partition-number [Id]\n"));
+	gpt_warning(argv[optind], 0);
 	do_change_id(argv[optind], argv[optind+1],
 		     (optind == argc-2) ? 0 : argv[optind+2]);
 	exit(exit_status);
@@ -2677,6 +2699,8 @@
       fatal(_("can specify only one device (except with -l or -s)\n"));
     dev = argv[optind];
 
+    gpt_warning(dev, 0);
+    
     if (opt_reread)
       do_reread(dev);
     else if (restore_sector_file)
@@ -2822,6 +2846,8 @@
 
     z = &oldp;
 
+    gpt_warning(dev, 0);
+    
     rw = (!no_write && (arg || ac > 1));
     fd = my_open(dev, rw, 0);
 
@@ -2895,6 +2921,8 @@
 
     z = &oldp;
 
+    gpt_warning(dev, 0);
+    
     rw = !no_write;
     fd = my_open(dev, rw, 0);
 

util-linux-2.12p-mount-ocfs2.patch:
 mount.c |  140 +++++++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 77 insertions(+), 63 deletions(-)

--- NEW FILE util-linux-2.12p-mount-ocfs2.patch ---
--- util-linux-2.12p/mount/mount.c.ocfs2	2005-07-12 16:31:16.000000000 +0200
+++ util-linux-2.12p/mount/mount.c	2005-07-12 16:31:46.000000000 +0200
@@ -466,6 +466,61 @@
 }
 
 /*
+ * check_special_mountprog()
+ *	If there is a special mount program for this type, exec it.
+ * returns: 0: no exec was done, 1: exec was done, status has result
+ */
+
+static int
+check_special_mountprog(const char *spec, const char *node, const char *type, int flags,
+			char *extra_opts, int *status) {
+  char mountprog[120];
+  struct stat statbuf;
+  int res;
+
+  if (!external_allowed)
+      return 0;
+
+  if (type && strlen(type) < 100) {
+       sprintf(mountprog, "/sbin/mount.%s", type);
+       if (stat(mountprog, &statbuf) == 0) {
+	    res = fork();
+	    if (res == 0) {
+		 char *oo, *mountargs[10];
+		 int i = 0;
+
+		 setuid(getuid());
+		 setgid(getgid());
+		 oo = fix_opts_string (flags, extra_opts, NULL);
+		 mountargs[i++] = mountprog;
+		 mountargs[i++] = spec;
+		 mountargs[i++] = node;
+		 if (nomtab)
+		      mountargs[i++] = "-n";
+		 if (verbose)
+		      mountargs[i++] = "-v";
+		 if (oo && *oo) {
+		      mountargs[i++] = "-o";
+		      mountargs[i++] = oo;
+		 }
+		 mountargs[i] = NULL;
+		 execv(mountprog, mountargs);
+		 exit(1);	/* exec failed */
+	    } else if (res != -1) {
+		 int st;
+		 wait(&st);
+		 *status = (WIFEXITED(st) ? WEXITSTATUS(st) : EX_SYSERR);
+		 return 1;
+	    } else {
+	    	 int errsv = errno;
+		 error(_("mount: cannot fork: %s"), strerror(errsv));
+	    }
+       }
+  }
+  return 0;
+}
+
+/*
  * guess_fstype_and_mount()
  *	Mount a single file system. Guess the type when unknown.
  * returns: 0: OK, -1: error in errno, 1: other error
@@ -474,9 +529,11 @@
  */
 static int
 guess_fstype_and_mount(const char *spec, const char *node, const char **types,
-		       int flags, char *mount_opts) {
+		       int flags, char *mount_opts, int *special, int *status) {
    struct mountargs args = { spec, node, NULL, flags & ~MS_NOSYS, mount_opts };
    
+   *special = 0;
+   
    if (*types && strcasecmp (*types, "auto") == 0)
       *types = NULL;
 
@@ -485,10 +542,16 @@
 
    if (!*types && !(flags & MS_REMOUNT)) {
       *types = guess_fstype(spec);
-      if (*types && !strcmp(*types, "swap")) {
-	  error(_("%s looks like swapspace - not mounted"), spec);
-	  *types = NULL;
-	  return 1;
+      if (*types) {
+	  if (!strcmp(*types, "swap")) {
+	      error(_("%s looks like swapspace - not mounted"), spec);
+	      *types = NULL;
+	      return 1;
+	  } else if (check_special_mountprog(spec, node, *types, flags,
+					     mount_opts, status)) {
+	      *special = 1;
+	      return 0;
+          }
       }
    }
 
@@ -741,61 +804,6 @@
 }
 
 /*
- * check_special_mountprog()
- *	If there is a special mount program for this type, exec it.
- * returns: 0: no exec was done, 1: exec was done, status has result
- */
-
-static int
-check_special_mountprog(const char *spec, const char *node, const char *type,
-			int flags, char *extra_opts, int *status) {
-  char mountprog[120];
-  struct stat statbuf;
-  int res;
-
-  if (!external_allowed)
-      return 0;
-
-  if (type && strlen(type) < 100) {
-       sprintf(mountprog, "/sbin/mount.%s", type);
-       if (stat(mountprog, &statbuf) == 0) {
-	    res = fork();
-	    if (res == 0) {
-		 const char *oo, *mountargs[10];
-		 int i = 0;
-
-		 setuid(getuid());
-		 setgid(getgid());
-		 oo = fix_opts_string (flags, extra_opts, NULL);
-		 mountargs[i++] = mountprog;
-		 mountargs[i++] = spec;
-		 mountargs[i++] = node;
-		 if (nomtab)
-		      mountargs[i++] = "-n";
-		 if (verbose)
-		      mountargs[i++] = "-v";
-		 if (oo && *oo) {
-		      mountargs[i++] = "-o";
-		      mountargs[i++] = oo;
-		 }
-		 mountargs[i] = NULL;
-		 execv(mountprog, (char **) mountargs);
-		 exit(1);	/* exec failed */
-	    } else if (res != -1) {
-		 int st;
-		 wait(&st);
-		 *status = (WIFEXITED(st) ? WEXITSTATUS(st) : EX_SYSERR);
-		 return 1;
-	    } else {
-	    	 int errsv = errno;
-		 error(_("mount: cannot fork: %s"), strerror(errsv));
-	    }
-       }
-  }
-  return 0;
-}
-
-/*
  * try_mount_one()
  *	Try to mount one file system. When "bg" is 1, this is a retry
  *	in the background. One additional exit code EX_BG is used here.
@@ -807,7 +815,7 @@
 static int
 try_mount_one (const char *spec0, const char *node0, const char *types0,
 	       const char *opts0, int freq, int pass, int bg, int ro) {
-  int res = 0, status;
+  int res = 0, status, special;
   int mnt5_res = 0;		/* only for gcc */
   int mnt_err;
   int flags;
@@ -898,9 +906,15 @@
   block_signals (SIG_BLOCK);
 nosigblock:
 
-  if (!fake)
+  if (!fake) {
     mnt5_res = guess_fstype_and_mount (spec, node, &types, flags & ~MS_NOSYS,
-				       mount_opts);
+				       mount_opts, &special, &status);
+
+    if (special) {
+      block_signals (SIG_UNBLOCK);
+      return status;
+    }
+  }
 
   if (fake || mnt5_res == 0) {
       /* Mount succeeded, report this (if verbose) and write mtab entry.  */


Index: util-linux.spec
===================================================================
RCS file: /cvs/dist/rpms/util-linux/FC-4/util-linux.spec,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- util-linux.spec	18 Jun 2005 09:18:58 -0000	1.77
+++ util-linux.spec	14 Jul 2005 09:18:25 -0000	1.78
@@ -27,7 +27,7 @@
 Summary: A collection of basic system utilities.
 Name: util-linux
 Version: 2.12p
-Release: 9.5
+Release: 9.6
 License: distributable
 Group: System Environment/Base
 
@@ -41,6 +41,7 @@
 BuildRequires: gettext
 BuildRequires: libselinux-devel
 BuildRequires: e2fsprogs-devel >= 1.36
+BuildRequires: audit-libs-devel
 
 Source0: ftp://ftp.win.tue.nl/pub/linux-local/utils/util-linux/util-linux-%{version}.tar.gz
 Source1: util-linux-selinux.pamd
@@ -134,6 +135,14 @@
 Patch200: util-linux-2.12p-sfdisk-fgets.patch
 # 157674 – sync option on VFAT mount destroys flash drives
 Patch201: util-linux-2.12p-mount-man-sync.patch
+# 159339 - util-linux updates for new audit system
+Patch202: util-linux-2.12p-audit-hwclock.patch
+# 158737 - sfdisk warning for large partitions, gpt
+Patch203: util-linux-2.12p-fdisk-gpt.patch
+# 150912 – Add ocfs2 support
+Patch204: util-linux-2.12p-mount-ocfs2.patch
+# NULL is better than zero at end of execl()
+Patch205: util-linux-2.12p-execl.patch
 
 # When adding patches, please make sure that it is easy to find out what bug # the 
 # patch fixes.
@@ -263,6 +272,10 @@
 %patch189 -p1
 %patch200 -p1
 %patch201 -p1
+%patch202 -p1
+%patch203 -p1
+%patch204 -p1
+%patch205 -p1
 
 %build
 unset LINGUAS || :
@@ -654,6 +667,12 @@
 /sbin/losetup
 
 %changelog
+* Tue Jul 12 2005 Karel Zak <kzak redhat com> 2.12p-9.6
+- fix #159339 - util-linux updates for new audit system
+- fix #158737 - sfdisk warning for large partitions, gpt
+- fix #150912 – Add ocfs2 support
+- NULL is better than zero at end of execl()
+
 * Thu Jun 16 2005 Karel Zak <kzak redhat com> 2.12p-9.5
 - fix #157656 - CRM 546998: Possible bug in vipw, changes permissions of /etc/shadow and /etc/gshadow
 - fix #159339 - util-linux updates for new audit system (pam_loginuid.so added to util-linux-selinux.pamd)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]