OpenSDE Packages Database (without history before r20070)
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.

99 lines
2.5 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../embutils/losetup.patch
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- T2-COPYRIGHT-NOTE-END ---
  16. Guess what ,-)
  17. - Rene Rebe <rene@exactcode.de>
  18. --- /dev/null 2005-06-19 08:33:32.285177368 +0200
  19. +++ embutils-0.17/losetup.c 2005-06-19 13:44:28.000000000 +0200
  20. @@ -0,0 +1,65 @@
  21. +/*
  22. + * Tiny losetup
  23. + *
  24. + * Copyright (c) 2005 by Rene Rebe <rene@exactcode.de>
  25. + *
  26. + * License: GPL, version 2
  27. + *
  28. + */
  29. +
  30. +#define _FILE_OFFSET_BITS 64
  31. +#include <sys/types.h>
  32. +#include <sys/stat.h>
  33. +#include <fcntl.h>
  34. +#include <sys/ioctl.h>
  35. +#include <errno.h>
  36. +
  37. +#include <linux/posix_types.h>
  38. +#include <linux/loop.h>
  39. +
  40. +#include "write12.h"
  41. +
  42. +void die(const char*msg) { __write2(msg); __write2("\n"); exit(1); }
  43. +
  44. +int main (int argc, char* argv[])
  45. +{
  46. + int ffd, fd;
  47. + struct loop_info loopinfo;
  48. +
  49. + if (argc != 3) {
  50. + die("usage: losetup [-d] loop_device\n losetup loop_device file");
  51. + }
  52. +
  53. + if (!strcmp(argv[1], "-d"))
  54. + {
  55. + fd=open(argv[2], O_RDONLY);
  56. + if (fd < 0)
  57. + die(strerror(errno));
  58. +
  59. + if (ioctl(fd, LOOP_CLR_FD, ffd))
  60. + die(strerror(errno));
  61. +
  62. + close(fd);
  63. + }
  64. + else
  65. + {
  66. + memset(&loopinfo, 0, sizeof(loopinfo));
  67. + strncpy(loopinfo.lo_name, argv[2], LO_NAME_SIZE);
  68. +
  69. + ffd=open(argv[2], O_RDONLY);
  70. + if (ffd < 0)
  71. + die(strerror(errno));
  72. +
  73. + fd=open(argv[1], O_RDONLY);
  74. + if (fd < 0)
  75. + die(strerror(errno));
  76. +
  77. + if (ioctl(fd, LOOP_SET_FD, ffd))
  78. + die(strerror(errno));
  79. + if (ioctl(fd, LOOP_SET_STATUS, &loopinfo))
  80. + die(strerror(errno));
  81. +
  82. + close(ffd);
  83. + close(fd);
  84. + }
  85. +}
  86. --- embutils-0.17/Makefile.orig 2005-06-19 13:46:49.000000000 +0200
  87. +++ embutils-0.17/Makefile 2005-05-31 11:53:22.000000000 +0200
  88. @@ -11,7 +11,7 @@
  89. install sosrm soscp sosmv sosln soslns md5sum sleep2 allinone kill uniq \
  90. dd tr mesg write touch du tail uuencode uudecode nohup nice cmp mktemp \
  91. truncate strings test date mount printenv umount pivot_root insmod rmmod \
  92. -lsmod free
  93. +lsmod free losetup
  94. OBJDIR:=bin
  95. TARGETS=$(patsubst %,$(OBJDIR)/%,$(PRGS))