Check-in [bf927c2247]
Overview
SHA1:bf927c2247eaef5474908e986f9dbe4f1c8a692a
Date: 2017-09-12 19:41:40
User: rkeene
Comment:Added "adjtime" support
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2017-09-12
19:42
[32375279e7] TUAPI 0.12 (user: rkeene, tags: trunk, 0.12)
19:41
[bf927c2247] Added "adjtime" support (user: rkeene, tags: trunk)
2017-08-14
22:22
[23693dd526] Updated license information (user: rkeene, tags: trunk)
Changes

Modified tuapi.c from [7aa2faf93b] to [6f7b792413].

28
29
30
31
32
33
34

35
36
37
38
39
40
41
....
2514
2515
2516
2517
2518
2519
2520






































2521
2522
2523
2524
2525
2526
2527
....
3249
3250
3251
3252
3253
3254
3255

3256
3257
3258
3259
3260
3261
3262
#include <sys/prctl.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/ioctl.h>

#include <sys/time.h>
#include <sys/klog.h>
#include <sys/swap.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/un.h>
#include <stdlib.h>
................................................................................
		Tcl_SetObjResult(interp, Tcl_NewStringObj(strerror(errno), -1));

		return(TCL_ERROR);
	}

	return(TCL_OK);
}







































#ifndef DISABLE_UNIX_SOCKETS
struct tuapi_socket_unix__chan_id {
	int fd;
	Tcl_Channel chan;
};

................................................................................
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::insmod", tuapi_insmod, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::rmmod", tuapi_rmmod, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::lsmod", tuapi_lsmod, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::hostname", tuapi_hostname, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::domainname", tuapi_domainname, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::klogctl", tuapi_klogctl, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::settimeofday", tuapi_settimeofday, NULL, NULL);


	/* Block or char device related commands */
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::losetup", tuapi_losetup, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::eject", tuapi_eject, NULL, NULL);

	/* Filesystem related commands */
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::mount", tuapi_mount, NULL, NULL);







>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>







28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
....
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
....
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
#include <sys/prctl.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/mount.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/timex.h>
#include <sys/time.h>
#include <sys/klog.h>
#include <sys/swap.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/un.h>
#include <stdlib.h>
................................................................................
		Tcl_SetObjResult(interp, Tcl_NewStringObj(strerror(errno), -1));

		return(TCL_ERROR);
	}

	return(TCL_OK);
}

static int tuapi_adjtime(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
	struct timeval tv, oldTV;
	Tcl_WideInt tv_sec_val, tv_usec_val;
	int adjtime_ret, tcl_ret;

	if (objc != 3) {
		Tcl_SetObjResult(interp, Tcl_NewStringObj("wrong # args: should be \"::tuapi::syscall::adjtime seconds microseconds\"", -1));

		return(TCL_ERROR);
	}

	tcl_ret = Tcl_GetWideIntFromObj(interp, objv[1], &tv_sec_val);
	if (tcl_ret != TCL_OK) {
		return(tcl_ret);
	}

	tcl_ret = Tcl_GetWideIntFromObj(interp, objv[2], &tv_usec_val);
	if (tcl_ret != TCL_OK) {
		return(tcl_ret);
	}

	tv.tv_sec = tv_sec_val;
	tv.tv_usec = tv_usec_val; 

	adjtime_ret = adjtime(&tv, &oldTV);

	if (adjtime_ret != 0) {
		Tcl_SetObjResult(interp, Tcl_NewStringObj(strerror(errno), -1));

		return(TCL_ERROR);
	}

	/* XXX TODO: Return old adjustment */

	return(TCL_OK);
}


#ifndef DISABLE_UNIX_SOCKETS
struct tuapi_socket_unix__chan_id {
	int fd;
	Tcl_Channel chan;
};

................................................................................
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::insmod", tuapi_insmod, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::rmmod", tuapi_rmmod, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::lsmod", tuapi_lsmod, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::hostname", tuapi_hostname, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::domainname", tuapi_domainname, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::klogctl", tuapi_klogctl, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::settimeofday", tuapi_settimeofday, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::adjtime", tuapi_adjtime, NULL, NULL);

	/* Block or char device related commands */
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::losetup", tuapi_losetup, NULL, NULL);
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::eject", tuapi_eject, NULL, NULL);

	/* Filesystem related commands */
	Tcl_CreateObjCommand(interp, "::tuapi::syscall::mount", tuapi_mount, NULL, NULL);