# --- T2-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # T2 SDE: package/.../embutils/losetup.patch # Copyright (C) 2005 - 2007 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 --- /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,66 @@ +/* + * Tiny losetup + * + * Copyright (c) 2005, 2007 by Rene Rebe + * + * License: GPL, version 2 + * + */ + +#define _FILE_OFFSET_BITS 64 +#include +#include +#include +#include +#include + +#include +#include + +#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); + } + return 0; +} --- ./Makefile~ 2006-11-05 11:45:35.000000000 +0100 +++ ./Makefile 2006-11-05 11:45:39.000000000 +0100 @@ -13,7 +13,7 @@ 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 +free losetup OS:=$(shell uname) ifeq ($(OS),Linux)