Репозитории ALT
S: | 0.5.11.18.g6f6d1f2-alt1 |
5.1: | 0.5.5.1-alt5 |
4.1: | 0.5.4-alt3 |
4.0: | 0.5.3-alt6 |
3.0: | 0.5.2-alt1 |
Группа :: Интерпретаторы команд
Пакет: ash
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: dash-0.5.4-alt-losetup.patch
Скачать
Скачать
--- dash-0.5.4/src/Makefile.am.fix 2007-10-14 00:37:22 +0400
+++ dash-0.5.4/src/Makefile.am 2007-10-14 00:37:41 +0400
@@ -20,9 +20,9 @@ bin_PROGRAMS = dash
dash_CFILES = \
alias.c arith_yacc.c arith_yylex.c cd.c error.c eval.c exec.c expand.c \
histedit.c input.c jobs.c mail.c main.c memalloc.c miscbltin.c \
mystring.c options.c parser.c redir.c show.c trap.c output.c \
- bltin/printf.c system.c bltin/test.c bltin/times.c var.c
+ bltin/printf.c system.c bltin/test.c bltin/times.c bltin/losetup.c var.c
dash_SOURCES = \
$(dash_CFILES) \
alias.h bltin/bltin.h cd.h error.h eval.h exec.h expand.h hetio.h \
init.h input.h jobs.h machdep.h mail.h main.h memalloc.h miscbltin.h \
--- /dev/null 2007-10-05 14:38:14 +0400
+++ dash-0.5.4/src/bltin/losetup.c 2007-10-14 00:37:23 +0400
@@ -0,0 +1,87 @@
+/*
+ * Losetup command.
+ */
+
+#define main losetupcmd
+
+#ifdef USE_GLIBC_STDIO
+#include <stdio.h>
+
+#include "../mystring.h"
+#else
+#include "bltin.h"
+#endif
+
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+#ifndef dev_t
+#define dev_t dev_t
+#endif
+#include <linux/loop.h>
+
+int
+main(int argc, const char *const *argv)
+{
+ int loopfd, targfd;
+ struct loop_info loopInfo;
+
+ if ( argc < 3 )
+ return 1;
+
+ if ( !strcmp( argv[1], "-d" ) )
+ {
+ loopfd = open( argv[2], O_RDONLY );
+ if ( loopfd < 0 )
+ {
+ fprintf( stderr, "losetup: error opening %s: %s\n", argv[2], strerror(errno) );
+ return 1;
+ }
+
+ if ( ioctl(loopfd, LOOP_CLR_FD, 0) < 0 )
+ {
+ fprintf( stderr, "losetup: error unassociating device: %s\n", strerror(errno) );
+ close( loopfd );
+ return 1;
+ }
+
+ close( loopfd );
+ return 0;
+ }
+
+ loopfd = open( argv[1], O_RDONLY );
+ if ( loopfd < 0 )
+ {
+ fprintf( stderr, "losetup: error opening %s: %s\n", argv[1], strerror(errno) );
+ return 1;
+ }
+
+ targfd = open( argv[2], O_RDONLY );
+ if ( targfd < 0 )
+ {
+ fprintf( stderr, "losetup: error opening %s: %s\n", argv[2], strerror(errno) );
+ close( loopfd );
+ return 1;
+ }
+
+ if ( ioctl(loopfd, LOOP_SET_FD, targfd) < 0 )
+ {
+ fprintf( stderr, "losetup: error setting up loopback device: %s\n", strerror(errno) );
+ close( loopfd );
+ close( targfd );
+ return 1;
+ }
+
+ memset(&loopInfo, 0, sizeof(loopInfo));
+ strcpy(loopInfo.lo_name, argv[2]);
+
+ if ( ioctl(loopfd, LOOP_SET_STATUS, &loopInfo) < 0 )
+ fprintf( stderr, "losetup: error setting up loopback device: %s\n", strerror(errno) );
+
+ close( loopfd );
+ close( targfd );
+
+ return 0;
+}
--- dash-0.5.4/src/builtins.def.in.fix 2007-10-14 00:37:22 +0400
+++ dash-0.5.4/src/builtins.def.in 2007-10-14 00:37:23 +0400
@@ -90,4 +90,5 @@ aliascmd -au alias
ulimitcmd ulimit
#endif
testcmd test [
killcmd -u kill
+losetupcmd losetup