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.

100 lines
2.5 KiB

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