1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777
|
/* ----------------------------------------------------------------------- *
*
* ctl-dev-lib.c - module for Linux automount mount table lookup functions
*
* Copyright 2008 Red Hat, Inc. All rights reserved.
* Copyright 2008 Ian Kent <raven@themaw.net> - All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
* USA; either version 2 of the License, or (at your option) any later
* version; incorporated herein by reference.
*
* ----------------------------------------------------------------------- */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <sys/vfs.h>
#include "automount.h"
/* ioctld control function interface */
static struct ioctl_ctl ctl = { -1, NULL };
#ifndef AUTOFS_SUPER_MAGIC
#define AUTOFS_SUPER_MAGIC 0x0187
#endif
/*
* Define functions for autofs ioctl control.
*
* We provide two interfaces. One which routes ioctls via a
* miscelaneous device node and can be used to obtain an ioctl
* file descriptor for autofs mounts that are covered by an
* active mount (eg. active direct or multi-mount offsets).
* The other provides the traditional autofs ioctl implementation.
*
* The miscielaneous device control functions are prefixed with
* dev_ctl_ and the traditional ones are prefixed with ioctl_.
*/
static int dev_ioctl_version(unsigned int, int, struct autofs_dev_ioctl *);
static int dev_ioctl_protover(unsigned int, int, unsigned int *);
static int dev_ioctl_protosubver(unsigned int, int, unsigned int *);
static int dev_ioctl_mount_device(unsigned int, const char *, unsigned int, dev_t *);
static int dev_ioctl_open(unsigned int, int *, dev_t, const char *);
static int dev_ioctl_close(unsigned int, int);
static int dev_ioctl_send_ready(unsigned int, int, unsigned int);
static int dev_ioctl_send_fail(unsigned int, int, unsigned int, int);
static int dev_ioctl_setpipefd(unsigned int, int, int);
static int dev_ioctl_catatonic(unsigned int, int);
static int dev_ioctl_timeout(unsigned int, int, time_t);
static int dev_ioctl_requester(unsigned int, int, const char *, uid_t *, gid_t *);
static int dev_ioctl_expire(unsigned int, int, const char *, unsigned int);
static int dev_ioctl_askumount(unsigned int, int, unsigned int *);
static int dev_ioctl_ismountpoint(unsigned int, int, const char *, unsigned int *);
static int ioctl_protover(unsigned int, int, unsigned int *);
static int ioctl_protosubver(unsigned int, int, unsigned int *);
static int ioctl_mount_device(unsigned int, const char *, unsigned int, dev_t *);
static int ioctl_open(unsigned int, int *, dev_t, const char *);
static int ioctl_close(unsigned int, int);
static int ioctl_send_ready(unsigned int, int, unsigned int);
static int ioctl_send_fail(unsigned int, int, unsigned int, int);
static int ioctl_catatonic(unsigned int, int);
static int ioctl_timeout(unsigned int, int, time_t);
static int ioctl_expire(unsigned int, int, const char *, unsigned int);
static int ioctl_askumount(unsigned int, int, unsigned int *);
static struct ioctl_ops dev_ioctl_ops = {
.version = dev_ioctl_version,
.protover = dev_ioctl_protover,
.protosubver = dev_ioctl_protosubver,
.mount_device = dev_ioctl_mount_device,
.open = dev_ioctl_open,
.close = dev_ioctl_close,
.send_ready = dev_ioctl_send_ready,
.send_fail = dev_ioctl_send_fail,
.setpipefd = dev_ioctl_setpipefd,
.catatonic = dev_ioctl_catatonic,
.timeout = dev_ioctl_timeout,
.requester = dev_ioctl_requester,
.expire = dev_ioctl_expire,
.askumount = dev_ioctl_askumount,
.ismountpoint = dev_ioctl_ismountpoint
};
static struct ioctl_ops ioctl_ops = {
.version = NULL,
.protover = ioctl_protover,
.protosubver = ioctl_protosubver,
.mount_device = ioctl_mount_device,
.open = ioctl_open,
.close = ioctl_close,
.send_ready = ioctl_send_ready,
.send_fail = ioctl_send_fail,
.setpipefd = NULL,
.catatonic = ioctl_catatonic,
.timeout = ioctl_timeout,
.requester = NULL,
.expire = ioctl_expire,
.askumount = ioctl_askumount,
.ismountpoint = NULL
};
/*
* Allocate the control struct that holds the misc device file
* descriptor and operation despatcher table.
*/
void init_ioctl_ctl(void)
{
int devfd;
if (ctl.ops)
return;
devfd = open_fd(CONTROL_DEVICE, O_RDONLY);
if (devfd == -1)
ctl.ops = &ioctl_ops;
else {
struct autofs_dev_ioctl param;
/*
* Check compile version against kernel.
* Selinux may allow us to open the device but not
* actually allow us to do anything.
*/
init_autofs_dev_ioctl(¶m);
if (ioctl(devfd, AUTOFS_DEV_IOCTL_VERSION, ¶m) == -1) {
close(devfd);
ctl.ops = &ioctl_ops;
} else {
ctl.devfd = devfd;
ctl.ops = &dev_ioctl_ops;
}
}
return;
}
void close_ioctl_ctl(void)
{
if (ctl.devfd != -1) {
close(ctl.devfd);
ctl.devfd = -1;
}
ctl.ops = NULL;
return;
}
/* Return a pointer to the operations control struct */
struct ioctl_ops *get_ioctl_ops(void)
{
if (!ctl.ops)
init_ioctl_ctl();
return ctl.ops;
}
/* Get kenrel version of misc device code */
static int dev_ioctl_version(unsigned int logopt,
int ioctlfd, struct autofs_dev_ioctl *param)
{
param->ioctlfd = ioctlfd;
if (ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_VERSION, param) == -1)
return -1;
return 0;
}
/* Get major version of autofs kernel module mount protocol */
static int dev_ioctl_protover(unsigned int logopt,
int ioctlfd, unsigned int *major)
{
struct autofs_dev_ioctl param;
init_autofs_dev_ioctl(¶m);
param.ioctlfd = ioctlfd;
if (ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_PROTOVER, ¶m) == -1)
return -1;
*major = param.protover.version;
return 0;
}
static int ioctl_protover(unsigned int logopt,
int ioctlfd, unsigned int *major)
{
return ioctl(ioctlfd, AUTOFS_IOC_PROTOVER, major);
}
/* Get minor version of autofs kernel module mount protocol */
static int dev_ioctl_protosubver(unsigned int logopt,
int ioctlfd, unsigned int *minor)
{
struct autofs_dev_ioctl param;
init_autofs_dev_ioctl(¶m);
param.ioctlfd = ioctlfd;
if (ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_PROTOSUBVER, ¶m) == -1)
return -1;
*minor = param.protosubver.sub_version;
return 0;
}
static int ioctl_protosubver(unsigned int logopt,
int ioctlfd, unsigned int *minor)
{
return ioctl(ioctlfd, AUTOFS_IOC_PROTOSUBVER, minor);
}
/*
* Allocate a parameter struct for misc device ioctl used when
* opening an autofs mount point. Attach the path to the end
* of the struct. and lookup the device number if not given.
* Locating the device number relies on the mount option
* "dev=<device number>" being present in the autofs fs mount
* options.
*/
static struct autofs_dev_ioctl *alloc_dev_ioctl_open(const char *path, dev_t devid)
{
struct autofs_dev_ioctl *ioctl;
size_t size, p_len;
dev_t devno = devid;
if (!path)
return NULL;
p_len = strlen(path);
size = sizeof(struct autofs_dev_ioctl) + p_len + 1;
ioctl = malloc(size);
if (!ioctl) {
errno = ENOMEM;
return NULL;
}
init_autofs_dev_ioctl(ioctl);
ioctl->size = size;
memcpy(ioctl->path, path, p_len);
ioctl->path[p_len] = '\0';
ioctl->openmount.devid = devno;
return ioctl;
}
static void free_dev_ioctl_open(struct autofs_dev_ioctl *ioctl)
{
free(ioctl);
return;
}
/*
* Allocate a parameter struct for misc device ioctl which includes
* a path. This is used when getting the last mount requester uid
* and gid and when checking if a path within the autofs filesystem
* is a mount point. We add the path to the end of the struct.
*/
static struct autofs_dev_ioctl *alloc_dev_ioctl_path(int ioctlfd, const char *path)
{
struct autofs_dev_ioctl *ioctl;
size_t size, p_len;
if (!path) {
errno = EINVAL;
return NULL;
}
p_len = strlen(path);
size = sizeof(struct autofs_dev_ioctl) + p_len + 1;
ioctl = malloc(size);
if (!ioctl) {
errno = ENOMEM;
return NULL;
}
init_autofs_dev_ioctl(ioctl);
ioctl->ioctlfd = ioctlfd;
ioctl->size = size;
memcpy(ioctl->path, path, p_len);
ioctl->path[p_len] = '\0';
return ioctl;
}
static void free_dev_ioctl_path(struct autofs_dev_ioctl *ioctl)
{
free(ioctl);
return;
}
/*
* Find the device number of an autofs mount with given path and
* type (eg..AUTOFS_TYPE_DIRECT). The device number is used by
* the kernel to identify the autofs super block when searching
* for the mount.
*/
static int dev_ioctl_mount_device(unsigned int logopt, const char *path, unsigned int type, dev_t *devid)
{
struct autofs_dev_ioctl *param;
int err;
if (!path) {
errno = EINVAL;
return -1;
}
*devid = -1;
param = alloc_dev_ioctl_path(-1, path);
if (!param)
return -1;
param->ismountpoint.in.type = type;
err = ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_ISMOUNTPOINT, param);
if (err == -1) {
int save_errno = errno;
free_dev_ioctl_path(param);
errno = save_errno;
return -1;
}
if (err)
*devid = param->ismountpoint.out.devid;
free_dev_ioctl_path(param);
return err;
}
static int ioctl_mount_device(unsigned int logopt,
const char *path, unsigned int type,
dev_t *devid)
{
return -1;
}
/* Get a file descriptor for control operations */
static int dev_ioctl_open(unsigned int logopt,
int *ioctlfd, dev_t devid, const char *path)
{
struct autofs_dev_ioctl *param;
*ioctlfd = -1;
param = alloc_dev_ioctl_open(path, devid);
if (!param)
return -1;
if (ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_OPENMOUNT, param) == -1) {
int save_errno = errno;
free_dev_ioctl_open(param);
errno = save_errno;
return -1;
}
*ioctlfd = param->ioctlfd;
free_dev_ioctl_open(param);
return 0;
}
static int ioctl_open(unsigned int logopt,
int *ioctlfd, dev_t devid, const char *path)
{
struct statfs sfs;
int save_errno, fd;
*ioctlfd = -1;
fd = open_fd(path, O_RDONLY);
if (fd == -1)
return -1;
if (fstatfs(fd, &sfs) == -1) {
save_errno = errno;
goto err;
}
if (sfs.f_type != AUTOFS_SUPER_MAGIC) {
save_errno = ENOENT;
goto err;
}
*ioctlfd = fd;
return 0;
err:
close(fd);
errno = save_errno;
return -1;
}
/* Close */
static int dev_ioctl_close(unsigned int logopt, int ioctlfd)
{
struct autofs_dev_ioctl param;
init_autofs_dev_ioctl(¶m);
param.ioctlfd = ioctlfd;
if (ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_CLOSEMOUNT, ¶m) == -1)
return -1;
return 0;
}
static int ioctl_close(unsigned int logopt, int ioctlfd)
{
return close(ioctlfd);
}
/* Send ready status for given token */
static int dev_ioctl_send_ready(unsigned int logopt,
int ioctlfd, unsigned int token)
{
struct autofs_dev_ioctl param;
if (token == 0) {
errno = EINVAL;
return -1;
}
debug(logopt, "token = %d", token);
init_autofs_dev_ioctl(¶m);
param.ioctlfd = ioctlfd;
param.ready.token = token;
if (ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_READY, ¶m) == -1) {
char *estr, buf[MAX_ERR_BUF];
int save_errno = errno;
estr = strerror_r(errno, buf, MAX_ERR_BUF);
logerr("AUTOFS_DEV_IOCTL_READY: error %s", estr);
errno = save_errno;
return -1;
}
return 0;
}
static int ioctl_send_ready(unsigned int logopt,
int ioctlfd, unsigned int token)
{
if (token == 0) {
errno = EINVAL;
return -1;
}
debug(logopt, "token = %d", token);
if (ioctl(ioctlfd, AUTOFS_IOC_READY, token) == -1) {
char *estr, buf[MAX_ERR_BUF];
int save_errno = errno;
estr = strerror_r(errno, buf, MAX_ERR_BUF);
logerr("AUTOFS_IOC_READY: error %s", estr);
errno = save_errno;
return -1;
}
return 0;
}
/*
* Send ready status for given token.
*
* The device node ioctl implementation allows for sending a status
* of other than ENOENT, unlike the tradional interface.
*/
static int dev_ioctl_send_fail(unsigned int logopt,
int ioctlfd, unsigned int token, int status)
{
struct autofs_dev_ioctl param;
if (token == 0) {
errno = EINVAL;
return -1;
}
debug(logopt, "token = %d", token);
init_autofs_dev_ioctl(¶m);
param.ioctlfd = ioctlfd;
param.fail.token = token;
param.fail.status = status;
if (ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_FAIL, ¶m) == -1) {
char *estr, buf[MAX_ERR_BUF];
int save_errno = errno;
estr = strerror_r(errno, buf, MAX_ERR_BUF);
logerr("AUTOFS_DEV_IOCTL_FAIL: error %s", estr);
errno = save_errno;
return -1;
}
return 0;
}
static int ioctl_send_fail(unsigned int logopt,
int ioctlfd, unsigned int token, int status)
{
if (token == 0) {
errno = EINVAL;
return -1;
}
debug(logopt, "token = %d", token);
if (ioctl(ioctlfd, AUTOFS_IOC_FAIL, token) == -1) {
char *estr, buf[MAX_ERR_BUF];
int save_errno = errno;
estr = strerror_r(errno, buf, MAX_ERR_BUF);
logerr("AUTOFS_IOC_FAIL: error %s", estr);
errno = save_errno;
return -1;
}
return 0;
}
/*
* Set the pipe fd for kernel communication.
*
* Normally this is set at mount using an option but if we
* are reconnecting to a busy mount then we need to use this
* to tell the autofs kernel module about the new pipe fd. In
* order to protect mounts against incorrectly setting the
* pipefd we also require that the autofs mount be catatonic.
*
* If successful this also sets the process group id used to
* identify the controlling process to the process group of
* the caller.
*/
static int dev_ioctl_setpipefd(unsigned int logopt, int ioctlfd, int pipefd)
{
struct autofs_dev_ioctl param;
if (pipefd == -1) {
errno = EBADF;
return -1;
}
init_autofs_dev_ioctl(¶m);
param.ioctlfd = ioctlfd;
param.setpipefd.pipefd = pipefd;
if (ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_SETPIPEFD, ¶m) == -1)
return -1;
return 0;
}
/*
* Make the autofs mount point catatonic, no longer responsive to
* mount requests. Also closes the kernel pipe file descriptor.
*/
static int dev_ioctl_catatonic(unsigned int logopt, int ioctlfd)
{
struct autofs_dev_ioctl param;
init_autofs_dev_ioctl(¶m);
param.ioctlfd = ioctlfd;
if (ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_CATATONIC, ¶m) == -1)
return -1;
return 0;
}
static int ioctl_catatonic(unsigned int logopt, int ioctlfd)
{
return ioctl(ioctlfd, AUTOFS_IOC_CATATONIC, 0);
}
/* Set the autofs mount timeout */
static int dev_ioctl_timeout(unsigned int logopt, int ioctlfd, time_t timeout)
{
struct autofs_dev_ioctl param;
init_autofs_dev_ioctl(¶m);
param.ioctlfd = ioctlfd;
param.timeout.timeout = timeout;
if (ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_TIMEOUT, ¶m) == -1)
return -1;
return 0;
}
static int ioctl_timeout(unsigned int logopt, int ioctlfd, time_t timeout)
{
time_t tout = timeout;
return ioctl(ioctlfd, AUTOFS_IOC_SETTIMEOUT, &tout);
}
/*
* Get the uid and gid of the last request for the mountpoint, path.
*
* When reconstructing an autofs mount tree with active mounts
* we need to re-connect to mounts that may have used the original
* process uid and gid (or string variations of them) for mount
* lookups within the map entry.
*/
static int dev_ioctl_requester(unsigned int logopt,
int ioctlfd, const char *path,
uid_t *uid, gid_t *gid)
{
struct autofs_dev_ioctl *param;
int err;
if (!path)
errno = EINVAL;
*uid = -1;
*gid = -1;
param = alloc_dev_ioctl_path(ioctlfd, path);
if (!param)
return -1;
err = ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_REQUESTER, param);
if (err == -1) {
int save_errno = errno;
free_dev_ioctl_open(param);
errno = save_errno;
return -1;
}
*uid = param->requester.uid;
*gid = param->requester.gid;
free_dev_ioctl_path(param);
return 0;
}
/*
* Call repeatedly until it returns EAGAIN, meaning there's nothing
* more that can be done.
*/
static int expire(unsigned int logopt,
int cmd, int fd, int ioctlfd, const char *path, void *arg)
{
int ret, retries = EXPIRE_RETRIES;
unsigned int may_umount;
while (retries--) {
struct timespec tm = {0, 100000000};
/* Ggenerate expire message for the mount. */
ret = ioctl(fd, cmd, arg);
if (ret == -1) {
/* Mount has gone away */
if (errno == EBADF || errno == EINVAL)
return 0;
/*
* Other than EAGAIN is an expire error so continue.
* Kernel will try the next mount for indirect maps
* and the same mount again for direct maps, limited
* by retries.
*/
if (errno == EAGAIN)
break;
}
nanosleep(&tm, NULL);
}
may_umount = 0;
if (ctl.ops->askumount(logopt, ioctlfd, &may_umount))
return -1;
if (!may_umount)
return 1;
return 0;
}
static int dev_ioctl_expire(unsigned int logopt,
int ioctlfd, const char *path, unsigned int when)
{
struct autofs_dev_ioctl param;
init_autofs_dev_ioctl(¶m);
param.ioctlfd = ioctlfd;
param.expire.how = when;
return expire(logopt, AUTOFS_DEV_IOCTL_EXPIRE,
ctl.devfd, ioctlfd, path, (void *) ¶m);
}
static int ioctl_expire(unsigned int logopt,
int ioctlfd, const char *path, unsigned int when)
{
return expire(logopt, AUTOFS_IOC_EXPIRE_MULTI,
ioctlfd, ioctlfd, path, (void *) &when);
}
/* Check if autofs mount point is in use */
static int dev_ioctl_askumount(unsigned int logopt,
int ioctlfd, unsigned int *busy)
{
struct autofs_dev_ioctl param;
init_autofs_dev_ioctl(¶m);
param.ioctlfd = ioctlfd;
if (ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_ASKUMOUNT, ¶m) == -1)
return -1;
*busy = param.askumount.may_umount;
return 0;
}
static int ioctl_askumount(unsigned int logopt,
int ioctlfd, unsigned int *busy)
{
return ioctl(ioctlfd, AUTOFS_IOC_ASKUMOUNT, busy);
}
/*
* Check if the given path is a mountpoint.
*
* The path is considered a mountpoint if it is itself a mountpoint
* or contains a mount, such as a multi-mount without a root mount.
* In addition, if the path is itself a mountpoint we return whether
* the mounted file system is an autofs filesystem or other file
* system.
*/
static int dev_ioctl_ismountpoint(unsigned int logopt,
int ioctlfd, const char *path,
unsigned int *mountpoint)
{
struct autofs_dev_ioctl *param;
int err;
*mountpoint = 0;
if (!path) {
errno = EINVAL;
return -1;
}
param = alloc_dev_ioctl_path(ioctlfd, path);
if (!param)
return -1;
set_autofs_type_any(¶m->ismountpoint.in.type);
err = ioctl(ctl.devfd, AUTOFS_DEV_IOCTL_ISMOUNTPOINT, param);
if (err == -1) {
int save_errno = errno;
free_dev_ioctl_path(param);
errno = save_errno;
return -1;
}
if (err) {
*mountpoint = DEV_IOCTL_IS_MOUNTED;
if (param->ismountpoint.out.magic == AUTOFS_SUPER_MAGIC)
*mountpoint |= DEV_IOCTL_IS_AUTOFS;
else
*mountpoint |= DEV_IOCTL_IS_OTHER;
}
free_dev_ioctl_path(param);
return 0;
}
|