mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.9 KiB

  1. --- devfsd/check_kernel.c.kernel25 2003-06-02 22:17:21.000000000 +0400
  2. +++ devfsd/check_kernel.c 2003-06-02 22:17:43.000000000 +0400
  3. @@ -0,0 +1,30 @@
  4. +#include <sys/types.h>
  5. +#include <stdio.h>
  6. +#include <unistd.h>
  7. +#include <errno.h>
  8. +#include <asm/unistd.h>
  9. +
  10. +extern char *modules_devfs;
  11. +
  12. +/* copied over from module-init-tools backward_compat.c */
  13. +#ifndef __ia64 /* breaks ia64. */
  14. +static _syscall2(long, create_module, const char *, name, size_t, size);
  15. +#else
  16. +#define create_module(name, size) \
  17. + syscall(__NR_create_module, (name), (size))
  18. +#endif
  19. +
  20. +void check_kernel_version (int verbose)
  21. +{
  22. + int k26 = 1;
  23. +
  24. + errno = 0;
  25. + if (create_module(NULL, 0) >= 0 | errno != ENOSYS) {
  26. + modules_devfs = "/etc/modules.devfs";
  27. + k26 = 0;
  28. + }
  29. +
  30. + if (verbose)
  31. + fprintf (stderr, "devfsd: kernel %s detected, using %s for MODLOAD\n",
  32. + k26 ? "2.6" : "2.4", modules_devfs);
  33. +}
  34. --- devfsd/devfsd.c.kernel25 2003-06-02 22:17:21.000000000 +0400
  35. +++ devfsd/devfsd.c 2003-06-02 22:17:21.000000000 +0400
  36. @@ -396,10 +396,14 @@ EXTERN_FUNCTION (flag st_expr_expand,
  37. EXTERN_FUNCTION (const char *get_old_name,
  38. (const char *devname, unsigned int namelen,
  39. char *buffer, unsigned int major, unsigned int minor) );
  40. -
  41. +EXTERN_FUNCTION (void check_kernel_version,
  42. + (int) );
  43. /* Public data */
  44. flag syslog_is_open = FALSE;
  45. +/* set to new style, runtime test might override it later */
  46. +char *modules_devfs = "/etc/modprobe.devfs";
  47. +
  48. /* Public functions */
  49. @@ -508,7 +512,6 @@ static struct event_type
  50. {0xffffffff, NULL, NULL}
  51. };
  52. -
  53. /* Public functions follow */
  54. int main (int argc, char **argv)
  55. @@ -652,6 +655,7 @@ int main (int argc, char **argv)
  56. /* Set umask so that mknod(2), open(2) and mkdir(2) have complete control
  57. over permissions */
  58. umask (0);
  59. + check_kernel_version (trace_level);
  60. read_config (CONFIG_FILE, FALSE, &event_mask);
  61. /* Do the scan before forking, so that boot scripts see the finished
  62. product */
  63. @@ -1243,7 +1247,7 @@ static void action_modload (const struct
  64. argv[0] = "/sbin/modprobe";
  65. argv[1] = "-k";
  66. argv[2] = "-C";
  67. - argv[3] = "/etc/modules.devfs";
  68. + argv[3] = modules_devfs;
  69. argv[4] = device;
  70. argv[5] = NULL;
  71. snprintf (device, sizeof (device), "/dev/%s", info->devname);
  72. --- devfsd/GNUmakefile.kernel25 2002-02-19 09:06:43.000000000 +0300
  73. +++ devfsd/GNUmakefile 2003-06-02 22:17:21.000000000 +0400
  74. @@ -18,13 +18,16 @@ endif
  75. all: devfsd rpm.spec
  76. -OBJECTS = devfsd.o expression.o compat_name.o
  77. +OBJECTS = devfsd.o expression.o compat_name.o check_kernel.o
  78. CFLAGS = -O2 -I. -I$(KERNEL_DIR)/include -Wall $(CEXTRAS) $(DEFINES)
  79. devfsd: $(OBJECTS)
  80. $(CC) -O2 -o devfsd $(OBJECTS) $(LDFLAGS) -export-dynamic -ldl
  81. +check_kernel.o: check_kernel.c
  82. + $(CC) -O2 -c $<
  83. +
  84. install: devfsd
  85. @if fgrep -q "Generic section: do not change" /etc/modules.conf ; then\
  86. echo "First remove the generic devfs entries from /etc/modules.conf"; exit 1; \