* updated kmousetool (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / package / base / embutils / losetup.patch
blob73d10cf36fa6fc3e91edcd42c53bcbfef7643a4a
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) 2005 - 2007 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 ---
17 Guess what ,-)
19 - Rene Rebe <rene@exactcode.de>
21 --- /dev/null 2005-06-19 08:33:32.285177368 +0200
22 +++ embutils-0.17/losetup.c 2005-06-19 13:44:28.000000000 +0200
23 @@ -0,0 +1,66 @@
24 +/*
25 + * Tiny losetup
26 + *
27 + * Copyright (c) 2005, 2007 by Rene Rebe <rene@exactcode.de>
28 + *
29 + * License: GPL, version 2
30 + *
31 + */
33 +#define _FILE_OFFSET_BITS 64
34 +#include <sys/types.h>
35 +#include <sys/stat.h>
36 +#include <fcntl.h>
37 +#include <sys/ioctl.h>
38 +#include <errno.h>
40 +#include <linux/posix_types.h>
41 +#include <linux/loop.h>
43 +#include "write12.h"
45 +void die(const char*msg) { __write2(msg); __write2("\n"); exit(1); }
47 +int main (int argc, char* argv[])
49 + int ffd, fd;
50 + struct loop_info loopinfo;
52 + if (argc != 3) {
53 + die("usage: losetup [-d] loop_device\n losetup loop_device file");
54 + }
56 + if (!strcmp(argv[1], "-d"))
57 + {
58 + fd=open(argv[2], O_RDONLY);
59 + if (fd < 0)
60 + die(strerror(errno));
62 + if (ioctl(fd, LOOP_CLR_FD, ffd))
63 + die(strerror(errno));
65 + close(fd);
66 + }
67 + else
68 + {
69 + memset(&loopinfo, 0, sizeof(loopinfo));
70 + strncpy(loopinfo.lo_name, argv[2], LO_NAME_SIZE);
72 + ffd=open(argv[2], O_RDONLY);
73 + if (ffd < 0)
74 + die(strerror(errno));
76 + fd=open(argv[1], O_RDONLY);
77 + if (fd < 0)
78 + die(strerror(errno));
80 + if (ioctl(fd, LOOP_SET_FD, ffd))
81 + die(strerror(errno));
82 + if (ioctl(fd, LOOP_SET_STATUS, &loopinfo))
83 + die(strerror(errno));
85 + close(ffd);
86 + close(fd);
87 + }
88 + return 0;
90 --- ./Makefile~ 2006-11-05 11:45:35.000000000 +0100
91 +++ ./Makefile 2006-11-05 11:45:39.000000000 +0100
92 @@ -13,7 +13,7 @@
93 sosrm soscp sosmv sosln soslns md5sum sleep2 allinone uniq tr mesg du \
94 uuencode uudecode nohup nice cmp mktemp truncate strings test date \
95 printenv chrootuid renice \
96 -free
97 +free losetup
99 OS:=$(shell uname)
100 ifeq ($(OS),Linux)