Skip to content

Commit

Permalink
CIFS: Print message when attempting a mount
Browse files Browse the repository at this point in the history
Currently, no messages are printed when mounting a CIFS filesystem and
no debug configuration is enabled.

However, a CIFS mount information is valuable when troubleshooting
and/or forensic analyzing a system and finding out if was a CIFS
endpoint mount attempted.

Other filesystems such as XFS, EXT* does issue a printk() when mounting
their filesystems.

A terse log message is printed only if cifsFYI is not enabled. Otherwise,
the default full debug message is printed.

In order to not clutter and classify correctly the event messages, these
are logged as KERN_INFO level.

Sample mount operations:

[root@corinthians ~]# mount -o user=administrator //172.25.250.18/c$ /mnt
(non-existent system)

[root@corinthians ~]# mount -o user=administrator //172.25.250.19/c$ /mnt
(Valid system)

Kernel message log for the mount operations:

[  450.464543] CIFS: Attempting to mount //172.25.250.18/c$
[  456.478186] CIFS VFS: Error connecting to socket. Aborting operation.
[  456.478381] CIFS VFS: cifs_mount failed w/return code = -113
[  467.688866] CIFS: Attempting to mount //172.25.250.19/c$

Signed-off-by: Rodrigo Freire <[email protected]>
Signed-off-by: Steve French <[email protected]>
  • Loading branch information
rfrht authored and Steve French committed Oct 24, 2018
1 parent 9a0efec commit f80eaed
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,12 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
struct cifs_mnt_data mnt_data;
struct dentry *root;

cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);
/* Prints in Kernel / CIFS log the attempted mount operation *
* IF CIFS_DEBUG && cifs_FYI */
if (cifsFYI)
cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);
else
cifs_info("Attempting to mount %s\n", dev_name);

volume_info = cifs_get_volume_info((char *)data, dev_name, is_smb3);
if (IS_ERR(volume_info))
Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ DeleteMidQEntry(struct mid_q_entry *midEntry)
if (cifsFYI & CIFS_TIMER) {
pr_debug(" CIFS slow rsp: cmd %d mid %llu",
midEntry->command, midEntry->mid);
pr_info(" A: 0x%lx S: 0x%lx R: 0x%lx\n",
cifs_info(" A: 0x%lx S: 0x%lx R: 0x%lx\n",
now - midEntry->when_alloc,
now - midEntry->when_sent,
now - midEntry->when_received);
Expand Down

0 comments on commit f80eaed

Please sign in to comment.