100 lines
2.5 KiB
100 lines
2.5 KiB
# --- SDE-COPYRIGHT-NOTE-BEGIN --- |
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
|
# |
|
# Filename: package/.../embutils/losetup.patch |
|
# Copyright (C) 2007 The OpenSDE Project |
|
# 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. |
|
# --- SDE-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); |
|
+ } |
|
+} |
|
--- ./Makefile.orig 2007-03-28 00:46:09.000000000 -0400 |
|
+++ ./Makefile 2007-03-28 00:46:49.000000000 -0400 |
|
@@ -12,7 +12,7 @@ |
|
domainname id ln mv cp yes which cat rm wc ls whoami mkfifo head install \ |
|
sosrm soscp sosmv sosln soslns md5sum sleep2 allinone uniq tr mesg du \ |
|
uuencode uudecode nohup nice cmp mktemp truncate strings test date \ |
|
-printenv chrootuid renice free |
|
+printenv chrootuid renice free losetup |
|
|
|
OS:=$(shell uname) |
|
ifeq ($(OS),Linux)
|
|
|