// SPDX-License-Identifier: GPL-2.0-or-later /* * Contains mounting routines used for handling traversal via SMB junctions. * * Copyright (c) 2007 Igor Mammedov * Copyright (C) International Business Machines Corp., 2008 * Author(s): Igor Mammedov (niallain@gmail.com) * Steve French (sfrench@us.ibm.com) * Copyright (c) 2023 Paulo Alcantara <palcantara@suse.de>
*/
mark_mounts_for_expiry(list); if (!list_empty(list))
schedule_delayed_work(&cifs_automount_task,
cifs_mountpoint_expiry_timeout);
}
void cifs_release_automount_timer(void)
{ if (WARN_ON(!list_empty(&cifs_automount_list))) return;
cancel_delayed_work_sync(&cifs_automount_task);
}
/** * cifs_build_devname - build a devicename from a UNC and optional prepath * @nodename: pointer to UNC string * @prepath: pointer to prefixpath (or NULL if there isn't one) * * Build a new cifs devicename after chasing a DFS referral. Allocate a buffer * big enough to hold the final thing. Copy the UNC from the nodename, and * concatenate the prepath onto the end of it if there is one. * * Returns pointer to the built string, or a ERR_PTR. Caller is responsible * for freeing the returned string.
*/ char *
cifs_build_devname(char *nodename, constchar *prepath)
{
size_t pplen;
size_t unclen; char *dev; char *pos;
/* skip over any preceding delimiters */
nodename += strspn(nodename, "\\"); if (!*nodename) return ERR_PTR(-EINVAL);
/* get length of UNC and set pos to last char */
unclen = strlen(nodename);
pos = nodename + unclen - 1;
/* trim off any trailing delimiters */ while (*pos == '\\') {
--pos;
--unclen;
}
/* allocate a buffer: * +2 for preceding "//" * +1 for delimiter between UNC and prepath * +1 for trailing NULL
*/
pplen = prepath ? strlen(prepath) : 0;
dev = kmalloc(2 + unclen + 1 + pplen + 1, GFP_KERNEL); if (!dev) return ERR_PTR(-ENOMEM);
if (ctx->multiuser) { if (!ctx->uid_specified)
ctx->linux_uid = uid; if (!ctx->gid_specified)
ctx->linux_gid = gid;
} if (!ctx->cruid_specified)
ctx->cred_uid = uid;
}
/* * Create a vfsmount that we can automount
*/ staticstruct vfsmount *cifs_do_automount(struct path *path)
{ int rc; struct dentry *mntpt = path->dentry; struct fs_context *fc; void *page = NULL; struct smb3_fs_context *ctx, *cur_ctx; struct smb3_fs_context tmp; char *full_path; struct vfsmount *mnt; struct cifs_sb_info *mntpt_sb; struct cifs_ses *ses;
if (IS_ROOT(mntpt)) return ERR_PTR(-ESTALE);
mntpt_sb = CIFS_SB(mntpt->d_sb);
ses = cifs_sb_master_tcon(mntpt_sb)->ses;
cur_ctx = mntpt_sb->ctx;
/* * At this point, the root session should be in the mntpt sb. We should * bring the sb context passwords in sync with the root session's * passwords. This would help prevent unnecessary retries and password * swaps for automounts.
*/
mutex_lock(&ses->session_mutex);
rc = smb3_sync_session_ctx_passwords(mntpt_sb, ses);
mutex_unlock(&ses->session_mutex);
if (rc) return ERR_PTR(rc);
fc = fs_context_for_submount(path->mnt->mnt_sb->s_type, mntpt); if (IS_ERR(fc)) return ERR_CAST(fc);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.