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

# --- T2-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# T2 SDE: package/.../embutils/losetup.patch
# Copyright (C) 2004 - 2006 The T2 SDE Project
#
# More information can be found in the files COPYING and README.
#
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or 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.
# --- T2-COPYRIGHT-NOTE-END ---
Guess what ,-)
- Rene Rebe <rene@exactcode.de>
--- /dev/null 2005-06-19 08:33:32.285177368 +0200
+++ embutils-0.17/losetup.c 2005-06-19 13:44:28.000000000 +0200
@@ -0,0 +1,65 @@
+/*
+ * Tiny losetup
+ *
+ * Copyright (c) 2005 by Rene Rebe <rene@exactcode.de>
+ *
+ * License: GPL, version 2
+ *
+ */
+
+#define _FILE_OFFSET_BITS 64
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#include <linux/posix_types.h>
+#include <linux/loop.h>
+
+#include "write12.h"
+
+void die(const char*msg) { __write2(msg); __write2("\n"); exit(1); }
+
+int main (int argc, char* argv[])
+{
+ int ffd, fd;
+ struct loop_info loopinfo;
+
+ if (argc != 3) {
+ die("usage: losetup [-d] loop_device\n losetup loop_device file");
+ }
+
+ if (!strcmp(argv[1], "-d"))
+ {
+ fd=open(argv[2], O_RDONLY);
+ if (fd < 0)
+ die(strerror(errno));
+
+ if (ioctl(fd, LOOP_CLR_FD, ffd))
+ die(strerror(errno));
+
+ close(fd);
+ }
+ else
+ {
+ memset(&loopinfo, 0, sizeof(loopinfo));
+ strncpy(loopinfo.lo_name, argv[2], LO_NAME_SIZE);
+
+ ffd=open(argv[2], O_RDONLY);
+ if (ffd < 0)
+ die(strerror(errno));
+
+ fd=open(argv[1], O_RDONLY);
+ if (fd < 0)
+ die(strerror(errno));
+
+ if (ioctl(fd, LOOP_SET_FD, ffd))
+ die(strerror(errno));
+ if (ioctl(fd, LOOP_SET_STATUS, &loopinfo))
+ die(strerror(errno));
+
+ close(ffd);
+ close(fd);
+ }
+}
--- embutils-0.17/Makefile.orig 2005-06-19 13:46:49.000000000 +0200
+++ embutils-0.17/Makefile 2005-05-31 11:53:22.000000000 +0200
@@ -11,7 +11,7 @@
install sosrm soscp sosmv sosln soslns md5sum sleep2 allinone kill uniq \
dd tr mesg write touch du tail uuencode uudecode nohup nice cmp mktemp \
truncate strings test date mount printenv umount pivot_root insmod rmmod \
-lsmod free
+lsmod free losetup
OBJDIR:=bin
TARGETS=$(patsubst %,$(OBJDIR)/%,$(PRGS))